ReactOS 0.4.16-dev-973-g9a0ff8b
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
73VOID
77
78#ifdef _WIN64
79#define HANDLE_LOW_BITS (PAGE_SHIFT - 4)
80#define HANDLE_HIGH_BITS (PAGE_SHIFT - 3)
81#else
82#define HANDLE_LOW_BITS (PAGE_SHIFT - 3)
83#define HANDLE_HIGH_BITS (PAGE_SHIFT - 2)
84#endif
85#define HANDLE_TAG_BITS 2
86#define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2 * HANDLE_HIGH_BITS)
87#define KERNEL_FLAG_BITS (sizeof(ULONG_PTR) * 8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
88
89typedef union _EXHANDLE
90{
91 struct
92 {
96 };
97 struct
98 {
104 };
109
110typedef struct _ETIMER
111{
122
123typedef struct
124{
128
130{
135
136#define MAX_FAST_REFS 7
137
138#define ExAcquireRundownProtection _ExAcquireRundownProtection
139#define ExReleaseRundownProtection _ExReleaseRundownProtection
140#define ExInitializeRundownProtection _ExInitializeRundownProtection
141#define ExWaitForRundownProtectionRelease _ExWaitForRundownProtectionRelease
142#define ExRundownCompleted _ExRundownCompleted
143#define ExGetPreviousMode KeGetPreviousMode
144
145
146//
147// Various bits tagged on the handle or handle table
148//
149#define EXHANDLE_TABLE_ENTRY_LOCK_BIT 1
150#define FREE_HANDLE_MASK -1
151
152//
153// Number of entries in each table level
154//
155#define LOW_LEVEL_ENTRIES (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))
156#define MID_LEVEL_ENTRIES (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))
157#define HIGH_LEVEL_ENTRIES (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))
158
159//
160// Maximum index in each table level before we need another table
161//
162#define MAX_LOW_INDEX LOW_LEVEL_ENTRIES
163#define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
164#define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
165
166#define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&(x)->Ptr, (PVOID)(y), (PVOID)(z))
167#define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)(x), (PVOID)(y), (PVOID)(z))
168#define ExpSetRundown(x, y) InterlockedExchangePointer(&(x)->Ptr, (PVOID)(y))
169
171NTAPI
173 IN PSYSTEM_POOLTAG_INFORMATION SystemInformation,
174 IN ULONG SystemInformationLength,
176);
177
179{
182 union
183 {
184 struct
185 {
188 UCHAR NodeId[6 /*SEED_BUFFER_SIZE*/];
189 };
190 UCHAR GuidInit[8]; /* Match GUID.Data4 */
191 };
193
195
196/* INITIALIZATION FUNCTIONS *************************************************/
197
198CODE_SEG("INIT")
200NTAPI
202
203VOID
204NTAPI
206
207VOID
208NTAPI
211);
212
213CODE_SEG("INIT")
214VOID
215NTAPI
217
219NTAPI
221 IN PLARGE_INTEGER SystemBootTime
222);
223
224CODE_SEG("INIT")
225VOID
226NTAPI
228
229VOID
230NTAPI
232
233CODE_SEG("INIT")
234VOID
235NTAPI
237
238CODE_SEG("INIT")
239VOID
240NTAPI
244 IN ULONG Size,
245 IN ULONG Tag,
246 IN USHORT MaximumDepth,
247 IN PLIST_ENTRY ListHead
248);
249
250CODE_SEG("INIT")
252NTAPI
254
255CODE_SEG("INIT")
257NTAPI
259
260CODE_SEG("INIT")
262NTAPI
264
265CODE_SEG("INIT")
266VOID
267NTAPI
269 IN ULONG Cpu,
270 IN PLOADER_PARAMETER_BLOCK LoaderBlock
271);
272
273VOID
274NTAPI
276
277CODE_SEG("INIT")
279NTAPI
281
282CODE_SEG("INIT")
284NTAPI
286
287CODE_SEG("INIT")
289NTAPI
291
292CODE_SEG("INIT")
294NTAPI
296
297CODE_SEG("INIT")
299NTAPI
301
302CODE_SEG("INIT")
304NTAPI
306
307CODE_SEG("INIT")
309NTAPI
311
312CODE_SEG("INIT")
313VOID
314NTAPI
316
317CODE_SEG("INIT")
318VOID
319NTAPI
321
322/* Callback Functions ********************************************************/
323
324VOID
325NTAPI
328);
329
331NTAPI
335);
336
337VOID
338NTAPI
340 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
341);
342
344NTAPI
346 IN OUT PEX_CALLBACK CallBack,
349);
350
352NTAPI
354 IN OUT PEX_CALLBACK CallBack
355);
356
357VOID
358NTAPI
360 IN OUT PEX_CALLBACK CallBack,
361 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
362);
363
365NTAPI
367 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
368);
369
370PVOID
371NTAPI
373 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
374);
375
376VOID
377NTAPI
379 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
380);
381
382/* Rundown Functions ********************************************************/
383
384VOID
387 OUT PEX_RUNDOWN_REF RunRef
388);
389
390VOID
393 OUT PEX_RUNDOWN_REF RunRef
394);
395
399 IN OUT PEX_RUNDOWN_REF RunRef
400);
401
405 IN OUT PEX_RUNDOWN_REF RunRef,
407);
408
409VOID
412 IN OUT PEX_RUNDOWN_REF RunRef
413);
414
415VOID
418 IN OUT PEX_RUNDOWN_REF RunRef,
420);
421
422VOID
425 OUT PEX_RUNDOWN_REF RunRef
426);
427
428VOID
431 IN OUT PEX_RUNDOWN_REF RunRef
432);
433
434/* HANDLE TABLE FUNCTIONS ***************************************************/
435
436typedef BOOLEAN
438 PHANDLE_TABLE_ENTRY HandleTableEntry,
441);
442
443typedef BOOLEAN
447 IN PHANDLE_TABLE_ENTRY HandleTableEntry,
448 IN PHANDLE_TABLE_ENTRY NewEntry
449);
450
451typedef BOOLEAN
453 PHANDLE_TABLE_ENTRY HandleTableEntry,
455);
456
457CODE_SEG("INIT")
458VOID
459NTAPI
461 VOID
462);
463
465NTAPI
468);
469
470VOID
471NTAPI
474 IN PHANDLE_TABLE_ENTRY HandleTableEntry
475);
476
477HANDLE
478NTAPI
481 IN PHANDLE_TABLE_ENTRY HandleTableEntry
482);
483
484VOID
485NTAPI
488 IN PVOID DestroyHandleProcedure OPTIONAL
489);
490
492NTAPI
496 IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL
497);
498
500NTAPI
504);
505
507NTAPI
511 IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure,
513);
514
516NTAPI
520 IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine,
522);
523
524VOID
525NTAPI
528 IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure,
530);
531
533NTAPI
537);
538
540NTAPI
543 IN PHANDLE_TABLE_ENTRY HandleTableEntry
544);
545
546/* PSEH EXCEPTION HANDLING **************************************************/
547
548LONG
549NTAPI
551
552/* CALLBACKS *****************************************************************/
553
555VOID
560{
561 PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
563
564 /* Reference the block */
565 CallbackBlock = ExReferenceCallBackBlock(Callback);
566 if (CallbackBlock)
567 {
568 /* Get the function */
569 Function = ExGetCallBackBlockRoutine(CallbackBlock);
570
571 /* Do the callback */
573
574 /* Now dereference it */
575 ExDereferenceCallBackBlock(Callback, CallbackBlock);
576 }
577}
578
579/* FAST REFS ******************************************************************/
580
582PVOID
584{
585 /* Return the unbiased pointer */
586 return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
587}
588
590ULONG
592{
593 /* Return the reference count */
594 return (ULONG)FastRef.RefCnt;
595}
596
598VOID
601{
602 /* Sanity check */
604
605 /* Check if an object is being set */
606 if (!Object)
607 {
608 /* Clear the field */
609 FastRef->Object = NULL;
610 }
611 else
612 {
613 /* Otherwise, we assume the object was referenced and is ready */
614 FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
615 }
616}
617
621{
622 EX_FAST_REF OldValue, NewValue;
623
624 /* Start reference loop */
625 for (;;)
626 {
627 /* Get the current reference count */
628 OldValue = *FastRef;
629 if (OldValue.RefCnt)
630 {
631 /* Increase the reference count */
632 NewValue.Value = OldValue.Value - 1;
633 NewValue.Object = ExpChangePushlock(&FastRef->Object,
634 NewValue.Object,
635 OldValue.Object);
636 if (NewValue.Object != OldValue.Object) continue;
637 }
638
639 /* We are done */
640 break;
641 }
642
643 /* Return the old value */
644 return OldValue;
645}
646
651{
652 EX_FAST_REF OldValue, NewValue;
653
654 /* Sanity checks */
656
657 /* Start update loop */
658 for (;;)
659 {
660 /* Get the current reference count */
661 OldValue = *FastRef;
662
663 /* Check if the current count is too high or if the pointer changed */
664 if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
665 ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
666 {
667 /* Fail */
668 return FALSE;
669 }
670
671 /* Update the reference count */
672 NewValue.Value = OldValue.Value + MAX_FAST_REFS;
673 NewValue.Object = ExpChangePushlock(&FastRef->Object,
674 NewValue.Object,
675 OldValue.Object);
676 if (NewValue.Object != OldValue.Object) continue;
677
678 /* We are done */
679 break;
680 }
681
682 /* Return success */
683 return TRUE;
684}
685
690{
691 EX_FAST_REF OldValue, NewValue;
692
693 /* Sanity checks */
694 ASSERT(Object != NULL);
696
697 /* Start reference loop */
698 for (;;)
699 {
700 /* Get the current reference count */
701 OldValue = *FastRef;
702
703 /* Check if we're full if if the pointer changed */
704 if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
705
706 /* Decrease the reference count */
707 NewValue.Value = OldValue.Value + 1;
708 NewValue.Object = ExpChangePushlock(&FastRef->Object,
709 NewValue.Object,
710 OldValue.Object);
711 if (NewValue.Object != OldValue.Object) continue;
712
713 /* We are done */
714 break;
715 }
716
717 /* Return success */
718 return TRUE;
719}
720
725{
726 EX_FAST_REF NewValue, OldValue;
727
728 /* Sanity check */
730
731 /* Check if an object is being set */
732 if (!Object)
733 {
734 /* Clear the field */
735 NewValue.Object = NULL;
736 }
737 else
738 {
739 /* Otherwise, we assume the object was referenced and is ready */
740 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
741 }
742
743 /* Update the object */
744 OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
745 return OldValue;
746}
747
752 IN PVOID OldObject)
753{
754 EX_FAST_REF OldValue, NewValue;
755
756 /* Sanity check and start swap loop */
758 for (;;)
759 {
760 /* Get the current value */
761 OldValue = *FastRef;
762
763 /* Make sure there's enough references to swap */
764 if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
765
766 /* Check if we have an object to swap */
767 if (Object)
768 {
769 /* Set up the value with maximum fast references */
770 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
771 }
772 else
773 {
774 /* Write the object address itself (which is empty) */
775 NewValue.Value = (ULONG_PTR)Object;
776 }
777
778 /* Do the actual compare exchange */
779 NewValue.Object = ExpChangePushlock(&FastRef->Object,
780 NewValue.Object,
781 OldValue.Object);
782 if (NewValue.Object != OldValue.Object) continue;
783
784 /* All done */
785 break;
786 }
787
788 /* Return the old value */
789 return OldValue;
790}
791
792/* RUNDOWN *******************************************************************/
793
797 IN ULONG ProcNumber)
798{
799 return (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs +
800 RunRefCacheAware->RunRefSize *
801 (ProcNumber % RunRefCacheAware->Number));
802}
803
804/*++
805 * @name ExfAcquireRundownProtection
806 * INTERNAL MACRO
807 *
808 * The ExfAcquireRundownProtection routine acquires rundown protection for
809 * the specified descriptor.
810 *
811 * @param RunRef
812 * Pointer to a rundown reference descriptor.
813 *
814 * @return TRUE if access to the protected structure was granted, FALSE otherwise.
815 *
816 * @remarks This is the internal macro for system use only.In case the rundown
817 * was active, then the slow-path will be called through the exported
818 * function.
819 *
820 *--*/
824{
825 ULONG_PTR Value, NewValue;
826
827 /* Get the current value and mask the active bit */
828 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
829
830 /* Add a reference */
831 NewValue = Value + EX_RUNDOWN_COUNT_INC;
832
833 /* Change the value */
834 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
835 if (NewValue != Value)
836 {
837 /* Rundown was active, use long path */
838 return ExfAcquireRundownProtection(RunRef);
839 }
840
841 /* Success */
842 return TRUE;
843}
844
845/*++
846 * @name ExReleaseRundownProtection
847 * INTERNAL MACRO
848 *
849 * The ExReleaseRundownProtection routine releases rundown protection for
850 * the specified descriptor.
851 *
852 * @param RunRef
853 * Pointer to a rundown reference descriptor.
854 *
855 * @return TRUE if access to the protected structure was granted, FALSE otherwise.
856 *
857 * @remarks This is the internal macro for system use only.In case the rundown
858 * was active, then the slow-path will be called through the exported
859 * function.
860 *
861 *--*/
863VOID
865{
866 ULONG_PTR Value, NewValue;
867
868 /* Get the current value and mask the active bit */
869 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
870
871 /* Remove a reference */
872 NewValue = Value - EX_RUNDOWN_COUNT_INC;
873
874 /* Change the value */
875 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
876
877 /* Check if the rundown was active */
878 if (NewValue != Value)
879 {
880 /* Rundown was active, use long path */
882 }
883 else
884 {
885 /* Sanity check */
887 }
888}
889
890/*++
891 * @name ExInitializeRundownProtection
892 * INTERNAL MACRO
893 *
894 * The ExInitializeRundownProtection routine initializes a rundown
895 * protection descriptor.
896 *
897 * @param RunRef
898 * Pointer to a rundown reference descriptor.
899 *
900 * @return None.
901 *
902 * @remarks This is the internal macro for system use only.
903 *
904 *--*/
906VOID
908{
909 /* Set the count to zero */
910 RunRef->Count = 0;
911}
912
913/*++
914 * @name ExWaitForRundownProtectionRelease
915 * INTERNAL MACRO
916 *
917 * The ExWaitForRundownProtectionRelease routine waits until the specified
918 * rundown descriptor has been released.
919 *
920 * @param RunRef
921 * Pointer to a rundown reference descriptor.
922 *
923 * @return None.
924 *
925 * @remarks This is the internal macro for system use only. If a wait is actually
926 * necessary, then the slow path is taken through the exported function.
927 *
928 *--*/
930VOID
932{
934
935 /* Set the active bit */
937 if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
938 {
939 /* If the the rundown wasn't already active, then take the long path */
941 }
942}
943
944/*++
945 * @name ExRundownCompleted
946 * INTERNAL MACRO
947 *
948 * The ExRundownCompleted routine completes the rundown of the specified
949 * descriptor by setting the active bit.
950 *
951 * @param RunRef
952 * Pointer to a rundown reference descriptor.
953 *
954 * @return None.
955 *
956 * @remarks This is the internal macro for system use only.
957 *
958 *--*/
960VOID
962{
963 /* Sanity check */
964 ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
965
966 /* Mark the counter as active */
968}
969
970/* PUSHLOCKS *****************************************************************/
971
972/* FIXME: VERIFY THESE! */
973
974VOID
977 IN PEX_PUSH_LOCK PushLock,
978 IN PVOID WaitBlock
979);
980
981VOID
984 IN PEX_PUSH_LOCK PushLock,
985 IN PVOID CurrentWaitBlock
986);
987
988VOID
991 IN PEX_PUSH_LOCK PushLock,
992 IN PVOID WaitBlock
993);
994
995/*++
996 * @name _ExInitializePushLock
997 * INTERNAL MACRO
998 *
999 * The _ExInitializePushLock macro initializes a PushLock.
1000 *
1001 * @params PushLock
1002 * Pointer to the pushlock which is to be initialized.
1003 *
1004 * @return None.
1005 *
1006 * @remarks None.
1007 *
1008 *--*/
1010VOID
1012{
1013 /* Set the value to 0 */
1014 PushLock->Ptr = 0;
1015}
1016#define ExInitializePushLock _ExInitializePushLock
1017
1018/*++
1019 * @name ExAcquirePushLockExclusive
1020 * INTERNAL MACRO
1021 *
1022 * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1023 *
1024 * @params PushLock
1025 * Pointer to the pushlock which is to be acquired.
1026 *
1027 * @return None.
1028 *
1029 * @remarks The function attempts the quickest route to acquire the lock, which is
1030 * to simply set the lock bit.
1031 * However, if the pushlock is already shared, the slower path is taken.
1032 *
1033 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1034 * This macro should usually be paired up with KeAcquireCriticalRegion.
1035 *
1036 *--*/
1038VOID
1040{
1041 /* Try acquiring the lock */
1043 {
1044 /* Someone changed it, use the slow path */
1046 }
1047
1048 /* Sanity check */
1049 ASSERT(PushLock->Locked);
1050}
1051
1052/*++
1053* @name ExTryToAcquirePushLockExclusive
1054* INTERNAL MACRO
1055*
1056* The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1057*
1058* @params PushLock
1059* Pointer to the pushlock which is to be acquired.
1060*
1061* @return None.
1062*
1063* @remarks The function attempts the quickest route to acquire the lock, which is
1064* to simply set the lock bit.
1065* However, if the pushlock is already shared, the slower path is taken.
1066*
1067* Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1068* This macro should usually be paired up with KeAcquireCriticalRegion.
1069*
1070*--*/
1072BOOLEAN
1074{
1075 /* Try acquiring the lock */
1077 {
1078 /* Can't acquire */
1079 return FALSE;
1080 }
1081
1082 /* Got acquired */
1083 ASSERT (PushLock->Locked);
1084 return TRUE;
1085}
1086
1087/*++
1088 * @name ExAcquirePushLockShared
1089 * INTERNAL MACRO
1090 *
1091 * The ExAcquirePushLockShared macro acquires a shared PushLock.
1092 *
1093 * @params PushLock
1094 * Pointer to the pushlock which is to be acquired.
1095 *
1096 * @return None.
1097 *
1098 * @remarks The function attempts the quickest route to acquire the lock, which is
1099 * to simply set the lock bit and set the share count to one.
1100 * However, if the pushlock is already shared, the slower path is taken.
1101 *
1102 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1103 * This macro should usually be paired up with KeAcquireCriticalRegion.
1104 *
1105 *--*/
1107VOID
1109{
1110 EX_PUSH_LOCK NewValue;
1111
1112 /* Try acquiring the lock */
1114 if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1115 {
1116 /* Someone changed it, use the slow path */
1117 ExfAcquirePushLockShared(PushLock);
1118 }
1119
1120 /* Sanity checks */
1121 ASSERT(PushLock->Locked);
1122}
1123
1124/*++
1125 * @name ExConvertPushLockSharedToExclusive
1126 * INTERNAL MACRO
1127 *
1128 * The ExConvertPushLockSharedToExclusive macro converts an exclusive
1129 * pushlock to a shared pushlock.
1130 *
1131 * @params PushLock
1132 * Pointer to the pushlock which is to be converted.
1133 *
1134 * @return FALSE if conversion failed, TRUE otherwise.
1135 *
1136 * @remarks The function attempts the quickest route to convert the lock, which is
1137 * to simply set the lock bit and remove any other bits.
1138 *
1139 *--*/
1141BOOLEAN
1143{
1144 EX_PUSH_LOCK OldValue;
1145
1146 /* Set the expected old value */
1148
1149 /* Try converting the lock */
1150 if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1151 OldValue.Ptr)
1152 {
1153 /* Conversion failed */
1154 return FALSE;
1155 }
1156
1157 /* Sanity check */
1158 ASSERT(PushLock->Locked);
1159 return TRUE;
1160}
1161
1162/*++
1163 * @name ExWaitOnPushLock
1164 * INTERNAL MACRO
1165 *
1166 * The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
1167 *
1168 * @params PushLock
1169 * Pointer to a pushlock.
1170 *
1171 * @return None.
1172 *
1173 * @remarks The function attempts to get any exclusive waiters out of their slow
1174 * path by forcing an instant acquire/release operation.
1175 *
1176 * Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
1177 *
1178 *--*/
1180VOID
1182{
1183 /* Check if we're locked */
1184 if (PushLock->Locked)
1185 {
1186 /* Acquire the lock */
1188 ASSERT(PushLock->Locked);
1189
1190 /* Release it */
1192 }
1193}
1194
1195/*++
1196 * @name ExReleasePushLockShared
1197 * INTERNAL MACRO
1198 *
1199 * The ExReleasePushLockShared macro releases a previously acquired PushLock.
1200 *
1201 * @params PushLock
1202 * Pointer to a previously acquired pushlock.
1203 *
1204 * @return None.
1205 *
1206 * @remarks The function attempts the quickest route to release the lock, which is
1207 * to simply decrease the share count and remove the lock bit.
1208 * However, if the pushlock is being waited on then the long path is taken.
1209 *
1210 * Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
1211 * This macro should usually be paired up with KeLeaveCriticalRegion.
1212 *
1213 *--*/
1215VOID
1217{
1218 EX_PUSH_LOCK OldValue;
1219
1220 /* Sanity checks */
1221 ASSERT(PushLock->Locked);
1222
1223 /* Try to clear the pushlock */
1225 if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1226 {
1227 /* There are still other people waiting on it */
1228 ExfReleasePushLockShared(PushLock);
1229 }
1230}
1231
1232/*++
1233 * @name ExReleasePushLockExclusive
1234 * INTERNAL MACRO
1235 *
1236 * The ExReleasePushLockExclusive macro releases a previously
1237 * exclusively acquired PushLock.
1238 *
1239 * @params PushLock
1240 * Pointer to a previously acquired pushlock.
1241 *
1242 * @return None.
1243 *
1244 * @remarks The function attempts the quickest route to release the lock, which is
1245 * to simply clear the locked bit.
1246 * However, if the pushlock is being waited on, the slow path is taken
1247 * in an attempt to wake up the lock.
1248 *
1249 * Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
1250 * This macro should usually be paired up with KeLeaveCriticalRegion.
1251 *
1252 *--*/
1254VOID
1256{
1257 EX_PUSH_LOCK OldValue;
1258
1259 /* Sanity checks */
1260 ASSERT(PushLock->Locked);
1261
1262 /* Unlock the pushlock */
1263 OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1265
1266 /* Sanity checks */
1267 ASSERT(OldValue.Locked);
1268 ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1269
1270 /* Check if anyone is waiting on it and it's not already waking*/
1271 if ((OldValue.Waiting) && !(OldValue.Waking))
1272 {
1273 /* Wake it up */
1274 ExfTryToWakePushLock(PushLock);
1275 }
1276}
1277
1278/*++
1279 * @name ExReleasePushLock
1280 * INTERNAL MACRO
1281 *
1282 * The ExReleasePushLock macro releases a previously acquired PushLock.
1283 *
1284 * @params PushLock
1285 * Pointer to a previously acquired pushlock.
1286 *
1287 * @return None.
1288 *
1289 * @remarks The function attempts the quickest route to release the lock, which is
1290 * to simply clear all the fields and decrease the share count if required.
1291 * However, if the pushlock is being waited on then the long path is taken.
1292 *
1293 * Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
1294 * This macro should usually be paired up with KeLeaveCriticalRegion.
1295 *
1296 *--*/
1298VOID
1300{
1301 EX_PUSH_LOCK OldValue = *PushLock;
1302 EX_PUSH_LOCK NewValue;
1303
1304 /* Sanity checks */
1305 ASSERT(OldValue.Locked);
1306
1307 /* Check if the pushlock is shared */
1308 if (OldValue.Shared > 1)
1309 {
1310 /* Decrease the share count */
1311 NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1312 }
1313 else
1314 {
1315 /* Clear the pushlock entirely */
1316 NewValue.Value = 0;
1317 }
1318
1319 /* Check if nobody is waiting on us and try clearing the lock here */
1320 if ((OldValue.Waiting) ||
1321 (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1322 OldValue.Ptr))
1323 {
1324 /* We have waiters, use the long path */
1325 ExfReleasePushLock(PushLock);
1326 }
1327}
1328
1329/* FAST MUTEX INLINES *********************************************************/
1330
1332VOID
1334{
1336
1337 /* Sanity check */
1339 (Thread->CombinedApcDisable != 0) ||
1340 (Thread->Teb == NULL) ||
1341 (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1342 ASSERT(FastMutex->Owner != Thread);
1343
1344 /* Decrease the count */
1345 if (InterlockedDecrement(&FastMutex->Count))
1346 {
1347 /* Someone is still holding it, use slow path */
1348 KiAcquireFastMutex(FastMutex);
1349 }
1350
1351 /* Set the owner */
1352 FastMutex->Owner = Thread;
1353}
1354
1356VOID
1358{
1360 (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1361 (KeGetCurrentThread()->Teb == NULL) ||
1363 ASSERT(FastMutex->Owner == KeGetCurrentThread());
1364
1365 /* Erase the owner */
1366 FastMutex->Owner = NULL;
1367
1368 /* Increase the count */
1369 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1370 {
1371 /* Someone was waiting for it, signal the waiter */
1372 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1373 }
1374}
1375
1377VOID
1379{
1380 KIRQL OldIrql;
1382
1383 /* Raise IRQL to APC */
1385
1386 /* Decrease the count */
1387 if (InterlockedDecrement(&FastMutex->Count))
1388 {
1389 /* Someone is still holding it, use slow path */
1390 KiAcquireFastMutex(FastMutex);
1391 }
1392
1393 /* Set the owner and IRQL */
1394 FastMutex->Owner = KeGetCurrentThread();
1395 FastMutex->OldIrql = OldIrql;
1396}
1397
1399VOID
1401{
1402 KIRQL OldIrql;
1404
1405 /* Erase the owner */
1406 FastMutex->Owner = NULL;
1407 OldIrql = (KIRQL)FastMutex->OldIrql;
1408
1409 /* Increase the count */
1410 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1411 {
1412 /* Someone was waiting for it, signal the waiter */
1413 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1414 }
1415
1416 /* Lower IRQL back */
1418}
1419
1421BOOLEAN
1423{
1424 KIRQL OldIrql;
1426
1427 /* Raise to APC_LEVEL */
1429
1430 /* Check if we can quickly acquire it */
1431 if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1432 {
1433 /* We have, set us as owners */
1434 FastMutex->Owner = KeGetCurrentThread();
1435 FastMutex->OldIrql = OldIrql;
1436 return TRUE;
1437 }
1438 else
1439 {
1440 /* Acquire attempt failed */
1443 return FALSE;
1444 }
1445}
1446
1448VOID
1450{
1451 /* Enter the Critical Region */
1453
1454 /* Acquire the mutex unsafely */
1455 _ExAcquireFastMutexUnsafe(FastMutex);
1456}
1457
1459VOID
1461{
1462 /* Release the mutex unsafely */
1463 _ExReleaseFastMutexUnsafe(FastMutex);
1464
1465 /* Leave the critical region */
1467}
1468
1469/* OTHER FUNCTIONS **********************************************************/
1470
1471BOOLEAN
1472NTAPI
1475);
1476
1479 IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
1480);
1481
1482BOOLEAN
1483NTAPI
1486);
1487
1488VOID
1489NTAPI
1491 VOID
1492);
1493
1494VOID
1495NTAPI
1497 IN BOOLEAN UpdateInterruptTime,
1498 IN ULONG MaxSepInSeconds
1499);
1500
1501VOID
1502NTAPI
1504 OUT LUID *LocallyUniqueId
1505);
1506
1507VOID
1508NTAPI
1510 VOID
1511);
1512
1513VOID
1514NTAPI
1516
1518NTAPI
1521 ULONG Length,
1524 PVOID *MappedSystemVa,
1525 PMDL *OutMdl);
1526
1527CODE_SEG("INIT")
1528VOID
1529NTAPI
1531 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1532);
1533
1534CODE_SEG("INIT")
1535VOID
1536NTAPI
1537XIPInit(
1538 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1539);
1540
1541#define InterlockedDecrementUL(Addend) \
1542 (ULONG)InterlockedDecrement((PLONG)(Addend))
1543
1544#define InterlockedIncrementUL(Addend) \
1545 (ULONG)InterlockedIncrement((PLONG)(Addend))
1546
1547#define InterlockedExchangeUL(Target, Value) \
1548 (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1549
1550#define InterlockedExchangeAddUL(Addend, Value) \
1551 (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
1552
1553#define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
1554 (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
1555
1556#define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \
1557 (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))
1558
1559#ifdef _WIN64
1560#define InterlockedExchangeSizeT(Target, Value) \
1561 (SIZE_T)InterlockedExchange64((PLONG64)(Target), (LONG64)(Value))
1562#else
1563#define InterlockedExchangeSizeT(Target, Value) \
1564 (SIZE_T)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1565#endif
1566
1567#define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
1568 (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
1569
1570#ifdef __cplusplus
1571} // extern "C"
1572#endif
#define CODE_SEG(...)
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG ReturnLength
#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
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:1357
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:136
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1299
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:1400
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:168
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1333
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:688
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:1460
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:591
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:83
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
VOID NTAPI ExpDebuggerWorker(_In_ PVOID Context)
Definition: dbgctrl.c:52
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
VOID NTAPI ExUnlockUserBuffer(PMDL Mdl)
Definition: sysinfo.c:194
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:1422
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:750
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:907
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:437
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:452
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:556
BOOLEAN ExpIsWinPEMode
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1039
_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
FORCEINLINE VOID _ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1378
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:85
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:86
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:649
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:931
VOID FASTCALL ExfReInitializeRundownProtection(OUT PEX_RUNDOWN_REF RunRef)
#define HANDLE_LOW_BITS
Definition: ex.h:82
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:599
#define KERNEL_FLAG_BITS
Definition: ex.h:87
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1108
VOID NTAPI ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
Definition: handle.c:963
NTSTATUS NTAPI ExLockUserBuffer(PVOID BaseAddress, ULONG Length, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation, PVOID *MappedSystemVa, PMDL *OutMdl)
Definition: sysinfo.c:202
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:1073
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:1216
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:177
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
Definition: ex.h:1142
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:86
ULONG NtMinorVersion
Definition: init.c:46
#define ExpChangeRundown(x, y, z)
Definition: ex.h:166
struct _UUID_CACHED_VALUES_STRUCT UUID_CACHED_VALUES_STRUCT
FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1449
FORCEINLINE BOOLEAN _ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:823
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:723
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:928
FORCEINLINE VOID _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:961
BOOLEAN NTAPI ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
Definition: time.c:145
#define ExpChangePushlock(x, y, z)
Definition: ex.h:167
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:583
VOID NTAPI Phase1Initialization(IN PVOID Context)
Definition: init.c:2060
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:59
FORCEINLINE VOID _ExInitializePushLock(OUT PEX_PUSH_LOCK PushLock)
Definition: ex.h:1011
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:864
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:796
BOOLEAN NTAPI ExRefreshTimeZoneInformation(IN PLARGE_INTEGER SystemBootTime)
Definition: time.c:320
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1255
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:444
struct _HARDERROR_USER_PARAMETERS HARDERROR_USER_PARAMETERS
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:620
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:1181
BOOLEAN NTAPI ExpUuidInitialization(VOID)
Definition: uuid.c:53
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FP_OP Operation
Definition: fpcontrol.c:150
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
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
#define MAXIMUM_HARDERROR_PARAMETERS
Definition: extypes.h:145
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define _In_
Definition: no_sal2.h:158
int Count
Definition: noreturn.cpp:7
#define FASTCALL
Definition: nt_native.h:50
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
VOID FASTCALL KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: wait.c:107
CCHAR KeNumberProcessors
Definition: processor.c:19
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:125
PWSTR Name
Definition: ex.h:126
Definition: ex.h:111
BOOLEAN WakeTimer
Definition: ex.h:119
KAPC TimerApc
Definition: ex.h:113
LIST_ENTRY WakeTimerListEntry
Definition: ex.h:120
LIST_ENTRY ActiveTimerListEntry
Definition: ex.h:115
KDPC TimerDpc
Definition: ex.h:114
LONG Period
Definition: ex.h:117
KSPIN_LOCK Lock
Definition: ex.h:116
KTIMER KeTimer
Definition: ex.h:112
BOOLEAN ApcAssociated
Definition: ex.h:118
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:132
Definition: ketypes.h:547
Definition: ketypes.h:699
Definition: typedefs.h:120
Definition: compat.h:836
UCHAR ClockSeqHiAndReserved
Definition: ex.h:186
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:90
ULONG_PTR KernelFlag2
Definition: ex.h:103
ULONG_PTR KernelFlag
Definition: ex.h:95
ULONG AsULONG
Definition: ex.h:107
ULONG_PTR HighIndex
Definition: ex.h:102
ULONG_PTR LowIndex
Definition: ex.h:100
ULONG_PTR TagBits2
Definition: ex.h:99
ULONG_PTR Index
Definition: ex.h:94
ULONG_PTR TagBits
Definition: ex.h:93
HANDLE GenericHandleOverlay
Definition: ex.h:105
ULONG_PTR Value
Definition: ex.h:106
ULONG_PTR MidIndex
Definition: ex.h:101
_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_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_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
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
enum _LOCK_OPERATION LOCK_OPERATION
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175