ReactOS  0.4.15-dev-1386-g5cb9f87
ex.h
Go to the documentation of this file.
1 #pragma once
2 
3 /* GLOBAL VARIABLES *********************************************************/
4 
7 extern ULONG ExpTimeZoneId;
15 extern BOOLEAN ExpIsWinPEMode;
20 extern ULONG NtGlobalFlag;
33 
36 
37 /*
38  * NT/Cm Version Info variables
39  */
40 extern ULONG NtMajorVersion;
41 extern ULONG NtMinorVersion;
42 extern ULONG NtBuildNumber;
44 extern ULONG CmNtCSDVersion;
48 extern CHAR NtBuildLab[];
49 
50 /*
51  * WinDBG Debugger Worker State Machine data (see dbgctrl.c)
52  */
53 typedef enum _WINKD_WORKER_STATE
54 {
59 
65 
67 
68 #ifdef _WIN64
69 #define HANDLE_LOW_BITS (PAGE_SHIFT - 4)
70 #define HANDLE_HIGH_BITS (PAGE_SHIFT - 3)
71 #else
72 #define HANDLE_LOW_BITS (PAGE_SHIFT - 3)
73 #define HANDLE_HIGH_BITS (PAGE_SHIFT - 2)
74 #endif
75 #define HANDLE_TAG_BITS (2)
76 #define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)
77 #define KERNEL_FLAG_BITS (sizeof(PVOID)*8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
78 
79 typedef union _EXHANDLE
80 {
81  struct
82  {
86  };
87  struct
88  {
94  };
99 
100 typedef struct _ETIMER
101 {
111 } ETIMER, *PETIMER;
112 
113 typedef struct
114 {
118 
120 {
125 
126 #define MAX_FAST_REFS 7
127 
128 #define ExAcquireRundownProtection _ExAcquireRundownProtection
129 #define ExReleaseRundownProtection _ExReleaseRundownProtection
130 #define ExInitializeRundownProtection _ExInitializeRundownProtection
131 #define ExWaitForRundownProtectionRelease _ExWaitForRundownProtectionRelease
132 #define ExRundownCompleted _ExRundownCompleted
133 #define ExGetPreviousMode KeGetPreviousMode
134 
135 
136 //
137 // Various bits tagged on the handle or handle table
138 //
139 #define EXHANDLE_TABLE_ENTRY_LOCK_BIT 1
140 #define FREE_HANDLE_MASK -1
141 
142 //
143 // Number of entries in each table level
144 //
145 #define LOW_LEVEL_ENTRIES (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))
146 #define MID_LEVEL_ENTRIES (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))
147 #define HIGH_LEVEL_ENTRIES (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))
148 
149 //
150 // Maximum index in each table level before we need another table
151 //
152 #define MAX_LOW_INDEX LOW_LEVEL_ENTRIES
153 #define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
154 #define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
155 
156 #define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)
157 #define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)
158 #define ExpSetRundown(x, y) InterlockedExchangePointer(&x->Ptr, (PVOID)y)
159 
160 NTSTATUS
161 NTAPI
163  IN PSYSTEM_POOLTAG_INFORMATION SystemInformation,
164  IN ULONG SystemInformationLength,
166 );
167 
169 {
172  union
173  {
174  struct
175  {
178  UCHAR NodeId[6 /*SEED_BUFFER_SIZE*/];
179  };
180  UCHAR GuidInit[8]; /* Match GUID.Data4 */
181  };
183 
185 
186 /* INITIALIZATION FUNCTIONS *************************************************/
187 
188 BOOLEAN
189 NTAPI
191 
192 VOID
193 NTAPI
194 ExInit2(VOID);
195 
196 VOID
197 NTAPI
200 );
201 
202 VOID
203 NTAPI
205 
206 BOOLEAN
207 NTAPI
209  IN PLARGE_INTEGER SystemBootTime
210 );
211 
212 VOID
213 NTAPI
215 
216 VOID
217 NTAPI
218 ExSwapinWorkerThreads(IN BOOLEAN AllowSwap);
219 
220 VOID
221 NTAPI
223 
224 VOID
225 NTAPI
228  IN POOL_TYPE Type,
229  IN ULONG Size,
230  IN ULONG Tag,
231  IN USHORT MaximumDepth,
232  IN PLIST_ENTRY ListHead
233 );
234 
235 BOOLEAN
236 NTAPI
238 
239 BOOLEAN
240 NTAPI
242 
243 BOOLEAN
244 NTAPI
246 
247 VOID
248 NTAPI
250  IN ULONG Cpu,
251  IN PLOADER_PARAMETER_BLOCK LoaderBlock
252 );
253 
254 VOID
255 NTAPI
257 
258 BOOLEAN
259 NTAPI
261 
262 BOOLEAN
263 NTAPI
265 
266 BOOLEAN
267 NTAPI
269 
270 BOOLEAN
271 NTAPI
273 
274 BOOLEAN
275 NTAPI
277 
278 BOOLEAN
279 NTAPI
281 
282 BOOLEAN
283 NTAPI
285 
286 VOID
287 NTAPI
289 
290 VOID
291 NTAPI
293 
294 /* Callback Functions ********************************************************/
295 
296 VOID
297 NTAPI
300 );
301 
303 NTAPI
307 );
308 
309 VOID
310 NTAPI
312  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
313 );
314 
315 BOOLEAN
316 NTAPI
318  IN OUT PEX_CALLBACK CallBack,
321 );
322 
324 NTAPI
326  IN OUT PEX_CALLBACK CallBack
327 );
328 
329 VOID
330 NTAPI
332  IN OUT PEX_CALLBACK CallBack,
333  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
334 );
335 
337 NTAPI
339  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
340 );
341 
342 PVOID
343 NTAPI
345  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
346 );
347 
348 VOID
349 NTAPI
351  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
352 );
353 
354 /* Rundown Functions ********************************************************/
355 
356 VOID
357 FASTCALL
359  OUT PEX_RUNDOWN_REF RunRef
360 );
361 
362 VOID
363 FASTCALL
365  OUT PEX_RUNDOWN_REF RunRef
366 );
367 
368 BOOLEAN
369 FASTCALL
371  IN OUT PEX_RUNDOWN_REF RunRef
372 );
373 
374 BOOLEAN
375 FASTCALL
377  IN OUT PEX_RUNDOWN_REF RunRef,
378  IN ULONG Count
379 );
380 
381 VOID
382 FASTCALL
384  IN OUT PEX_RUNDOWN_REF RunRef
385 );
386 
387 VOID
388 FASTCALL
390  IN OUT PEX_RUNDOWN_REF RunRef,
391  IN ULONG Count
392 );
393 
394 VOID
395 FASTCALL
397  OUT PEX_RUNDOWN_REF RunRef
398 );
399 
400 VOID
401 FASTCALL
403  IN OUT PEX_RUNDOWN_REF RunRef
404 );
405 
406 /* HANDLE TABLE FUNCTIONS ***************************************************/
407 
408 typedef BOOLEAN
410  PHANDLE_TABLE_ENTRY HandleTableEntry,
411  HANDLE Handle,
412  PVOID Context
413 );
414 
415 typedef BOOLEAN
419  IN PHANDLE_TABLE_ENTRY HandleTableEntry,
420  IN PHANDLE_TABLE_ENTRY NewEntry
421 );
422 
423 typedef BOOLEAN
425  PHANDLE_TABLE_ENTRY HandleTableEntry,
427 );
428 
429 VOID
430 NTAPI
432  VOID
433 );
434 
436 NTAPI
439 );
440 
441 VOID
442 NTAPI
445  IN PHANDLE_TABLE_ENTRY HandleTableEntry
446 );
447 
448 HANDLE
449 NTAPI
452  IN PHANDLE_TABLE_ENTRY HandleTableEntry
453 );
454 
455 VOID
456 NTAPI
459  IN PVOID DestroyHandleProcedure OPTIONAL
460 );
461 
462 BOOLEAN
463 NTAPI
466  IN HANDLE Handle,
467  IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL
468 );
469 
471 NTAPI
475 );
476 
478 NTAPI
482  IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure,
484 );
485 
486 BOOLEAN
487 NTAPI
490  IN HANDLE Handle,
491  IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine,
493 );
494 
495 VOID
496 NTAPI
499  IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure,
501 );
502 
504 NTAPI
508 );
509 
510 BOOLEAN
511 NTAPI
514  IN PHANDLE_TABLE_ENTRY HandleTableEntry
515 );
516 
517 /* PSEH EXCEPTION HANDLING **************************************************/
518 
519 LONG
520 NTAPI
522 
523 /* CALLBACKS *****************************************************************/
524 
526 VOID
528  IN PVOID Context,
531 {
532  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
534 
535  /* Reference the block */
536  CallbackBlock = ExReferenceCallBackBlock(Callback);
537  if (CallbackBlock)
538  {
539  /* Get the function */
540  Function = ExGetCallBackBlockRoutine(CallbackBlock);
541 
542  /* Do the callback */
544 
545  /* Now dereference it */
546  ExDereferenceCallBackBlock(Callback, CallbackBlock);
547  }
548 }
549 
550 /* FAST REFS ******************************************************************/
551 
553 PVOID
555 {
556  /* Return the unbiased pointer */
557  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
558 }
559 
561 ULONG
563 {
564  /* Return the reference count */
565  return (ULONG)FastRef.RefCnt;
566 }
567 
569 VOID
572 {
573  /* Sanity check */
574  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
575 
576  /* Check if an object is being set */
577  if (!Object)
578  {
579  /* Clear the field */
580  FastRef->Object = NULL;
581  }
582  else
583  {
584  /* Otherwise, we assume the object was referenced and is ready */
585  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
586  }
587 }
588 
592 {
593  EX_FAST_REF OldValue, NewValue;
594 
595  /* Start reference loop */
596  for (;;)
597  {
598  /* Get the current reference count */
599  OldValue = *FastRef;
600  if (OldValue.RefCnt)
601  {
602  /* Increase the reference count */
603  NewValue.Value = OldValue.Value - 1;
604  NewValue.Object = ExpChangePushlock(&FastRef->Object,
605  NewValue.Object,
606  OldValue.Object);
607  if (NewValue.Object != OldValue.Object) continue;
608  }
609 
610  /* We are done */
611  break;
612  }
613 
614  /* Return the old value */
615  return OldValue;
616 }
617 
619 BOOLEAN
621  IN PVOID Object)
622 {
623  EX_FAST_REF OldValue, NewValue;
624 
625  /* Sanity checks */
627 
628  /* Start update loop */
629  for (;;)
630  {
631  /* Get the current reference count */
632  OldValue = *FastRef;
633 
634  /* Check if the current count is too high or if the pointer changed */
635  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
636  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
637  {
638  /* Fail */
639  return FALSE;
640  }
641 
642  /* Update the reference count */
643  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
644  NewValue.Object = ExpChangePushlock(&FastRef->Object,
645  NewValue.Object,
646  OldValue.Object);
647  if (NewValue.Object != OldValue.Object) continue;
648 
649  /* We are done */
650  break;
651  }
652 
653  /* Return success */
654  return TRUE;
655 }
656 
658 BOOLEAN
660  IN PVOID Object)
661 {
662  EX_FAST_REF OldValue, NewValue;
663 
664  /* Sanity checks */
665  ASSERT(Object != NULL);
667 
668  /* Start reference loop */
669  for (;;)
670  {
671  /* Get the current reference count */
672  OldValue = *FastRef;
673 
674  /* Check if we're full if if the pointer changed */
675  if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
676 
677  /* Decrease the reference count */
678  NewValue.Value = OldValue.Value + 1;
679  NewValue.Object = ExpChangePushlock(&FastRef->Object,
680  NewValue.Object,
681  OldValue.Object);
682  if (NewValue.Object != OldValue.Object) continue;
683 
684  /* We are done */
685  break;
686  }
687 
688  /* Return success */
689  return TRUE;
690 }
691 
695  IN PVOID Object)
696 {
697  EX_FAST_REF NewValue, OldValue;
698 
699  /* Sanity check */
700  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
701 
702  /* Check if an object is being set */
703  if (!Object)
704  {
705  /* Clear the field */
706  NewValue.Object = NULL;
707  }
708  else
709  {
710  /* Otherwise, we assume the object was referenced and is ready */
711  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
712  }
713 
714  /* Update the object */
715  OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
716  return OldValue;
717 }
718 
722  IN PVOID Object,
723  IN PVOID OldObject)
724 {
725  EX_FAST_REF OldValue, NewValue;
726 
727  /* Sanity check and start swap loop */
729  for (;;)
730  {
731  /* Get the current value */
732  OldValue = *FastRef;
733 
734  /* Make sure there's enough references to swap */
735  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
736 
737  /* Check if we have an object to swap */
738  if (Object)
739  {
740  /* Set up the value with maximum fast references */
741  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
742  }
743  else
744  {
745  /* Write the object address itself (which is empty) */
746  NewValue.Value = (ULONG_PTR)Object;
747  }
748 
749  /* Do the actual compare exchange */
750  NewValue.Object = ExpChangePushlock(&FastRef->Object,
751  NewValue.Object,
752  OldValue.Object);
753  if (NewValue.Object != OldValue.Object) continue;
754 
755  /* All done */
756  break;
757  }
758 
759  /* Return the old value */
760  return OldValue;
761 }
762 
763 /* RUNDOWN *******************************************************************/
764 
768  IN ULONG ProcNumber)
769 {
770  return (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs +
771  RunRefCacheAware->RunRefSize *
772  (ProcNumber % RunRefCacheAware->Number));
773 }
774 
775 /*++
776  * @name ExfAcquireRundownProtection
777  * INTERNAL MACRO
778  *
779  * The ExfAcquireRundownProtection routine acquires rundown protection for
780  * the specified descriptor.
781  *
782  * @param RunRef
783  * Pointer to a rundown reference descriptor.
784  *
785  * @return TRUE if access to the protected structure was granted, FALSE otherwise.
786  *
787  * @remarks This is the internal macro for system use only.In case the rundown
788  * was active, then the slow-path will be called through the exported
789  * function.
790  *
791  *--*/
793 BOOLEAN
795 {
796  ULONG_PTR Value, NewValue;
797 
798  /* Get the current value and mask the active bit */
799  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
800 
801  /* Add a reference */
802  NewValue = Value + EX_RUNDOWN_COUNT_INC;
803 
804  /* Change the value */
805  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
806  if (NewValue != Value)
807  {
808  /* Rundown was active, use long path */
809  return ExfAcquireRundownProtection(RunRef);
810  }
811 
812  /* Success */
813  return TRUE;
814 }
815 
816 /*++
817  * @name ExReleaseRundownProtection
818  * INTERNAL MACRO
819  *
820  * The ExReleaseRundownProtection routine releases rundown protection for
821  * the specified descriptor.
822  *
823  * @param RunRef
824  * Pointer to a rundown reference descriptor.
825  *
826  * @return TRUE if access to the protected structure was granted, FALSE otherwise.
827  *
828  * @remarks This is the internal macro for system use only.In case the rundown
829  * was active, then the slow-path will be called through the exported
830  * function.
831  *
832  *--*/
834 VOID
836 {
837  ULONG_PTR Value, NewValue;
838 
839  /* Get the current value and mask the active bit */
840  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
841 
842  /* Remove a reference */
843  NewValue = Value - EX_RUNDOWN_COUNT_INC;
844 
845  /* Change the value */
846  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
847 
848  /* Check if the rundown was active */
849  if (NewValue != Value)
850  {
851  /* Rundown was active, use long path */
853  }
854  else
855  {
856  /* Sanity check */
858  }
859 }
860 
861 /*++
862  * @name ExInitializeRundownProtection
863  * INTERNAL MACRO
864  *
865  * The ExInitializeRundownProtection routine initializes a rundown
866  * protection descriptor.
867  *
868  * @param RunRef
869  * Pointer to a rundown reference descriptor.
870  *
871  * @return None.
872  *
873  * @remarks This is the internal macro for system use only.
874  *
875  *--*/
877 VOID
879 {
880  /* Set the count to zero */
881  RunRef->Count = 0;
882 }
883 
884 /*++
885  * @name ExWaitForRundownProtectionRelease
886  * INTERNAL MACRO
887  *
888  * The ExWaitForRundownProtectionRelease routine waits until the specified
889  * rundown descriptor has been released.
890  *
891  * @param RunRef
892  * Pointer to a rundown reference descriptor.
893  *
894  * @return None.
895  *
896  * @remarks This is the internal macro for system use only. If a wait is actually
897  * necessary, then the slow path is taken through the exported function.
898  *
899  *--*/
901 VOID
903 {
905 
906  /* Set the active bit */
908  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
909  {
910  /* If the the rundown wasn't already active, then take the long path */
912  }
913 }
914 
915 /*++
916  * @name ExRundownCompleted
917  * INTERNAL MACRO
918  *
919  * The ExRundownCompleted routine completes the rundown of the specified
920  * descriptor by setting the active bit.
921  *
922  * @param RunRef
923  * Pointer to a rundown reference descriptor.
924  *
925  * @return None.
926  *
927  * @remarks This is the internal macro for system use only.
928  *
929  *--*/
931 VOID
933 {
934  /* Sanity check */
935  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
936 
937  /* Mark the counter as active */
939 }
940 
941 /* PUSHLOCKS *****************************************************************/
942 
943 /* FIXME: VERIFY THESE! */
944 
945 VOID
946 FASTCALL
948  IN PEX_PUSH_LOCK PushLock,
949  IN PVOID WaitBlock
950 );
951 
952 VOID
953 FASTCALL
955  IN PEX_PUSH_LOCK PushLock,
956  IN PVOID CurrentWaitBlock
957 );
958 
959 VOID
960 FASTCALL
962  IN PEX_PUSH_LOCK PushLock,
963  IN PVOID WaitBlock
964 );
965 
966 /*++
967  * @name _ExInitializePushLock
968  * INTERNAL MACRO
969  *
970  * The _ExInitializePushLock macro initializes a PushLock.
971  *
972  * @params PushLock
973  * Pointer to the pushlock which is to be initialized.
974  *
975  * @return None.
976  *
977  * @remarks None.
978  *
979  *--*/
981 VOID
983 {
984  /* Set the value to 0 */
985  PushLock->Ptr = 0;
986 }
987 #define ExInitializePushLock _ExInitializePushLock
988 
989 /*++
990  * @name ExAcquirePushLockExclusive
991  * INTERNAL MACRO
992  *
993  * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
994  *
995  * @params PushLock
996  * Pointer to the pushlock which is to be acquired.
997  *
998  * @return None.
999  *
1000  * @remarks The function attempts the quickest route to acquire the lock, which is
1001  * to simply set the lock bit.
1002  * However, if the pushlock is already shared, the slower path is taken.
1003  *
1004  * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1005  * This macro should usually be paired up with KeAcquireCriticalRegion.
1006  *
1007  *--*/
1009 VOID
1011 {
1012  /* Try acquiring the lock */
1014  {
1015  /* Someone changed it, use the slow path */
1016  ExfAcquirePushLockExclusive(PushLock);
1017  }
1018 
1019  /* Sanity check */
1020  ASSERT(PushLock->Locked);
1021 }
1022 
1023 /*++
1024 * @name ExTryToAcquirePushLockExclusive
1025 * INTERNAL MACRO
1026 *
1027 * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1028 *
1029 * @params PushLock
1030 * Pointer to the pushlock which is to be acquired.
1031 *
1032 * @return None.
1033 *
1034 * @remarks The function attempts the quickest route to acquire the lock, which is
1035 * to simply set the lock bit.
1036 * However, if the pushlock is already shared, the slower path is taken.
1037 *
1038 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1039 * This macro should usually be paired up with KeAcquireCriticalRegion.
1040 *
1041 *--*/
1043 BOOLEAN
1045 {
1046  /* Try acquiring the lock */
1048  {
1049  /* Can't acquire */
1050  return FALSE;
1051  }
1052 
1053  /* Got acquired */
1054  ASSERT (PushLock->Locked);
1055  return TRUE;
1056 }
1057 
1058 /*++
1059  * @name ExAcquirePushLockShared
1060  * INTERNAL MACRO
1061  *
1062  * The ExAcquirePushLockShared macro acquires a shared PushLock.
1063  *
1064  * @params PushLock
1065  * Pointer to the pushlock which is to be acquired.
1066  *
1067  * @return None.
1068  *
1069  * @remarks The function attempts the quickest route to acquire the lock, which is
1070  * to simply set the lock bit and set the share count to one.
1071  * However, if the pushlock is already shared, the slower path is taken.
1072  *
1073  * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1074  * This macro should usually be paired up with KeAcquireCriticalRegion.
1075  *
1076  *--*/
1078 VOID
1080 {
1081  EX_PUSH_LOCK NewValue;
1082 
1083  /* Try acquiring the lock */
1085  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1086  {
1087  /* Someone changed it, use the slow path */
1088  ExfAcquirePushLockShared(PushLock);
1089  }
1090 
1091  /* Sanity checks */
1092  ASSERT(PushLock->Locked);
1093 }
1094 
1095 /*++
1096  * @name ExConvertPushLockSharedToExclusive
1097  * INTERNAL MACRO
1098  *
1099  * The ExConvertPushLockSharedToExclusive macro converts an exclusive
1100  * pushlock to a shared pushlock.
1101  *
1102  * @params PushLock
1103  * Pointer to the pushlock which is to be converted.
1104  *
1105  * @return FALSE if conversion failed, TRUE otherwise.
1106  *
1107  * @remarks The function attempts the quickest route to convert the lock, which is
1108  * to simply set the lock bit and remove any other bits.
1109  *
1110  *--*/
1112 BOOLEAN
1114 {
1115  EX_PUSH_LOCK OldValue;
1116 
1117  /* Set the expected old value */
1119 
1120  /* Try converting the lock */
1121  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1122  OldValue.Ptr)
1123  {
1124  /* Conversion failed */
1125  return FALSE;
1126  }
1127 
1128  /* Sanity check */
1129  ASSERT(PushLock->Locked);
1130  return TRUE;
1131 }
1132 
1133 /*++
1134  * @name ExWaitOnPushLock
1135  * INTERNAL MACRO
1136  *
1137  * The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
1138  *
1139  * @params PushLock
1140  * Pointer to a pushlock.
1141  *
1142  * @return None.
1143  *
1144  * @remarks The function attempts to get any exclusive waiters out of their slow
1145  * path by forcing an instant acquire/release operation.
1146  *
1147  * Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
1148  *
1149  *--*/
1151 VOID
1153 {
1154  /* Check if we're locked */
1155  if (PushLock->Locked)
1156  {
1157  /* Acquire the lock */
1158  ExfAcquirePushLockExclusive(PushLock);
1159  ASSERT(PushLock->Locked);
1160 
1161  /* Release it */
1162  ExfReleasePushLockExclusive(PushLock);
1163  }
1164 }
1165 
1166 /*++
1167  * @name ExReleasePushLockShared
1168  * INTERNAL MACRO
1169  *
1170  * The ExReleasePushLockShared macro releases a previously acquired PushLock.
1171  *
1172  * @params PushLock
1173  * Pointer to a previously acquired pushlock.
1174  *
1175  * @return None.
1176  *
1177  * @remarks The function attempts the quickest route to release the lock, which is
1178  * to simply decrease the share count and remove the lock bit.
1179  * However, if the pushlock is being waited on then the long path is taken.
1180  *
1181  * Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
1182  * This macro should usually be paired up with KeLeaveCriticalRegion.
1183  *
1184  *--*/
1186 VOID
1188 {
1189  EX_PUSH_LOCK OldValue;
1190 
1191  /* Sanity checks */
1192  ASSERT(PushLock->Locked);
1193 
1194  /* Try to clear the pushlock */
1196  if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1197  {
1198  /* There are still other people waiting on it */
1199  ExfReleasePushLockShared(PushLock);
1200  }
1201 }
1202 
1203 /*++
1204  * @name ExReleasePushLockExclusive
1205  * INTERNAL MACRO
1206  *
1207  * The ExReleasePushLockExclusive macro releases a previously
1208  * exclusively acquired PushLock.
1209  *
1210  * @params PushLock
1211  * Pointer to a previously acquired pushlock.
1212  *
1213  * @return None.
1214  *
1215  * @remarks The function attempts the quickest route to release the lock, which is
1216  * to simply clear the locked bit.
1217  * However, if the pushlock is being waited on, the slow path is taken
1218  * in an attempt to wake up the lock.
1219  *
1220  * Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
1221  * This macro should usually be paired up with KeLeaveCriticalRegion.
1222  *
1223  *--*/
1225 VOID
1227 {
1228  EX_PUSH_LOCK OldValue;
1229 
1230  /* Sanity checks */
1231  ASSERT(PushLock->Locked);
1232 
1233  /* Unlock the pushlock */
1234  OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1236 
1237  /* Sanity checks */
1238  ASSERT(OldValue.Locked);
1239  ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1240 
1241  /* Check if anyone is waiting on it and it's not already waking*/
1242  if ((OldValue.Waiting) && !(OldValue.Waking))
1243  {
1244  /* Wake it up */
1245  ExfTryToWakePushLock(PushLock);
1246  }
1247 }
1248 
1249 /*++
1250  * @name ExReleasePushLock
1251  * INTERNAL MACRO
1252  *
1253  * The ExReleasePushLock macro releases a previously acquired PushLock.
1254  *
1255  * @params PushLock
1256  * Pointer to a previously acquired pushlock.
1257  *
1258  * @return None.
1259  *
1260  * @remarks The function attempts the quickest route to release the lock, which is
1261  * to simply clear all the fields and decrease the share count if required.
1262  * However, if the pushlock is being waited on then the long path is taken.
1263  *
1264  * Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
1265  * This macro should usually be paired up with KeLeaveCriticalRegion.
1266  *
1267  *--*/
1269 VOID
1271 {
1272  EX_PUSH_LOCK OldValue = *PushLock;
1273  EX_PUSH_LOCK NewValue;
1274 
1275  /* Sanity checks */
1276  ASSERT(OldValue.Locked);
1277 
1278  /* Check if the pushlock is shared */
1279  if (OldValue.Shared > 1)
1280  {
1281  /* Decrease the share count */
1282  NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1283  }
1284  else
1285  {
1286  /* Clear the pushlock entirely */
1287  NewValue.Value = 0;
1288  }
1289 
1290  /* Check if nobody is waiting on us and try clearing the lock here */
1291  if ((OldValue.Waiting) ||
1292  (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1293  OldValue.Ptr))
1294  {
1295  /* We have waiters, use the long path */
1296  ExfReleasePushLock(PushLock);
1297  }
1298 }
1299 
1300 /* FAST MUTEX INLINES *********************************************************/
1301 
1303 VOID
1305 {
1307 
1308  /* Sanity check */
1310  (Thread->CombinedApcDisable != 0) ||
1311  (Thread->Teb == NULL) ||
1312  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1313  ASSERT(FastMutex->Owner != Thread);
1314 
1315  /* Decrease the count */
1316  if (InterlockedDecrement(&FastMutex->Count))
1317  {
1318  /* Someone is still holding it, use slow path */
1319  KiAcquireFastMutex(FastMutex);
1320  }
1321 
1322  /* Set the owner */
1323  FastMutex->Owner = Thread;
1324 }
1325 
1327 VOID
1329 {
1331  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1332  (KeGetCurrentThread()->Teb == NULL) ||
1334  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1335 
1336  /* Erase the owner */
1337  FastMutex->Owner = NULL;
1338 
1339  /* Increase the count */
1340  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1341  {
1342  /* Someone was waiting for it, signal the waiter */
1343  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1344  }
1345 }
1346 
1348 VOID
1350 {
1351  KIRQL OldIrql;
1353 
1354  /* Raise IRQL to APC */
1356 
1357  /* Decrease the count */
1358  if (InterlockedDecrement(&FastMutex->Count))
1359  {
1360  /* Someone is still holding it, use slow path */
1361  KiAcquireFastMutex(FastMutex);
1362  }
1363 
1364  /* Set the owner and IRQL */
1365  FastMutex->Owner = KeGetCurrentThread();
1366  FastMutex->OldIrql = OldIrql;
1367 }
1368 
1370 VOID
1372 {
1373  KIRQL OldIrql;
1375 
1376  /* Erase the owner */
1377  FastMutex->Owner = NULL;
1378  OldIrql = (KIRQL)FastMutex->OldIrql;
1379 
1380  /* Increase the count */
1381  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1382  {
1383  /* Someone was waiting for it, signal the waiter */
1384  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1385  }
1386 
1387  /* Lower IRQL back */
1389 }
1390 
1392 BOOLEAN
1394 {
1395  KIRQL OldIrql;
1397 
1398  /* Raise to APC_LEVEL */
1400 
1401  /* Check if we can quickly acquire it */
1402  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1403  {
1404  /* We have, set us as owners */
1405  FastMutex->Owner = KeGetCurrentThread();
1406  FastMutex->OldIrql = OldIrql;
1407  return TRUE;
1408  }
1409  else
1410  {
1411  /* Acquire attempt failed */
1413  YieldProcessor();
1414  return FALSE;
1415  }
1416 }
1417 
1419 VOID
1421 {
1422  /* Enter the Critical Region */
1424 
1425  /* Acquire the mutex unsafely */
1426  _ExAcquireFastMutexUnsafe(FastMutex);
1427 }
1428 
1430 VOID
1432 {
1433  /* Release the mutex unsafely */
1434  _ExReleaseFastMutexUnsafe(FastMutex);
1435 
1436  /* Leave the critical region */
1438 }
1439 
1440 /* OTHER FUNCTIONS **********************************************************/
1441 
1442 BOOLEAN
1443 NTAPI
1446 );
1447 
1448 NTSTATUS
1450  IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
1451 );
1452 
1453 BOOLEAN
1454 NTAPI
1456  IN BOOLEAN Wait
1457 );
1458 
1459 VOID
1460 NTAPI
1462  VOID
1463 );
1464 
1465 VOID
1466 NTAPI
1468  IN BOOLEAN UpdateInterruptTime,
1469  IN ULONG MaxSepInSeconds
1470 );
1471 
1472 VOID
1473 NTAPI
1475  OUT LUID *LocallyUniqueId
1476 );
1477 
1478 VOID
1479 NTAPI
1481  VOID
1482 );
1483 
1484 VOID
1485 NTAPI
1486 HeadlessInit(
1487  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1488 );
1489 
1490 VOID
1491 NTAPI
1492 XIPInit(
1493  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1494 );
1495 
1496 #define InterlockedDecrementUL(Addend) \
1497  (ULONG)InterlockedDecrement((PLONG)(Addend))
1498 
1499 #define InterlockedIncrementUL(Addend) \
1500  (ULONG)InterlockedIncrement((PLONG)(Addend))
1501 
1502 #define InterlockedExchangeUL(Target, Value) \
1503  (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1504 
1505 #define InterlockedExchangeAddUL(Addend, Value) \
1506  (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
1507 
1508 #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
1509  (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
1510 
1511 #define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \
1512  (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))
1513 
1514 #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
1515  (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
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:110
FORCEINLINE VOID _ExReleaseRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:835
BOOLEAN NTAPI ExpInitializeCallbacks(VOID)
Definition: callback.c:256
FORCEINLINE BOOLEAN ExTryToAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1044
#define ExpSetRundown(x, y)
Definition: ex.h:158
#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:1010
VOID FASTCALL ExfRundownCompleted(OUT PEX_RUNDOWN_REF RunRef)
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:554
VOID NTAPI ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
Definition: handle.c:927
#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:52
FORCEINLINE VOID _ExInitializePushLock(OUT PEX_PUSH_LOCK PushLock)
Definition: ex.h:982
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
PHANDLE_TABLE NTAPI ExDupHandleTable(IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure, IN ULONG_PTR Mask)
Definition: handle.c:1036
FORCEINLINE VOID ExInitializeFastReference(OUT PEX_FAST_REF FastRef, IN OPTIONAL PVOID Object)
Definition: ex.h:570
LONG Period
Definition: ex.h:107
FORCEINLINE BOOLEAN ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:620
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define HANDLE_LOW_BITS
Definition: ex.h:72
_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:765
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:848
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:62
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:84
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
PVOID ExpDefaultErrorPort
Definition: harderr.c:20
#define TRUE
Definition: types.h:120
ULONG NtMajorVersion
Definition: init.c:43
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:60
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:878
char CHAR
Definition: xmlstorage.h:175
union _EXHANDLE EXHANDLE
BOOLEAN WakeTimer
Definition: ex.h:109
PVOID Ptr
Definition: extypes.h:466
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING NtSystemRoot
Definition: init.c:73
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:29
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1152
FORCEINLINE VOID _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:932
#define KERNEL_FLAG_BITS
Definition: ex.h:77
#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:108
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:1345
BOOLEAN ExpIsWinPEMode
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack)
Definition: callback.c:122
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:83
ULONG ExpAltTimeZoneBias
Definition: time.c:24
LIST_ENTRY ActiveTimerListEntry
Definition: ex.h:105
BOOLEAN NTAPI ExpInitializeEventPairImplementation(VOID)
Definition: evtpair.c:33
FORCEINLINE VOID _ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1371
PWSTR Name
Definition: ex.h:116
#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:122
ULONG_PTR Index
Definition: ex.h:84
BOOLEAN(NTAPI * PEX_CHANGE_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)
Definition: ex.h:424
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:83
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
ULONG ExpInitializationPhase
Definition: init.c:66
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:416
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:591
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:351
_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:1226
Definition: extypes.h:595
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
Definition: work.c:625
unsigned char BOOLEAN
VOID FASTCALL ExfUnblockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID CurrentWaitBlock)
KSPIN_LOCK Lock
Definition: ex.h:106
FORCEINLINE EX_FAST_REF ExSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:694
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
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:1153
FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1420
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:53
VOID NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:515
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
Definition: handle.c:1010
_In_ PVOID Argument2
Definition: classpnp.h:721
ULONG ExpOemCodePageDataOffset
Definition: init.c:83
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:91
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
FAST_MUTEX
Definition: extypes.h:17
VOID NTAPI ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
Definition: uuid.c:334
int Count
Definition: noreturn.cpp:7
PVOID ExpNlsSectionPointer
Definition: init.c:87
#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:73
#define ASSERT(a)
Definition: mode.c:45
if(!(yy_init))
Definition: macro.lex.yy.c:714
FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1431
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID NTAPI Phase1Initialization(IN PVOID Context)
Definition: init.c:2017
INT POOL_TYPE
Definition: typedefs.h:78
uint64_t ULONGLONG
Definition: typedefs.h:67
BOOLEAN NTAPI ExpInitializeProfileImplementation(VOID)
Definition: profile.c:64
FORCEINLINE BOOLEAN _ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:794
#define ExpChangeRundown(x, y, z)
Definition: ex.h:156
HANDLE GenericHandleOverlay
Definition: ex.h:95
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:2653
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:562
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:44
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:100
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:20
KAPC TimerApc
Definition: ex.h:103
PCALLBACK_OBJECT PowerStateCallback
Definition: callback.c:29
ULONG ExCriticalWorkerThreads
Definition: work.c:34
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: ex.h:79
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:790
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:659
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
KDPC TimerDpc
Definition: ex.h:104
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:721
processorSet Mask
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:52
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1270
ULONG CmNtCSDVersion
Definition: init.c:57
BOOLEAN NTAPI ExLuidInitialization(VOID)
Definition: uuid.c:324
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1079
Definition: compat.h:694
FORCEINLINE PEX_RUNDOWN_REF ExGetRunRefForGivenProcessor(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, IN ULONG ProcNumber)
Definition: ex.h:767
VOID FASTCALL ExfAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:645
* PFAST_MUTEX
Definition: extypes.h:17
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
#define InterlockedIncrement
Definition: armddk.h:53
FORCEINLINE VOID _ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1349
ULONG AsULONG
Definition: ex.h:97
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:948
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:527
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:1113
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation(VOID)
Definition: sem.c:39
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
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
PEPROCESS ExpDefaultErrorPortProcess
Definition: harderr.c:21
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:791
ULONG_PTR KernelFlag2
Definition: ex.h:93
FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1393
ULONG CmNtCSDReleaseType
Definition: init.c:58
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
struct tagContext Context
Definition: acpixf.h:1034
#define BOOLEAN
Definition: pedump.c:73
#define OUT
Definition: typedefs.h:40
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1187
PCALLBACK_OBJECT * CallbackObject
Definition: ex.h:115
struct _HARDERROR_USER_PARAMETERS * PHARDERROR_USER_PARAMETERS
ULONG_PTR HighIndex
Definition: ex.h:92
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:27
KTIMER KeTimer
Definition: ex.h:102
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:1304
#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:126
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:176
ULONG_PTR LowIndex
Definition: ex.h:90
ULONG_PTR Value
Definition: ex.h:96
#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:1328
#define KeGetCurrentThread
Definition: hal.h:44
VOID NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:919
#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:1196
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:157
signed int * PLONG
Definition: retypes.h:5
#define HANDLE_INDEX_BITS
Definition: ex.h:76
UNICODE_STRING CmVersionString
Definition: init.c:59
#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:89
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:18
#define EX_RUNDOWN_ACTIVE
ULONG_PTR KernelFlag
Definition: ex.h:85
ULONG NtBuildNumber
Definition: init.c:48
BOOLEAN(NTAPI * PEX_SWEEP_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, HANDLE Handle, PVOID Context)
Definition: ex.h:409
WORK_QUEUE_ITEM ExpDebuggerWorkItem
Definition: dbgctrl.c:20
FORCEINLINE VOID _ExWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:902
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
#define HANDLE_TAG_BITS
Definition: ex.h:75
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:56
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