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