ReactOS 0.4.15-dev-5853-gcb454ef
ex.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef __cplusplus
4extern "C"
5{
6#endif
7
8/* GLOBAL VARIABLES *********************************************************/
9
12extern ULONG ExpTimeZoneId;
26extern ULONG NtGlobalFlag;
39
42
43/*
44 * NT/Cm Version Info variables
45 */
48extern ULONG NtBuildNumber;
54extern CHAR NtBuildLab[];
55
56/*
57 * WinDBG Debugger Worker State Machine data (see dbgctrl.c)
58 */
60{
65
71
73
74#ifdef _WIN64
75#define HANDLE_LOW_BITS (PAGE_SHIFT - 4)
76#define HANDLE_HIGH_BITS (PAGE_SHIFT - 3)
77#else
78#define HANDLE_LOW_BITS (PAGE_SHIFT - 3)
79#define HANDLE_HIGH_BITS (PAGE_SHIFT - 2)
80#endif
81#define HANDLE_TAG_BITS (2)
82#define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)
83#define KERNEL_FLAG_BITS (sizeof(PVOID)*8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
84
85typedef union _EXHANDLE
86{
87 struct
88 {
92 };
93 struct
94 {
100 };
105
106typedef struct _ETIMER
107{
118
119typedef struct
120{
124
126{
131
132#define MAX_FAST_REFS 7
133
134#define ExAcquireRundownProtection _ExAcquireRundownProtection
135#define ExReleaseRundownProtection _ExReleaseRundownProtection
136#define ExInitializeRundownProtection _ExInitializeRundownProtection
137#define ExWaitForRundownProtectionRelease _ExWaitForRundownProtectionRelease
138#define ExRundownCompleted _ExRundownCompleted
139#define ExGetPreviousMode KeGetPreviousMode
140
141
142//
143// Various bits tagged on the handle or handle table
144//
145#define EXHANDLE_TABLE_ENTRY_LOCK_BIT 1
146#define FREE_HANDLE_MASK -1
147
148//
149// Number of entries in each table level
150//
151#define LOW_LEVEL_ENTRIES (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))
152#define MID_LEVEL_ENTRIES (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))
153#define HIGH_LEVEL_ENTRIES (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))
154
155//
156// Maximum index in each table level before we need another table
157//
158#define MAX_LOW_INDEX LOW_LEVEL_ENTRIES
159#define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
160#define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
161
162#define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)
163#define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)
164#define ExpSetRundown(x, y) InterlockedExchangePointer(&x->Ptr, (PVOID)y)
165
167NTAPI
169 IN PSYSTEM_POOLTAG_INFORMATION SystemInformation,
170 IN ULONG SystemInformationLength,
172);
173
175{
178 union
179 {
180 struct
181 {
184 UCHAR NodeId[6 /*SEED_BUFFER_SIZE*/];
185 };
186 UCHAR GuidInit[8]; /* Match GUID.Data4 */
187 };
189
191
192/* INITIALIZATION FUNCTIONS *************************************************/
193
194CODE_SEG("INIT")
196NTAPI
198
199VOID
200NTAPI
202
203VOID
204NTAPI
207);
208
209CODE_SEG("INIT")
210VOID
211NTAPI
213
215NTAPI
217 IN PLARGE_INTEGER SystemBootTime
218);
219
220CODE_SEG("INIT")
221VOID
222NTAPI
224
225VOID
226NTAPI
228
229CODE_SEG("INIT")
230VOID
231NTAPI
233
234CODE_SEG("INIT")
235VOID
236NTAPI
240 IN ULONG Size,
241 IN ULONG Tag,
242 IN USHORT MaximumDepth,
243 IN PLIST_ENTRY ListHead
244);
245
246CODE_SEG("INIT")
248NTAPI
250
251CODE_SEG("INIT")
253NTAPI
255
256CODE_SEG("INIT")
258NTAPI
260
261CODE_SEG("INIT")
262VOID
263NTAPI
265 IN ULONG Cpu,
266 IN PLOADER_PARAMETER_BLOCK LoaderBlock
267);
268
269VOID
270NTAPI
272
273CODE_SEG("INIT")
275NTAPI
277
278CODE_SEG("INIT")
280NTAPI
282
283CODE_SEG("INIT")
285NTAPI
287
288CODE_SEG("INIT")
290NTAPI
292
293CODE_SEG("INIT")
295NTAPI
297
298CODE_SEG("INIT")
300NTAPI
302
303CODE_SEG("INIT")
305NTAPI
307
308CODE_SEG("INIT")
309VOID
310NTAPI
312
313CODE_SEG("INIT")
314VOID
315NTAPI
317
318/* Callback Functions ********************************************************/
319
320VOID
321NTAPI
324);
325
327NTAPI
331);
332
333VOID
334NTAPI
336 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
337);
338
340NTAPI
342 IN OUT PEX_CALLBACK CallBack,
345);
346
348NTAPI
350 IN OUT PEX_CALLBACK CallBack
351);
352
353VOID
354NTAPI
356 IN OUT PEX_CALLBACK CallBack,
357 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
358);
359
361NTAPI
363 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
364);
365
366PVOID
367NTAPI
369 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
370);
371
372VOID
373NTAPI
375 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
376);
377
378/* Rundown Functions ********************************************************/
379
380VOID
383 OUT PEX_RUNDOWN_REF RunRef
384);
385
386VOID
389 OUT PEX_RUNDOWN_REF RunRef
390);
391
395 IN OUT PEX_RUNDOWN_REF RunRef
396);
397
401 IN OUT PEX_RUNDOWN_REF RunRef,
403);
404
405VOID
408 IN OUT PEX_RUNDOWN_REF RunRef
409);
410
411VOID
414 IN OUT PEX_RUNDOWN_REF RunRef,
416);
417
418VOID
421 OUT PEX_RUNDOWN_REF RunRef
422);
423
424VOID
427 IN OUT PEX_RUNDOWN_REF RunRef
428);
429
430/* HANDLE TABLE FUNCTIONS ***************************************************/
431
432typedef BOOLEAN
434 PHANDLE_TABLE_ENTRY HandleTableEntry,
437);
438
439typedef BOOLEAN
443 IN PHANDLE_TABLE_ENTRY HandleTableEntry,
444 IN PHANDLE_TABLE_ENTRY NewEntry
445);
446
447typedef BOOLEAN
449 PHANDLE_TABLE_ENTRY HandleTableEntry,
451);
452
453CODE_SEG("INIT")
454VOID
455NTAPI
457 VOID
458);
459
461NTAPI
464);
465
466VOID
467NTAPI
470 IN PHANDLE_TABLE_ENTRY HandleTableEntry
471);
472
473HANDLE
474NTAPI
477 IN PHANDLE_TABLE_ENTRY HandleTableEntry
478);
479
480VOID
481NTAPI
484 IN PVOID DestroyHandleProcedure OPTIONAL
485);
486
488NTAPI
492 IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL
493);
494
496NTAPI
500);
501
503NTAPI
507 IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure,
509);
510
512NTAPI
516 IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine,
518);
519
520VOID
521NTAPI
524 IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure,
526);
527
529NTAPI
533);
534
536NTAPI
539 IN PHANDLE_TABLE_ENTRY HandleTableEntry
540);
541
542/* PSEH EXCEPTION HANDLING **************************************************/
543
544LONG
545NTAPI
547
548/* CALLBACKS *****************************************************************/
549
551VOID
556{
557 PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
559
560 /* Reference the block */
561 CallbackBlock = ExReferenceCallBackBlock(Callback);
562 if (CallbackBlock)
563 {
564 /* Get the function */
565 Function = ExGetCallBackBlockRoutine(CallbackBlock);
566
567 /* Do the callback */
569
570 /* Now dereference it */
571 ExDereferenceCallBackBlock(Callback, CallbackBlock);
572 }
573}
574
575/* FAST REFS ******************************************************************/
576
578PVOID
580{
581 /* Return the unbiased pointer */
582 return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
583}
584
586ULONG
588{
589 /* Return the reference count */
590 return (ULONG)FastRef.RefCnt;
591}
592
594VOID
597{
598 /* Sanity check */
600
601 /* Check if an object is being set */
602 if (!Object)
603 {
604 /* Clear the field */
605 FastRef->Object = NULL;
606 }
607 else
608 {
609 /* Otherwise, we assume the object was referenced and is ready */
610 FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
611 }
612}
613
617{
618 EX_FAST_REF OldValue, NewValue;
619
620 /* Start reference loop */
621 for (;;)
622 {
623 /* Get the current reference count */
624 OldValue = *FastRef;
625 if (OldValue.RefCnt)
626 {
627 /* Increase the reference count */
628 NewValue.Value = OldValue.Value - 1;
629 NewValue.Object = ExpChangePushlock(&FastRef->Object,
630 NewValue.Object,
631 OldValue.Object);
632 if (NewValue.Object != OldValue.Object) continue;
633 }
634
635 /* We are done */
636 break;
637 }
638
639 /* Return the old value */
640 return OldValue;
641}
642
647{
648 EX_FAST_REF OldValue, NewValue;
649
650 /* Sanity checks */
652
653 /* Start update loop */
654 for (;;)
655 {
656 /* Get the current reference count */
657 OldValue = *FastRef;
658
659 /* Check if the current count is too high or if the pointer changed */
660 if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
661 ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
662 {
663 /* Fail */
664 return FALSE;
665 }
666
667 /* Update the reference count */
668 NewValue.Value = OldValue.Value + MAX_FAST_REFS;
669 NewValue.Object = ExpChangePushlock(&FastRef->Object,
670 NewValue.Object,
671 OldValue.Object);
672 if (NewValue.Object != OldValue.Object) continue;
673
674 /* We are done */
675 break;
676 }
677
678 /* Return success */
679 return TRUE;
680}
681
686{
687 EX_FAST_REF OldValue, NewValue;
688
689 /* Sanity checks */
690 ASSERT(Object != NULL);
692
693 /* Start reference loop */
694 for (;;)
695 {
696 /* Get the current reference count */
697 OldValue = *FastRef;
698
699 /* Check if we're full if if the pointer changed */
700 if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
701
702 /* Decrease the reference count */
703 NewValue.Value = OldValue.Value + 1;
704 NewValue.Object = ExpChangePushlock(&FastRef->Object,
705 NewValue.Object,
706 OldValue.Object);
707 if (NewValue.Object != OldValue.Object) continue;
708
709 /* We are done */
710 break;
711 }
712
713 /* Return success */
714 return TRUE;
715}
716
721{
722 EX_FAST_REF NewValue, OldValue;
723
724 /* Sanity check */
726
727 /* Check if an object is being set */
728 if (!Object)
729 {
730 /* Clear the field */
731 NewValue.Object = NULL;
732 }
733 else
734 {
735 /* Otherwise, we assume the object was referenced and is ready */
736 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
737 }
738
739 /* Update the object */
740 OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
741 return OldValue;
742}
743
748 IN PVOID OldObject)
749{
750 EX_FAST_REF OldValue, NewValue;
751
752 /* Sanity check and start swap loop */
754 for (;;)
755 {
756 /* Get the current value */
757 OldValue = *FastRef;
758
759 /* Make sure there's enough references to swap */
760 if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
761
762 /* Check if we have an object to swap */
763 if (Object)
764 {
765 /* Set up the value with maximum fast references */
766 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
767 }
768 else
769 {
770 /* Write the object address itself (which is empty) */
771 NewValue.Value = (ULONG_PTR)Object;
772 }
773
774 /* Do the actual compare exchange */
775 NewValue.Object = ExpChangePushlock(&FastRef->Object,
776 NewValue.Object,
777 OldValue.Object);
778 if (NewValue.Object != OldValue.Object) continue;
779
780 /* All done */
781 break;
782 }
783
784 /* Return the old value */
785 return OldValue;
786}
787
788/* RUNDOWN *******************************************************************/
789
793 IN ULONG ProcNumber)
794{
795 return (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs +
796 RunRefCacheAware->RunRefSize *
797 (ProcNumber % RunRefCacheAware->Number));
798}
799
800/*++
801 * @name ExfAcquireRundownProtection
802 * INTERNAL MACRO
803 *
804 * The ExfAcquireRundownProtection routine acquires rundown protection for
805 * the specified descriptor.
806 *
807 * @param RunRef
808 * Pointer to a rundown reference descriptor.
809 *
810 * @return TRUE if access to the protected structure was granted, FALSE otherwise.
811 *
812 * @remarks This is the internal macro for system use only.In case the rundown
813 * was active, then the slow-path will be called through the exported
814 * function.
815 *
816 *--*/
820{
821 ULONG_PTR Value, NewValue;
822
823 /* Get the current value and mask the active bit */
824 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
825
826 /* Add a reference */
827 NewValue = Value + EX_RUNDOWN_COUNT_INC;
828
829 /* Change the value */
830 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
831 if (NewValue != Value)
832 {
833 /* Rundown was active, use long path */
834 return ExfAcquireRundownProtection(RunRef);
835 }
836
837 /* Success */
838 return TRUE;
839}
840
841/*++
842 * @name ExReleaseRundownProtection
843 * INTERNAL MACRO
844 *
845 * The ExReleaseRundownProtection routine releases rundown protection for
846 * the specified descriptor.
847 *
848 * @param RunRef
849 * Pointer to a rundown reference descriptor.
850 *
851 * @return TRUE if access to the protected structure was granted, FALSE otherwise.
852 *
853 * @remarks This is the internal macro for system use only.In case the rundown
854 * was active, then the slow-path will be called through the exported
855 * function.
856 *
857 *--*/
859VOID
861{
862 ULONG_PTR Value, NewValue;
863
864 /* Get the current value and mask the active bit */
865 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
866
867 /* Remove a reference */
868 NewValue = Value - EX_RUNDOWN_COUNT_INC;
869
870 /* Change the value */
871 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
872
873 /* Check if the rundown was active */
874 if (NewValue != Value)
875 {
876 /* Rundown was active, use long path */
878 }
879 else
880 {
881 /* Sanity check */
883 }
884}
885
886/*++
887 * @name ExInitializeRundownProtection
888 * INTERNAL MACRO
889 *
890 * The ExInitializeRundownProtection routine initializes a rundown
891 * protection descriptor.
892 *
893 * @param RunRef
894 * Pointer to a rundown reference descriptor.
895 *
896 * @return None.
897 *
898 * @remarks This is the internal macro for system use only.
899 *
900 *--*/
902VOID
904{
905 /* Set the count to zero */
906 RunRef->Count = 0;
907}
908
909/*++
910 * @name ExWaitForRundownProtectionRelease
911 * INTERNAL MACRO
912 *
913 * The ExWaitForRundownProtectionRelease routine waits until the specified
914 * rundown descriptor has been released.
915 *
916 * @param RunRef
917 * Pointer to a rundown reference descriptor.
918 *
919 * @return None.
920 *
921 * @remarks This is the internal macro for system use only. If a wait is actually
922 * necessary, then the slow path is taken through the exported function.
923 *
924 *--*/
926VOID
928{
930
931 /* Set the active bit */
933 if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
934 {
935 /* If the the rundown wasn't already active, then take the long path */
937 }
938}
939
940/*++
941 * @name ExRundownCompleted
942 * INTERNAL MACRO
943 *
944 * The ExRundownCompleted routine completes the rundown of the specified
945 * descriptor by setting the active bit.
946 *
947 * @param RunRef
948 * Pointer to a rundown reference descriptor.
949 *
950 * @return None.
951 *
952 * @remarks This is the internal macro for system use only.
953 *
954 *--*/
956VOID
958{
959 /* Sanity check */
960 ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
961
962 /* Mark the counter as active */
964}
965
966/* PUSHLOCKS *****************************************************************/
967
968/* FIXME: VERIFY THESE! */
969
970VOID
973 IN PEX_PUSH_LOCK PushLock,
974 IN PVOID WaitBlock
975);
976
977VOID
980 IN PEX_PUSH_LOCK PushLock,
981 IN PVOID CurrentWaitBlock
982);
983
984VOID
987 IN PEX_PUSH_LOCK PushLock,
988 IN PVOID WaitBlock
989);
990
991/*++
992 * @name _ExInitializePushLock
993 * INTERNAL MACRO
994 *
995 * The _ExInitializePushLock macro initializes a PushLock.
996 *
997 * @params PushLock
998 * Pointer to the pushlock which is to be initialized.
999 *
1000 * @return None.
1001 *
1002 * @remarks None.
1003 *
1004 *--*/
1006VOID
1008{
1009 /* Set the value to 0 */
1010 PushLock->Ptr = 0;
1011}
1012#define ExInitializePushLock _ExInitializePushLock
1013
1014/*++
1015 * @name ExAcquirePushLockExclusive
1016 * INTERNAL MACRO
1017 *
1018 * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1019 *
1020 * @params PushLock
1021 * Pointer to the pushlock which is to be acquired.
1022 *
1023 * @return None.
1024 *
1025 * @remarks The function attempts the quickest route to acquire the lock, which is
1026 * to simply set the lock bit.
1027 * However, if the pushlock is already shared, the slower path is taken.
1028 *
1029 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1030 * This macro should usually be paired up with KeAcquireCriticalRegion.
1031 *
1032 *--*/
1034VOID
1036{
1037 /* Try acquiring the lock */
1039 {
1040 /* Someone changed it, use the slow path */
1042 }
1043
1044 /* Sanity check */
1045 ASSERT(PushLock->Locked);
1046}
1047
1048/*++
1049* @name ExTryToAcquirePushLockExclusive
1050* INTERNAL MACRO
1051*
1052* The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1053*
1054* @params PushLock
1055* Pointer to the pushlock which is to be acquired.
1056*
1057* @return None.
1058*
1059* @remarks The function attempts the quickest route to acquire the lock, which is
1060* to simply set the lock bit.
1061* However, if the pushlock is already shared, the slower path is taken.
1062*
1063* Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1064* This macro should usually be paired up with KeAcquireCriticalRegion.
1065*
1066*--*/
1068BOOLEAN
1070{
1071 /* Try acquiring the lock */
1073 {
1074 /* Can't acquire */
1075 return FALSE;
1076 }
1077
1078 /* Got acquired */
1079 ASSERT (PushLock->Locked);
1080 return TRUE;
1081}
1082
1083/*++
1084 * @name ExAcquirePushLockShared
1085 * INTERNAL MACRO
1086 *
1087 * The ExAcquirePushLockShared macro acquires a shared PushLock.
1088 *
1089 * @params PushLock
1090 * Pointer to the pushlock which is to be acquired.
1091 *
1092 * @return None.
1093 *
1094 * @remarks The function attempts the quickest route to acquire the lock, which is
1095 * to simply set the lock bit and set the share count to one.
1096 * However, if the pushlock is already shared, the slower path is taken.
1097 *
1098 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1099 * This macro should usually be paired up with KeAcquireCriticalRegion.
1100 *
1101 *--*/
1103VOID
1105{
1106 EX_PUSH_LOCK NewValue;
1107
1108 /* Try acquiring the lock */
1110 if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1111 {
1112 /* Someone changed it, use the slow path */
1113 ExfAcquirePushLockShared(PushLock);
1114 }
1115
1116 /* Sanity checks */
1117 ASSERT(PushLock->Locked);
1118}
1119
1120/*++
1121 * @name ExConvertPushLockSharedToExclusive
1122 * INTERNAL MACRO
1123 *
1124 * The ExConvertPushLockSharedToExclusive macro converts an exclusive
1125 * pushlock to a shared pushlock.
1126 *
1127 * @params PushLock
1128 * Pointer to the pushlock which is to be converted.
1129 *
1130 * @return FALSE if conversion failed, TRUE otherwise.
1131 *
1132 * @remarks The function attempts the quickest route to convert the lock, which is
1133 * to simply set the lock bit and remove any other bits.
1134 *
1135 *--*/
1137BOOLEAN
1139{
1140 EX_PUSH_LOCK OldValue;
1141
1142 /* Set the expected old value */
1144
1145 /* Try converting the lock */
1146 if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1147 OldValue.Ptr)
1148 {
1149 /* Conversion failed */
1150 return FALSE;
1151 }
1152
1153 /* Sanity check */
1154 ASSERT(PushLock->Locked);
1155 return TRUE;
1156}
1157
1158/*++
1159 * @name ExWaitOnPushLock
1160 * INTERNAL MACRO
1161 *
1162 * The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
1163 *
1164 * @params PushLock
1165 * Pointer to a pushlock.
1166 *
1167 * @return None.
1168 *
1169 * @remarks The function attempts to get any exclusive waiters out of their slow
1170 * path by forcing an instant acquire/release operation.
1171 *
1172 * Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
1173 *
1174 *--*/
1176VOID
1178{
1179 /* Check if we're locked */
1180 if (PushLock->Locked)
1181 {
1182 /* Acquire the lock */
1184 ASSERT(PushLock->Locked);
1185
1186 /* Release it */
1188 }
1189}
1190
1191/*++
1192 * @name ExReleasePushLockShared
1193 * INTERNAL MACRO
1194 *
1195 * The ExReleasePushLockShared macro releases a previously acquired PushLock.
1196 *
1197 * @params PushLock
1198 * Pointer to a previously acquired pushlock.
1199 *
1200 * @return None.
1201 *
1202 * @remarks The function attempts the quickest route to release the lock, which is
1203 * to simply decrease the share count and remove the lock bit.
1204 * However, if the pushlock is being waited on then the long path is taken.
1205 *
1206 * Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
1207 * This macro should usually be paired up with KeLeaveCriticalRegion.
1208 *
1209 *--*/
1211VOID
1213{
1214 EX_PUSH_LOCK OldValue;
1215
1216 /* Sanity checks */
1217 ASSERT(PushLock->Locked);
1218
1219 /* Try to clear the pushlock */
1221 if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1222 {
1223 /* There are still other people waiting on it */
1224 ExfReleasePushLockShared(PushLock);
1225 }
1226}
1227
1228/*++
1229 * @name ExReleasePushLockExclusive
1230 * INTERNAL MACRO
1231 *
1232 * The ExReleasePushLockExclusive macro releases a previously
1233 * exclusively acquired PushLock.
1234 *
1235 * @params PushLock
1236 * Pointer to a previously acquired pushlock.
1237 *
1238 * @return None.
1239 *
1240 * @remarks The function attempts the quickest route to release the lock, which is
1241 * to simply clear the locked bit.
1242 * However, if the pushlock is being waited on, the slow path is taken
1243 * in an attempt to wake up the lock.
1244 *
1245 * Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
1246 * This macro should usually be paired up with KeLeaveCriticalRegion.
1247 *
1248 *--*/
1250VOID
1252{
1253 EX_PUSH_LOCK OldValue;
1254
1255 /* Sanity checks */
1256 ASSERT(PushLock->Locked);
1257
1258 /* Unlock the pushlock */
1259 OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1261
1262 /* Sanity checks */
1263 ASSERT(OldValue.Locked);
1264 ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1265
1266 /* Check if anyone is waiting on it and it's not already waking*/
1267 if ((OldValue.Waiting) && !(OldValue.Waking))
1268 {
1269 /* Wake it up */
1270 ExfTryToWakePushLock(PushLock);
1271 }
1272}
1273
1274/*++
1275 * @name ExReleasePushLock
1276 * INTERNAL MACRO
1277 *
1278 * The ExReleasePushLock macro releases a previously acquired PushLock.
1279 *
1280 * @params PushLock
1281 * Pointer to a previously acquired pushlock.
1282 *
1283 * @return None.
1284 *
1285 * @remarks The function attempts the quickest route to release the lock, which is
1286 * to simply clear all the fields and decrease the share count if required.
1287 * However, if the pushlock is being waited on then the long path is taken.
1288 *
1289 * Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
1290 * This macro should usually be paired up with KeLeaveCriticalRegion.
1291 *
1292 *--*/
1294VOID
1296{
1297 EX_PUSH_LOCK OldValue = *PushLock;
1298 EX_PUSH_LOCK NewValue;
1299
1300 /* Sanity checks */
1301 ASSERT(OldValue.Locked);
1302
1303 /* Check if the pushlock is shared */
1304 if (OldValue.Shared > 1)
1305 {
1306 /* Decrease the share count */
1307 NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1308 }
1309 else
1310 {
1311 /* Clear the pushlock entirely */
1312 NewValue.Value = 0;
1313 }
1314
1315 /* Check if nobody is waiting on us and try clearing the lock here */
1316 if ((OldValue.Waiting) ||
1317 (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1318 OldValue.Ptr))
1319 {
1320 /* We have waiters, use the long path */
1321 ExfReleasePushLock(PushLock);
1322 }
1323}
1324
1325/* FAST MUTEX INLINES *********************************************************/
1326
1328VOID
1330{
1332
1333 /* Sanity check */
1335 (Thread->CombinedApcDisable != 0) ||
1336 (Thread->Teb == NULL) ||
1337 (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1338 ASSERT(FastMutex->Owner != Thread);
1339
1340 /* Decrease the count */
1341 if (InterlockedDecrement(&FastMutex->Count))
1342 {
1343 /* Someone is still holding it, use slow path */
1344 KiAcquireFastMutex(FastMutex);
1345 }
1346
1347 /* Set the owner */
1348 FastMutex->Owner = Thread;
1349}
1350
1352VOID
1354{
1356 (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1357 (KeGetCurrentThread()->Teb == NULL) ||
1359 ASSERT(FastMutex->Owner == KeGetCurrentThread());
1360
1361 /* Erase the owner */
1362 FastMutex->Owner = NULL;
1363
1364 /* Increase the count */
1365 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1366 {
1367 /* Someone was waiting for it, signal the waiter */
1368 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1369 }
1370}
1371
1373VOID
1375{
1376 KIRQL OldIrql;
1378
1379 /* Raise IRQL to APC */
1381
1382 /* Decrease the count */
1383 if (InterlockedDecrement(&FastMutex->Count))
1384 {
1385 /* Someone is still holding it, use slow path */
1386 KiAcquireFastMutex(FastMutex);
1387 }
1388
1389 /* Set the owner and IRQL */
1390 FastMutex->Owner = KeGetCurrentThread();
1391 FastMutex->OldIrql = OldIrql;
1392}
1393
1395VOID
1397{
1398 KIRQL OldIrql;
1400
1401 /* Erase the owner */
1402 FastMutex->Owner = NULL;
1403 OldIrql = (KIRQL)FastMutex->OldIrql;
1404
1405 /* Increase the count */
1406 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1407 {
1408 /* Someone was waiting for it, signal the waiter */
1409 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1410 }
1411
1412 /* Lower IRQL back */
1414}
1415
1417BOOLEAN
1419{
1420 KIRQL OldIrql;
1422
1423 /* Raise to APC_LEVEL */
1425
1426 /* Check if we can quickly acquire it */
1427 if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1428 {
1429 /* We have, set us as owners */
1430 FastMutex->Owner = KeGetCurrentThread();
1431 FastMutex->OldIrql = OldIrql;
1432 return TRUE;
1433 }
1434 else
1435 {
1436 /* Acquire attempt failed */
1439 return FALSE;
1440 }
1441}
1442
1444VOID
1446{
1447 /* Enter the Critical Region */
1449
1450 /* Acquire the mutex unsafely */
1451 _ExAcquireFastMutexUnsafe(FastMutex);
1452}
1453
1455VOID
1457{
1458 /* Release the mutex unsafely */
1459 _ExReleaseFastMutexUnsafe(FastMutex);
1460
1461 /* Leave the critical region */
1463}
1464
1465/* OTHER FUNCTIONS **********************************************************/
1466
1467BOOLEAN
1468NTAPI
1471);
1472
1475 IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
1476);
1477
1478BOOLEAN
1479NTAPI
1482);
1483
1484VOID
1485NTAPI
1487 VOID
1488);
1489
1490VOID
1491NTAPI
1493 IN BOOLEAN UpdateInterruptTime,
1494 IN ULONG MaxSepInSeconds
1495);
1496
1497VOID
1498NTAPI
1500 OUT LUID *LocallyUniqueId
1501);
1502
1503VOID
1504NTAPI
1506 VOID
1507);
1508
1509CODE_SEG("INIT")
1510VOID
1511NTAPI
1513 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1514);
1515
1516CODE_SEG("INIT")
1517VOID
1518NTAPI
1519XIPInit(
1520 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1521);
1522
1523#define InterlockedDecrementUL(Addend) \
1524 (ULONG)InterlockedDecrement((PLONG)(Addend))
1525
1526#define InterlockedIncrementUL(Addend) \
1527 (ULONG)InterlockedIncrement((PLONG)(Addend))
1528
1529#define InterlockedExchangeUL(Target, Value) \
1530 (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1531
1532#define InterlockedExchangeAddUL(Addend, Value) \
1533 (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
1534
1535#define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
1536 (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
1537
1538#define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \
1539 (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))
1540
1541#ifdef _WIN64
1542#define InterlockedExchangeSizeT(Target, Value) \
1543 (SIZE_T)InterlockedExchange64((PLONG64)Target, (LONG64)Value)
1544#else
1545#define InterlockedExchangeSizeT(Target, Value) \
1546 (SIZE_T)InterlockedExchange((PLONG)Target, (LONG)Value)
1547#endif
1548
1549#define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
1550 (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
1551
1552#ifdef __cplusplus
1553} // extern "C"
1554#endif
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
#define EX_PUSH_LOCK_LOCK_V
Definition: Object.c:28
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define InterlockedIncrement
Definition: armddk.h:53
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
LONG_PTR SSIZE_T
Definition: basetsd.h:183
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
Definition: bufpool.h:45
_In_ PVOID Argument2
Definition: classpnp.h:721
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ERESOURCE * PERESOURCE
Definition: env_spec_w32.h:595
ULONG ERESOURCE
Definition: env_spec_w32.h:594
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
Definition: eventobj.c:229
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1353
ULONG ExpInitializationPhase
Definition: init.c:68
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation(VOID)
Definition: sem.c:43
VOID NTAPI ExWaitForCallBacks(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:85
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:26
VOID NTAPI ExShutdownSystem(VOID)
Definition: shutdown.c:21
RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
Definition: time.c:21
VOID NTAPI ExSweepHandleTable(IN PHANDLE_TABLE HandleTable, IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure, IN PVOID Context)
Definition: handle.c:1232
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:18
#define MAX_FAST_REFS
Definition: ex.h:132
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1295
BOOLEAN NTAPI ExChangeHandle(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine, IN ULONG_PTR Context)
Definition: handle.c:1189
FORCEINLINE VOID _ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1396
NTSTATUS ExpSetTimeZoneInformation(IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
BOOLEAN NTAPI ExpInitializeTimerImplementation(VOID)
Definition: timer.c:223
VOID FASTCALL ExBlockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID WaitBlock)
union _EXHANDLE EXHANDLE
#define ExpSetRundown(x, y)
Definition: ex.h:164
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1329
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:20
ULONG CmNtCSDReleaseType
Definition: init.c:60
FORCEINLINE BOOLEAN ExReleaseFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:684
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:27
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:34
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1456
HANDLE NTAPI ExCreateHandle(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:827
VOID NTAPI ExpResourceInitialization(VOID)
Definition: resource.c:169
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:587
POBJECT_TYPE _ExEventObjectType
BOOLEAN NTAPI ExpInitializeProfileImplementation(VOID)
Definition: profile.c:62
PCALLBACK_OBJECT PowerStateCallback
Definition: callback.c:29
VOID NTAPI XIPInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: xipdisp.c:55
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
#define HANDLE_HIGH_BITS
Definition: ex.h:79
NTSTATUS NTAPI ExGetPoolTagInfo(IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, IN ULONG SystemInformationLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: expool.c:1353
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:25
VOID FASTCALL ExfInitializeRundownProtection(OUT PEX_RUNDOWN_REF RunRef)
PVOID NTAPI ExGetCallBackBlockContext(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:101
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:28
UNICODE_STRING NtSystemRoot
Definition: init.c:75
VOID NTAPI ExInitializeSystemLookasideList(IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
Definition: lookas.c:31
LIST_ENTRY ExPoolLookasideListHead
Definition: lookas.c:22
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation(VOID)
ULONG NtBuildNumber
Definition: init.c:50
POBJECT_TYPE _ExSemaphoreObjectType
Definition: ex.h:16
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:18
LIST_ENTRY ExpFirmwareTableProviderListHead
Definition: sysinfo.c:31
FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1418
ULONG ExpOemCodePageDataOffset
Definition: ex.h:23
struct _ETIMER * PETIMER
VOID NTAPI ExUpdateSystemTimeFromCmos(IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
Definition: time.c:217
BOOLEAN NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:259
ULONG NtMajorVersion
Definition: init.c:45
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:86
BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:2129
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:746
VOID NTAPI ExpInitializePushLocks(VOID)
Definition: pushlock.c:45
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27
FORCEINLINE VOID _ExInitializeRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:903
BOOLEAN NTAPI ExpInitializeEventImplementation(VOID)
Definition: event.c:39
PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:93
PVOID ExpDefaultErrorPort
Definition: harderr.c:18
CHAR NtBuildLab[]
Definition: init.c:64
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:29
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:19
VOID FASTCALL ExWaitForUnblockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID WaitBlock)
Definition: pushlock.c:395
PHANDLE_TABLE NTAPI ExCreateHandleTable(IN PEPROCESS Process OPTIONAL)
Definition: handle.c:801
ULONG ExCriticalWorkerThreads
Definition: work.c:34
BOOLEAN(NTAPI * PEX_SWEEP_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, HANDLE Handle, PVOID Context)
Definition: ex.h:433
ULONG NtGlobalFlag
Definition: init.c:54
enum _WINKD_WORKER_STATE WINKD_WORKER_STATE
BOOLEAN NTAPI ExCompareExchangeCallBack(IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK NewBlock, IN PEX_CALLBACK_ROUTINE_BLOCK OldBlock)
Definition: callback.c:170
BOOLEAN(NTAPI * PEX_CHANGE_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)
Definition: ex.h:448
VOID NTAPI ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
Definition: uuid.c:335
VOID FASTCALL ExfReleaseRundownProtectionEx(IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
FORCEINLINE VOID ExDoCallBack(IN OUT PEX_CALLBACK Callback, IN PVOID Context, IN PVOID Argument1, IN PVOID Argument2)
Definition: ex.h:552
BOOLEAN ExpIsWinPEMode
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1035
_WINKD_WORKER_STATE
Definition: ex.h:60
@ WinKdWorkerStart
Definition: ex.h:62
@ WinKdWorkerReady
Definition: ex.h:61
@ WinKdWorkerInitialized
Definition: ex.h:63
union _EXHANDLE * PEXHANDLE
UNICODE_STRING CmVersionString
Definition: init.c:61
PVOID ExpNlsSectionPointer
Definition: init.c:89
VOID NTAPI ExInitializeCallBack(IN OUT PEX_CALLBACK Callback)
Definition: callback.c:46
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack)
Definition: callback.c:122
ULONG ExDelayedWorkerThreads
Definition: work.c:35
VOID FASTCALL ExfRundownCompleted(OUT PEX_RUNDOWN_REF RunRef)
LIST_ENTRY ExpSystemResourcesList
Definition: resource.c:76
PEPROCESS ExpDefaultErrorPortProcess
Definition: harderr.c:19
ULONG ExpAltTimeZoneBias
Definition: time.c:24
VOID NTAPI ExpDebuggerWorker(IN PVOID Context)
Definition: dbgctrl.c:52
FORCEINLINE VOID _ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1374
BOOLEAN NTAPI ExpInitializeCallbacks(VOID)
Definition: callback.c:256
VOID NTAPI ExInit2(VOID)
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:21
ERESOURCE ExpFirmwareTableResource
Definition: sysinfo.c:30
#define HANDLE_TAG_BITS
Definition: ex.h:81
BOOLEAN NTAPI ExDestroyHandle(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
Definition: handle.c:984
#define HANDLE_INDEX_BITS
Definition: ex.h:82
ULONG ExpTickCountMultiplier
Definition: time.c:26
ULONG ExpLastTimeZoneBias
Definition: time.c:22
WORK_QUEUE_ITEM ExpDebuggerWorkItem
Definition: dbgctrl.c:20
FORCEINLINE BOOLEAN ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:645
BOOLEAN NTAPI ExpInitializeMutantImplementation(VOID)
Definition: mutant.c:52
ULONG CmNtSpBuildNumber
Definition: init.c:58
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
ULONG ExpTimeZoneId
Definition: time.c:25
FORCEINLINE VOID _ExWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:927
VOID FASTCALL ExfReInitializeRundownProtection(OUT PEX_RUNDOWN_REF RunRef)
#define HANDLE_LOW_BITS
Definition: ex.h:78
VOID NTAPI ExFreeCallBack(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:77
FORCEINLINE VOID ExInitializeFastReference(OUT PEX_FAST_REF FastRef, IN OPTIONAL PVOID Object)
Definition: ex.h:595
#define KERNEL_FLAG_BITS
Definition: ex.h:83
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1104
VOID NTAPI ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
Definition: handle.c:963
VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
Definition: handle.c:1046
FORCEINLINE BOOLEAN ExTryToAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1069
VOID NTAPI ExDereferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:109
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1212
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:83
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
Definition: ex.h:1138
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:85
ULONG NtMinorVersion
Definition: init.c:46
#define ExpChangeRundown(x, y, z)
Definition: ex.h:162
struct _UUID_CACHED_VALUES_STRUCT UUID_CACHED_VALUES_STRUCT
FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1445
FORCEINLINE BOOLEAN _ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:819
struct _ETIMER ETIMER
ULONG CmNtCSDVersion
Definition: init.c:59
FORCEINLINE EX_FAST_REF ExSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:719
VOID FASTCALL ExfWaitForRundownProtectionRelease(IN OUT PEX_RUNDOWN_REF RunRef)
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:17
VOID NTAPI ExTimerRundown(VOID)
Definition: timer.c:43
VOID NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:922
FORCEINLINE VOID _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:957
BOOLEAN NTAPI ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
Definition: time.c:51
#define ExpChangePushlock(x, y, z)
Definition: ex.h:163
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:579
VOID NTAPI Phase1Initialization(IN PVOID Context)
Definition: init.c:2018
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:59
FORCEINLINE VOID _ExInitializePushLock(OUT PEX_PUSH_LOCK PushLock)
Definition: ex.h:1007
VOID FASTCALL ExfReleaseRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
BOOLEAN NTAPI ExpInitializeEventPairImplementation(VOID)
Definition: evtpair.c:33
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:923
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
Definition: work.c:637
UNICODE_STRING CmCSDVersionString
Definition: init.c:62
FORCEINLINE VOID _ExReleaseRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:860
LONG NTAPI ExSystemExceptionFilter(VOID)
Definition: harderr.c:349
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack(IN PEX_CALLBACK_FUNCTION Function, IN PVOID Context)
Definition: callback.c:54
BOOLEAN FASTCALL ExfAcquireRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
BOOLEAN NTAPI ExLuidInitialization(VOID)
Definition: uuid.c:325
FORCEINLINE PEX_RUNDOWN_REF ExGetRunRefForGivenProcessor(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, IN ULONG ProcNumber)
Definition: ex.h:792
BOOLEAN NTAPI ExRefreshTimeZoneInformation(IN PLARGE_INTEGER SystemBootTime)
Definition: time.c:226
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1251
VOID NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:522
VOID FASTCALL ExfUnblockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID CurrentWaitBlock)
PHANDLE_TABLE NTAPI ExDupHandleTable(IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure, IN ULONG_PTR Mask)
Definition: handle.c:1072
BOOLEAN(NTAPI * PEX_DUPLICATE_HANDLE_CALLBACK)(IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN PHANDLE_TABLE_ENTRY NewEntry)
Definition: ex.h:440
struct _HARDERROR_USER_PARAMETERS HARDERROR_USER_PARAMETERS
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:616
struct _HARDERROR_USER_PARAMETERS * PHARDERROR_USER_PARAMETERS
struct _UUID_CACHED_VALUES_STRUCT * PUUID_CACHED_VALUES_STRUCT
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1177
BOOLEAN NTAPI ExpUuidInitialization(VOID)
Definition: uuid.c:53
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
unsigned int Mask
Definition: fpcontrol.c:82
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
ULONG Handle
Definition: gdb_input.c:15
#define KeGetCurrentThread
Definition: hal.h:55
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
#define InterlockedExchangeAddSizeT(a, b)
Definition: interlocked.h:196
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define C_ASSERT(e)
Definition: intsafe.h:73
VOID ExpInitLookasideLists()
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
#define MAXIMUM_HARDERROR_PARAMETERS
Definition: extypes.h:145
int Count
Definition: noreturn.cpp:7
#define FASTCALL
Definition: nt_native.h:50
VOID FASTCALL KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: wait.c:107
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
VOID FASTCALL ExfReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:810
VOID FASTCALL ExfTryToWakePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1165
VOID FASTCALL ExfReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:956
VOID FASTCALL ExfReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1091
VOID FASTCALL ExfAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:471
VOID FASTCALL ExfAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:645
#define YieldProcessor
Definition: ke.h:48
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PCALLBACK_OBJECT * CallbackObject
Definition: ex.h:121
PWSTR Name
Definition: ex.h:122
Definition: ex.h:107
BOOLEAN WakeTimer
Definition: ex.h:115
KAPC TimerApc
Definition: ex.h:109
LIST_ENTRY WakeTimerListEntry
Definition: ex.h:116
LIST_ENTRY ActiveTimerListEntry
Definition: ex.h:111
KDPC TimerDpc
Definition: ex.h:110
LONG Period
Definition: ex.h:113
KSPIN_LOCK Lock
Definition: ex.h:112
KTIMER KeTimer
Definition: ex.h:108
BOOLEAN ApcAssociated
Definition: ex.h:114
PVOID Object
Definition: extypes.h:422
ULONG_PTR Value
Definition: extypes.h:424
ULONG_PTR RefCnt
Definition: extypes.h:423
ULONG_PTR Value
Definition: extypes.h:465
PVOID Ptr
Definition: extypes.h:466
ULONG_PTR Waiting
Definition: extypes.h:460
ULONG_PTR Waking
Definition: extypes.h:461
ULONG_PTR Shared
Definition: extypes.h:463
ULONG_PTR Locked
Definition: extypes.h:459
Definition: extypes.h:596
UNICODE_STRING Strings[MAXIMUM_HARDERROR_PARAMETERS]
Definition: ex.h:128
Definition: ketypes.h:535
Definition: ketypes.h:687
Definition: typedefs.h:120
Definition: compat.h:836
UCHAR ClockSeqHiAndReserved
Definition: ex.h:182
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
Definition: ex.h:86
ULONG_PTR KernelFlag2
Definition: ex.h:99
ULONG_PTR KernelFlag
Definition: ex.h:91
ULONG AsULONG
Definition: ex.h:103
ULONG_PTR HighIndex
Definition: ex.h:98
ULONG_PTR LowIndex
Definition: ex.h:96
ULONG_PTR TagBits2
Definition: ex.h:95
ULONG_PTR Index
Definition: ex.h:90
ULONG_PTR TagBits
Definition: ex.h:89
HANDLE GenericHandleOverlay
Definition: ex.h:101
ULONG_PTR Value
Definition: ex.h:102
ULONG_PTR MidIndex
Definition: ex.h:97
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define FORCEINLINE
Definition: wdftypes.h:67
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:698
* PFAST_MUTEX
Definition: extypes.h:17
#define EX_RUNDOWN_COUNT_INC
#define EX_RUNDOWN_ACTIVE
FAST_MUTEX
Definition: extypes.h:17
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175