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