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