ReactOS  0.4.14-dev-52-g6116262
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 // #ifdef _WINKD_
51 /*
52  * WinDBG Debugger Worker State Machine data (see dbgctrl.c)
53  */
54 typedef enum _WINKD_WORKER_STATE
55 {
60 
66 
68 // #endif /* _WINKD_ */
69 
70 #ifdef _WIN64
71 #define HANDLE_LOW_BITS (PAGE_SHIFT - 4)
72 #define HANDLE_HIGH_BITS (PAGE_SHIFT - 3)
73 #else
74 #define HANDLE_LOW_BITS (PAGE_SHIFT - 3)
75 #define HANDLE_HIGH_BITS (PAGE_SHIFT - 2)
76 #endif
77 #define HANDLE_TAG_BITS (2)
78 #define HANDLE_INDEX_BITS (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)
79 #define KERNEL_FLAG_BITS (sizeof(PVOID)*8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
80 
81 typedef union _EXHANDLE
82 {
83  struct
84  {
88  };
89  struct
90  {
96  };
100 } EXHANDLE, *PEXHANDLE;
101 
102 typedef struct _ETIMER
103 {
113 } ETIMER, *PETIMER;
114 
115 typedef struct
116 {
120 
122 {
127 
128 #define MAX_FAST_REFS 7
129 
130 #define ExAcquireRundownProtection _ExAcquireRundownProtection
131 #define ExReleaseRundownProtection _ExReleaseRundownProtection
132 #define ExInitializeRundownProtection _ExInitializeRundownProtection
133 #define ExWaitForRundownProtectionRelease _ExWaitForRundownProtectionRelease
134 #define ExRundownCompleted _ExRundownCompleted
135 #define ExGetPreviousMode KeGetPreviousMode
136 
137 
138 //
139 // Various bits tagged on the handle or handle table
140 //
141 #define EXHANDLE_TABLE_ENTRY_LOCK_BIT 1
142 #define FREE_HANDLE_MASK -1
143 
144 //
145 // Number of entries in each table level
146 //
147 #define LOW_LEVEL_ENTRIES (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))
148 #define MID_LEVEL_ENTRIES (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))
149 #define HIGH_LEVEL_ENTRIES (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))
150 
151 //
152 // Maximum index in each table level before we need another table
153 //
154 #define MAX_LOW_INDEX LOW_LEVEL_ENTRIES
155 #define MAX_MID_INDEX (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
156 #define MAX_HIGH_INDEX (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
157 
158 #define ExpChangeRundown(x, y, z) (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)
159 #define ExpChangePushlock(x, y, z) InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)
160 #define ExpSetRundown(x, y) InterlockedExchangePointer(&x->Ptr, (PVOID)y)
161 
162 NTSTATUS
163 NTAPI
165  IN PSYSTEM_POOLTAG_INFORMATION SystemInformation,
166  IN ULONG SystemInformationLength,
168 );
169 
171 {
176  UCHAR NodeId [ 6 ] ;
178 
179 /* INITIALIZATION FUNCTIONS *************************************************/
180 
181 INIT_FUNCTION
182 BOOLEAN
183 NTAPI
185 
186 VOID
187 NTAPI
188 ExInit2(VOID);
189 
190 VOID
191 NTAPI
194 );
195 
196 INIT_FUNCTION
197 VOID
198 NTAPI
200 
201 BOOLEAN
202 NTAPI
204  IN PLARGE_INTEGER SystemBootTime
205 );
206 
207 INIT_FUNCTION
208 VOID
209 NTAPI
211 
212 VOID
213 NTAPI
214 ExSwapinWorkerThreads(IN BOOLEAN AllowSwap);
215 
216 INIT_FUNCTION
217 VOID
218 NTAPI
220 
221 INIT_FUNCTION
222 VOID
223 NTAPI
226  IN POOL_TYPE Type,
227  IN ULONG Size,
228  IN ULONG Tag,
229  IN USHORT MaximumDepth,
230  IN PLIST_ENTRY ListHead
231 );
232 
233 INIT_FUNCTION
234 BOOLEAN
235 NTAPI
237 
238 INIT_FUNCTION
239 BOOLEAN
240 NTAPI
242 
243 INIT_FUNCTION
244 BOOLEAN
245 NTAPI
247 
248 INIT_FUNCTION
249 VOID
250 NTAPI
252  IN ULONG Cpu,
253  IN PLOADER_PARAMETER_BLOCK LoaderBlock
254 );
255 
256 VOID
257 NTAPI
259 
260 INIT_FUNCTION
261 BOOLEAN
262 NTAPI
264 
265 INIT_FUNCTION
266 BOOLEAN
267 NTAPI
269 
270 INIT_FUNCTION
271 BOOLEAN
272 NTAPI
274 
275 INIT_FUNCTION
276 BOOLEAN
277 NTAPI
279 
280 INIT_FUNCTION
281 BOOLEAN
282 NTAPI
284 
285 INIT_FUNCTION
286 BOOLEAN
287 NTAPI
289 
290 INIT_FUNCTION
291 BOOLEAN
292 NTAPI
294 
295 INIT_FUNCTION
296 VOID
297 NTAPI
299 
300 INIT_FUNCTION
301 VOID
302 NTAPI
304 
305 /* Callback Functions ********************************************************/
306 
307 VOID
308 NTAPI
311 );
312 
314 NTAPI
318 );
319 
320 VOID
321 NTAPI
323  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
324 );
325 
326 BOOLEAN
327 NTAPI
329  IN OUT PEX_CALLBACK CallBack,
332 );
333 
335 NTAPI
337  IN OUT PEX_CALLBACK CallBack
338 );
339 
340 VOID
341 NTAPI
343  IN OUT PEX_CALLBACK CallBack,
344  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
345 );
346 
348 NTAPI
350  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
351 );
352 
353 PVOID
354 NTAPI
356  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
357 );
358 
359 VOID
360 NTAPI
362  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
363 );
364 
365 /* Rundown Functions ********************************************************/
366 
367 VOID
368 FASTCALL
370  OUT PEX_RUNDOWN_REF RunRef
371 );
372 
373 VOID
374 FASTCALL
376  OUT PEX_RUNDOWN_REF RunRef
377 );
378 
379 BOOLEAN
380 FASTCALL
382  IN OUT PEX_RUNDOWN_REF RunRef
383 );
384 
385 BOOLEAN
386 FASTCALL
388  IN OUT PEX_RUNDOWN_REF RunRef,
389  IN ULONG Count
390 );
391 
392 VOID
393 FASTCALL
395  IN OUT PEX_RUNDOWN_REF RunRef
396 );
397 
398 VOID
399 FASTCALL
401  IN OUT PEX_RUNDOWN_REF RunRef,
402  IN ULONG Count
403 );
404 
405 VOID
406 FASTCALL
408  OUT PEX_RUNDOWN_REF RunRef
409 );
410 
411 VOID
412 FASTCALL
414  IN OUT PEX_RUNDOWN_REF RunRef
415 );
416 
417 /* HANDLE TABLE FUNCTIONS ***************************************************/
418 
419 typedef BOOLEAN
421  PHANDLE_TABLE_ENTRY HandleTableEntry,
422  HANDLE Handle,
423  PVOID Context
424 );
425 
426 typedef BOOLEAN
430  IN PHANDLE_TABLE_ENTRY HandleTableEntry,
431  IN PHANDLE_TABLE_ENTRY NewEntry
432 );
433 
434 typedef BOOLEAN
436  PHANDLE_TABLE_ENTRY HandleTableEntry,
438 );
439 
440 INIT_FUNCTION
441 VOID
442 NTAPI
444  VOID
445 );
446 
448 NTAPI
451 );
452 
453 VOID
454 NTAPI
457  IN PHANDLE_TABLE_ENTRY HandleTableEntry
458 );
459 
460 HANDLE
461 NTAPI
464  IN PHANDLE_TABLE_ENTRY HandleTableEntry
465 );
466 
467 VOID
468 NTAPI
471  IN PVOID DestroyHandleProcedure OPTIONAL
472 );
473 
474 BOOLEAN
475 NTAPI
478  IN HANDLE Handle,
479  IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL
480 );
481 
483 NTAPI
487 );
488 
490 NTAPI
494  IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure,
495  IN ULONG_PTR Mask
496 );
497 
498 BOOLEAN
499 NTAPI
502  IN HANDLE Handle,
503  IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine,
505 );
506 
507 VOID
508 NTAPI
511  IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure,
513 );
514 
516 NTAPI
520 );
521 
522 BOOLEAN
523 NTAPI
526  IN PHANDLE_TABLE_ENTRY HandleTableEntry
527 );
528 
529 /* PSEH EXCEPTION HANDLING **************************************************/
530 
531 LONG
532 NTAPI
534 
535 /* CALLBACKS *****************************************************************/
536 
538 VOID
540  IN PVOID Context,
543 {
544  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
546 
547  /* Reference the block */
548  CallbackBlock = ExReferenceCallBackBlock(Callback);
549  if (CallbackBlock)
550  {
551  /* Get the function */
552  Function = ExGetCallBackBlockRoutine(CallbackBlock);
553 
554  /* Do the callback */
556 
557  /* Now dereference it */
558  ExDereferenceCallBackBlock(Callback, CallbackBlock);
559  }
560 }
561 
562 /* FAST REFS ******************************************************************/
563 
565 PVOID
567 {
568  /* Return the unbiased pointer */
569  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
570 }
571 
573 ULONG
575 {
576  /* Return the reference count */
577  return (ULONG)FastRef.RefCnt;
578 }
579 
581 VOID
584 {
585  /* Sanity check */
586  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
587 
588  /* Check if an object is being set */
589  if (!Object)
590  {
591  /* Clear the field */
592  FastRef->Object = NULL;
593  }
594  else
595  {
596  /* Otherwise, we assume the object was referenced and is ready */
597  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
598  }
599 }
600 
604 {
605  EX_FAST_REF OldValue, NewValue;
606 
607  /* Start reference loop */
608  for (;;)
609  {
610  /* Get the current reference count */
611  OldValue = *FastRef;
612  if (OldValue.RefCnt)
613  {
614  /* Increase the reference count */
615  NewValue.Value = OldValue.Value - 1;
616  NewValue.Object = ExpChangePushlock(&FastRef->Object,
617  NewValue.Object,
618  OldValue.Object);
619  if (NewValue.Object != OldValue.Object) continue;
620  }
621 
622  /* We are done */
623  break;
624  }
625 
626  /* Return the old value */
627  return OldValue;
628 }
629 
631 BOOLEAN
633  IN PVOID Object)
634 {
635  EX_FAST_REF OldValue, NewValue;
636 
637  /* Sanity checks */
639 
640  /* Start update loop */
641  for (;;)
642  {
643  /* Get the current reference count */
644  OldValue = *FastRef;
645 
646  /* Check if the current count is too high or if the pointer changed */
647  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
648  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
649  {
650  /* Fail */
651  return FALSE;
652  }
653 
654  /* Update the reference count */
655  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
656  NewValue.Object = ExpChangePushlock(&FastRef->Object,
657  NewValue.Object,
658  OldValue.Object);
659  if (NewValue.Object != OldValue.Object) continue;
660 
661  /* We are done */
662  break;
663  }
664 
665  /* Return success */
666  return TRUE;
667 }
668 
670 BOOLEAN
672  IN PVOID Object)
673 {
674  EX_FAST_REF OldValue, NewValue;
675 
676  /* Sanity checks */
677  ASSERT(Object != NULL);
679 
680  /* Start reference loop */
681  for (;;)
682  {
683  /* Get the current reference count */
684  OldValue = *FastRef;
685 
686  /* Check if we're full if if the pointer changed */
687  if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
688 
689  /* Decrease the reference count */
690  NewValue.Value = OldValue.Value + 1;
691  NewValue.Object = ExpChangePushlock(&FastRef->Object,
692  NewValue.Object,
693  OldValue.Object);
694  if (NewValue.Object != OldValue.Object) continue;
695 
696  /* We are done */
697  break;
698  }
699 
700  /* Return success */
701  return TRUE;
702 }
703 
707  IN PVOID Object)
708 {
709  EX_FAST_REF NewValue, OldValue;
710 
711  /* Sanity check */
712  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
713 
714  /* Check if an object is being set */
715  if (!Object)
716  {
717  /* Clear the field */
718  NewValue.Object = NULL;
719  }
720  else
721  {
722  /* Otherwise, we assume the object was referenced and is ready */
723  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
724  }
725 
726  /* Update the object */
727  OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
728  return OldValue;
729 }
730 
734  IN PVOID Object,
735  IN PVOID OldObject)
736 {
737  EX_FAST_REF OldValue, NewValue;
738 
739  /* Sanity check and start swap loop */
741  for (;;)
742  {
743  /* Get the current value */
744  OldValue = *FastRef;
745 
746  /* Make sure there's enough references to swap */
747  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
748 
749  /* Check if we have an object to swap */
750  if (Object)
751  {
752  /* Set up the value with maximum fast references */
753  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
754  }
755  else
756  {
757  /* Write the object address itself (which is empty) */
758  NewValue.Value = (ULONG_PTR)Object;
759  }
760 
761  /* Do the actual compare exchange */
762  NewValue.Object = ExpChangePushlock(&FastRef->Object,
763  NewValue.Object,
764  OldValue.Object);
765  if (NewValue.Object != OldValue.Object) continue;
766 
767  /* All done */
768  break;
769  }
770 
771  /* Return the old value */
772  return OldValue;
773 }
774 
775 /* RUNDOWN *******************************************************************/
776 
781 {
782  return (PEX_RUNDOWN_REF)((ULONG_PTR)RunRefCacheAware->RunRefs +
783  RunRefCacheAware->RunRefSize *
784  (ProcNumber % RunRefCacheAware->Number));
785 }
786 
787 /*++
788  * @name ExfAcquireRundownProtection
789  * INTERNAL MACRO
790  *
791  * The ExfAcquireRundownProtection routine acquires rundown protection for
792  * the specified descriptor.
793  *
794  * @param RunRef
795  * Pointer to a rundown reference descriptor.
796  *
797  * @return TRUE if access to the protected structure was granted, FALSE otherwise.
798  *
799  * @remarks This is the internal macro for system use only.In case the rundown
800  * was active, then the slow-path will be called through the exported
801  * function.
802  *
803  *--*/
805 BOOLEAN
807 {
808  ULONG_PTR Value, NewValue;
809 
810  /* Get the current value and mask the active bit */
811  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
812 
813  /* Add a reference */
814  NewValue = Value + EX_RUNDOWN_COUNT_INC;
815 
816  /* Change the value */
817  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
818  if (NewValue != Value)
819  {
820  /* Rundown was active, use long path */
821  return ExfAcquireRundownProtection(RunRef);
822  }
823 
824  /* Success */
825  return TRUE;
826 }
827 
828 /*++
829  * @name ExReleaseRundownProtection
830  * INTERNAL MACRO
831  *
832  * The ExReleaseRundownProtection routine releases rundown protection for
833  * the specified descriptor.
834  *
835  * @param RunRef
836  * Pointer to a rundown reference descriptor.
837  *
838  * @return TRUE if access to the protected structure was granted, FALSE otherwise.
839  *
840  * @remarks This is the internal macro for system use only.In case the rundown
841  * was active, then the slow-path will be called through the exported
842  * function.
843  *
844  *--*/
846 VOID
848 {
849  ULONG_PTR Value, NewValue;
850 
851  /* Get the current value and mask the active bit */
852  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
853 
854  /* Remove a reference */
855  NewValue = Value - EX_RUNDOWN_COUNT_INC;
856 
857  /* Change the value */
858  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
859 
860  /* Check if the rundown was active */
861  if (NewValue != Value)
862  {
863  /* Rundown was active, use long path */
865  }
866  else
867  {
868  /* Sanity check */
870  }
871 }
872 
873 /*++
874  * @name ExInitializeRundownProtection
875  * INTERNAL MACRO
876  *
877  * The ExInitializeRundownProtection routine initializes a rundown
878  * protection descriptor.
879  *
880  * @param RunRef
881  * Pointer to a rundown reference descriptor.
882  *
883  * @return None.
884  *
885  * @remarks This is the internal macro for system use only.
886  *
887  *--*/
889 VOID
891 {
892  /* Set the count to zero */
893  RunRef->Count = 0;
894 }
895 
896 /*++
897  * @name ExWaitForRundownProtectionRelease
898  * INTERNAL MACRO
899  *
900  * The ExWaitForRundownProtectionRelease routine waits until the specified
901  * rundown descriptor has been released.
902  *
903  * @param RunRef
904  * Pointer to a rundown reference descriptor.
905  *
906  * @return None.
907  *
908  * @remarks This is the internal macro for system use only. If a wait is actually
909  * necessary, then the slow path is taken through the exported function.
910  *
911  *--*/
913 VOID
915 {
917 
918  /* Set the active bit */
920  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
921  {
922  /* If the the rundown wasn't already active, then take the long path */
924  }
925 }
926 
927 /*++
928  * @name ExRundownCompleted
929  * INTERNAL MACRO
930  *
931  * The ExRundownCompleted routine completes the rundown of the specified
932  * descriptor by setting the active bit.
933  *
934  * @param RunRef
935  * Pointer to a rundown reference descriptor.
936  *
937  * @return None.
938  *
939  * @remarks This is the internal macro for system use only.
940  *
941  *--*/
943 VOID
945 {
946  /* Sanity check */
947  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
948 
949  /* Mark the counter as active */
951 }
952 
953 /* PUSHLOCKS *****************************************************************/
954 
955 /* FIXME: VERIFY THESE! */
956 
957 VOID
958 FASTCALL
960  IN PEX_PUSH_LOCK PushLock,
961  IN PVOID WaitBlock
962 );
963 
964 VOID
965 FASTCALL
967  IN PEX_PUSH_LOCK PushLock,
968  IN PVOID CurrentWaitBlock
969 );
970 
971 VOID
972 FASTCALL
974  IN PEX_PUSH_LOCK PushLock,
975  IN PVOID WaitBlock
976 );
977 
978 /*++
979  * @name _ExInitializePushLock
980  * INTERNAL MACRO
981  *
982  * The _ExInitializePushLock macro initializes a PushLock.
983  *
984  * @params PushLock
985  * Pointer to the pushlock which is to be initialized.
986  *
987  * @return None.
988  *
989  * @remarks None.
990  *
991  *--*/
993 VOID
995 {
996  /* Set the value to 0 */
997  PushLock->Ptr = 0;
998 }
999 #define ExInitializePushLock _ExInitializePushLock
1000 
1001 /*++
1002  * @name ExAcquirePushLockExclusive
1003  * INTERNAL MACRO
1004  *
1005  * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1006  *
1007  * @params PushLock
1008  * Pointer to the pushlock which is to be acquired.
1009  *
1010  * @return None.
1011  *
1012  * @remarks The function attempts the quickest route to acquire the lock, which is
1013  * to simply set the lock bit.
1014  * However, if the pushlock is already shared, the slower path is taken.
1015  *
1016  * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1017  * This macro should usually be paired up with KeAcquireCriticalRegion.
1018  *
1019  *--*/
1021 VOID
1023 {
1024  /* Try acquiring the lock */
1026  {
1027  /* Someone changed it, use the slow path */
1028  ExfAcquirePushLockExclusive(PushLock);
1029  }
1030 
1031  /* Sanity check */
1032  ASSERT(PushLock->Locked);
1033 }
1034 
1035 /*++
1036 * @name ExTryToAcquirePushLockExclusive
1037 * INTERNAL MACRO
1038 *
1039 * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
1040 *
1041 * @params PushLock
1042 * Pointer to the pushlock which is to be acquired.
1043 *
1044 * @return None.
1045 *
1046 * @remarks The function attempts the quickest route to acquire the lock, which is
1047 * to simply set the lock bit.
1048 * However, if the pushlock is already shared, the slower path is taken.
1049 *
1050 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1051 * This macro should usually be paired up with KeAcquireCriticalRegion.
1052 *
1053 *--*/
1055 BOOLEAN
1057 {
1058  /* Try acquiring the lock */
1060  {
1061  /* Can't acquire */
1062  return FALSE;
1063  }
1064 
1065  /* Got acquired */
1066  ASSERT (PushLock->Locked);
1067  return TRUE;
1068 }
1069 
1070 /*++
1071  * @name ExAcquirePushLockShared
1072  * INTERNAL MACRO
1073  *
1074  * The ExAcquirePushLockShared macro acquires a shared PushLock.
1075  *
1076  * @params PushLock
1077  * Pointer to the pushlock which is to be acquired.
1078  *
1079  * @return None.
1080  *
1081  * @remarks The function attempts the quickest route to acquire the lock, which is
1082  * to simply set the lock bit and set the share count to one.
1083  * However, if the pushlock is already shared, the slower path is taken.
1084  *
1085  * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1086  * This macro should usually be paired up with KeAcquireCriticalRegion.
1087  *
1088  *--*/
1090 VOID
1092 {
1093  EX_PUSH_LOCK NewValue;
1094 
1095  /* Try acquiring the lock */
1097  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1098  {
1099  /* Someone changed it, use the slow path */
1100  ExfAcquirePushLockShared(PushLock);
1101  }
1102 
1103  /* Sanity checks */
1104  ASSERT(PushLock->Locked);
1105 }
1106 
1107 /*++
1108  * @name ExConvertPushLockSharedToExclusive
1109  * INTERNAL MACRO
1110  *
1111  * The ExConvertPushLockSharedToExclusive macro converts an exclusive
1112  * pushlock to a shared pushlock.
1113  *
1114  * @params PushLock
1115  * Pointer to the pushlock which is to be converted.
1116  *
1117  * @return FALSE if conversion failed, TRUE otherwise.
1118  *
1119  * @remarks The function attempts the quickest route to convert the lock, which is
1120  * to simply set the lock bit and remove any other bits.
1121  *
1122  *--*/
1124 BOOLEAN
1126 {
1127  EX_PUSH_LOCK OldValue;
1128 
1129  /* Set the expected old value */
1131 
1132  /* Try converting the lock */
1133  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1134  OldValue.Ptr)
1135  {
1136  /* Conversion failed */
1137  return FALSE;
1138  }
1139 
1140  /* Sanity check */
1141  ASSERT(PushLock->Locked);
1142  return TRUE;
1143 }
1144 
1145 /*++
1146  * @name ExWaitOnPushLock
1147  * INTERNAL MACRO
1148  *
1149  * The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
1150  *
1151  * @params PushLock
1152  * Pointer to a pushlock.
1153  *
1154  * @return None.
1155  *
1156  * @remarks The function attempts to get any exclusive waiters out of their slow
1157  * path by forcing an instant acquire/release operation.
1158  *
1159  * Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
1160  *
1161  *--*/
1163 VOID
1165 {
1166  /* Check if we're locked */
1167  if (PushLock->Locked)
1168  {
1169  /* Acquire the lock */
1170  ExfAcquirePushLockExclusive(PushLock);
1171  ASSERT(PushLock->Locked);
1172 
1173  /* Release it */
1174  ExfReleasePushLockExclusive(PushLock);
1175  }
1176 }
1177 
1178 /*++
1179  * @name ExReleasePushLockShared
1180  * INTERNAL MACRO
1181  *
1182  * The ExReleasePushLockShared macro releases a previously acquired PushLock.
1183  *
1184  * @params PushLock
1185  * Pointer to a previously acquired pushlock.
1186  *
1187  * @return None.
1188  *
1189  * @remarks The function attempts the quickest route to release the lock, which is
1190  * to simply decrease the share count and remove the lock bit.
1191  * However, if the pushlock is being waited on then the long path is taken.
1192  *
1193  * Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
1194  * This macro should usually be paired up with KeLeaveCriticalRegion.
1195  *
1196  *--*/
1198 VOID
1200 {
1201  EX_PUSH_LOCK OldValue;
1202 
1203  /* Sanity checks */
1204  ASSERT(PushLock->Locked);
1205 
1206  /* Try to clear the pushlock */
1208  if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1209  {
1210  /* There are still other people waiting on it */
1211  ExfReleasePushLockShared(PushLock);
1212  }
1213 }
1214 
1215 /*++
1216  * @name ExReleasePushLockExclusive
1217  * INTERNAL MACRO
1218  *
1219  * The ExReleasePushLockExclusive macro releases a previously
1220  * exclusively acquired PushLock.
1221  *
1222  * @params PushLock
1223  * Pointer to a previously acquired pushlock.
1224  *
1225  * @return None.
1226  *
1227  * @remarks The function attempts the quickest route to release the lock, which is
1228  * to simply clear the locked bit.
1229  * However, if the pushlock is being waited on, the slow path is taken
1230  * in an attempt to wake up the lock.
1231  *
1232  * Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
1233  * This macro should usually be paired up with KeLeaveCriticalRegion.
1234  *
1235  *--*/
1237 VOID
1239 {
1240  EX_PUSH_LOCK OldValue;
1241 
1242  /* Sanity checks */
1243  ASSERT(PushLock->Locked);
1244 
1245  /* Unlock the pushlock */
1246  OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1248 
1249  /* Sanity checks */
1250  ASSERT(OldValue.Locked);
1251  ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1252 
1253  /* Check if anyone is waiting on it and it's not already waking*/
1254  if ((OldValue.Waiting) && !(OldValue.Waking))
1255  {
1256  /* Wake it up */
1257  ExfTryToWakePushLock(PushLock);
1258  }
1259 }
1260 
1261 /*++
1262  * @name ExReleasePushLock
1263  * INTERNAL MACRO
1264  *
1265  * The ExReleasePushLock macro releases a previously acquired PushLock.
1266  *
1267  * @params PushLock
1268  * Pointer to a previously acquired pushlock.
1269  *
1270  * @return None.
1271  *
1272  * @remarks The function attempts the quickest route to release the lock, which is
1273  * to simply clear all the fields and decrease the share count if required.
1274  * However, if the pushlock is being waited on then the long path is taken.
1275  *
1276  * Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
1277  * This macro should usually be paired up with KeLeaveCriticalRegion.
1278  *
1279  *--*/
1281 VOID
1283 {
1284  EX_PUSH_LOCK OldValue = *PushLock;
1285  EX_PUSH_LOCK NewValue;
1286 
1287  /* Sanity checks */
1288  ASSERT(OldValue.Locked);
1289 
1290  /* Check if the pushlock is shared */
1291  if (OldValue.Shared > 1)
1292  {
1293  /* Decrease the share count */
1294  NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1295  }
1296  else
1297  {
1298  /* Clear the pushlock entirely */
1299  NewValue.Value = 0;
1300  }
1301 
1302  /* Check if nobody is waiting on us and try clearing the lock here */
1303  if ((OldValue.Waiting) ||
1304  (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1305  OldValue.Ptr))
1306  {
1307  /* We have waiters, use the long path */
1308  ExfReleasePushLock(PushLock);
1309  }
1310 }
1311 
1312 /* FAST MUTEX INLINES *********************************************************/
1313 
1315 VOID
1317 {
1319 
1320  /* Sanity check */
1322  (Thread->CombinedApcDisable != 0) ||
1323  (Thread->Teb == NULL) ||
1324  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1325  ASSERT(FastMutex->Owner != Thread);
1326 
1327  /* Decrease the count */
1328  if (InterlockedDecrement(&FastMutex->Count))
1329  {
1330  /* Someone is still holding it, use slow path */
1331  KiAcquireFastMutex(FastMutex);
1332  }
1333 
1334  /* Set the owner */
1335  FastMutex->Owner = Thread;
1336 }
1337 
1339 VOID
1341 {
1343  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1344  (KeGetCurrentThread()->Teb == NULL) ||
1346  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1347 
1348  /* Erase the owner */
1349  FastMutex->Owner = NULL;
1350 
1351  /* Increase the count */
1352  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1353  {
1354  /* Someone was waiting for it, signal the waiter */
1355  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1356  }
1357 }
1358 
1360 VOID
1362 {
1363  KIRQL OldIrql;
1365 
1366  /* Raise IRQL to APC */
1368 
1369  /* Decrease the count */
1370  if (InterlockedDecrement(&FastMutex->Count))
1371  {
1372  /* Someone is still holding it, use slow path */
1373  KiAcquireFastMutex(FastMutex);
1374  }
1375 
1376  /* Set the owner and IRQL */
1377  FastMutex->Owner = KeGetCurrentThread();
1378  FastMutex->OldIrql = OldIrql;
1379 }
1380 
1382 VOID
1384 {
1385  KIRQL OldIrql;
1387 
1388  /* Erase the owner */
1389  FastMutex->Owner = NULL;
1390  OldIrql = (KIRQL)FastMutex->OldIrql;
1391 
1392  /* Increase the count */
1393  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1394  {
1395  /* Someone was waiting for it, signal the waiter */
1396  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1397  }
1398 
1399  /* Lower IRQL back */
1401 }
1402 
1404 BOOLEAN
1406 {
1407  KIRQL OldIrql;
1409 
1410  /* Raise to APC_LEVEL */
1412 
1413  /* Check if we can quickly acquire it */
1414  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1415  {
1416  /* We have, set us as owners */
1417  FastMutex->Owner = KeGetCurrentThread();
1418  FastMutex->OldIrql = OldIrql;
1419  return TRUE;
1420  }
1421  else
1422  {
1423  /* Acquire attempt failed */
1425  YieldProcessor();
1426  return FALSE;
1427  }
1428 }
1429 
1431 VOID
1433 {
1434  /* Enter the Critical Region */
1436 
1437  /* Acquire the mutex unsafely */
1438  _ExAcquireFastMutexUnsafe(FastMutex);
1439 }
1440 
1442 VOID
1444 {
1445  /* Release the mutex unsafely */
1446  _ExReleaseFastMutexUnsafe(FastMutex);
1447 
1448  /* Leave the critical region */
1450 }
1451 
1452 /* OTHER FUNCTIONS **********************************************************/
1453 
1454 BOOLEAN
1455 NTAPI
1458 );
1459 
1460 NTSTATUS
1462  IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
1463 );
1464 
1465 BOOLEAN
1466 NTAPI
1468  IN BOOLEAN Wait
1469 );
1470 
1471 VOID
1472 NTAPI
1474  VOID
1475 );
1476 
1477 VOID
1478 NTAPI
1480  IN BOOLEAN UpdateInterruptTime,
1481  IN ULONG MaxSepInSeconds
1482 );
1483 
1484 VOID
1485 NTAPI
1487  OUT LUID *LocallyUniqueId
1488 );
1489 
1490 VOID
1491 NTAPI
1493  VOID
1494 );
1495 
1496 INIT_FUNCTION
1497 VOID
1498 NTAPI
1499 HeadlessInit(
1500  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1501 );
1502 
1503 INIT_FUNCTION
1504 VOID
1505 NTAPI
1506 XIPInit(
1507  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1508 );
1509 
1510 #define InterlockedDecrementUL(Addend) \
1511  (ULONG)InterlockedDecrement((PLONG)(Addend))
1512 
1513 #define InterlockedIncrementUL(Addend) \
1514  (ULONG)InterlockedIncrement((PLONG)(Addend))
1515 
1516 #define InterlockedExchangeUL(Target, Value) \
1517  (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1518 
1519 #define InterlockedExchangeAddUL(Addend, Value) \
1520  (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
1521 
1522 #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
1523  (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
1524 
1525 #define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \
1526  (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))
1527 
1528 #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
1529  (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
ULONG_PTR Value
Definition: extypes.h:465
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:23
#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:112
FORCEINLINE VOID _ExReleaseRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:847
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
FORCEINLINE BOOLEAN ExTryToAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1056
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeCallbacks(VOID)
Definition: callback.c:256
#define ExpSetRundown(x, y)
Definition: ex.h:160
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1022
VOID FASTCALL ExfRundownCompleted(OUT PEX_RUNDOWN_REF RunRef)
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:566
VOID NTAPI ExDestroyHandleTable(IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
Definition: handle.c:927
#define IN
Definition: typedefs.h:38
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:51
FORCEINLINE VOID _ExInitializePushLock(OUT PEX_PUSH_LOCK PushLock)
Definition: ex.h:994
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
INIT_FUNCTION VOID NTAPI ExpInitLookasideLists(VOID)
Definition: lookas.c:93
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:582
#define TRUE
Definition: types.h:120
LONG Period
Definition: ex.h:109
FORCEINLINE BOOLEAN ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:632
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define HANDLE_LOW_BITS
Definition: ex.h:74
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
Type
Definition: Type.h:6
PHANDLE_TABLE NTAPI ExCreateHandleTable(IN PEPROCESS Process OPTIONAL)
Definition: handle.c:765
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
ULONG_PTR RefCnt
Definition: extypes.h:423
INIT_FUNCTION VOID NTAPI ExpResourceInitialization(VOID)
Definition: resource.c:169
VOID NTAPI ExDereferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:109
CHAR NtBuildLab[]
Definition: init.c:61
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:83
#define ANYSIZE_ARRAY
Definition: typedefs.h:45
PVOID ExpDefaultErrorPort
Definition: harderr.c:20
INIT_FUNCTION VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:63
ULONG NtMajorVersion
Definition: init.c:42
INIT_FUNCTION VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
INIT_FUNCTION VOID NTAPI ExpInitializePushLocks(VOID)
Definition: pushlock.c:45
uint16_t * PWSTR
Definition: typedefs.h:54
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:83
UNICODE_STRING CmCSDVersionString
Definition: init.c:59
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:890
char CHAR
Definition: xmlstorage.h:175
union _EXHANDLE EXHANDLE
BOOLEAN WakeTimer
Definition: ex.h:111
PVOID Ptr
Definition: extypes.h:466
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING NtSystemRoot
Definition: init.c:72
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:29
INIT_FUNCTION VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1164
FORCEINLINE VOID _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:944
#define KERNEL_FLAG_BITS
Definition: ex.h:79
_Out_ PPROCESSOR_NUMBER ProcNumber
Definition: kefuncs.h:53
#define InterlockedCompareExchange
Definition: interlocked.h:104
PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:93
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
INIT_FUNCTION VOID NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:918
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:110
BOOLEAN NTAPI ExCompareExchangeCallBack(IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK NewBlock, IN PEX_CALLBACK_ROUTINE_BLOCK OldBlock)
Definition: callback.c:170
INIT_FUNCTION BOOLEAN NTAPI ExpUuidInitialization(VOID)
Definition: uuid.c:58
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
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:82
ULONG ExpAltTimeZoneBias
Definition: time.c:24
INIT_FUNCTION BOOLEAN NTAPI ExLuidInitialization(VOID)
Definition: uuid.c:330
LIST_ENTRY ActiveTimerListEntry
Definition: ex.h:107
FORCEINLINE VOID _ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1383
PWSTR Name
Definition: ex.h:118
#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:124
ULONG_PTR Index
Definition: ex.h:86
BOOLEAN(NTAPI * PEX_CHANGE_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)
Definition: ex.h:435
VOID FASTCALL ExWaitForUnblockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID WaitBlock)
Definition: pushlock.c:395
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeEventPairImplementation(VOID)
Definition: evtpair.c:37
VOID NTAPI ExInit2(VOID)
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONG_PTR TagBits
Definition: ex.h:85
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
ULONG ExpInitializationPhase
Definition: init.c:65
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:427
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:603
ERESOURCE * PERESOURCE
Definition: env_spec_w32.h:595
ULONG_PTR * PSIZE_T
Definition: typedefs.h:78
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:848
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
PVOID Object
Definition: extypes.h:422
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeKeyedEventImplementation(VOID)
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:26
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1238
Definition: extypes.h:595
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
Definition: work.c:631
unsigned char BOOLEAN
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeProfileImplementation(VOID)
Definition: profile.c:68
VOID FASTCALL ExfUnblockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID CurrentWaitBlock)
KSPIN_LOCK Lock
Definition: ex.h:108
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE EX_FAST_REF ExSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:706
ULONG_PTR Waiting
Definition: extypes.h:460
#define FORCEINLINE
Definition: ntbasedef.h:221
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:1432
VOID FASTCALL ExfInitializeRundownProtection(OUT PEX_RUNDOWN_REF RunRef)
VOID NTAPI ExpDebuggerWorker(IN PVOID Context)
Definition: dbgctrl.c:55
Definition: bufpool.h:45
_WINKD_WORKER_STATE
Definition: ex.h:54
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeEventImplementation(VOID)
Definition: event.c:43
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer(IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
Definition: handle.c:1010
_In_ PVOID Argument2
Definition: classpnp.h:680
ULONG ExpOemCodePageDataOffset
Definition: init.c:82
ULONG_PTR Waking
Definition: extypes.h:461
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:22
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:21
ULONG_PTR MidIndex
Definition: ex.h:93
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
INIT_FUNCTION VOID NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:521
FAST_MUTEX
Definition: extypes.h:17
VOID NTAPI ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
Definition: uuid.c:340
_In_ HANDLE Handle
Definition: extypes.h:390
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeSemaphoreImplementation(VOID)
Definition: sem.c:43
PVOID ExpNlsSectionPointer
Definition: init.c:86
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
INIT_FUNCTION BOOLEAN NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:263
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define HANDLE_HIGH_BITS
Definition: ex.h:75
LIST_ENTRY List
Definition: psmgr.c:57
if(!(yy_init))
Definition: macro.lex.yy.c:714
FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1443
__wchar_t WCHAR
Definition: xmlstorage.h:180
VOID NTAPI Phase1Initialization(IN PVOID Context)
Definition: init.c:2016
INT POOL_TYPE
Definition: typedefs.h:76
uint64_t ULONGLONG
Definition: typedefs.h:65
FORCEINLINE BOOLEAN _ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:806
#define ExpChangeRundown(x, y, z)
Definition: ex.h:158
HANDLE GenericHandleOverlay
Definition: ex.h:97
ULONG_PTR Parameters[MAXIMUM_HARDERROR_PARAMETERS]
Definition: ex.h:123
VOID FASTCALL ExfReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:810
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:27
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:574
VOID FASTCALL ExfReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:956
POBJECT_TYPE _ExSemaphoreObjectType
ULONG NtMinorVersion
Definition: init.c:43
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:102
static IUnknown Object
Definition: main.c:512
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:24
KAPC TimerApc
Definition: ex.h:105
PCALLBACK_OBJECT PowerStateCallback
Definition: callback.c:29
ULONG ExCriticalWorkerThreads
Definition: work.c:38
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: ex.h:81
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeTimerImplementation(VOID)
Definition: timer.c:223
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:803
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:671
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
KDPC TimerDpc
Definition: ex.h:106
LIST_ENTRY ExpFirmwareTableProviderListHead
Definition: sysinfo.c:31
Definition: ketypes.h:535
Definition: typedefs.h:117
INIT_FUNCTION 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:35
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:733
ULONG_PTR Shared
Definition: extypes.h:463
RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
Definition: time.c:21
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
VOID NTAPI ExShutdownSystem(VOID)
Definition: shutdown.c:21
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1282
ULONG CmNtCSDVersion
Definition: init.c:56
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1091
Definition: compat.h:484
FORCEINLINE PEX_RUNDOWN_REF ExGetRunRefForGivenProcessor(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, IN ULONG ProcNumber)
Definition: ex.h:779
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:1361
ULONG AsULONG
Definition: ex.h:99
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:26
unsigned short USHORT
Definition: pedump.c:61
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:25
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:539
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
struct _HARDERROR_USER_PARAMETERS HARDERROR_USER_PARAMETERS
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive(IN PEX_PUSH_LOCK PushLock)
Definition: ex.h:1125
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
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeMutantImplementation(VOID)
Definition: mutant.c:56
PEPROCESS ExpDefaultErrorPortProcess
Definition: harderr.c:21
ULONG ExDelayedWorkerThreads
Definition: work.c:39
HANDLE NTAPI ExCreateHandle(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:791
ULONG_PTR KernelFlag2
Definition: ex.h:95
FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1405
ULONG CmNtCSDReleaseType
Definition: init.c:57
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
NTSTATUS ExpSetTimeZoneInformation(IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
INIT_FUNCTION VOID NTAPI XIPInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: xipdisp.c:55
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:696
#define BOOLEAN
Definition: pedump.c:73
#define OUT
Definition: typedefs.h:39
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1199
PCALLBACK_OBJECT * CallbackObject
Definition: ex.h:117
struct _HARDERROR_USER_PARAMETERS * PHARDERROR_USER_PARAMETERS
ULONG_PTR HighIndex
Definition: ex.h:94
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:28
KTIMER KeTimer
Definition: ex.h:104
struct tagContext Context
Definition: acpixf.h:1024
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:1316
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:128
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:29
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:174
ULONG_PTR LowIndex
Definition: ex.h:92
ULONG_PTR Value
Definition: ex.h:98
#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:1340
#define KeGetCurrentThread
Definition: hal.h:44
#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:159
signed int * PLONG
Definition: retypes.h:5
LPFNPSPCALLBACK Callback
Definition: desk.c:111
#define HANDLE_INDEX_BITS
Definition: ex.h:78
UNICODE_STRING CmVersionString
Definition: init.c:58
#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:91
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:22
#define EX_RUNDOWN_ACTIVE
ULONG_PTR KernelFlag
Definition: ex.h:87
ULONG NtBuildNumber
Definition: init.c:47
BOOLEAN(NTAPI * PEX_SWEEP_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, HANDLE Handle, PVOID Context)
Definition: ex.h:420
WORK_QUEUE_ITEM ExpDebuggerWorkItem
Definition: dbgctrl.c:21
FORCEINLINE VOID _ExWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:914
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
#define HANDLE_TAG_BITS
Definition: ex.h:77
struct _UUID_CACHED_VALUES_STRUCT * PUUID_CACHED_VALUES_STRUCT
BOOLEAN NTAPI ExAcquireTimeRefreshLock(IN BOOLEAN Wait)
Definition: time.c:51
ULONG CmNtSpBuildNumber
Definition: init.c:55
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
IN BOOLEAN Wait
Definition: fatprocs.h:1529
VOID FASTCALL ExfTryToWakePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1165
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68