ReactOS  0.4.11-dev-433-g473ca91
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 
170 /* INITIALIZATION FUNCTIONS *************************************************/
171 
172 BOOLEAN
173 NTAPI
175 
176 VOID
177 NTAPI
178 ExInit2(VOID);
179 
180 VOID
181 NTAPI
184 );
185 
186 VOID
187 NTAPI
189 
190 BOOLEAN
191 NTAPI
193  IN PLARGE_INTEGER SystemBootTime
194 );
195 
196 VOID
197 NTAPI
199 
200 VOID
201 NTAPI
202 ExSwapinWorkerThreads(IN BOOLEAN AllowSwap);
203 
204 VOID
205 NTAPI
207 
208 VOID
209 NTAPI
212  IN POOL_TYPE Type,
213  IN ULONG Size,
214  IN ULONG Tag,
215  IN USHORT MaximumDepth,
216  IN PLIST_ENTRY ListHead
217 );
218 
219 BOOLEAN
220 NTAPI
222 
223 VOID
224 NTAPI
226 
227 VOID
228 NTAPI
230  IN ULONG Cpu,
231  IN PLOADER_PARAMETER_BLOCK LoaderBlock
232 );
233 
234 VOID
235 NTAPI
237 
238 BOOLEAN
239 NTAPI
241 
242 BOOLEAN
243 NTAPI
245 
246 BOOLEAN
247 NTAPI
249 
250 BOOLEAN
251 NTAPI
253 
254 BOOLEAN
255 NTAPI
257 
258 BOOLEAN
259 NTAPI
261 
262 BOOLEAN
263 NTAPI
265 
266 VOID
267 NTAPI
269 
270 VOID
271 NTAPI
273 
274 /* Callback Functions ********************************************************/
275 
276 VOID
277 NTAPI
280 );
281 
283 NTAPI
287 );
288 
289 VOID
290 NTAPI
292  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
293 );
294 
295 BOOLEAN
296 NTAPI
298  IN OUT PEX_CALLBACK CallBack,
301 );
302 
304 NTAPI
306  IN OUT PEX_CALLBACK CallBack
307 );
308 
309 VOID
310 NTAPI
312  IN OUT PEX_CALLBACK CallBack,
313  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
314 );
315 
317 NTAPI
319  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
320 );
321 
322 PVOID
323 NTAPI
325  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
326 );
327 
328 VOID
329 NTAPI
331  IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock
332 );
333 
334 /* Rundown Functions ********************************************************/
335 
336 VOID
337 FASTCALL
339  OUT PEX_RUNDOWN_REF RunRef
340 );
341 
342 VOID
343 FASTCALL
345  OUT PEX_RUNDOWN_REF RunRef
346 );
347 
348 BOOLEAN
349 FASTCALL
351  IN OUT PEX_RUNDOWN_REF RunRef
352 );
353 
354 BOOLEAN
355 FASTCALL
357  IN OUT PEX_RUNDOWN_REF RunRef,
358  IN ULONG Count
359 );
360 
361 VOID
362 FASTCALL
364  IN OUT PEX_RUNDOWN_REF RunRef
365 );
366 
367 VOID
368 FASTCALL
370  IN OUT PEX_RUNDOWN_REF RunRef,
371  IN ULONG Count
372 );
373 
374 VOID
375 FASTCALL
377  OUT PEX_RUNDOWN_REF RunRef
378 );
379 
380 VOID
381 FASTCALL
383  IN OUT PEX_RUNDOWN_REF RunRef
384 );
385 
386 /* HANDLE TABLE FUNCTIONS ***************************************************/
387 
388 typedef BOOLEAN
390  PHANDLE_TABLE_ENTRY HandleTableEntry,
391  HANDLE Handle,
392  PVOID Context
393 );
394 
395 typedef BOOLEAN
399  IN PHANDLE_TABLE_ENTRY HandleTableEntry,
400  IN PHANDLE_TABLE_ENTRY NewEntry
401 );
402 
403 typedef BOOLEAN
405  PHANDLE_TABLE_ENTRY HandleTableEntry,
407 );
408 
409 VOID
410 NTAPI
412  VOID
413 );
414 
416 NTAPI
418  IN PEPROCESS Process OPTIONAL
419 );
420 
421 VOID
422 NTAPI
424  IN PHANDLE_TABLE HandleTable,
425  IN PHANDLE_TABLE_ENTRY HandleTableEntry
426 );
427 
428 HANDLE
429 NTAPI
431  IN PHANDLE_TABLE HandleTable,
432  IN PHANDLE_TABLE_ENTRY HandleTableEntry
433 );
434 
435 VOID
436 NTAPI
438  IN PHANDLE_TABLE HandleTable,
439  IN PVOID DestroyHandleProcedure OPTIONAL
440 );
441 
442 BOOLEAN
443 NTAPI
445  IN PHANDLE_TABLE HandleTable,
446  IN HANDLE Handle,
447  IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL
448 );
449 
451 NTAPI
453  IN PHANDLE_TABLE HandleTable,
454  IN HANDLE Handle
455 );
456 
458 NTAPI
460  IN PEPROCESS Process,
461  IN PHANDLE_TABLE HandleTable,
462  IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure,
463  IN ULONG_PTR Mask
464 );
465 
466 BOOLEAN
467 NTAPI
469  IN PHANDLE_TABLE HandleTable,
470  IN HANDLE Handle,
471  IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine,
473 );
474 
475 VOID
476 NTAPI
478  IN PHANDLE_TABLE HandleTable,
479  IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure,
481 );
482 
484 NTAPI
486  IN PHANDLE_TABLE HandleTable,
487  IN EXHANDLE Handle
488 );
489 
490 BOOLEAN
491 NTAPI
493  IN PHANDLE_TABLE HandleTable,
494  IN PHANDLE_TABLE_ENTRY HandleTableEntry
495 );
496 
497 /* PSEH EXCEPTION HANDLING **************************************************/
498 
499 LONG
500 NTAPI
502 
503 /* CALLBACKS *****************************************************************/
504 
506 VOID
508  IN PVOID Context,
511 {
512  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
514 
515  /* Reference the block */
516  CallbackBlock = ExReferenceCallBackBlock(Callback);
517  if (CallbackBlock)
518  {
519  /* Get the function */
520  Function = ExGetCallBackBlockRoutine(CallbackBlock);
521 
522  /* Do the callback */
523  Function(Context, Argument1, Argument2);
524 
525  /* Now dereference it */
526  ExDereferenceCallBackBlock(Callback, CallbackBlock);
527  }
528 }
529 
530 /* FAST REFS ******************************************************************/
531 
533 PVOID
535 {
536  /* Return the unbiased pointer */
537  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
538 }
539 
541 ULONG
543 {
544  /* Return the reference count */
545  return (ULONG)FastRef.RefCnt;
546 }
547 
549 VOID
552 {
553  /* Sanity check */
554  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
555 
556  /* Check if an object is being set */
557  if (!Object)
558  {
559  /* Clear the field */
560  FastRef->Object = NULL;
561  }
562  else
563  {
564  /* Otherwise, we assume the object was referenced and is ready */
565  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
566  }
567 }
568 
572 {
573  EX_FAST_REF OldValue, NewValue;
574 
575  /* Start reference loop */
576  for (;;)
577  {
578  /* Get the current reference count */
579  OldValue = *FastRef;
580  if (OldValue.RefCnt)
581  {
582  /* Increase the reference count */
583  NewValue.Value = OldValue.Value - 1;
584  NewValue.Object = ExpChangePushlock(&FastRef->Object,
585  NewValue.Object,
586  OldValue.Object);
587  if (NewValue.Object != OldValue.Object) continue;
588  }
589 
590  /* We are done */
591  break;
592  }
593 
594  /* Return the old value */
595  return OldValue;
596 }
597 
599 BOOLEAN
601  IN PVOID Object)
602 {
603  EX_FAST_REF OldValue, NewValue;
604 
605  /* Sanity checks */
606  ASSERT(!(((ULONG_PTR)Object) & MAX_FAST_REFS));
607 
608  /* Start update loop */
609  for (;;)
610  {
611  /* Get the current reference count */
612  OldValue = *FastRef;
613 
614  /* Check if the current count is too high or if the pointer changed */
615  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
616  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
617  {
618  /* Fail */
619  return FALSE;
620  }
621 
622  /* Update the reference count */
623  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
624  NewValue.Object = ExpChangePushlock(&FastRef->Object,
625  NewValue.Object,
626  OldValue.Object);
627  if (NewValue.Object != OldValue.Object) continue;
628 
629  /* We are done */
630  break;
631  }
632 
633  /* Return success */
634  return TRUE;
635 }
636 
638 BOOLEAN
640  IN PVOID Object)
641 {
642  EX_FAST_REF OldValue, NewValue;
643 
644  /* Sanity checks */
645  ASSERT(Object != NULL);
646  ASSERT(!(((ULONG_PTR)Object) & MAX_FAST_REFS));
647 
648  /* Start reference loop */
649  for (;;)
650  {
651  /* Get the current reference count */
652  OldValue = *FastRef;
653 
654  /* Check if we're full if if the pointer changed */
655  if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
656 
657  /* Decrease the reference count */
658  NewValue.Value = OldValue.Value + 1;
659  NewValue.Object = ExpChangePushlock(&FastRef->Object,
660  NewValue.Object,
661  OldValue.Object);
662  if (NewValue.Object != OldValue.Object) continue;
663 
664  /* We are done */
665  break;
666  }
667 
668  /* Return success */
669  return TRUE;
670 }
671 
675  IN PVOID Object)
676 {
677  EX_FAST_REF NewValue, OldValue;
678 
679  /* Sanity check */
680  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
681 
682  /* Check if an object is being set */
683  if (!Object)
684  {
685  /* Clear the field */
686  NewValue.Object = NULL;
687  }
688  else
689  {
690  /* Otherwise, we assume the object was referenced and is ready */
691  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
692  }
693 
694  /* Update the object */
695  OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
696  return OldValue;
697 }
698 
702  IN PVOID Object,
703  IN PVOID OldObject)
704 {
705  EX_FAST_REF OldValue, NewValue;
706 
707  /* Sanity check and start swap loop */
708  ASSERT(!(((ULONG_PTR)Object) & MAX_FAST_REFS));
709  for (;;)
710  {
711  /* Get the current value */
712  OldValue = *FastRef;
713 
714  /* Make sure there's enough references to swap */
715  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
716 
717  /* Check if we have an object to swap */
718  if (Object)
719  {
720  /* Set up the value with maximum fast references */
721  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
722  }
723  else
724  {
725  /* Write the object address itself (which is empty) */
726  NewValue.Value = (ULONG_PTR)Object;
727  }
728 
729  /* Do the actual compare exchange */
730  NewValue.Object = ExpChangePushlock(&FastRef->Object,
731  NewValue.Object,
732  OldValue.Object);
733  if (NewValue.Object != OldValue.Object) continue;
734 
735  /* All done */
736  break;
737  }
738 
739  /* Return the old value */
740  return OldValue;
741 }
742 
743 /* RUNDOWN *******************************************************************/
744 
745 /*++
746  * @name ExfAcquireRundownProtection
747  * INTERNAL MACRO
748  *
749  * The ExfAcquireRundownProtection routine acquires rundown protection for
750  * the specified descriptor.
751  *
752  * @param RunRef
753  * Pointer to a rundown reference descriptor.
754  *
755  * @return TRUE if access to the protected structure was granted, FALSE otherwise.
756  *
757  * @remarks This is the internal macro for system use only.In case the rundown
758  * was active, then the slow-path will be called through the exported
759  * function.
760  *
761  *--*/
763 BOOLEAN
765 {
766  ULONG_PTR Value, NewValue;
767 
768  /* Get the current value and mask the active bit */
769  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
770 
771  /* Add a reference */
772  NewValue = Value + EX_RUNDOWN_COUNT_INC;
773 
774  /* Change the value */
775  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
776  if (NewValue != Value)
777  {
778  /* Rundown was active, use long path */
779  return ExfAcquireRundownProtection(RunRef);
780  }
781 
782  /* Success */
783  return TRUE;
784 }
785 
786 /*++
787  * @name ExReleaseRundownProtection
788  * INTERNAL MACRO
789  *
790  * The ExReleaseRundownProtection routine releases rundown protection for
791  * the specified descriptor.
792  *
793  * @param RunRef
794  * Pointer to a rundown reference descriptor.
795  *
796  * @return TRUE if access to the protected structure was granted, FALSE otherwise.
797  *
798  * @remarks This is the internal macro for system use only.In case the rundown
799  * was active, then the slow-path will be called through the exported
800  * function.
801  *
802  *--*/
804 VOID
806 {
807  ULONG_PTR Value, NewValue;
808 
809  /* Get the current value and mask the active bit */
810  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
811 
812  /* Remove a reference */
813  NewValue = Value - EX_RUNDOWN_COUNT_INC;
814 
815  /* Change the value */
816  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
817 
818  /* Check if the rundown was active */
819  if (NewValue != Value)
820  {
821  /* Rundown was active, use long path */
823  }
824  else
825  {
826  /* Sanity check */
827  ASSERT((Value >= EX_RUNDOWN_COUNT_INC) || (KeNumberProcessors > 1));
828  }
829 }
830 
831 /*++
832  * @name ExInitializeRundownProtection
833  * INTERNAL MACRO
834  *
835  * The ExInitializeRundownProtection routine initializes a rundown
836  * protection descriptor.
837  *
838  * @param RunRef
839  * Pointer to a rundown reference descriptor.
840  *
841  * @return None.
842  *
843  * @remarks This is the internal macro for system use only.
844  *
845  *--*/
847 VOID
849 {
850  /* Set the count to zero */
851  RunRef->Count = 0;
852 }
853 
854 /*++
855  * @name ExWaitForRundownProtectionRelease
856  * INTERNAL MACRO
857  *
858  * The ExWaitForRundownProtectionRelease routine waits until the specified
859  * rundown descriptor has been released.
860  *
861  * @param RunRef
862  * Pointer to a rundown reference descriptor.
863  *
864  * @return None.
865  *
866  * @remarks This is the internal macro for system use only. If a wait is actually
867  * necessary, then the slow path is taken through the exported function.
868  *
869  *--*/
871 VOID
873 {
875 
876  /* Set the active bit */
877  Value = ExpChangeRundown(RunRef, EX_RUNDOWN_ACTIVE, 0);
878  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
879  {
880  /* If the the rundown wasn't already active, then take the long path */
882  }
883 }
884 
885 /*++
886  * @name ExRundownCompleted
887  * INTERNAL MACRO
888  *
889  * The ExRundownCompleted routine completes the rundown of the specified
890  * descriptor by setting the active bit.
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  /* Sanity check */
905  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
906 
907  /* Mark the counter as active */
909 }
910 
911 /* PUSHLOCKS *****************************************************************/
912 
913 /* FIXME: VERIFY THESE! */
914 
915 VOID
916 FASTCALL
918  IN PEX_PUSH_LOCK PushLock,
919  IN PVOID WaitBlock
920 );
921 
922 VOID
923 FASTCALL
925  IN PEX_PUSH_LOCK PushLock,
926  IN PVOID CurrentWaitBlock
927 );
928 
929 VOID
930 FASTCALL
932  IN PEX_PUSH_LOCK PushLock,
933  IN PVOID WaitBlock
934 );
935 
936 /*++
937  * @name _ExInitializePushLock
938  * INTERNAL MACRO
939  *
940  * The _ExInitializePushLock macro initializes a PushLock.
941  *
942  * @params PushLock
943  * Pointer to the pushlock which is to be initialized.
944  *
945  * @return None.
946  *
947  * @remarks None.
948  *
949  *--*/
951 VOID
953 {
954  /* Set the value to 0 */
955  PushLock->Ptr = 0;
956 }
957 #define ExInitializePushLock _ExInitializePushLock
958 
959 /*++
960  * @name ExAcquirePushLockExclusive
961  * INTERNAL MACRO
962  *
963  * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
964  *
965  * @params PushLock
966  * Pointer to the pushlock which is to be acquired.
967  *
968  * @return None.
969  *
970  * @remarks The function attempts the quickest route to acquire the lock, which is
971  * to simply set the lock bit.
972  * However, if the pushlock is already shared, the slower path is taken.
973  *
974  * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
975  * This macro should usually be paired up with KeAcquireCriticalRegion.
976  *
977  *--*/
979 VOID
981 {
982  /* Try acquiring the lock */
984  {
985  /* Someone changed it, use the slow path */
986  ExfAcquirePushLockExclusive(PushLock);
987  }
988 
989  /* Sanity check */
990  ASSERT(PushLock->Locked);
991 }
992 
993 /*++
994 * @name ExTryToAcquirePushLockExclusive
995 * INTERNAL MACRO
996 *
997 * The ExAcquirePushLockExclusive macro exclusively acquires a PushLock.
998 *
999 * @params PushLock
1000 * Pointer to the pushlock which is to be acquired.
1001 *
1002 * @return None.
1003 *
1004 * @remarks The function attempts the quickest route to acquire the lock, which is
1005 * to simply set the lock bit.
1006 * However, if the pushlock is already shared, the slower path is taken.
1007 *
1008 * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1009 * This macro should usually be paired up with KeAcquireCriticalRegion.
1010 *
1011 *--*/
1013 BOOLEAN
1015 {
1016  /* Try acquiring the lock */
1018  {
1019  /* Can't acquire */
1020  return FALSE;
1021  }
1022 
1023  /* Got acquired */
1024  ASSERT (PushLock->Locked);
1025  return TRUE;
1026 }
1027 
1028 /*++
1029  * @name ExAcquirePushLockShared
1030  * INTERNAL MACRO
1031  *
1032  * The ExAcquirePushLockShared macro acquires a shared PushLock.
1033  *
1034  * @params PushLock
1035  * Pointer to the pushlock which is to be acquired.
1036  *
1037  * @return None.
1038  *
1039  * @remarks The function attempts the quickest route to acquire the lock, which is
1040  * to simply set the lock bit and set the share count to one.
1041  * However, if the pushlock is already shared, the slower path is taken.
1042  *
1043  * Callers of ExAcquirePushLockShared must be running at IRQL <= APC_LEVEL.
1044  * This macro should usually be paired up with KeAcquireCriticalRegion.
1045  *
1046  *--*/
1048 VOID
1050 {
1051  EX_PUSH_LOCK NewValue;
1052 
1053  /* Try acquiring the lock */
1055  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1056  {
1057  /* Someone changed it, use the slow path */
1058  ExfAcquirePushLockShared(PushLock);
1059  }
1060 
1061  /* Sanity checks */
1062  ASSERT(PushLock->Locked);
1063 }
1064 
1065 /*++
1066  * @name ExConvertPushLockSharedToExclusive
1067  * INTERNAL MACRO
1068  *
1069  * The ExConvertPushLockSharedToExclusive macro converts an exclusive
1070  * pushlock to a shared pushlock.
1071  *
1072  * @params PushLock
1073  * Pointer to the pushlock which is to be converted.
1074  *
1075  * @return FALSE if conversion failed, TRUE otherwise.
1076  *
1077  * @remarks The function attempts the quickest route to convert the lock, which is
1078  * to simply set the lock bit and remove any other bits.
1079  *
1080  *--*/
1082 BOOLEAN
1084 {
1085  EX_PUSH_LOCK OldValue;
1086 
1087  /* Set the expected old value */
1089 
1090  /* Try converting the lock */
1091  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1092  OldValue.Ptr)
1093  {
1094  /* Conversion failed */
1095  return FALSE;
1096  }
1097 
1098  /* Sanity check */
1099  ASSERT(PushLock->Locked);
1100  return TRUE;
1101 }
1102 
1103 /*++
1104  * @name ExWaitOnPushLock
1105  * INTERNAL MACRO
1106  *
1107  * The ExWaitOnPushLock macro acquires and instantly releases a pushlock.
1108  *
1109  * @params PushLock
1110  * Pointer to a pushlock.
1111  *
1112  * @return None.
1113  *
1114  * @remarks The function attempts to get any exclusive waiters out of their slow
1115  * path by forcing an instant acquire/release operation.
1116  *
1117  * Callers of ExWaitOnPushLock must be running at IRQL <= APC_LEVEL.
1118  *
1119  *--*/
1121 VOID
1123 {
1124  /* Check if we're locked */
1125  if (PushLock->Locked)
1126  {
1127  /* Acquire the lock */
1128  ExfAcquirePushLockExclusive(PushLock);
1129  ASSERT(PushLock->Locked);
1130 
1131  /* Release it */
1132  ExfReleasePushLockExclusive(PushLock);
1133  }
1134 }
1135 
1136 /*++
1137  * @name ExReleasePushLockShared
1138  * INTERNAL MACRO
1139  *
1140  * The ExReleasePushLockShared macro releases a previously acquired PushLock.
1141  *
1142  * @params PushLock
1143  * Pointer to a previously acquired pushlock.
1144  *
1145  * @return None.
1146  *
1147  * @remarks The function attempts the quickest route to release the lock, which is
1148  * to simply decrease the share count and remove the lock bit.
1149  * However, if the pushlock is being waited on then the long path is taken.
1150  *
1151  * Callers of ExReleasePushLockShared must be running at IRQL <= APC_LEVEL.
1152  * This macro should usually be paired up with KeLeaveCriticalRegion.
1153  *
1154  *--*/
1156 VOID
1158 {
1159  EX_PUSH_LOCK OldValue;
1160 
1161  /* Sanity checks */
1162  ASSERT(PushLock->Locked);
1163 
1164  /* Try to clear the pushlock */
1166  if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1167  {
1168  /* There are still other people waiting on it */
1169  ExfReleasePushLockShared(PushLock);
1170  }
1171 }
1172 
1173 /*++
1174  * @name ExReleasePushLockExclusive
1175  * INTERNAL MACRO
1176  *
1177  * The ExReleasePushLockExclusive macro releases a previously
1178  * exclusively acquired PushLock.
1179  *
1180  * @params PushLock
1181  * Pointer to a previously acquired pushlock.
1182  *
1183  * @return None.
1184  *
1185  * @remarks The function attempts the quickest route to release the lock, which is
1186  * to simply clear the locked bit.
1187  * However, if the pushlock is being waited on, the slow path is taken
1188  * in an attempt to wake up the lock.
1189  *
1190  * Callers of ExReleasePushLockExclusive must be running at IRQL <= APC_LEVEL.
1191  * This macro should usually be paired up with KeLeaveCriticalRegion.
1192  *
1193  *--*/
1195 VOID
1197 {
1198  EX_PUSH_LOCK OldValue;
1199 
1200  /* Sanity checks */
1201  ASSERT(PushLock->Locked);
1202 
1203  /* Unlock the pushlock */
1204  OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1206 
1207  /* Sanity checks */
1208  ASSERT(OldValue.Locked);
1209  ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1210 
1211  /* Check if anyone is waiting on it and it's not already waking*/
1212  if ((OldValue.Waiting) && !(OldValue.Waking))
1213  {
1214  /* Wake it up */
1215  ExfTryToWakePushLock(PushLock);
1216  }
1217 }
1218 
1219 /*++
1220  * @name ExReleasePushLock
1221  * INTERNAL MACRO
1222  *
1223  * The ExReleasePushLock macro releases a previously acquired PushLock.
1224  *
1225  * @params PushLock
1226  * Pointer to a previously acquired pushlock.
1227  *
1228  * @return None.
1229  *
1230  * @remarks The function attempts the quickest route to release the lock, which is
1231  * to simply clear all the fields and decrease the share count if required.
1232  * However, if the pushlock is being waited on then the long path is taken.
1233  *
1234  * Callers of ExReleasePushLock must be running at IRQL <= APC_LEVEL.
1235  * This macro should usually be paired up with KeLeaveCriticalRegion.
1236  *
1237  *--*/
1239 VOID
1241 {
1242  EX_PUSH_LOCK OldValue = *PushLock;
1243  EX_PUSH_LOCK NewValue;
1244 
1245  /* Sanity checks */
1246  ASSERT(OldValue.Locked);
1247 
1248  /* Check if the pushlock is shared */
1249  if (OldValue.Shared > 1)
1250  {
1251  /* Decrease the share count */
1252  NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1253  }
1254  else
1255  {
1256  /* Clear the pushlock entirely */
1257  NewValue.Value = 0;
1258  }
1259 
1260  /* Check if nobody is waiting on us and try clearing the lock here */
1261  if ((OldValue.Waiting) ||
1262  (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1263  OldValue.Ptr))
1264  {
1265  /* We have waiters, use the long path */
1266  ExfReleasePushLock(PushLock);
1267  }
1268 }
1269 
1270 /* FAST MUTEX INLINES *********************************************************/
1271 
1273 VOID
1275 {
1277 
1278  /* Sanity check */
1280  (Thread->CombinedApcDisable != 0) ||
1281  (Thread->Teb == NULL) ||
1282  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1283  ASSERT(FastMutex->Owner != Thread);
1284 
1285  /* Decrease the count */
1286  if (InterlockedDecrement(&FastMutex->Count))
1287  {
1288  /* Someone is still holding it, use slow path */
1289  KiAcquireFastMutex(FastMutex);
1290  }
1291 
1292  /* Set the owner */
1293  FastMutex->Owner = Thread;
1294 }
1295 
1297 VOID
1299 {
1301  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1302  (KeGetCurrentThread()->Teb == NULL) ||
1304  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1305 
1306  /* Erase the owner */
1307  FastMutex->Owner = NULL;
1308 
1309  /* Increase the count */
1310  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1311  {
1312  /* Someone was waiting for it, signal the waiter */
1313  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1314  }
1315 }
1316 
1318 VOID
1320 {
1321  KIRQL OldIrql;
1323 
1324  /* Raise IRQL to APC */
1325  KeRaiseIrql(APC_LEVEL, &OldIrql);
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 and IRQL */
1335  FastMutex->Owner = KeGetCurrentThread();
1336  FastMutex->OldIrql = OldIrql;
1337 }
1338 
1340 VOID
1342 {
1343  KIRQL OldIrql;
1345 
1346  /* Erase the owner */
1347  FastMutex->Owner = NULL;
1348  OldIrql = (KIRQL)FastMutex->OldIrql;
1349 
1350  /* Increase the count */
1351  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1352  {
1353  /* Someone was waiting for it, signal the waiter */
1354  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1355  }
1356 
1357  /* Lower IRQL back */
1358  KeLowerIrql(OldIrql);
1359 }
1360 
1362 BOOLEAN
1364 {
1365  KIRQL OldIrql;
1367 
1368  /* Raise to APC_LEVEL */
1369  KeRaiseIrql(APC_LEVEL, &OldIrql);
1370 
1371  /* Check if we can quickly acquire it */
1372  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1373  {
1374  /* We have, set us as owners */
1375  FastMutex->Owner = KeGetCurrentThread();
1376  FastMutex->OldIrql = OldIrql;
1377  return TRUE;
1378  }
1379  else
1380  {
1381  /* Acquire attempt failed */
1382  KeLowerIrql(OldIrql);
1383  YieldProcessor();
1384  return FALSE;
1385  }
1386 }
1387 
1389 VOID
1391 {
1392  /* Enter the Critical Region */
1394 
1395  /* Acquire the mutex unsafely */
1396  _ExAcquireFastMutexUnsafe(FastMutex);
1397 }
1398 
1400 VOID
1402 {
1403  /* Release the mutex unsafely */
1404  _ExReleaseFastMutexUnsafe(FastMutex);
1405 
1406  /* Leave the critical region */
1408 }
1409 
1410 /* OTHER FUNCTIONS **********************************************************/
1411 
1412 BOOLEAN
1413 NTAPI
1416 );
1417 
1418 NTSTATUS
1420  IN PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
1421 );
1422 
1423 BOOLEAN
1424 NTAPI
1426  IN BOOLEAN Wait
1427 );
1428 
1429 VOID
1430 NTAPI
1432  VOID
1433 );
1434 
1435 VOID
1436 NTAPI
1438  IN BOOLEAN UpdateInterruptTime,
1439  IN ULONG MaxSepInSeconds
1440 );
1441 
1442 VOID
1443 NTAPI
1445  OUT LUID *LocallyUniqueId
1446 );
1447 
1448 VOID
1449 NTAPI
1451  VOID
1452 );
1453 
1454 VOID
1455 NTAPI
1456 HeadlessInit(
1457  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1458 );
1459 
1460 VOID
1461 NTAPI
1462 XIPInit(
1463  IN PLOADER_PARAMETER_BLOCK LoaderBlock
1464 );
1465 
1466 #define InterlockedDecrementUL(Addend) \
1467  (ULONG)InterlockedDecrement((PLONG)(Addend))
1468 
1469 #define InterlockedIncrementUL(Addend) \
1470  (ULONG)InterlockedIncrement((PLONG)(Addend))
1471 
1472 #define InterlockedExchangeUL(Target, Value) \
1473  (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
1474 
1475 #define InterlockedExchangeAddUL(Addend, Value) \
1476  (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
1477 
1478 #define InterlockedCompareExchangeUL(Destination, Exchange, Comperand) \
1479  (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
1480 
1481 #define InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand) \
1482  (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))
1483 
1484 #define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand) \
1485  (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
ULONG_PTR Value
Definition: extypes.h:465
DWORD *typedef PVOID
Definition: winlogon.h:61
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:805
BOOLEAN NTAPI ExpInitializeCallbacks(VOID)
Definition: callback.c:256
FORCEINLINE BOOLEAN ExTryToAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1014
#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:980
VOID FASTCALL ExfRundownCompleted(OUT PEX_RUNDOWN_REF RunRef)
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:534
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:952
#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:550
#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:600
#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
VOID NTAPI ExpInitLookasideLists(VOID)
Definition: lookas.c:93
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:61
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:83
#define ANYSIZE_ARRAY
Definition: typedefs.h:45
ULONG CombinedApcDisable
Definition: ketypes.h:1773
PVOID ExpDefaultErrorPort
Definition: harderr.c:20
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG NtMajorVersion
Definition: init.c:42
VOID NTAPI ExReleaseTimeRefreshLock(VOID)
Definition: time.c:83
IN OUT PIRP IN ULONG IN WMIENABLEDISABLECONTROL Function
Definition: wmilib.h:37
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:848
char CHAR
Definition: xmlstorage.h:175
union _EXHANDLE EXHANDLE
BOOLEAN WakeTimer
Definition: ex.h:111
PVOID Ptr
Definition: extypes.h:466
UNICODE_STRING NtSystemRoot
Definition: init.c:72
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:29
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1122
FORCEINLINE VOID _ExRundownCompleted(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:902
PVOID *typedef PWSTR
Definition: winlogon.h:66
#define KERNEL_FLAG_BITS
Definition: ex.h:79
#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
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
NTSTATUS NTAPI ExGetPoolTagInfo(IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, IN ULONG SystemInformationLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: expool.c:1348
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
LIST_ENTRY ActiveTimerListEntry
Definition: ex.h:107
BOOLEAN NTAPI ExpInitializeEventPairImplementation(VOID)
Definition: evtpair.c:37
FORCEINLINE VOID _ExReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1341
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
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: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
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:571
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
#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:26
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1196
Definition: extypes.h:595
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
Definition: work.c:631
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:674
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:396
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
ULONG_PTR Waiting
Definition: extypes.h:460
#define FORCEINLINE
Definition: ntbasedef.h:221
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:1390
VOID FASTCALL ExfInitializeRundownProtection(OUT PEX_RUNDOWN_REF RunRef)
VOID NTAPI ExpDebuggerWorker(IN PVOID Context)
Definition: dbgctrl.c:55
BOOLEAN NTAPI ExpInitializeMutantImplementation(VOID)
Definition: mutant.c:56
Definition: bufpool.h:45
_WINKD_WORKER_STATE
Definition: ex.h:54
VOID NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:521
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
UINTN Size
Definition: acefiex.h:555
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:21
ULONG_PTR MidIndex
Definition: ex.h:93
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
FAST_MUTEX
Definition: extypes.h:17
VOID NTAPI ExAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
Definition: uuid.c:232
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned char BOOLEAN
PVOID ExpNlsSectionPointer
Definition: init.c:86
#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:75
LONG NTSTATUS
Definition: precomp.h:26
LIST_ENTRY List
Definition: psmgr.c:57
if(!(yy_init))
Definition: macro.lex.yy.c:717
FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1401
VOID NTAPI Phase1Initialization(IN PVOID Context)
Definition: init.c:2013
INT POOL_TYPE
Definition: typedefs.h:76
BOOLEAN NTAPI ExpInitializeProfileImplementation(VOID)
Definition: profile.c:68
FORCEINLINE BOOLEAN _ExAcquireRundownProtection(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:764
#define ExpChangeRundown(x, y, z)
Definition: ex.h:158
HANDLE GenericHandleOverlay
Definition: ex.h:97
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:542
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: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)
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:24
KAPC TimerApc
Definition: ex.h:105
PCALLBACK_OBJECT PowerStateCallback
Definition: callback.c:29
BOOLEAN(NTAPI * PEX_SWEEP_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, HANDLE Handle, PVOID Context)
Definition: ex.h:389
ULONG ExCriticalWorkerThreads
Definition: work.c:38
Definition: ex.h:81
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:639
#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
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:701
UINTN UINT8 Value
Definition: acefiex.h:751
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:1240
ULONG CmNtCSDVersion
Definition: init.c:56
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1049
Definition: compat.h:484
DWORD *typedef HANDLE
Definition: winlogon.h:61
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:1319
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:507
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:1083
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
PEPROCESS ExpDefaultErrorPortProcess
Definition: harderr.c:21
ULONG ExDelayedWorkerThreads
Definition: work.c:39
BOOLEAN NTAPI ExpWin32kInit(VOID)
Definition: win32k.c:263
_In_ BOOLEAN Wait
Definition: cctypes.h:23
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:1363
PVOID Teb
Definition: ketypes.h:1697
ULONG CmNtCSDReleaseType
Definition: init.c:57
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
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
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:43
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:1157
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:1014
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:1274
#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:128
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:63
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)
VOID NTAPI ExpInitUuids(VOID)
Definition: uuid.c:51
ULONG_PTR LowIndex
Definition: ex.h:92
ULONG_PTR Value
Definition: ex.h:98
#define MAXIMUM_HARDERROR_PARAMETERS
Definition: extypes.h:145
VOID NTAPI ExUpdateSystemTimeFromCmos(IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
Definition: time.c:217
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1298
#define KeGetCurrentThread
Definition: hal.h:44
VOID NTAPI ExpInitializeExecutive(IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:914
#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
IN HDEVINFO IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
Definition: devinst.c:44
WORK_QUEUE_ITEM ExpDebuggerWorkItem
Definition: dbgctrl.c:21
FORCEINLINE VOID _ExWaitForRundownProtectionRelease(IN PEX_RUNDOWN_REF RunRef)
Definition: ex.h:872
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
BOOLEAN(NTAPI * PEX_CHANGE_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)
Definition: ex.h:404
#define HANDLE_TAG_BITS
Definition: ex.h:77
IN SCSI_ADAPTER_CONTROL_TYPE IN PVOID Parameters
Definition: srb.h:488
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
VOID FASTCALL ExfTryToWakePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1165