ReactOS 0.4.16-dev-258-g81860b4
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;
27extern ULONG NtGlobalFlag;
40
43
44/*
45 * NT/Cm Version Info variables
46 */
49extern ULONG NtBuildNumber;
55extern CHAR NtBuildLab[];
56
57/*
58 * WinDBG Debugger Worker State Machine data (see dbgctrl.c)
59 */
61{
66
72
74
75#ifdef _WIN64
76#define HANDLE_LOW_BITS (PAGE_SHIFT - 4)
77#define HANDLE_HIGH_BITS (PAGE_SHIFT - 3)
78#else
79#define HANDLE_LOW_BITS (PAGE_SHIFT - 3)
80#define HANDLE_HIGH_BITS (PAGE_SHIFT - 2)
81#endif
82#define HANDLE_TAG_BITS 2
83#define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2 * HANDLE_HIGH_BITS)
84#define KERNEL_FLAG_BITS (sizeof(ULONG_PTR) * 8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
85
86typedef union _EXHANDLE
87{
88 struct
89 {
93 };
94 struct
95 {
101 };
106
107typedef struct _ETIMER
108{
119
120typedef struct
121{
125
127{
132
133#define MAX_FAST_REFS 7
134
135#define ExAcquireRundownProtection _ExAcquireRundownProtection
136#define ExReleaseRundownProtection _ExReleaseRundownProtection
137#define ExInitializeRundownProtection _ExInitializeRundownProtection
138#define ExWaitForRundownProtectionRelease _ExWaitForRundownProtectionRelease
139#define ExRundownCompleted _ExRundownCompleted
140#define ExGetPreviousMode KeGetPreviousMode
141
142
143//
144// Various bits tagged on the handle or handle table
145//
146#define EXHANDLE_TABLE_ENTRY_LOCK_BIT 1
147#define FREE_HANDLE_MASK -1
148
149//
150// Number of entries in each table level
151//
152#define LOW_LEVEL_ENTRIES (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))
153#define MID_LEVEL_ENTRIES (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))
154#define HIGH_LEVEL_ENTRIES (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))
155
156//
157// Maximum index in each table level before we need another table
158//
159#define MAX_LOW_INDEX LOW_LEVEL_ENTRIES
160#define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
161#define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
162
163#define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&(x)->Ptr, (PVOID)(y), (PVOID)(z))
164#define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)(x), (PVOID)(y), (PVOID)(z))
165#define ExpSetRundown(x, y) InterlockedExchangePointer(&(x)->Ptr, (PVOID)(y))
166
168NTAPI
170 IN PSYSTEM_POOLTAG_INFORMATION SystemInformation,
171 IN ULONG SystemInformationLength,
173);
174
176{
179 union
180 {
181 struct
182 {
185 UCHAR NodeId[6 /*SEED_BUFFER_SIZE*/];
186 };
187 UCHAR GuidInit[8]; /* Match GUID.Data4 */
188 };
190
192
193/* INITIALIZATION FUNCTIONS *************************************************/
194
195CODE_SEG("INIT")
197NTAPI
199
200VOID
201NTAPI
203
204VOID
205NTAPI
208);
209
210CODE_SEG("INIT")
211VOID
212NTAPI
214
216NTAPI
218 IN PLARGE_INTEGER SystemBootTime
219);
220
221CODE_SEG("INIT")
222VOID
223NTAPI
225
226VOID
227NTAPI
229
230CODE_SEG("INIT")
231VOID
232NTAPI
234
235CODE_SEG("INIT")
236VOID
237NTAPI
241 IN ULONG Size,
242 IN ULONG Tag,
243 IN USHORT MaximumDepth,
244 IN PLIST_ENTRY ListHead
245);
246
247CODE_SEG("INIT")
249NTAPI
251
252CODE_SEG("INIT")
254NTAPI
256
257CODE_SEG("INIT")
259NTAPI
261
262CODE_SEG("INIT")
263VOID
264NTAPI
266 IN ULONG Cpu,
267 IN PLOADER_PARAMETER_BLOCK LoaderBlock
268);
269
270VOID
271NTAPI
273
274CODE_SEG("INIT")
276NTAPI
278
279CODE_SEG("INIT")
281NTAPI
283
284CODE_SEG("INIT")
286NTAPI
288
289CODE_SEG("INIT")
291NTAPI
293
294CODE_SEG("INIT")
296NTAPI
298
299CODE_SEG("INIT")
301NTAPI
303
304CODE_SEG("INIT")
306NTAPI
308
309CODE_SEG("INIT")
310VOID
311NTAPI
313
314CODE_SEG("INIT")
315VOID
316NTAPI
318
319/* Callback Functions ********************************************************/
320
321VOID
322NTAPI
325);
326
328NTAPI
332);
333
334VOID
335NTAPI
337 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
338);
339
341NTAPI
343 IN OUT PEX_CALLBACK CallBack,
346);
347
349NTAPI
351 IN OUT PEX_CALLBACK CallBack
352);
353
354VOID
355NTAPI
357 IN OUT PEX_CALLBACK CallBack,
358 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
359);
360
362NTAPI
364 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
365);
366
367PVOID
368NTAPI
370 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
371);
372
373VOID
374NTAPI
376 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
377);
378
379/* Rundown Functions ********************************************************/
380
381VOID
384 OUT PEX_RUNDOWN_REF RunRef
385);
386
387VOID
390 OUT PEX_RUNDOWN_REF RunRef
391);
392
396 IN OUT PEX_RUNDOWN_REF RunRef
397);
398
402 IN OUT PEX_RUNDOWN_REF RunRef,
404);
405
406VOID
409 IN OUT PEX_RUNDOWN_REF RunRef
410);
411
412VOID
415 IN OUT PEX_RUNDOWN_REF RunRef,
417);
418
419VOID
422 OUT PEX_RUNDOWN_REF RunRef
423);
424
425VOID
428 IN OUT PEX_RUNDOWN_REF RunRef
429);
430
431/* HANDLE TABLE FUNCTIONS ***************************************************/
432
433typedef BOOLEAN
435 PHANDLE_TABLE_ENTRY HandleTableEntry,
438);
439
440typedef BOOLEAN
444 IN PHANDLE_TABLE_ENTRY HandleTableEntry,
445 IN PHANDLE_TABLE_ENTRY NewEntry
446);
447
448typedef BOOLEAN
450 PHANDLE_TABLE_ENTRY HandleTableEntry,
452);
453
454CODE_SEG("INIT")
455VOID
456NTAPI
458 VOID
459);
460
462NTAPI
465);
466
467VOID
468NTAPI
471 IN PHANDLE_TABLE_ENTRY HandleTableEntry
472);
473
474HANDLE
475NTAPI
478 IN PHANDLE_TABLE_ENTRY HandleTableEntry
479);
480
481VOID
482NTAPI
485 IN PVOID DestroyHandleProcedure OPTIONAL
486);
487
489NTAPI
493 IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL
494);
495
497NTAPI
501);
502
504NTAPI
508 IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure,
510);
511
513NTAPI
517 IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine,
519);
520
521VOID
522NTAPI
525 IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure,
527);
528
530NTAPI
534);
535
537NTAPI
540 IN PHANDLE_TABLE_ENTRY HandleTableEntry
541);
542
543/* PSEH EXCEPTION HANDLING **************************************************/
544
545LONG
546NTAPI
548
549/* CALLBACKS *****************************************************************/
550
552VOID
557{
558 PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
560
561 /* Reference the block */
562 CallbackBlock = ExReferenceCallBackBlock(Callback);
563 if (CallbackBlock)
564 {
565 /* Get the function */
566 Function = ExGetCallBackBlockRoutine(CallbackBlock);
567
568 /* Do the callback */
570
571 /* Now dereference it */
572 ExDereferenceCallBackBlock(Callback, CallbackBlock);
573 }
574}
575
576/* FAST REFS ******************************************************************/
577
579PVOID
581{
582 /* Return the unbiased pointer */
583 return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
584}
585
587ULONG
589{
590 /* Return the reference count */
591 return (ULONG)FastRef.RefCnt;
592}
593
595VOID
598{
599 /* Sanity check */
601
602 /* Check if an object is being set */
603 if (!Object)
604 {
605 /* Clear the field */
606 FastRef->Object = NULL;
607 }
608 else
609 {
610 /* Otherwise, we assume the object was referenced and is ready */
611 FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
612 }
613}
614
618{
619 EX_FAST_REF OldValue, NewValue;
620
621 /* Start reference loop */
622 for (;;)
623 {
624 /* Get the current reference count */
625 OldValue = *FastRef;
626 if (OldValue.RefCnt)
627 {
628 /* Increase the reference count */
629 NewValue.Value = OldValue.Value - 1;
630 NewValue.Object = ExpChangePushlock(&FastRef->Object,
631 NewValue.Object,
632 OldValue.Object);
633 if (NewValue.Object != OldValue.Object) continue;
634 }
635
636 /* We are done */
637 break;
638 }
639
640 /* Return the old value */
641 return OldValue;
642}
643
648{
649 EX_FAST_REF OldValue, NewValue;
650
651 /* Sanity checks */
653
654 /* Start update loop */
655 for (;;)
656 {
657 /* Get the current reference count */
658 OldValue = *FastRef;
659
660 /* Check if the current count is too high or if the pointer changed */
661 if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
662 ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
663 {
664 /* Fail */
665 return FALSE;
666 }
667
668 /* Update the reference count */
669 NewValue.Value = OldValue.Value + MAX_FAST_REFS;
670 NewValue.Object = ExpChangePushlock(&FastRef->Object,
671 NewValue.Object,
672 OldValue.Object);
673 if (NewValue.Object != OldValue.Object) continue;
674
675 /* We are done */
676 break;
677 }
678
679 /* Return success */
680 return TRUE;
681}
682
687{
688 EX_FAST_REF OldValue, NewValue;
689
690 /* Sanity checks */
691 ASSERT(Object != NULL);
693
694 /* Start reference loop */
695 for (;;)
696 {
697 /* Get the current reference count */
698 OldValue = *FastRef;
699
700 /* Check if we're full if if the pointer changed */
701 if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
702
703 /* Decrease the reference count */
704 NewValue.Value = OldValue.Value + 1;
705 NewValue.Object = ExpChangePushlock(&FastRef->Object,
706 NewValue.Object,
707 OldValue.Object);
708 if (NewValue.Object != OldValue.Object) continue;
709
710 /* We are done */
711 break;
712 }
713
714 /* Return success */
715 return TRUE;
716}
717
722{
723 EX_FAST_REF NewValue, OldValue;
724
725 /* Sanity check */
727
728 /* Check if an object is being set */
729 if (!Object)
730 {
731 /* Clear the field */
732 NewValue.Object = NULL;
733 }
734 else
735 {
736 /* Otherwise, we assume the object was referenced and is ready */
737 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
738 }
739
740 /* Update the object */
741 OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
742 return OldValue;
743}
744
749 IN PVOID OldObject)
750{
751 EX_FAST_REF OldValue, NewValue;
752
753 /* Sanity check and start swap loop */
755 for (;;)
756 {
757 /* Get the current value */
758 OldValue = *FastRef;
759
760 /* Make sure there's enough references to swap */
761 if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
762
763 /* Check if we have an object to swap */
764 if (Object)
765 {
766 /* Set up the value with maximum fast references */
767 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
768 }
769 else
770 {
771 /* Write the object address itself (which is empty) */
772 NewValue.Value = (ULONG_PTR)Object;
773 }
774
775 /* Do the actual compare exchange */
776 NewValue.Object = ExpChangePushlock(&FastRef->Object,
777 NewValue.Object,
778 OldValue.Object);
779 if (NewValue.Object != OldValue.Object) continue;
780
781 /* All done */
782 break;
783 }
784
785 /* Return the old value */
786 return OldValue;
787}
788
789/* RUNDOWN *******************************************************************/
790
794 IN ULONG ProcNumber)
795{
796 return (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs +
797 RunRefCacheAware->RunRefSize *
798 (ProcNumber % RunRefCacheAware->Number));
799}
800
801/*++
802 * @name ExfAcquireRundownProtection
803 * INTERNAL MACRO
804 *
805 * The ExfAcquireRundownProtection routine acquires rundown protection for
806 * the specified descriptor.
807 *
808 * @param RunRef
809 * Pointer to a rundown reference descriptor.
810 *
811 * @return TRUE if access to the protected structure was granted, FALSE otherwise.
812 *
813 * @remarks This is the internal macro for system use only.In case the rundown
814 * was active, then the slow-path will be called through the exported
815 * function.
816 *
817 *--*/
821{
822 ULONG_PTR Value, NewValue;
823
824 /* Get the current value and mask the active bit */
825 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
826
827 /* Add a reference */
828 NewValue = Value + EX_RUNDOWN_COUNT_INC;
829
830 /* Change the value */
831 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
832 if (NewValue != Value)
833 {
834 /* Rundown was active, use long path */
835 return ExfAcquireRundownProtection(RunRef);
836 }
837
838 /* Success */
839 return TRUE;
840}
841
842/*++
843 * @name ExReleaseRundownProtection
844 * INTERNAL MACRO
845 *
846 * The ExReleaseRundownProtection routine releases rundown protection for
847 * the specified descriptor.
848 *
849 * @param RunRef
850 * Pointer to a rundown reference descriptor.
851 *
852 * @return TRUE if access to the protected structure was granted, FALSE otherwise.
853 *
854 * @remarks This is the internal macro for system use only.In case the rundown
855 * was active, then the slow-path will be called through the exported
856 * function.
857 *
858 *--*/
860VOID
862{
863 ULONG_PTR Value, NewValue;
864
865 /* Get the current value and mask the active bit */
866 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
867
868 /* Remove a reference */
869 NewValue = Value - EX_RUNDOWN_COUNT_INC;
870
871 /* Change the value */
872 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
873
874 /* Check if the rundown was active */
875 if (NewValue != Value)
876 {
877 /* Rundown was active, use long path */
879 }
880 else
881 {
882 /* Sanity check */
884 }
885}
886
887/*++
888 * @name ExInitializeRundownProtection
889 * INTERNAL MACRO
890 *
891 * The ExInitializeRundownProtection routine initializes a rundown
892 * protection descriptor.
893 *
894 * @param RunRef
895 * Pointer to a rundown reference descriptor.
896 *
897 * @return None.
898 *
899 * @remarks This is the internal macro for system use only.
900 *
901 *--*/
903VOID
905{
906 /* Set the count to zero */
907 RunRef->Count = 0;
908}
909
910/*++
911 * @name ExWaitForRundownProtectionRelease
912 * INTERNAL MACRO
913 *
914 * The ExWaitForRundownProtectionRelease routine waits until the specified
915 * rundown descriptor has been released.
916 *
917 * @param RunRef
918 * Pointer to a rundown reference descriptor.
919 *
920 * @return None.
921 *
922 * @remarks This is the internal macro for system use only. If a wait is actually
923 * necessary, then the slow path is taken through the exported function.
924 *
925 *--*/
927VOID
929{
931
932 /* Set the active bit */
934 if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
935 {
936 /* If the the rundown wasn't already active, then take the long path */
938 }
939}
940
941/*++
942 * @name ExRundownCompleted
943 * INTERNAL MACRO
944 *
945 * The ExRundownCompleted routine completes the rundown of the specified
946 * descriptor by setting the active bit.
947 *
948 * @param RunRef
949 * Pointer to a rundown reference descriptor.
950 *
951 * @return None.
952 *
953 * @remarks This is the internal macro for system use only.
954 *
955 *--*/
957VOID
959{
960 /* Sanity check */
961 ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
962
963 /* Mark the counter as active */
965}
966
967/* PUSHLOCKS *****************************************************************/
968
969/* FIXME: VERIFY THESE! */
970
971VOID
974 IN PEX_PUSH_LOCK PushLock,
975 IN PVOID WaitBlock
976);
977
978VOID
981 IN PEX_PUSH_LOCK PushLock,
982 IN PVOID CurrentWaitBlock
983);
984
985VOID
988 IN PEX_PUSH_LOCK PushLock,
989 IN PVOID WaitBlock
990);
991
992/*++
993 * @name _ExInitializePushLock
994 * INTERNAL MACRO
995 *
996 * The _ExInitializePushLock macro initializes a PushLock.
997 *
998 * @params PushLock
999 * Pointer to the pushlock which is to be initialized.
1000 *
1001 * @return None.
1002 *
1003 * @remarks None.
1004 *
1005 *--*/
1007VOID
1009{
1010 /* Set the value to 0 */
1011 PushLock->Ptr = 0;
1012}
1013#define ExInitializePushLock _ExInitializePushLock
1014
1015/*++
1016 * @name ExAcquirePushLockExclusive
1017 * INTERNAL MACRO
1018 *
1019 * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1020 *
1021 * @params PushLock
1022 * Pointer to the pushlock which is to be acquired.
1023 *
1024 * @return None.
1025 *
1026 * @remarks The function attempts the quickest route to acquire the lock, which is
1027 * to simply set the lock bit.
1028 * However, if the pushlock is already shared, the slower path is taken.
1029 *
1030 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1031 * This macro should usually be paired up with KeAcquireCriticalRegion.
1032 *
1033 *--*/
1035VOID
1037{
1038 /* Try acquiring the lock */
1040 {
1041 /* Someone changed it, use the slow path */
1043 }
1044
1045 /* Sanity check */
1046 ASSERT(PushLock->Locked);
1047}
1048
1049/*++
1050* @name ExTryToAcquirePushLockExclusive
1051* INTERNAL MACRO
1052*
1053* The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1054*
1055* @params PushLock
1056* Pointer to the pushlock which is to be acquired.
1057*
1058* @return None.
1059*
1060* @remarks The function attempts the quickest route to acquire the lock, which is
1061* to simply set the lock bit.
1062* However, if the pushlock is already shared, the slower path is taken.
1063*
1064* Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1065* This macro should usually be paired up with KeAcquireCriticalRegion.
1066*
1067*--*/
1069BOOLEAN
1071{
1072 /* Try acquiring the lock */
1074 {
1075 /* Can't acquire */
1076 return FALSE;
1077 }
1078
1079 /* Got acquired */
1080 ASSERT (PushLock->Locked);
1081 return TRUE;
1082}
1083
1084/*++
1085 * @name ExAcquirePushLockShared
1086 * INTERNAL MACRO
1087 *
1088 * The ExAcquirePushLockShared macro acquires a shared PushLock.
1089 *
1090 * @params PushLock
1091 * Pointer to the pushlock which is to be acquired.
1092 *
1093 * @return None.
1094 *
1095 * @remarks The function attempts the quickest route to acquire the lock, which is
1096 * to simply set the lock bit and set the share count to one.
1097 * However, if the pushlock is already shared, the slower path is taken.
1098 *
1099 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1100 * This macro should usually be paired up with KeAcquireCriticalRegion.
1101 *
1102 *--*/
1104VOID
1106{
1107 EX_PUSH_LOCK NewValue;
1108
1109 /* Try acquiring the lock */
1111 if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1112 {
1113 /* Someone changed it, use the slow path */
1114 ExfAcquirePushLockShared(PushLock);
1115 }
1116
1117 /* Sanity checks */
1118 ASSERT(PushLock->Locked);
1119}
1120
1121/*++
1122 * @name ExConvertPushLockSharedToExclusive
1123 * INTERNAL MACRO
1124 *
1125 * The ExConvertPushLockSharedToExclusive macro converts an exclusive
1126 * pushlock to a shared pushlock.
1127 *
1128 * @params PushLock
1129 * Pointer to the pushlock which is to be converted.
1130 *
1131 * @return FALSE if conversion failed, TRUE otherwise.
1132 *
1133 * @remarks The function attempts the quickest route to convert the lock, which is
1134 * to simply set the lock bit and remove any other bits.
1135 *
1136 *--*/
1138BOOLEAN
1140{
1141 EX_PUSH_LOCK OldValue;
1142
1143 /* Set the expected old value */
1145
1146 /* Try converting the lock */
1147 if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1148 OldValue.Ptr)
1149 {
1150 /* Conversion failed */
1151 return FALSE;
1152 }
1153
1154 /* Sanity check */
1155 ASSERT(PushLock->Locked);
1156 return TRUE;
1157}
1158
1159/*++
1160 * @name ExWaitOnPushLock
1161 * INTERNAL MACRO
1162 *
1163 * The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
1164 *
1165 * @params PushLock
1166 * Pointer to a pushlock.
1167 *
1168 * @return None.
1169 *
1170 * @remarks The function attempts to get any exclusive waiters out of their slow
1171 * path by forcing an instant acquire/release operation.
1172 *
1173 * Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
1174 *
1175 *--*/
1177VOID
1179{
1180 /* Check if we're locked */
1181 if (PushLock->Locked)
1182 {
1183 /* Acquire the lock */
1185 ASSERT(PushLock->Locked);
1186
1187 /* Release it */
1189 }
1190}
1191
1192/*++
1193 * @name ExReleasePushLockShared
1194 * INTERNAL MACRO
1195 *
1196 * The ExReleasePushLockShared macro releases a previously acquired PushLock.
1197 *
1198 * @params PushLock
1199 * Pointer to a previously acquired pushlock.
1200 *
1201 * @return None.
1202 *
1203 * @remarks The function attempts the quickest route to release the lock, which is
1204 * to simply decrease the share count and remove the lock bit.
1205 * However, if the pushlock is being waited on then the long path is taken.
1206 *
1207 * Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
1208 * This macro should usually be paired up with KeLeaveCriticalRegion.
1209 *
1210 *--*/
1212VOID
1214{
1215 EX_PUSH_LOCK OldValue;
1216
1217 /* Sanity checks */
1218 ASSERT(PushLock->Locked);
1219
1220 /* Try to clear the pushlock */
1222 if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1223 {
1224 /* There are still other people waiting on it */
1225 ExfReleasePushLockShared(PushLock);
1226 }
1227}
1228
1229/*++
1230 * @name ExReleasePushLockExclusive
1231 * INTERNAL MACRO
1232 *
1233 * The ExReleasePushLockExclusive macro releases a previously
1234 * exclusively acquired PushLock.
1235 *
1236 * @params PushLock
1237 * Pointer to a previously acquired pushlock.
1238 *
1239 * @return None.
1240 *
1241 * @remarks The function attempts the quickest route to release the lock, which is
1242 * to simply clear the locked bit.
1243 * However, if the pushlock is being waited on, the slow path is taken
1244 * in an attempt to wake up the lock.
1245 *
1246 * Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
1247 * This macro should usually be paired up with KeLeaveCriticalRegion.
1248 *
1249 *--*/
1251VOID
1253{
1254 EX_PUSH_LOCK OldValue;
1255
1256 /* Sanity checks */
1257 ASSERT(PushLock->Locked);
1258
1259 /* Unlock the pushlock */
1260 OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1262
1263 /* Sanity checks */
1264 ASSERT(OldValue.Locked);
1265 ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1266
1267 /* Check if anyone is waiting on it and it's not already waking*/
1268 if ((OldValue.Waiting) && !(OldValue.Waking))
1269 {
1270 /* Wake it up */
1271 ExfTryToWakePushLock(PushLock);
1272 }
1273}
1274
1275/*++
1276 * @name ExReleasePushLock
1277 * INTERNAL MACRO
1278 *
1279 * The ExReleasePushLock macro releases a previously acquired PushLock.
1280 *
1281 * @params PushLock
1282 * Pointer to a previously acquired pushlock.
1283 *
1284 * @return None.
1285 *
1286 * @remarks The function attempts the quickest route to release the lock, which is
1287 * to simply clear all the fields and decrease the share count if required.
1288 * However, if the pushlock is being waited on then the long path is taken.
1289 *
1290 * Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
1291 * This macro should usually be paired up with KeLeaveCriticalRegion.
1292 *
1293 *--*/
1295VOID
1297{
1298 EX_PUSH_LOCK OldValue = *PushLock;
1299 EX_PUSH_LOCK NewValue;
1300
1301 /* Sanity checks */
1302 ASSERT(OldValue.Locked);
1303
1304 /* Check if the pushlock is shared */
1305 if (OldValue.Shared > 1)
1306 {
1307 /* Decrease the share count */
1308 NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1309 }
1310 else
1311 {
1312 /* Clear the pushlock entirely */
1313 NewValue.Value = 0;
1314 }
1315
1316 /* Check if nobody is waiting on us and try clearing the lock here */
1317 if ((OldValue.Waiting) ||
1318 (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1319 OldValue.Ptr))
1320 {
1321 /* We have waiters, use the long path */
1322 ExfReleasePushLock(PushLock);
1323 }
1324}
1325
1326/* FAST MUTEX INLINES *********************************************************/
1327
1329VOID
1331{
1333
1334 /* Sanity check */
1336 (Thread->CombinedApcDisable != 0) ||
1337 (Thread->Teb == NULL) ||
1338 (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1339 ASSERT(FastMutex->Owner != Thread);
1340
1341 /* Decrease the count */
1342 if (InterlockedDecrement(&FastMutex->Count))
1343 {
1344 /* Someone is still holding it, use slow path */
1345 KiAcquireFastMutex(FastMutex);
1346 }
1347
1348 /* Set the owner */
1349 FastMutex->Owner = Thread;
1350}
1351
1353VOID
1355{
1357 (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1358 (KeGetCurrentThread()->Teb == NULL) ||
1360 ASSERT(FastMutex->Owner == KeGetCurrentThread());
1361
1362 /* Erase the owner */
1363 FastMutex->Owner = NULL;
1364
1365 /* Increase the count */
1366 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1367 {
1368 /* Someone was waiting for it, signal the waiter */
1369 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1370 }
1371}
1372
1374VOID
1376{
1377 KIRQL OldIrql;
1379
1380 /* Raise IRQL to APC */
1382
1383 /* Decrease the count */
1384 if (InterlockedDecrement(&FastMutex->Count))
1385 {
1386 /* Someone is still holding it, use slow path */
1387 KiAcquireFastMutex(FastMutex);
1388 }
1389
1390 /* Set the owner and IRQL */
1391 FastMutex->Owner = KeGetCurrentThread();
1392 FastMutex->OldIrql = OldIrql;
1393}
1394
1396VOID
1398{
1399 KIRQL OldIrql;
1401
1402 /* Erase the owner */
1403 FastMutex->Owner = NULL;
1404 OldIrql = (KIRQL)FastMutex->OldIrql;
1405
1406 /* Increase the count */
1407 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1408 {
1409 /* Someone was waiting for it, signal the waiter */
1410 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1411 }
1412
1413 /* Lower IRQL back */
1415}
1416
1418BOOLEAN
1420{
1421 KIRQL OldIrql;
1423
1424 /* Raise to APC_LEVEL */
1426
1427 /* Check if we can quickly acquire it */
1428 if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1429 {
1430 /* We have, set us as owners */
1431 FastMutex->Owner = KeGetCurrentThread();
1432 FastMutex->OldIrql = OldIrql;
1433 return TRUE;
1434 }
1435 else
1436 {
1437 /* Acquire attempt failed */
1440 return FALSE;
1441 }
1442}
1443
1445VOID
1447{
1448 /* Enter the Critical Region */
1450
1451 /* Acquire the mutex unsafely */
1452 _ExAcquireFastMutexUnsafe(FastMutex);
1453}
1454
1456VOID
1458{
1459 /* Release the mutex unsafely */
1460 _ExReleaseFastMutexUnsafe(FastMutex);
1461
1462 /* Leave the critical region */
1464}
1465
1466/* OTHER FUNCTIONS **********************************************************/
1467
1468BOOLEAN
1469NTAPI
1472);
1473
1476 IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
1477);
1478
1479BOOLEAN
1480NTAPI
1483);
1484
1485VOID
1486NTAPI
1488 VOID
1489);
1490
1491VOID
1492NTAPI
1494 IN BOOLEAN UpdateInterruptTime,
1495 IN ULONG MaxSepInSeconds
1496);
1497
1498VOID
1499NTAPI
1501 OUT LUID *LocallyUniqueId
1502);
1503
1504VOID
1505NTAPI
1507 VOID
1508);
1509
1510CODE_SEG("INIT")
1511VOID
1512NTAPI
1514 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1515);
1516
1517CODE_SEG("INIT")
1518VOID
1519NTAPI
1520XIPInit(
1521 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1522);
1523
1524#define InterlockedDecrementUL(Addend) \
1525 (ULONG)InterlockedDecrement((PLONG)(Addend))
1526
1527#define InterlockedIncrementUL(Addend) \
1528 (ULONG)InterlockedIncrement((PLONG)(Addend))
1529
1530#define InterlockedExchangeUL(Target, Value) \
1531 (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1532
1533#define InterlockedExchangeAddUL(Addend, Value) \
1534 (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
1535
1536#define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
1537 (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
1538
1539#define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \
1540 (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))
1541
1542#ifdef _WIN64
1543#define InterlockedExchangeSizeT(Target, Value) \
1544 (SIZE_T)InterlockedExchange64((PLONG64)(Target), (LONG64)(Value))
1545#else
1546#define InterlockedExchangeSizeT(Target, Value) \
1547 (SIZE_T)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1548#endif
1549
1550#define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
1551 (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
1552
1553#ifdef __cplusplus
1554} // extern "C"
1555#endif
#define CODE_SEG(...)
#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:181
_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:1354
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:133
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1296
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:1397
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:165
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1330
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:685
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:1457
HANDLE NTAPI ExCreateHandle(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:827
VOID NTAPI ExpResourceInitialization(VOID)
Definition: resource.c:173
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:588
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:80
NTSTATUS NTAPI ExGetPoolTagInfo(IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, IN ULONG SystemInformationLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: expool.c:1356
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:76
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:1419
ULONG ExpOemCodePageDataOffset
Definition: ex.h:24
struct _ETIMER * PETIMER
VOID NTAPI ExUpdateSystemTimeFromCmos(IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
Definition: time.c:311
BOOLEAN NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:259
ULONG NtMajorVersion
Definition: init.c:45
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:87
BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:2134
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:747
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:904
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:434
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:449
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:553
BOOLEAN ExpIsWinPEMode
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1036
_WINKD_WORKER_STATE
Definition: ex.h:61
@ WinKdWorkerStart
Definition: ex.h:63
@ WinKdWorkerReady
Definition: ex.h:62
@ WinKdWorkerInitialized
Definition: ex.h:64
union _EXHANDLE * PEXHANDLE
UNICODE_STRING CmVersionString
Definition: init.c:61
PVOID ExpNlsSectionPointer
Definition: init.c:90
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:80
PEPROCESS ExpDefaultErrorPortProcess
Definition: harderr.c:19
ULONG ExpAltTimeZoneBias
Definition: time.c:24
ULONG ExpResourceTimeoutCount
Definition: resource.c:77
VOID NTAPI ExpDebuggerWorker(IN PVOID Context)
Definition: dbgctrl.c:52
FORCEINLINE VOID _ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1375
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:82
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:83
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:646
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:928
VOID FASTCALL ExfReInitializeRundownProtection(OUT PEX_RUNDOWN_REF RunRef)
#define HANDLE_LOW_BITS
Definition: ex.h:79
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:596
#define KERNEL_FLAG_BITS
Definition: ex.h:84
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1105
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:1070
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:1213
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:177
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
Definition: ex.h:1139
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:86
ULONG NtMinorVersion
Definition: init.c:46
#define ExpChangeRundown(x, y, z)
Definition: ex.h:163
struct _UUID_CACHED_VALUES_STRUCT UUID_CACHED_VALUES_STRUCT
FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1446
FORCEINLINE BOOLEAN _ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:820
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:720
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:923
FORCEINLINE VOID _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:958
BOOLEAN NTAPI ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
Definition: time.c:145
#define ExpChangePushlock(x, y, z)
Definition: ex.h:164
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:580
VOID NTAPI Phase1Initialization(IN PVOID Context)
Definition: init.c:2023
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:59
FORCEINLINE VOID _ExInitializePushLock(OUT PEX_PUSH_LOCK PushLock)
Definition: ex.h:1008
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:861
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:793
BOOLEAN NTAPI ExRefreshTimeZoneInformation(IN PLARGE_INTEGER SystemBootTime)
Definition: time.c:320
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1252
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:441
struct _HARDERROR_USER_PARAMETERS HARDERROR_USER_PARAMETERS
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:617
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:1178
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()
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
#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:122
PWSTR Name
Definition: ex.h:123
Definition: ex.h:108
BOOLEAN WakeTimer
Definition: ex.h:116
KAPC TimerApc
Definition: ex.h:110
LIST_ENTRY WakeTimerListEntry
Definition: ex.h:117
LIST_ENTRY ActiveTimerListEntry
Definition: ex.h:112
KDPC TimerDpc
Definition: ex.h:111
LONG Period
Definition: ex.h:114
KSPIN_LOCK Lock
Definition: ex.h:113
KTIMER KeTimer
Definition: ex.h:109
BOOLEAN ApcAssociated
Definition: ex.h:115
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:129
Definition: ketypes.h:547
Definition: ketypes.h:699
Definition: typedefs.h:120
Definition: compat.h:836
UCHAR ClockSeqHiAndReserved
Definition: ex.h:183
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:87
ULONG_PTR KernelFlag2
Definition: ex.h:100
ULONG_PTR KernelFlag
Definition: ex.h:92
ULONG AsULONG
Definition: ex.h:104
ULONG_PTR HighIndex
Definition: ex.h:99
ULONG_PTR LowIndex
Definition: ex.h:97
ULONG_PTR TagBits2
Definition: ex.h:96
ULONG_PTR Index
Definition: ex.h:91
ULONG_PTR TagBits
Definition: ex.h:90
HANDLE GenericHandleOverlay
Definition: ex.h:102
ULONG_PTR Value
Definition: ex.h:103
ULONG_PTR MidIndex
Definition: ex.h:98
_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:778
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175