ReactOS  r75400
ex.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  _EXHANDLE
 
struct  _ETIMER
 
struct  SYSTEM_CALLBACKS
 
struct  _HARDERROR_USER_PARAMETERS
 

Macros

#define HANDLE_LOW_BITS   (PAGE_SHIFT - 3)
 
#define HANDLE_HIGH_BITS   (PAGE_SHIFT - 2)
 
#define KERNEL_FLAG_BITS   (sizeof(PVOID)*8 - 31)
 
#define MAX_FAST_REFS   7
 
#define ExAcquireRundownProtection   _ExAcquireRundownProtection
 
#define ExReleaseRundownProtection   _ExReleaseRundownProtection
 
#define ExInitializeRundownProtection   _ExInitializeRundownProtection
 
#define ExWaitForRundownProtectionRelease   _ExWaitForRundownProtectionRelease
 
#define ExRundownCompleted   _ExRundownCompleted
 
#define ExGetPreviousMode   KeGetPreviousMode
 
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT   1
 
#define FREE_HANDLE_MASK   -1
 
#define LOW_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))
 
#define MID_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))
 
#define HIGH_LEVEL_ENTRIES   (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))
 
#define MAX_LOW_INDEX   LOW_LEVEL_ENTRIES
 
#define MAX_MID_INDEX   (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
 
#define MAX_HIGH_INDEX   (MID_LEVEL_ENTRIES * MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)
 
#define ExpChangeRundown(x, y, z)   (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)
 
#define ExpChangePushlock(x, y, z)   InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)
 
#define ExpSetRundown(x, y)   InterlockedExchangePointer(&x->Ptr, (PVOID)y)
 
#define ExInitializePushLock   _ExInitializePushLock
 
#define InterlockedDecrementUL(Addend)   (ULONG)InterlockedDecrement((PLONG)(Addend))
 
#define InterlockedIncrementUL(Addend)   (ULONG)InterlockedIncrement((PLONG)(Addend))
 
#define InterlockedExchangeUL(Target, Value)   (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))
 
#define InterlockedExchangeAddUL(Addend, Value)   (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))
 
#define InterlockedCompareExchangeUL(Destination, Exchange, Comperand)   (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
 
#define ExfInterlockedCompareExchange64UL(Destination, Exchange, Comperand)   (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
 

Typedefs

typedef enum _WINKD_WORKER_STATE WINKD_WORKER_STATE
 
typedef union _EXHANDLE EXHANDLE
 
typedef union _EXHANDLEPEXHANDLE
 
typedef struct _ETIMER ETIMER
 
typedef struct _ETIMERPETIMER
 
typedef struct
_HARDERROR_USER_PARAMETERS 
HARDERROR_USER_PARAMETERS
 
typedef struct
_HARDERROR_USER_PARAMETERS
PHARDERROR_USER_PARAMETERS
 
typedef BOOLEAN(NTAPIPEX_SWEEP_HANDLE_CALLBACK )(PHANDLE_TABLE_ENTRY HandleTableEntry, HANDLE Handle, PVOID Context)
 
typedef BOOLEAN(NTAPIPEX_DUPLICATE_HANDLE_CALLBACK )(IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN PHANDLE_TABLE_ENTRY NewEntry)
 
typedef BOOLEAN(NTAPIPEX_CHANGE_HANDLE_CALLBACK )(PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)
 

Enumerations

enum  _WINKD_WORKER_STATE { WinKdWorkerReady = 0, WinKdWorkerStart, WinKdWorkerInitialized }
 

Functions

VOID NTAPI ExpDebuggerWorker (IN PVOID Context)
 
NTSTATUS NTAPI ExGetPoolTagInfo (IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, IN ULONG SystemInformationLength, IN OUT PULONG ReturnLength OPTIONAL)
 
BOOLEAN NTAPI ExpWin32kInit (VOID)
 
VOID NTAPI ExInit2 (VOID)
 
VOID NTAPI Phase1Initialization (IN PVOID Context)
 
VOID NTAPI ExpInitializePushLocks (VOID)
 
BOOLEAN NTAPI ExRefreshTimeZoneInformation (IN PLARGE_INTEGER SystemBootTime)
 
VOID NTAPI ExpInitializeWorkerThreads (VOID)
 
VOID NTAPI ExSwapinWorkerThreads (IN BOOLEAN AllowSwap)
 
VOID NTAPI ExpInitLookasideLists (VOID)
 
VOID NTAPI ExInitializeSystemLookasideList (IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
 
BOOLEAN NTAPI ExpInitializeCallbacks (VOID)
 
VOID NTAPI ExpInitUuids (VOID)
 
VOID NTAPI ExpInitializeExecutive (IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
BOOLEAN NTAPI ExpInitializeEventImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeEventPairImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeMutantImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeTimerImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeProfileImplementation (VOID)
 
VOID NTAPI ExpResourceInitialization (VOID)
 
VOID NTAPI ExInitPoolLookasidePointers (VOID)
 
VOID NTAPI ExInitializeCallBack (IN OUT PEX_CALLBACK Callback)
 
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack (IN PEX_CALLBACK_FUNCTION Function, IN PVOID Context)
 
VOID NTAPI ExFreeCallBack (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
BOOLEAN NTAPI ExCompareExchangeCallBack (IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK NewBlock, IN PEX_CALLBACK_ROUTINE_BLOCK OldBlock)
 
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock (IN OUT PEX_CALLBACK CallBack)
 
VOID NTAPI ExDereferenceCallBackBlock (IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
PVOID NTAPI ExGetCallBackBlockContext (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
VOID NTAPI ExWaitForCallBacks (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
VOID FASTCALL ExfInitializeRundownProtection (OUT PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExfReInitializeRundownProtection (OUT PEX_RUNDOWN_REF RunRef)
 
BOOLEAN FASTCALL ExfAcquireRundownProtection (IN OUT PEX_RUNDOWN_REF RunRef)
 
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx (IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
 
VOID FASTCALL ExfReleaseRundownProtection (IN OUT PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExfReleaseRundownProtectionEx (IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
 
VOID FASTCALL ExfRundownCompleted (OUT PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExfWaitForRundownProtectionRelease (IN OUT PEX_RUNDOWN_REF RunRef)
 
VOID NTAPI ExpInitializeHandleTables (VOID)
 
PHANDLE_TABLE NTAPI ExCreateHandleTable (IN PEPROCESS Process OPTIONAL)
 
VOID NTAPI ExUnlockHandleTableEntry (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 
HANDLE NTAPI ExCreateHandle (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 
VOID NTAPI ExDestroyHandleTable (IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
 
BOOLEAN NTAPI ExDestroyHandle (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
 
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
 
PHANDLE_TABLE NTAPI ExDupHandleTable (IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure, IN ULONG_PTR Mask)
 
BOOLEAN NTAPI ExChangeHandle (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine, IN ULONG_PTR Context)
 
VOID NTAPI ExSweepHandleTable (IN PHANDLE_TABLE HandleTable, IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure, IN PVOID Context)
 
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry (IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
 
BOOLEAN NTAPI ExpLockHandleTableEntry (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 
LONG NTAPI ExSystemExceptionFilter (VOID)
 
FORCEINLINE VOID ExDoCallBack (IN OUT PEX_CALLBACK Callback, IN PVOID Context, IN PVOID Argument1, IN PVOID Argument2)
 
FORCEINLINE PVOID ExGetObjectFastReference (IN EX_FAST_REF FastRef)
 
FORCEINLINE ULONG ExGetCountFastReference (IN EX_FAST_REF FastRef)
 
FORCEINLINE VOID ExInitializeFastReference (OUT PEX_FAST_REF FastRef, IN OPTIONAL PVOID Object)
 
FORCEINLINE EX_FAST_REF ExAcquireFastReference (IN OUT PEX_FAST_REF FastRef)
 
FORCEINLINE BOOLEAN ExInsertFastReference (IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
 
FORCEINLINE BOOLEAN ExReleaseFastReference (IN PEX_FAST_REF FastRef, IN PVOID Object)
 
FORCEINLINE EX_FAST_REF ExSwapFastReference (IN PEX_FAST_REF FastRef, IN PVOID Object)
 
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference (IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
 
FORCEINLINE BOOLEAN _ExAcquireRundownProtection (IN PEX_RUNDOWN_REF RunRef)
 
FORCEINLINE VOID _ExReleaseRundownProtection (IN PEX_RUNDOWN_REF RunRef)
 
FORCEINLINE VOID _ExInitializeRundownProtection (IN PEX_RUNDOWN_REF RunRef)
 
FORCEINLINE VOID _ExWaitForRundownProtectionRelease (IN PEX_RUNDOWN_REF RunRef)
 
FORCEINLINE VOID _ExRundownCompleted (IN PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExBlockPushLock (IN PEX_PUSH_LOCK PushLock, IN PVOID WaitBlock)
 
VOID FASTCALL ExfUnblockPushLock (IN PEX_PUSH_LOCK PushLock, IN PVOID CurrentWaitBlock)
 
VOID FASTCALL ExWaitForUnblockPushLock (IN PEX_PUSH_LOCK PushLock, IN PVOID WaitBlock)
 
FORCEINLINE VOID _ExInitializePushLock (OUT PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExAcquirePushLockExclusive (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE BOOLEAN ExTryToAcquirePushLockExclusive (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExAcquirePushLockShared (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive (IN PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExWaitOnPushLock (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExReleasePushLockShared (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExReleasePushLockExclusive (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID ExReleasePushLock (PEX_PUSH_LOCK PushLock)
 
FORCEINLINE VOID _ExAcquireFastMutexUnsafe (IN PFAST_MUTEX FastMutex)
 
FORCEINLINE VOID _ExReleaseFastMutexUnsafe (IN OUT PFAST_MUTEX FastMutex)
 
FORCEINLINE VOID _ExAcquireFastMutex (IN PFAST_MUTEX FastMutex)
 
FORCEINLINE VOID _ExReleaseFastMutex (IN OUT PFAST_MUTEX FastMutex)
 
FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex (IN OUT PFAST_MUTEX FastMutex)
 
FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe (IN OUT PFAST_MUTEX FastMutex)
 
FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion (IN OUT PFAST_MUTEX FastMutex)
 
BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite (IN PERESOURCE Resource)
 
NTSTATUS ExpSetTimeZoneInformation (IN PTIME_ZONE_INFORMATION TimeZoneInformation)
 
BOOLEAN NTAPI ExAcquireTimeRefreshLock (IN BOOLEAN Wait)
 
VOID NTAPI ExReleaseTimeRefreshLock (VOID)
 
VOID NTAPI ExUpdateSystemTimeFromCmos (IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
 
VOID NTAPI ExAllocateLocallyUniqueId (OUT LUID *LocallyUniqueId)
 
VOID NTAPI ExTimerRundown (VOID)
 
VOID NTAPI HeadlessInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI XIPInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 

Variables

TIME_ZONE_INFORMATION ExpTimeZoneInfo
 
LARGE_INTEGER ExpTimeZoneBias
 
ULONG ExpTimeZoneId
 
ULONG ExpTickCountMultiplier
 
ULONG ExpLastTimeZoneBias
 
POBJECT_TYPE ExEventPairObjectType
 
POBJECT_TYPE _ExEventObjectType
 
POBJECT_TYPE _ExSemaphoreObjectType
 
FAST_MUTEX ExpEnvironmentLock
 
ERESOURCE ExpFirmwareTableResource
 
LIST_ENTRY ExpFirmwareTableProviderListHead
 
BOOLEAN ExpIsWinPEMode
 
LIST_ENTRY ExpSystemResourcesList
 
ULONG ExpAnsiCodePageDataOffset
 
ULONG ExpOemCodePageDataOffset
 
ULONG ExpUnicodeCaseTableDataOffset
 
PVOID ExpNlsSectionPointer
 
ULONG NtGlobalFlag
 
UNICODE_STRING NtSystemRoot
 
ULONG ExpInitializationPhase
 
ULONG ExpAltTimeZoneBias
 
LIST_ENTRY ExSystemLookasideListHead
 
PCALLBACK_OBJECT PowerStateCallback
 
LIST_ENTRY ExPoolLookasideListHead
 
LIST_ENTRY ExpNonPagedLookasideListHead
 
LIST_ENTRY ExpPagedLookasideListHead
 
KSPIN_LOCK ExpNonPagedLookasideListLock
 
KSPIN_LOCK ExpPagedLookasideListLock
 
ULONG NtMajorVersion
 
ULONG NtMinorVersion
 
ULONG NtBuildNumber
 
ULONG CmNtSpBuildNumber
 
ULONG CmNtCSDVersion
 
ULONG CmNtCSDReleaseType
 
UNICODE_STRING CmVersionString
 
UNICODE_STRING CmCSDVersionString
 
CHAR NtBuildLab []
 
WORK_QUEUE_ITEM ExpDebuggerWorkItem
 
WINKD_WORKER_STATE ExpDebuggerWork
 
PEPROCESS ExpDebuggerProcessAttach
 
PEPROCESS ExpDebuggerProcessKill
 
ULONG_PTR ExpDebuggerPageIn
 

Macro Definition Documentation

#define ExfInterlockedCompareExchange64UL (   Destination,
  Exchange,
  Comperand 
)    (ULONGLONG)ExfInterlockedCompareExchange64((PLONGLONG)(Destination), (PLONGLONG)(Exchange), (PLONGLONG)(Comperand))
#define ExGetPreviousMode   KeGetPreviousMode

Definition at line 125 of file ex.h.

#define EXHANDLE_TABLE_ENTRY_LOCK_BIT   1
#define ExInitializeRundownProtection   _ExInitializeRundownProtection

Definition at line 122 of file ex.h.

#define ExpSetRundown (   x,
  y 
)    InterlockedExchangePointer(&x->Ptr, (PVOID)y)
#define ExReleaseRundownProtection   _ExReleaseRundownProtection

Definition at line 121 of file ex.h.

#define ExRundownCompleted   _ExRundownCompleted

Definition at line 124 of file ex.h.

#define ExWaitForRundownProtectionRelease   _ExWaitForRundownProtectionRelease

Definition at line 123 of file ex.h.

#define FREE_HANDLE_MASK   -1

Definition at line 132 of file ex.h.

Referenced by ExpAllocateHandleTableEntry(), and ExpFreeHandleTableEntry().

#define HANDLE_HIGH_BITS   (PAGE_SHIFT - 2)

Definition at line 69 of file ex.h.

#define HANDLE_LOW_BITS   (PAGE_SHIFT - 3)

Definition at line 68 of file ex.h.

#define HIGH_LEVEL_ENTRIES   (16777216 / (LOW_LEVEL_ENTRIES * MID_LEVEL_ENTRIES))

Definition at line 139 of file ex.h.

Referenced by ExpAllocateHandleTableEntrySlow(), and ExpFreeHandleTable().

#define InterlockedCompareExchangeUL (   Destination,
  Exchange,
  Comperand 
)    (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))
#define InterlockedExchangeAddUL (   Addend,
  Value 
)    (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))

Definition at line 1461 of file ex.h.

Referenced by KdpLoggerThread(), MmDeleteAllRmaps(), MmDeleteRmap(), and MmInsertRmap().

#define KERNEL_FLAG_BITS   (sizeof(PVOID)*8 - 31)

Definition at line 71 of file ex.h.

Definition at line 146 of file ex.h.

#define MAX_LOW_INDEX   LOW_LEVEL_ENTRIES

Definition at line 144 of file ex.h.

#define MAX_MID_INDEX   (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)

Definition at line 145 of file ex.h.

Referenced by ExpAllocateHandleTableEntrySlow().

#define MID_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))

Definition at line 138 of file ex.h.

Referenced by ExpAllocateHandleTableEntrySlow(), and ExpFreeHandleTable().

Typedef Documentation

typedef union _EXHANDLE EXHANDLE
typedef struct _ETIMER * PETIMER
typedef BOOLEAN(NTAPI * PEX_CHANGE_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)

Definition at line 390 of file ex.h.

typedef BOOLEAN(NTAPI * PEX_DUPLICATE_HANDLE_CALLBACK)(IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN PHANDLE_TABLE_ENTRY NewEntry)

Definition at line 382 of file ex.h.

typedef BOOLEAN(NTAPI * PEX_SWEEP_HANDLE_CALLBACK)(PHANDLE_TABLE_ENTRY HandleTableEntry, HANDLE Handle, PVOID Context)

Definition at line 375 of file ex.h.

typedef union _EXHANDLE * PEXHANDLE

Enumeration Type Documentation

Enumerator
WinKdWorkerReady 
WinKdWorkerStart 
WinKdWorkerInitialized 

Definition at line 49 of file ex.h.

50 {
51  WinKdWorkerReady = 0,
enum _WINKD_WORKER_STATE WINKD_WORKER_STATE

Function Documentation

FORCEINLINE VOID _ExAcquireFastMutex ( IN PFAST_MUTEX  FastMutex)

Definition at line 1305 of file ex.h.

Referenced by ExAcquireFastMutex().

1306 {
1307  KIRQL OldIrql;
1309 
1310  /* Raise IRQL to APC */
1311  KeRaiseIrql(APC_LEVEL, &OldIrql);
1312 
1313  /* Decrease the count */
1314  if (InterlockedDecrement(&FastMutex->Count))
1315  {
1316  /* Someone is still holding it, use slow path */
1317  KiAcquireFastMutex(FastMutex);
1318  }
1319 
1320  /* Set the owner and IRQL */
1321  FastMutex->Owner = KeGetCurrentThread();
1322  FastMutex->OldIrql = OldIrql;
1323 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID FASTCALL KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: wait.c:107
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE VOID _ExAcquireFastMutexUnsafe ( IN PFAST_MUTEX  FastMutex)

Definition at line 1260 of file ex.h.

Referenced by _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(), and ExAcquireFastMutexUnsafe().

1261 {
1263 
1264  /* Sanity check */
1266  (Thread->CombinedApcDisable != 0) ||
1267  (Thread->Teb == NULL) ||
1268  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1269  ASSERT(FastMutex->Owner != Thread);
1270 
1271  /* Decrease the count */
1272  if (InterlockedDecrement(&FastMutex->Count))
1273  {
1274  /* Someone is still holding it, use slow path */
1275  KiAcquireFastMutex(FastMutex);
1276  }
1277 
1278  /* Set the owner */
1279  FastMutex->Owner = Thread;
1280 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG CombinedApcDisable
Definition: ketypes.h:1054
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
struct _TEB * Teb
Definition: ketypes.h:1057
smooth NULL
Definition: ftsmooth.c:513
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define InterlockedDecrement
Definition: armddk.h:52
VOID FASTCALL KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: wait.c:107
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:484
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE BOOLEAN _ExAcquireRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 750 of file ex.h.

751 {
752  ULONG_PTR Value, NewValue;
753 
754  /* Get the current value and mask the active bit */
755  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
756 
757  /* Add a reference */
758  NewValue = Value + EX_RUNDOWN_COUNT_INC;
759 
760  /* Change the value */
761  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
762  if (NewValue != Value)
763  {
764  /* Rundown was active, use long path */
765  return ExfAcquireRundownProtection(RunRef);
766  }
767 
768  /* Success */
769  return TRUE;
770 }
#define TRUE
Definition: types.h:120
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ExpChangeRundown(x, y, z)
Definition: ex.h:148
UINTN UINT8 Value
Definition: acefiex.h:725
BOOLEAN FASTCALL ExfAcquireRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
#define EX_RUNDOWN_ACTIVE
FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1376 of file ex.h.

Referenced by ExEnterCriticalRegionAndAcquireFastMutexUnsafe().

1377 {
1378  /* Enter the Critical Region */
1380 
1381  /* Acquire the mutex unsafely */
1382  _ExAcquireFastMutexUnsafe(FastMutex);
1383 }
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1260
FORCEINLINE VOID _ExInitializePushLock ( OUT PEX_PUSH_LOCK  PushLock)

Definition at line 938 of file ex.h.

939 {
940  /* Set the value to 0 */
941  PushLock->Ptr = 0;
942 }
FORCEINLINE VOID _ExInitializeRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 834 of file ex.h.

835 {
836  /* Set the count to zero */
837  RunRef->Count = 0;
838 }
FORCEINLINE VOID _ExReleaseFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1327 of file ex.h.

Referenced by ExReleaseFastMutex().

1328 {
1329  KIRQL OldIrql;
1331 
1332  /* Erase the owner */
1333  FastMutex->Owner = NULL;
1334  OldIrql = (KIRQL)FastMutex->OldIrql;
1335 
1336  /* Increase the count */
1337  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1338  {
1339  /* Someone was waiting for it, signal the waiter */
1340  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1341  }
1342 
1343  /* Lower IRQL back */
1344  KeLowerIrql(OldIrql);
1345 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:513
if(!(yy_init))
Definition: macro.lex.yy.c:704
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define InterlockedIncrement
Definition: armddk.h:53
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
Definition: eventobj.c:229
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE VOID _ExReleaseFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1284 of file ex.h.

Referenced by _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(), and ExReleaseFastMutexUnsafe().

1285 {
1287  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1288  (KeGetCurrentThread()->Teb == NULL) ||
1290  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1291 
1292  /* Erase the owner */
1293  FastMutex->Owner = NULL;
1294 
1295  /* Increase the count */
1296  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1297  {
1298  /* Someone was waiting for it, signal the waiter */
1299  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1300  }
1301 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
smooth NULL
Definition: ftsmooth.c:513
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:484
#define InterlockedIncrement
Definition: armddk.h:53
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
Definition: eventobj.c:229
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1387 of file ex.h.

Referenced by ExReleaseFastMutexUnsafeAndLeaveCriticalRegion().

1388 {
1389  /* Release the mutex unsafely */
1390  _ExReleaseFastMutexUnsafe(FastMutex);
1391 
1392  /* Leave the critical region */
1394 }
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1284
FORCEINLINE VOID _ExReleaseRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 791 of file ex.h.

792 {
793  ULONG_PTR Value, NewValue;
794 
795  /* Get the current value and mask the active bit */
796  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
797 
798  /* Remove a reference */
799  NewValue = Value - EX_RUNDOWN_COUNT_INC;
800 
801  /* Change the value */
802  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
803 
804  /* Check if the rundown was active */
805  if (NewValue != Value)
806  {
807  /* Rundown was active, use long path */
809  }
810  else
811  {
812  /* Sanity check */
813  ASSERT((Value >= EX_RUNDOWN_COUNT_INC) || (KeNumberProcessors > 1));
814  }
815 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ExpChangeRundown(x, y, z)
Definition: ex.h:148
UINTN UINT8 Value
Definition: acefiex.h:725
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
VOID FASTCALL ExfReleaseRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
#define EX_RUNDOWN_ACTIVE
FORCEINLINE VOID _ExRundownCompleted ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 888 of file ex.h.

889 {
890  /* Sanity check */
891  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
892 
893  /* Mark the counter as active */
895 }
#define ExpSetRundown(x, y)
Definition: ex.h:150
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define EX_RUNDOWN_ACTIVE
FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1349 of file ex.h.

Referenced by ExTryToAcquireFastMutex().

1350 {
1351  KIRQL OldIrql;
1353 
1354  /* Raise to APC_LEVEL */
1355  KeRaiseIrql(APC_LEVEL, &OldIrql);
1356 
1357  /* Check if we can quickly acquire it */
1358  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1359  {
1360  /* We have, set us as owners */
1361  FastMutex->Owner = KeGetCurrentThread();
1362  FastMutex->OldIrql = OldIrql;
1363  return TRUE;
1364  }
1365  else
1366  {
1367  /* Acquire attempt failed */
1368  KeLowerIrql(OldIrql);
1369  YieldProcessor();
1370  return FALSE;
1371  }
1372 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define InterlockedCompareExchange
Definition: interlocked.h:104
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
FORCEINLINE VOID _ExWaitForRundownProtectionRelease ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 858 of file ex.h.

859 {
861 
862  /* Set the active bit */
863  Value = ExpChangeRundown(RunRef, EX_RUNDOWN_ACTIVE, 0);
864  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
865  {
866  /* If the the rundown wasn't already active, then take the long path */
868  }
869 }
VOID FASTCALL ExfWaitForRundownProtectionRelease(IN OUT PEX_RUNDOWN_REF RunRef)
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ExpChangeRundown(x, y, z)
Definition: ex.h:148
UINTN UINT8 Value
Definition: acefiex.h:725
#define EX_RUNDOWN_ACTIVE
FORCEINLINE EX_FAST_REF ExAcquireFastReference ( IN OUT PEX_FAST_REF  FastRef)

Definition at line 557 of file ex.h.

Referenced by ExReferenceCallBackBlock(), ObFastReferenceObject(), and ObpReferenceSecurityDescriptor().

558 {
559  EX_FAST_REF OldValue, NewValue;
560 
561  /* Start reference loop */
562  for (;;)
563  {
564  /* Get the current reference count */
565  OldValue = *FastRef;
566  if (OldValue.RefCnt)
567  {
568  /* Increase the reference count */
569  NewValue.Value = OldValue.Value - 1;
570  NewValue.Object = ExpChangePushlock(&FastRef->Object,
571  NewValue.Object,
572  OldValue.Object);
573  if (NewValue.Object != OldValue.Object) continue;
574  }
575 
576  /* We are done */
577  break;
578  }
579 
580  /* Return the old value */
581  return OldValue;
582 }
ULONG_PTR RefCnt
Definition: extypes.h:423
PVOID Object
Definition: extypes.h:422
#define ExpChangePushlock(x, y, z)
Definition: ex.h:149
ULONG_PTR Value
Definition: extypes.h:424
FORCEINLINE VOID ExAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 966 of file ex.h.

Referenced by CmLoadKey(), CmpDestroyHive(), CmpInitializeHive(), CmpUnlinkHiveFromMaster(), ExCreateHandleTable(), ExDupHandleTable(), ExpAllocateHandleTableEntry(), ExRemoveHandleTable(), GDIOBJ_hInsertObject(), GDIOBJ_LockObject(), GdiPoolAllocate(), GdiPoolFree(), MiLockProcessWorkingSet(), MiLockProcessWorkingSetUnsafe(), MiLockWorkingSet(), NtUnloadKey2(), ObpAcquireDirectoryLockExclusive(), ObpSdAcquireLock(), PspCreateThread(), PspDeleteThread(), PspExitThread(), PspLockProcessSecurityExclusive(), PspLockThreadSecurityExclusive(), PsSetProcessWin32Process(), and TEXTOBJ_LockText().

967 {
968  /* Try acquiring the lock */
970  {
971  /* Someone changed it, use the slow path */
972  ExfAcquirePushLockExclusive(PushLock);
973  }
974 
975  /* Sanity check */
976  ASSERT(PushLock->Locked);
977 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
VOID FASTCALL ExfAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:471
#define EX_PUSH_LOCK_LOCK_V
Definition: Object.c:28
signed int * PLONG
Definition: retypes.h:5
FORCEINLINE VOID ExAcquirePushLockShared ( PEX_PUSH_LOCK  PushLock)

Definition at line 1035 of file ex.h.

Referenced by CmpDoFlushAll(), CmpDoFlushNextHive(), ExpAllocateHandleTableEntry(), MiLockProcessWorkingSetShared(), NtSetInformationProcess(), NtSetInformationThread(), ObpAcquireDirectoryLockShared(), ObpSdAcquireLockShared(), PsGetNextProcessThread(), PspLockProcessSecurityShared(), PspLockThreadSecurityShared(), and QSI_DEF().

1036 {
1037  EX_PUSH_LOCK NewValue;
1038 
1039  /* Try acquiring the lock */
1041  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1042  {
1043  /* Someone changed it, use the slow path */
1044  ExfAcquirePushLockShared(PushLock);
1045  }
1046 
1047  /* Sanity checks */
1048  ASSERT(PushLock->Locked);
1049 }
ULONG_PTR Value
Definition: extypes.h:465
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PVOID Ptr
Definition: extypes.h:466
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
VOID FASTCALL ExfAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:645
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define ExpChangePushlock(x, y, z)
Definition: ex.h:149
ULONG_PTR Locked
Definition: extypes.h:459
BOOLEAN NTAPI ExAcquireTimeRefreshLock ( IN BOOLEAN  Wait)

Definition at line 51 of file time.c.

Referenced by ExSetTimerResolution(), and KdpTimeSlipWork().

52 {
53  /* Block APCs */
55 
56  /* Attempt lock acquisition */
58  {
59  /* Lock was not acquired, enable APCs and fail */
61  return FALSE;
62  }
63 
64  /* Lock has been acquired */
65  return TRUE;
66 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define FALSE
Definition: types.h:117
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
_In_ BOOLEAN Wait
Definition: cctypes.h:23
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack ( IN PEX_CALLBACK_FUNCTION  Function,
IN PVOID  Context 
)

Definition at line 54 of file callback.c.

Referenced by PsSetCreateProcessNotifyRoutine(), PsSetCreateThreadNotifyRoutine(), PsSetLoadImageNotifyRoutine(), and TestPrivateFunctions().

56 {
57  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
58 
59  /* Allocate a callback */
60  CallbackBlock = ExAllocatePoolWithTag(PagedPool,
63  if (CallbackBlock)
64  {
65  /* Initialize it */
66  CallbackBlock->Function = Function;
67  CallbackBlock->Context = Context;
69  }
70 
71  /* Return it */
72  return CallbackBlock;
73 }
IN OUT PIRP IN ULONG IN WMIENABLEDISABLECONTROL Function
Definition: wmilib.h:37
NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection(_Out_ PEX_RUNDOWN_REF RunRef)
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
EX_RUNDOWN_REF RundownProtect
Definition: extypes.h:537
struct tagContext Context
Definition: acpixf.h:1013
#define TAG_CALLBACK_ROUTINE_BLOCK
Definition: tag.h:11
VOID NTAPI ExAllocateLocallyUniqueId ( OUT LUID LocallyUniqueId)

Definition at line 232 of file uuid.c.

Referenced by NtAllocateLocallyUniqueId(), SeCreateAccessStateEx(), SepCreateToken(), and SepDuplicateToken().

233 {
234  LARGE_INTEGER NewLuid, PrevLuid;
235 
236  /* atomically increment the luid */
237  do
238  {
239  PrevLuid = LuidValue;
240  NewLuid = RtlLargeIntegerAdd(PrevLuid,
241  LuidIncrement);
243  &NewLuid.QuadPart,
244  &PrevLuid.QuadPart,
245  NULL) != PrevLuid.QuadPart);
246 
247  LocallyUniqueId->LowPart = NewLuid.u.LowPart;
248  LocallyUniqueId->HighPart = NewLuid.u.HighPart;
249 }
NTSYSAPI LONGLONG WINAPI RtlLargeIntegerAdd(LONGLONG, LONGLONG)
static LARGE_INTEGER LuidValue
Definition: uuid.c:44
NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64(IN OUT PLONGLONG Destination, IN PLONGLONG Exchange, IN PLONGLONG Comparand, IN PKSPIN_LOCK Lock)
Definition: interlocked.c:113
smooth NULL
Definition: ftsmooth.c:513
struct _LARGE_INTEGER::@2028 u
static LARGE_INTEGER LuidIncrement
Definition: uuid.c:43
LONGLONG QuadPart
Definition: typedefs.h:113
VOID FASTCALL ExBlockPushLock ( IN PEX_PUSH_LOCK  PushLock,
IN PVOID  WaitBlock 
)
BOOLEAN NTAPI ExChangeHandle ( IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle,
IN PEX_CHANGE_HANDLE_CALLBACK  ChangeRoutine,
IN ULONG_PTR  Context 
)

Definition at line 1149 of file handle.c.

Referenced by NtSetInformationObject(), and ObSetHandleAttributes().

1153 {
1154  EXHANDLE ExHandle;
1155  PHANDLE_TABLE_ENTRY HandleTableEntry;
1156  BOOLEAN Result = FALSE;
1157  PAGED_CODE();
1158 
1159  /* Set the handle value */
1160  ExHandle.GenericHandleOverlay = Handle;
1161 
1162  /* Find the entry for this handle */
1163  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1164 
1165  /* Make sure that we found an entry, and that it's valid */
1166  if (!(HandleTableEntry) ||
1167  !(HandleTableEntry->Object) ||
1168  (HandleTableEntry->NextFreeTableEntry == -2))
1169  {
1170  /* It isn't, fail */
1171  return FALSE;
1172  }
1173 
1174  /* Enter a critical region */
1176 
1177  /* Try locking the handle entry */
1178  if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1179  {
1180  /* Call the change routine and unlock the entry */
1181  Result = ChangeRoutine(HandleTableEntry, Context);
1182  ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
1183  }
1184 
1185  /* Leave the critical region and return the callback result */
1187  return Result;
1188 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:36
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:883
#define FALSE
Definition: types.h:117
Definition: extypes.h:595
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned char BOOLEAN
HANDLE GenericHandleOverlay
Definition: ex.h:88
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:844
#define PAGED_CODE()
Definition: video.h:57
Definition: ex.h:73
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
LONG NextFreeTableEntry
Definition: extypes.h:612
PVOID Object
Definition: extypes.h:599
BOOLEAN NTAPI ExCompareExchangeCallBack ( IN OUT PEX_CALLBACK  CallBack,
IN PEX_CALLBACK_ROUTINE_BLOCK  NewBlock,
IN PEX_CALLBACK_ROUTINE_BLOCK  OldBlock 
)

Definition at line 170 of file callback.c.

Referenced by PsRemoveCreateThreadNotifyRoutine(), PsRemoveLoadImageNotifyRoutine(), PsSetCreateProcessNotifyRoutine(), PsSetCreateThreadNotifyRoutine(), and PsSetLoadImageNotifyRoutine().

173 {
174  EX_FAST_REF OldValue;
175  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
176  ULONG Count;
177 
178  /* Check that we have a new block */
179  if (NewBlock)
180  {
181  /* Acquire rundown */
182  if (!ExfAcquireRundownProtectionEx(&NewBlock->RundownProtect,
183  MAX_FAST_REFS + 1))
184  {
185  /* This should never happen */
186  ASSERTMSG("Callback block is already undergoing rundown", FALSE);
187  return FALSE;
188  }
189  }
190 
191  /* Do the swap */
192  OldValue = ExCompareSwapFastReference(&CallBack->RoutineBlock,
193  NewBlock,
194  OldBlock);
195 
196  /* Get the routine block */
197  CallbackBlock = ExGetObjectFastReference(OldValue);
198  Count = ExGetCountFastReference(OldValue);
199 
200  /* Make sure the swap worked */
201  if (CallbackBlock == OldBlock)
202  {
203  /* Make sure we replaced a valid pointer */
204  if (CallbackBlock)
205  {
206  /* Acquire the flush lock and immediately release it */
209 
210  /* Release rundown protection */
213  Count + 1);
214  }
215 
216  /* Compare worked */
217  return TRUE;
218  }
219  else
220  {
221  /* It failed, check if we had a block */
222  if (NewBlock)
223  {
224  /* We did, remove the references that we had added */
225  ExfReleaseRundownProtectionEx(&NewBlock->RundownProtect,
226  MAX_FAST_REFS + 1);
227  }
228 
229  /* Return failure */
230  return FALSE;
231  }
232 }
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:520
#define TRUE
Definition: types.h:120
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1108
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:528
VOID FASTCALL ExfReleaseRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:259
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:687
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:77
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
EX_RUNDOWN_REF RundownProtect
Definition: extypes.h:537
unsigned int ULONG
Definition: retypes.h:1
#define MAX_FAST_REFS
Definition: ex.h:118
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference ( IN PEX_FAST_REF  FastRef,
IN PVOID  Object,
IN PVOID  OldObject 
)

Definition at line 687 of file ex.h.

Referenced by ExCompareExchangeCallBack(), and ObSetSecurityDescriptorInfo().

690 {
691  EX_FAST_REF OldValue, NewValue;
692 
693  /* Sanity check and start swap loop */
695  for (;;)
696  {
697  /* Get the current value */
698  OldValue = *FastRef;
699 
700  /* Make sure there's enough references to swap */
701  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
702 
703  /* Check if we have an object to swap */
704  if (Object)
705  {
706  /* Set up the value with maximum fast references */
707  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
708  }
709  else
710  {
711  /* Write the object address itself (which is empty) */
712  NewValue.Value = (ULONG_PTR)Object;
713  }
714 
715  /* Do the actual compare exchange */
716  NewValue.Object = ExpChangePushlock(&FastRef->Object,
717  NewValue.Object,
718  OldValue.Object);
719  if (NewValue.Object != OldValue.Object) continue;
720 
721  /* All done */
722  break;
723  }
724 
725  /* Return the old value */
726  return OldValue;
727 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
uint32_t ULONG_PTR
Definition: typedefs.h:64
PVOID Object
Definition: extypes.h:422
static IUnknown Object
Definition: main.c:512
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:118
#define ExpChangePushlock(x, y, z)
Definition: ex.h:149
ULONG_PTR Value
Definition: extypes.h:424
FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive ( IN PEX_PUSH_LOCK  PushLock)

Definition at line 1069 of file ex.h.

Referenced by CmpTryToConvertKcbSharedToExclusive(), and ObpLookupEntryDirectory().

1070 {
1071  EX_PUSH_LOCK OldValue;
1072 
1073  /* Set the expected old value */
1075 
1076  /* Try converting the lock */
1077  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1078  OldValue.Ptr)
1079  {
1080  /* Conversion failed */
1081  return FALSE;
1082  }
1083 
1084  /* Sanity check */
1085  ASSERT(PushLock->Locked);
1086  return TRUE;
1087 }
ULONG_PTR Value
Definition: extypes.h:465
#define TRUE
Definition: types.h:120
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PVOID Ptr
Definition: extypes.h:466
#define FALSE
Definition: types.h:117
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define ExpChangePushlock(x, y, z)
Definition: ex.h:149
HANDLE NTAPI ExCreateHandle ( IN PHANDLE_TABLE  HandleTable,
IN PHANDLE_TABLE_ENTRY  HandleTableEntry 
)

Definition at line 787 of file handle.c.

Referenced by ObDuplicateObject(), ObpCreateHandle(), ObpCreateUnnamedHandle(), PspCreateProcess(), PspCreateThread(), and RtlpCreateAtomHandle().

789 {
791  PHANDLE_TABLE_ENTRY NewEntry;
792  PAGED_CODE();
793 
794  /* Start with a clean handle */
795  Handle.GenericHandleOverlay = NULL;
796 
797  /* Allocate a new entry */
798  NewEntry = ExpAllocateHandleTableEntry(HandleTable, &Handle);
799  if (NewEntry)
800  {
801  /* Enter a critical region */
803 
804  /* Write the entry */
805  *NewEntry = *HandleTableEntry;
806 
807  /* Unlock it and leave the critical region */
810  }
811 
812  /* Return the handle value */
813  return Handle.GenericHandleOverlay;
814 }
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:883
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:513
_In_ HANDLE Handle
Definition: extypes.h:390
PHANDLE_TABLE_ENTRY NTAPI ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, OUT PEXHANDLE NewHandle)
Definition: handle.c:644
HANDLE GenericHandleOverlay
Definition: ex.h:88
#define PAGED_CODE()
Definition: video.h:57
Definition: ex.h:73
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
PHANDLE_TABLE NTAPI ExCreateHandleTable ( IN PEPROCESS Process  OPTIONAL)

Definition at line 761 of file handle.c.

Referenced by ObInitProcess(), ObInitSystem(), PspInitPhase0(), and RtlpCreateAtomHandleTable().

762 {
764  PAGED_CODE();
765 
766  /* Allocate the handle table */
767  HandleTable = ExpAllocateHandleTable(Process, TRUE);
768  if (!HandleTable) return NULL;
769 
770  /* Acquire the handle table lock */
773 
774  /* Insert it into the list */
776 
777  /* Release the lock */
780 
781  /* Return the handle table */
782  return HandleTable;
783 }
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:306
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:966
#define TRUE
Definition: types.h:120
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
LIST_ENTRY HandleTableList
Definition: extypes.h:627
#define InsertTailList(ListHead, Entry)
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1182
smooth NULL
Definition: ftsmooth.c:513
#define PAGED_CODE()
Definition: video.h:57
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
LIST_ENTRY HandleTableListHead
Definition: handle.c:18
VOID NTAPI ExDereferenceCallBackBlock ( IN OUT PEX_CALLBACK  CallBack,
IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock 
)

Definition at line 109 of file callback.c.

Referenced by ExDoCallBack(), PsRemoveCreateThreadNotifyRoutine(), PsRemoveLoadImageNotifyRoutine(), and PsSetCreateProcessNotifyRoutine().

111 {
112  /* Release a fast reference */
113  if (!ExReleaseFastReference(&CallBack->RoutineBlock, CallbackBlock))
114  {
115  /* Take slow path */
116  ExReleaseRundownProtection(&CallbackBlock->RundownProtect);
117  }
118 }
NTKERNELAPI VOID FASTCALL ExReleaseRundownProtection(_Inout_ PEX_RUNDOWN_REF RunRef)
FORCEINLINE BOOLEAN ExReleaseFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:625
BOOLEAN NTAPI ExDestroyHandle ( IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle,
IN PHANDLE_TABLE_ENTRY HandleTableEntry  OPTIONAL 
)

Definition at line 944 of file handle.c.

Referenced by ObpCloseHandleTableEntry(), PspDeleteProcess(), PspDeleteThread(), RtlpCloseHandleCallback(), RtlpCreateAtomHandle(), and RtlpFreeAtomHandle().

947 {
948  EXHANDLE ExHandle;
949  PVOID Object;
950  PAGED_CODE();
951 
952  /* Setup the actual handle value */
953  ExHandle.GenericHandleOverlay = Handle;
954 
955  /* Enter a critical region and check if we have to lookup the handle */
957  if (!HandleTableEntry)
958  {
959  /* Lookup the entry */
960  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
961 
962  /* Make sure that we found an entry, and that it's valid */
963  if (!(HandleTableEntry) ||
964  !(HandleTableEntry->Object) ||
965  (HandleTableEntry->NextFreeTableEntry == -2))
966  {
967  /* Invalid handle, fail */
969  return FALSE;
970  }
971 
972  /* Lock the entry */
973  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
974  {
975  /* Couldn't lock, fail */
977  return FALSE;
978  }
979  }
980  else
981  {
982  /* Make sure the handle is locked */
983  ASSERT((HandleTableEntry->Value & EXHANDLE_TABLE_ENTRY_LOCK_BIT) == 0);
984  }
985 
986  /* Clear the handle */
987  Object = InterlockedExchangePointer((PVOID*)&HandleTableEntry->Object, NULL);
988 
989  /* Sanity checks */
990  ASSERT(Object != NULL);
991  ASSERT((((ULONG_PTR)Object) & EXHANDLE_TABLE_ENTRY_LOCK_BIT) == 0);
992 
993  /* Unblock the pushlock */
994  ExfUnblockPushLock(&HandleTable->HandleContentionEvent, NULL);
995 
996  /* Free the actual entry */
997  ExpFreeHandleTableEntry(HandleTable, ExHandle, HandleTableEntry);
998 
999  /* If we got here, return success */
1001  return TRUE;
1002 }
DWORD *typedef PVOID
Definition: winlogon.h:52
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:36
#define TRUE
Definition: types.h:120
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
_In_ HANDLE Handle
Definition: extypes.h:390
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
HANDLE GenericHandleOverlay
Definition: ex.h:88
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:844
#define PAGED_CODE()
Definition: video.h:57
static IUnknown Object
Definition: main.c:512
Definition: ex.h:73
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:131
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
VOID FASTCALL ExfUnblockPushLock(PEX_PUSH_LOCK PushLock, PVOID CurrentWaitBlock)
Definition: pushlock.c:1205
VOID NTAPI ExpFreeHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:254
VOID NTAPI ExDestroyHandleTable ( IN PHANDLE_TABLE  HandleTable,
IN PVOID DestroyHandleProcedure  OPTIONAL 
)

Definition at line 923 of file handle.c.

Referenced by ObKillProcess(), and RtlpDestroyAtomHandleTable().

925 {
926  PAGED_CODE();
927 
928  /* Remove the handle from the list */
930 
931  /* Check if we have a destroy callback */
932  if (DestroyHandleProcedure)
933  {
934  /* FIXME: */
935  ASSERT(FALSE);
936  }
937 
938  /* Free the handle table */
940 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
#define FALSE
Definition: types.h:117
VOID NTAPI ExRemoveHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:904
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:178
FORCEINLINE VOID ExDoCallBack ( IN OUT PEX_CALLBACK  Callback,
IN PVOID  Context,
IN PVOID  Argument1,
IN PVOID  Argument2 
)

Definition at line 493 of file ex.h.

Referenced by PspRunCreateProcessNotifyRoutines(), PspRunCreateThreadNotifyRoutines(), and PspRunLoadImageNotifyRoutines().

497 {
498  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
500 
501  /* Reference the block */
502  CallbackBlock = ExReferenceCallBackBlock(Callback);
503  if (CallbackBlock)
504  {
505  /* Get the function */
506  Function = ExGetCallBackBlockRoutine(CallbackBlock);
507 
508  /* Do the callback */
510 
511  /* Now dereference it */
512  ExDereferenceCallBackBlock(Callback, CallbackBlock);
513  }
514 }
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
VOID NTAPI ExDereferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:109
IN OUT PIRP IN ULONG IN WMIENABLEDISABLECONTROL Function
Definition: wmilib.h:37
PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:93
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack)
Definition: callback.c:122
_In_ PVOID Argument2
Definition: classpnp.h:680
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:696
LPFNPSPCALLBACK Callback
Definition: desk.c:111
PHANDLE_TABLE NTAPI ExDupHandleTable ( IN PEPROCESS  Process,
IN PHANDLE_TABLE  HandleTable,
IN PEX_DUPLICATE_HANDLE_CALLBACK  DupHandleProcedure,
IN ULONG_PTR  Mask 
)

Definition at line 1032 of file handle.c.

Referenced by ObInitProcess().

1036 {
1037  PHANDLE_TABLE NewTable;
1038  EXHANDLE Handle;
1039  PHANDLE_TABLE_ENTRY HandleTableEntry, NewEntry;
1040  BOOLEAN Failed = FALSE;
1041  PAGED_CODE();
1042 
1043  /* Allocate the duplicated copy */
1044  NewTable = ExpAllocateHandleTable(Process, FALSE);
1045  if (!NewTable) return NULL;
1046 
1047  /* Loop each entry */
1048  while (NewTable->NextHandleNeedingPool <
1049  HandleTable->NextHandleNeedingPool)
1050  {
1051  /* Insert it into the duplicated copy */
1052  if (!ExpAllocateHandleTableEntrySlow(NewTable, FALSE))
1053  {
1054  /* Insert failed, free the new copy and return */
1055  ExpFreeHandleTable(NewTable);
1056  return NULL;
1057  }
1058  }
1059 
1060  /* Setup the initial handle table data */
1061  NewTable->HandleCount = 0;
1062  NewTable->ExtraInfoPages = 0;
1063  NewTable->FirstFree = 0;
1064 
1065  /* Setup the first handle value */
1066  Handle.Value = SizeOfHandle(1);
1067 
1068  /* Enter a critical region and lookup the new entry */
1070  while ((NewEntry = ExpLookupHandleTableEntry(NewTable, Handle)))
1071  {
1072  /* Lookup the old entry */
1073  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle);
1074 
1075  /* Loop each entry */
1076  do
1077  {
1078  /* Check if it doesn't match the audit mask */
1079  if (!(HandleTableEntry->Value & Mask))
1080  {
1081  /* Free it since we won't use it */
1082  Failed = TRUE;
1083  }
1084  else
1085  {
1086  /* Lock the entry */
1087  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1088  {
1089  /* Free it since we can't lock it, so we won't use it */
1090  Failed = TRUE;
1091  }
1092  else
1093  {
1094  /* Copy the handle value */
1095  *NewEntry = *HandleTableEntry;
1096 
1097  /* Call the duplicate callback */
1098  if (DupHandleProcedure(Process,
1099  HandleTable,
1100  HandleTableEntry,
1101  NewEntry))
1102  {
1103  /* Clear failure flag */
1104  Failed = FALSE;
1105 
1106  /* Lock the entry, increase the handle count */
1107  NewEntry->Value |= EXHANDLE_TABLE_ENTRY_LOCK_BIT;
1108  NewTable->HandleCount++;
1109  }
1110  else
1111  {
1112  /* Duplication callback refused, fail */
1113  Failed = TRUE;
1114  }
1115  }
1116  }
1117 
1118  /* Check if we failed earlier and need to free */
1119  if (Failed)
1120  {
1121  /* Free this entry */
1122  NewEntry->Object = NULL;
1123  NewEntry->NextFreeTableEntry = NewTable->FirstFree;
1124  NewTable->FirstFree = (ULONG)Handle.Value;
1125  }
1126 
1127  /* Increase the handle value and move to the next entry */
1128  Handle.Value += SizeOfHandle(1);
1129  NewEntry++;
1130  HandleTableEntry++;
1131  } while (Handle.Value % SizeOfHandle(LOW_LEVEL_ENTRIES));
1132 
1133  /* We're done, skip the last entry */
1134  Handle.Value += SizeOfHandle(1);
1135  }
1136 
1137  /* Acquire the table lock and insert this new table into the list */
1141 
1142  /* Leave the critical region we entered previously and return the table */
1144  return NewTable;
1145 }
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:306
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:966
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:36
#define TRUE
Definition: types.h:120
ULONG NextHandleNeedingPool
Definition: extypes.h:645
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
LONG ExtraInfoPages
Definition: extypes.h:635
LIST_ENTRY HandleTableList
Definition: extypes.h:627
#define InsertTailList(ListHead, Entry)
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI ExpAllocateHandleTableEntrySlow(IN PHANDLE_TABLE HandleTable, IN BOOLEAN DoInit)
Definition: handle.c:463
#define SizeOfHandle(x)
Definition: handle.c:20
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1182
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:513
LONG HandleCount
Definition: extypes.h:644
Definition: arc.h:79
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned char BOOLEAN
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:844
#define PAGED_CODE()
Definition: video.h:57
Definition: ex.h:73
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:131
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
ULONG_PTR Value
Definition: extypes.h:602
#define LOW_LEVEL_ENTRIES
Definition: ex.h:137
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:178
LONG NextFreeTableEntry
Definition: extypes.h:612
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
unsigned int ULONG
Definition: retypes.h:1
PVOID Object
Definition: extypes.h:599
LIST_ENTRY HandleTableListHead
Definition: handle.c:18
ULONG_PTR Value
Definition: ex.h:89
BOOLEAN FASTCALL ExfAcquireRundownProtection ( IN OUT PEX_RUNDOWN_REF  RunRef)
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx ( IN OUT PEX_RUNDOWN_REF  RunRef,
IN ULONG  Count 
)
VOID FASTCALL ExfInitializeRundownProtection ( OUT PEX_RUNDOWN_REF  RunRef)
VOID NTAPI ExFreeCallBack ( IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock)

Definition at line 77 of file callback.c.

Referenced by PsRemoveCreateThreadNotifyRoutine(), PsRemoveLoadImageNotifyRoutine(), PsSetCreateProcessNotifyRoutine(), PsSetCreateThreadNotifyRoutine(), PsSetLoadImageNotifyRoutine(), and TestPrivateFunctions().

78 {
79  /* Just free it from memory */
81 }
#define TAG_CALLBACK_ROUTINE_BLOCK
Definition: tag.h:11
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
VOID FASTCALL ExfReInitializeRundownProtection ( OUT PEX_RUNDOWN_REF  RunRef)
VOID FASTCALL ExfReleaseRundownProtection ( IN OUT PEX_RUNDOWN_REF  RunRef)
VOID FASTCALL ExfReleaseRundownProtectionEx ( IN OUT PEX_RUNDOWN_REF  RunRef,
IN ULONG  Count 
)
VOID FASTCALL ExfRundownCompleted ( OUT PEX_RUNDOWN_REF  RunRef)
VOID FASTCALL ExfUnblockPushLock ( IN PEX_PUSH_LOCK  PushLock,
IN PVOID  CurrentWaitBlock 
)
VOID FASTCALL ExfWaitForRundownProtectionRelease ( IN OUT PEX_RUNDOWN_REF  RunRef)
PVOID NTAPI ExGetCallBackBlockContext ( IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock)

Definition at line 101 of file callback.c.

102 {
103  /* Return the context */
104  return CallbackBlock->Context;
105 }
PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine ( IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock)

Definition at line 93 of file callback.c.

Referenced by ExDoCallBack(), PsRemoveCreateThreadNotifyRoutine(), PsRemoveLoadImageNotifyRoutine(), and PsSetCreateProcessNotifyRoutine().

94 {
95  /* Return the function */
96  return CallbackBlock->Function;
97 }
FORCEINLINE ULONG ExGetCountFastReference ( IN EX_FAST_REF  FastRef)

Definition at line 528 of file ex.h.

Referenced by ExCompareExchangeCallBack(), ExReferenceCallBackBlock(), ObDeassignSecurity(), ObFastReferenceObject(), ObFastReplaceObject(), ObpReferenceSecurityDescriptor(), and ObSetSecurityDescriptorInfo().

529 {
530  /* Return the reference count */
531  return (ULONG)FastRef.RefCnt;
532 }
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE PVOID ExGetObjectFastReference ( IN EX_FAST_REF  FastRef)

Definition at line 520 of file ex.h.

Referenced by ExCompareExchangeCallBack(), ExReferenceCallBackBlock(), ObDeassignSecurity(), ObFastReferenceObject(), ObFastReferenceObjectLocked(), ObFastReplaceObject(), ObpReferenceSecurityDescriptor(), and ObSetSecurityDescriptorInfo().

521 {
522  /* Return the unbiased pointer */
523  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
524 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define MAX_FAST_REFS
Definition: ex.h:118
NTSTATUS NTAPI ExGetPoolTagInfo ( IN PSYSTEM_POOLTAG_INFORMATION  SystemInformation,
IN ULONG  SystemInformationLength,
IN OUT PULONG ReturnLength  OPTIONAL 
)

Definition at line 1182 of file expool.c.

Referenced by QSI_DEF().

1185 {
1186  ULONG TableSize, CurrentLength;
1187  ULONG EntryCount;
1189  PSYSTEM_POOLTAG TagEntry;
1190  PPOOL_TRACKER_TABLE Buffer, TrackerEntry;
1193 
1194  //
1195  // Keep track of how much data the caller's buffer must hold
1196  //
1197  CurrentLength = FIELD_OFFSET(SYSTEM_POOLTAG_INFORMATION, TagInfo);
1198 
1199  //
1200  // Initialize the caller's buffer
1201  //
1202  TagEntry = &SystemInformation->TagInfo[0];
1203  SystemInformation->Count = 0;
1204 
1205  //
1206  // Capture the number of entries, and the total size needed to make a copy
1207  // of the table
1208  //
1209  EntryCount = (ULONG)PoolTrackTableSize;
1210  TableSize = EntryCount * sizeof(POOL_TRACKER_TABLE);
1211 
1212  //
1213  // Allocate the "Generic DPC" temporary buffer
1214  //
1215  Buffer = ExAllocatePoolWithTag(NonPagedPool, TableSize, 'ofnI');
1216  if (!Buffer) return STATUS_INSUFFICIENT_RESOURCES;
1217 
1218  //
1219  // Do a "Generic DPC" to atomically retrieve the tag and allocation data
1220  //
1221  Context.PoolTrackTable = Buffer;
1223  Context.PoolTrackTableExpansion = NULL;
1224  Context.PoolTrackTableSizeExpansion = 0;
1226 
1227  //
1228  // Now parse the results
1229  //
1230  for (TrackerEntry = Buffer; TrackerEntry < (Buffer + EntryCount); TrackerEntry++)
1231  {
1232  //
1233  // If the entry is empty, skip it
1234  //
1235  if (!TrackerEntry->Key) continue;
1236 
1237  //
1238  // Otherwise, add one more entry to the caller's buffer, and ensure that
1239  // enough space has been allocated in it
1240  //
1241  SystemInformation->Count++;
1242  CurrentLength += sizeof(*TagEntry);
1243  if (SystemInformationLength < CurrentLength)
1244  {
1245  //
1246  // The caller's buffer is too small, so set a failure code. The
1247  // caller will know the count, as well as how much space is needed.
1248  //
1249  // We do NOT break out of the loop, because we want to keep incrementing
1250  // the Count as well as CurrentLength so that the caller can know the
1251  // final numbers
1252  //
1253  Status = STATUS_INFO_LENGTH_MISMATCH;
1254  }
1255  else
1256  {
1257  //
1258  // Small sanity check that our accounting is working correctly
1259  //
1260  ASSERT(TrackerEntry->PagedAllocs >= TrackerEntry->PagedFrees);
1261  ASSERT(TrackerEntry->NonPagedAllocs >= TrackerEntry->NonPagedFrees);
1262 
1263  //
1264  // Return the data into the caller's buffer
1265  //
1266  TagEntry->TagUlong = TrackerEntry->Key;
1267  TagEntry->PagedAllocs = TrackerEntry->PagedAllocs;
1268  TagEntry->PagedFrees = TrackerEntry->PagedFrees;
1269  TagEntry->PagedUsed = TrackerEntry->PagedBytes;
1270  TagEntry->NonPagedAllocs = TrackerEntry->NonPagedAllocs;
1271  TagEntry->NonPagedFrees = TrackerEntry->NonPagedFrees;
1272  TagEntry->NonPagedUsed = TrackerEntry->NonPagedBytes;
1273  TagEntry++;
1274  }
1275  }
1276 
1277  //
1278  // Free the "Generic DPC" temporary buffer, return the buffer length and status
1279  //
1280  ExFreePoolWithTag(Buffer, 'ofnI');
1281  if (ReturnLength) *ReturnLength = CurrentLength;
1282  return Status;
1283 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
PVOID NTAPI ExAllocatePoolWithTag(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: expool.c:1566
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
ULONG PagedAllocs
Definition: extypes.h:1129
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
SIZE_T PoolTrackTableSize
Definition: expool.c:28
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
SIZE_T PoolTrackTableSize
Definition: expool.c:38
ULONG NonPagedFrees
Definition: extypes.h:1133
SIZE_T PoolTrackTableSizeExpansion
Definition: expool.c:30
PPOOL_TRACKER_TABLE PoolTrackTableExpansion
Definition: expool.c:29
smooth NULL
Definition: ftsmooth.c:513
SIZE_T NonPagedBytes
Definition: miarm.h:349
ULONG NonPagedAllocs
Definition: extypes.h:1132
struct _POOL_TRACKER_TABLE POOL_TRACKER_TABLE
SIZE_T NonPagedUsed
Definition: extypes.h:1134
VOID NTAPI ExpGetPoolTagInfoTarget(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: expool.c:1147
SIZE_T PagedUsed
Definition: extypes.h:1131
LONG NonPagedFrees
Definition: miarm.h:348
PPOOL_TRACKER_TABLE PoolTrackTable
Definition: expool.c:27
UINTN VOID * Buffer
Definition: acefiex.h:370
SIZE_T PagedBytes
Definition: miarm.h:352
ULONG PagedFrees
Definition: extypes.h:1130
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
VOID NTAPI KeGenericCallDpc(IN PKDEFERRED_ROUTINE Routine, IN PVOID Context)
Definition: dpc.c:983
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
LONG NonPagedAllocs
Definition: miarm.h:347
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:3937
struct tagContext Context
Definition: acpixf.h:1013
unsigned int ULONG
Definition: retypes.h:1
ULONG TagUlong
Definition: extypes.h:1127
VOID NTAPI ExFreePoolWithTag(IN PVOID P, IN ULONG TagToFree)
Definition: expool.c:2124
ACPI_EFI_GUID ACPI_EFI_OPEN_PROTOCOL_INFORMATION_ENTRY UINTN * EntryCount
Definition: acefiex.h:668
VOID NTAPI ExInit2 ( VOID  )
VOID NTAPI ExInitializeCallBack ( IN OUT PEX_CALLBACK  Callback)

Definition at line 46 of file callback.c.

Referenced by CmpInitCallback(), and PspInitPhase0().

47 {
48  /* Initialize the fast reference */
49  ExInitializeFastReference(&Callback->RoutineBlock, NULL);
50 }
FORCEINLINE VOID ExInitializeFastReference(OUT PEX_FAST_REF FastRef, IN OPTIONAL PVOID Object)
Definition: ex.h:536
smooth NULL
Definition: ftsmooth.c:513
LPFNPSPCALLBACK Callback
Definition: desk.c:111
FORCEINLINE VOID ExInitializeFastReference ( OUT PEX_FAST_REF  FastRef,
IN OPTIONAL PVOID  Object 
)

Definition at line 536 of file ex.h.

Referenced by ExInitializeCallBack(), ObAssignObjectSecurityDescriptor(), and ObInitializeFastReference().

538 {
539  /* Sanity check */
540  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
541 
542  /* Check if an object is being set */
543  if (!Object)
544  {
545  /* Clear the field */
546  FastRef->Object = NULL;
547  }
548  else
549  {
550  /* Otherwise, we assume the object was referenced and is ready */
551  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
552  }
553 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
uint32_t ULONG_PTR
Definition: typedefs.h:64
smooth NULL
Definition: ftsmooth.c:513
static IUnknown Object
Definition: main.c:512
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:118
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 at line 35 of file lookas.c.

Referenced by ExpInitLookasideLists(), IopInitLookasideLists(), ObInit2(), and ObInitSystem().

41 {
42  /* Initialize the list */
43  List->Tag = Tag;
44  List->Type = Type;
45  List->Size = Size;
46  InsertHeadList(ListHead, &List->ListEntry);
47  List->MaximumDepth = MaximumDepth;
48  List->Depth = 2;
49  List->Allocate = ExAllocatePoolWithTag;
50  List->Free = ExFreePool;
51  InitializeSListHead(&List->ListHead);
52  List->TotalAllocates = 0;
53  List->AllocateHits = 0;
54  List->TotalFrees = 0;
55  List->FreeHits = 0;
56  List->LastTotalAllocates = 0;
57  List->LastAllocateHits = 0;
58 }
Type
Definition: Type.h:6
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
UINTN Size
Definition: acefiex.h:550
LIST_ENTRY List
Definition: psmgr.c:57
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN ULONG IN ULONG Tag
Definition: evtlib.h:153
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
WINBASEAPI VOID WINAPI InitializeSListHead(_Out_ PSLIST_HEADER ListHead)
Definition: rtlfuncs.h:3353
VOID NTAPI ExInitPoolLookasidePointers ( VOID  )

Definition at line 63 of file lookas.c.

Referenced by ExpInitializeExecutive(), and KiSystemStartupBootStack().

64 {
65  ULONG i;
66  PKPRCB Prcb = KeGetCurrentPrcb();
68 
69  /* Loop for all pool lists */
70  for (i = 0; i < MAXIMUM_PROCESSORS; i++)
71  {
72  /* Initialize the non-paged list */
74  InitializeSListHead(&Entry->ListHead);
75 
76  /* Bind to PRCB */
77  Prcb->PPNPagedLookasideList[i].P = Entry;
78  Prcb->PPNPagedLookasideList[i].L = Entry;
79 
80  /* Initialize the paged list */
82  InitializeSListHead(&Entry->ListHead);
83 
84  /* Bind to PRCB */
85  Prcb->PPPagedLookasideList[i].P = Entry;
86  Prcb->PPPagedLookasideList[i].L = Entry;
87  }
88 }
#define MAXIMUM_PROCESSORS
Definition: rwlock.h:5
GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:625
struct _Entry Entry
Definition: kefuncs.h:640
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1054
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:27
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:28
unsigned int ULONG
Definition: retypes.h:1
WINBASEAPI VOID WINAPI InitializeSListHead(_Out_ PSLIST_HEADER ListHead)
Definition: rtlfuncs.h:3353
GENERAL_LOOKASIDE_POOL PPPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:626
FORCEINLINE BOOLEAN ExInsertFastReference ( IN OUT PEX_FAST_REF  FastRef,
IN PVOID  Object 
)

Definition at line 586 of file ex.h.

Referenced by ExReferenceCallBackBlock(), ObFastReferenceObject(), and ObpReferenceSecurityDescriptor().

588 {
589  EX_FAST_REF OldValue, NewValue;
590 
591  /* Sanity checks */
593 
594  /* Start update loop */
595  for (;;)
596  {
597  /* Get the current reference count */
598  OldValue = *FastRef;
599 
600  /* Check if the current count is too high or if the pointer changed */
601  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
602  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
603  {
604  /* Fail */
605  return FALSE;
606  }
607 
608  /* Update the reference count */
609  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
610  NewValue.Object = ExpChangePushlock(&FastRef->Object,
611  NewValue.Object,
612  OldValue.Object);
613  if (NewValue.Object != OldValue.Object) continue;
614 
615  /* We are done */
616  break;
617  }
618 
619  /* Return success */
620  return TRUE;
621 }
#define TRUE
Definition: types.h:120
ULONG_PTR RefCnt
Definition: extypes.h:423
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define FALSE
Definition: types.h:117
PVOID Object
Definition: extypes.h:422
static IUnknown Object
Definition: main.c:512
#define MAX_FAST_REFS
Definition: ex.h:118
#define ExpChangePushlock(x, y, z)
Definition: ex.h:149
ULONG_PTR Value
Definition: extypes.h:424
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer ( IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle 
)

Definition at line 1006 of file handle.c.

Referenced by NtWaitForMultipleObjects(), ObpCloseHandle(), ObpReferenceProcessObjectByHandle(), ObQueryObjectAuditingByHandle(), ObReferenceObjectByHandle(), PsLookupProcessByProcessId(), PsLookupProcessThreadByCid(), PsLookupThreadByThreadId(), and RtlpGetAtomEntry().

1008 {
1009  EXHANDLE ExHandle;
1010  PHANDLE_TABLE_ENTRY HandleTableEntry;
1011  PAGED_CODE();
1012 
1013  /* Set the handle value */
1014  ExHandle.GenericHandleOverlay = Handle;
1015 
1016  /* Fail if we got an invalid index */
1017  if (!(ExHandle.Index & (LOW_LEVEL_ENTRIES - 1))) return NULL;
1018 
1019  /* Do the lookup */
1020  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1021  if (!HandleTableEntry) return NULL;
1022 
1023  /* Lock it */
1024  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry)) return NULL;
1025 
1026  /* Return the entry */
1027  return HandleTableEntry;
1028 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:36
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
ULONG_PTR Index
Definition: ex.h:78
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:513
_In_ HANDLE Handle
Definition: extypes.h:390
HANDLE GenericHandleOverlay
Definition: ex.h:88
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:844
#define PAGED_CODE()
Definition: video.h:57
Definition: ex.h:73
#define LOW_LEVEL_ENTRIES
Definition: ex.h:137
VOID NTAPI ExpDebuggerWorker ( IN PVOID  Context)

Definition at line 55 of file dbgctrl.c.

Referenced by ExpWorkerThreadBalanceManager().

56 {
57  PEPROCESS ProcessToAttach, ProcessToKill;
58  ULONG_PTR PageInAddress;
61 
63 
64  /* Be sure we were started in an initialized state */
65  ASSERTMSG("ExpDebuggerWorker being entered in non-initialized state!\n",
68  {
69  /* An error happened, so get a chance to restart proper */
71  return;
72  }
73 
74  /* Get the processes to be attached or killed, and the address to page in */
75  ProcessToAttach = ExpDebuggerProcessAttach;
76  ProcessToKill = ExpDebuggerProcessKill;
77  PageInAddress = ExpDebuggerPageIn;
78 
79  /* Reset the state machine to its ready state */
84 
85  /* Default to the current process if we don't find the process to be attached or killed */
86  Process = NULL;
87 
88  /* Check if we need to attach or kill some process */
89  if (ProcessToAttach != NULL || ProcessToKill != NULL)
90  {
91  /* Find the process in the list */
92  Process = PsGetNextProcess(Process);
93  while (Process)
94  {
95  /* Is this the process we want to attach to? */
96  if (Process == ProcessToAttach)
97  {
98  /* Yes, attach ourselves to it */
99  KeStackAttachProcess(&Process->Pcb, &ApcState);
100  break;
101  }
102  /* Or is this the process we want to kill? */
103  else if (Process == ProcessToKill)
104  {
105  /* Yes, kill and dereference it, then return */
107  ObDereferenceObject(Process);
108  return;
109  }
110 
111  /* Get the next process */
112  Process = PsGetNextProcess(Process);
113  }
114 
115  /* We either have found a process, or we default to the current process */
116  }
117 
118  /* If we have an address to page in... */
119  if (PageInAddress)
120  {
121  /* ... try to do it by attempting to read at this address */
122  _SEH2_TRY
123  {
124  ProbeForReadUchar(PageInAddress);
125  }
127  {
128  DPRINT1("Failed to page in address 0x%p, Status 0x%08lx\n", PageInAddress, _SEH2_GetExceptionCode());
129  }
130  _SEH2_END;
131  }
132 
133  /* Break into the process (or the current one if Process == NULL) */
135 
136  /* If we are attached to a process, not the current one... */
137  if (Process)
138  {
139  /* ... we can detach from the process */
140  KeUnstackDetachProcess(&ApcState);
141  /* Dereference the process which was referenced for us by PsGetNextProcess */
142  ObDereferenceObject(Process);
143  }
144 }
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:28
KAPC_STATE
Definition: ketypes.h:1258
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:315
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:27
#define DBG_STATUS_WORKER
Definition: kdtypes.h:45
uint32_t ULONG_PTR
Definition: typedefs.h:64
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:649
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define _SEH2_END
Definition: pseh2_64.h:7
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:513
NTSTATUS NTAPI PsTerminateProcess(IN PEPROCESS Process, IN NTSTATUS ExitStatus)
Definition: kill.c:129
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:29
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
KPROCESS Pcb
Definition: pstypes.h:1194
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:701
#define _SEH2_TRY
Definition: pseh2_64.h:5
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1415
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:26
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
BOOLEAN NTAPI ExpInitializeCallbacks ( VOID  )

Definition at line 256 of file callback.c.

Referenced by ExpInitSystemPhase1().

257 {
260  UNICODE_STRING DirName = RTL_CONSTANT_STRING(L"\\Callback");
261  UNICODE_STRING CallbackName;
263  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
265  ULONG i;
266 
267  /* Setup lightweight callback lock */
269 
270  /* Initialize the Callback Object type */
271  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
272  RtlInitUnicodeString(&Name, L"Callback");
273  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
274  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
275  ObjectTypeInitializer.GenericMapping = ExpCallbackMapping;
276  ObjectTypeInitializer.PoolType = NonPagedPool;
277  ObjectTypeInitializer.DeleteProcedure = ExpDeleteCallback;
278  ObjectTypeInitializer.ValidAccessMask = CALLBACK_ALL_ACCESS;
279  Status = ObCreateObjectType(&Name,
280  &ObjectTypeInitializer,
281  NULL,
283  if (!NT_SUCCESS(Status)) return FALSE;
284 
285  /* Initialize the Object */
286  InitializeObjectAttributes(&ObjectAttributes,
287  &DirName,
289  NULL,
291 
292  /* Create the Object Directory */
293  Status = NtCreateDirectoryObject(&DirectoryHandle,
295  &ObjectAttributes);
296  if (!NT_SUCCESS(Status)) return FALSE;
297 
298  /* Close Handle... */
299  NtClose(DirectoryHandle);
300 
301  /* Initialize Event used when unregistering */
303 
304  /* Default NT Kernel Callbacks. */
305  for (i = 0; ExpInitializeCallback[i].CallbackObject; i++)
306  {
307  /* Create the name from the structure */
308  RtlInitUnicodeString(&CallbackName, ExpInitializeCallback[i].Name);
309 
310  /* Initialize the Object Attributes Structure */
311  InitializeObjectAttributes(&ObjectAttributes,
312  &CallbackName,
314  NULL,
315  NULL);
316 
317  /* Create the Callback Object */
318  Status = ExCreateCallback(ExpInitializeCallback[i].CallbackObject,
319  &ObjectAttributes,
320  TRUE,
321  TRUE);
322  if (!NT_SUCCESS(Status)) return FALSE;
323  }
324 
325  /* Everything successful */
326  return TRUE;
327 }
ULONG_PTR Value
Definition: extypes.h:465
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define CALLBACK_ALL_ACCESS
Definition: extypes.h:90
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
POBJECT_TYPE ExCallbackObjectType
Definition: callback.c:38
static HANDLE DirectoryHandle
Definition: ObType.c:48
#define OBJ_OPENLINK
Definition: winternl.h:230
NTSTATUS NTAPI ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
Definition: callback.c:361
#define OBJ_PERMANENT
Definition: winternl.h:226
KEVENT ExpCallbackEvent
Definition: callback.c:39
GLenum GLclampf GLint i
Definition: glfuncs.h:14
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
PSECURITY_DESCRIPTOR SePublicDefaultSd
Definition: sd.c:22
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3392
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
Status
Definition: gdiplustypes.h:24
VOID NTAPI ExpDeleteCallback(IN PVOID Object)
Definition: callback.c:236
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:731
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
SYSTEM_CALLBACKS ExpInitializeCallback[]
Definition: callback.c:30
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
PCALLBACK_OBJECT * CallbackObject
Definition: ex.h:107
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
GENERIC_MAPPING ExpCallbackMapping
Definition: callback.c:18
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
BOOLEAN NTAPI ExpInitializeEventImplementation ( VOID  )

Definition at line 43 of file event.c.

Referenced by ExpInitSystemPhase1().

44 {
45  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
48  DPRINT("Creating Event Object Type\n");
49 
50  /* Create the Event Object Type */
51  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
52  RtlInitUnicodeString(&Name, L"Event");
53  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
54  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT);
55  ObjectTypeInitializer.GenericMapping = ExpEventMapping;
56  ObjectTypeInitializer.PoolType = NonPagedPool;
57  ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS;
58  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
59  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventObjectType);
60  if (!NT_SUCCESS(Status)) return FALSE;
61  return TRUE;
62 }
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
#define OBJ_OPENLINK
Definition: winternl.h:230
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
#define FALSE
Definition: types.h:117
GENERIC_MAPPING ExpEventMapping
Definition: event.c:24
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:513
void DPRINT(...)
Definition: polytest.cpp:61
struct _KEVENT KEVENT
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
BOOLEAN NTAPI ExpInitializeEventPairImplementation ( VOID  )

Definition at line 37 of file evtpair.c.

Referenced by ExpInitSystemPhase1().

38 {
39  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
42  DPRINT("Creating Event Pair Object Type\n");
43 
44  /* Create the Event Pair Object Type */
45  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
46  RtlInitUnicodeString(&Name, L"EventPair");
47  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
48  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT_PAIR);
49  ObjectTypeInitializer.GenericMapping = ExEventPairMapping;
50  ObjectTypeInitializer.PoolType = NonPagedPool;
51  ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS;
52  ObjectTypeInitializer.UseDefaultObject = TRUE;
53  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
54  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventPairObjectType);
55  if (!NT_SUCCESS(Status)) return FALSE;
56  return TRUE;
57 }
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
#define OBJ_OPENLINK
Definition: winternl.h:230
struct _KEVENT_PAIR KEVENT_PAIR
#define FALSE
Definition: types.h:117
#define EVENT_PAIR_ALL_ACCESS
Definition: extypes.h:125
smooth NULL
Definition: ftsmooth.c:513
void DPRINT(...)
Definition: polytest.cpp:61
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
GENERIC_MAPPING ExEventPairMapping
Definition: evtpair.c:24
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:22
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
VOID NTAPI ExpInitializeExecutive ( IN ULONG  Cpu,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 914 of file init.c.

Referenced by KiInitializeKernel().

916 {
917  PNLS_DATA_BLOCK NlsData;
918  CHAR Buffer[256];
919  ANSI_STRING AnsiPath;
921  PCHAR CommandLine, PerfMem;
922  ULONG PerfMemUsed;
923  PLDR_DATA_TABLE_ENTRY NtosEntry;
924  PMESSAGE_RESOURCE_ENTRY MsgEntry;
925  ANSI_STRING CSDString;
926  size_t Remaining = 0;
927  PCHAR RcEnd = NULL;
928  CHAR VersionBuffer[65];
929 
930  /* Validate Loader */
931  if (!ExpIsLoaderValid(LoaderBlock))
932  {
933  /* Invalid loader version */
934  KeBugCheckEx(MISMATCHED_HAL,
935  3,
936  LoaderBlock->Extension->Size,
937  LoaderBlock->Extension->MajorVersion,
938  LoaderBlock->Extension->MinorVersion);
939  }
940 
941  /* Initialize PRCB pool lookaside pointers */
943 
944  /* Check if this is an application CPU */
945  if (Cpu)
946  {
947  /* Then simply initialize it with HAL */
948  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
949  {
950  /* Initialization failed */
951  KeBugCheck(HAL_INITIALIZATION_FAILED);
952  }
953 
954  /* We're done */
955  return;
956  }
957 
958  /* Assume no text-mode or remote boot */
961 
962  /* Check if we have a setup loader block */
963  if (LoaderBlock->SetupLdrBlock)
964  {
965  /* Check if this is text-mode setup */
966  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE) ExpInTextModeSetup = TRUE;
967 
968  /* Check if this is network boot */
969  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
970  {
971  /* Set variable */
973 
974  /* Make sure we're actually booting off the network */
975  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
976  }
977  }
978 
979  /* Set phase to 0 */
981 
982  /* Get boot command line */
983  CommandLine = LoaderBlock->LoadOptions;
984  if (CommandLine)
985  {
986  /* Upcase it for comparison and check if we're in performance mode */
987  _strupr(CommandLine);
988  PerfMem = strstr(CommandLine, "PERFMEM");
989  if (PerfMem)
990  {
991  /* Check if the user gave a number of bytes to use */
992  PerfMem = strstr(PerfMem, "=");
993  if (PerfMem)
994  {
995  /* Read the number of pages we'll use */
996  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
997  if (PerfMem)
998  {
999  /* FIXME: TODO */
1000  DPRINT1("BBT performance mode not yet supported."
1001  "/PERFMEM option ignored.\n");
1002  }
1003  }
1004  }
1005 
1006  /* Check if we're burning memory */
1007  PerfMem = strstr(CommandLine, "BURNMEMORY");
1008  if (PerfMem)
1009  {
1010  /* Check if the user gave a number of bytes to use */
1011  PerfMem = strstr(PerfMem, "=");
1012  if (PerfMem)
1013  {
1014  /* Read the number of pages we'll use */
1015  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1016  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1017  }
1018  }
1019  }
1020 
1021  /* Setup NLS Base and offsets */
1022  NlsData = LoaderBlock->NlsData;
1023  ExpNlsTableBase = NlsData->AnsiCodePageData;
1026  (ULONG_PTR)NlsData->AnsiCodePageData);
1028  (ULONG_PTR)NlsData->AnsiCodePageData);
1029 
1030  /* Initialize the NLS Tables */
1037  &ExpNlsTableInfo);
1039 
1040  /* Now initialize the HAL */
1041  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1042  {
1043  /* HAL failed to initialize, bugcheck */
1044  KeBugCheck(HAL_INITIALIZATION_FAILED);
1045  }
1046 
1047  /* Make sure interrupts are active now */
1048  _enable();
1049 
1050  /* Clear the crypto exponent */
1051  SharedUserData->CryptoExponent = 0;
1052 
1053  /* Set global flags for the checked build */
1054 #if DBG
1057 #endif
1058 
1059  /* Setup NT System Root Path */
1060  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1061 
1062  /* Convert to ANSI_STRING and null-terminate it */
1063  RtlInitString(&AnsiPath, Buffer);
1064  Buffer[--AnsiPath.Length] = ANSI_NULL;
1065 
1066  /* Get the string from KUSER_SHARED_DATA's buffer */
1067  RtlInitEmptyUnicodeString(&NtSystemRoot,
1068  SharedUserData->NtSystemRoot,
1069  sizeof(SharedUserData->NtSystemRoot));
1070 
1071  /* Now fill it in */
1072  Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
1073  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1074 
1075  /* Setup bugcheck messages */
1077 
1078  /* Setup initial system settings */
1079  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1080 
1081  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1083  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1084  {
1086  }
1087 
1088  /* Add loaded CmNtGlobalFlag value */
1090 
1091  /* Initialize the executive at phase 0 */
1092  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1093 
1094  /* Initialize the memory manager at phase 0 */
1095  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1096 
1097  /* Load boot symbols */
1098  ExpLoadBootSymbols(LoaderBlock);
1099 
1100  /* Check if we should break after symbol load */
1102 
1103  /* Check if this loader is compatible with NT 5.2 */
1104  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1105  {
1106  /* Setup headless terminal settings */
1107  HeadlessInit(LoaderBlock);
1108  }
1109 
1110  /* Set system ranges */
1111 #ifdef _M_AMD64
1114 #else
1117 #endif
1118 
1119  /* Make a copy of the NLS Tables */
1120  ExpInitNls(LoaderBlock);
1121 
1122  /* Get the kernel's load entry */
1123  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1125  InLoadOrderLinks);
1126 
1127  /* Check if this is a service pack */
1128  if (CmNtCSDVersion & 0xFFFF)
1129  {
1130  /* Get the service pack string */
1131  Status = RtlFindMessage(NtosEntry->DllBase,
1132  11,
1133  0,
1134  WINDOWS_NT_CSD_STRING,
1135  &MsgEntry);
1136  if (NT_SUCCESS(Status))
1137  {
1138  /* Setup the string */
1139  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1140 
1141  /* Remove trailing newline */
1142  while ((CSDString.Length > 0) &&
1143  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1144  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1145  {
1146  /* Skip the trailing character */
1147  CSDString.Length--;
1148  }
1149 
1150  /* Fill the buffer with version information */
1151  Status = RtlStringCbPrintfA(Buffer,
1152  sizeof(Buffer),
1153  "%Z %u%c",
1154  &CSDString,
1155  (CmNtCSDVersion & 0xFF00) >> 8,
1156  (CmNtCSDVersion & 0xFF) ?
1157  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1158  ANSI_NULL);
1159  }
1160  else
1161  {
1162  /* Build default string */
1163  Status = RtlStringCbPrintfA(Buffer,
1164  sizeof(Buffer),
1165  "CSD %04x",
1166  CmNtCSDVersion);
1167  }
1168 
1169  /* Check for success */
1170  if (!NT_SUCCESS(Status))
1171  {
1172  /* Fail */
1173  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1174  }
1175  }
1176  else
1177  {
1178  /* Then this is a beta */
1179  Status = RtlStringCbCopyExA(Buffer,
1180  sizeof(Buffer),
1182  NULL,
1183  &Remaining,
1184  0);
1185  if (!NT_SUCCESS(Status))
1186  {
1187  /* Fail */
1188  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1189  }
1190 
1191  /* Update length */
1192  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1193  }
1194 
1195  /* Check if we have an RC number */
1196  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1197  {
1198  /* Check if we have no version data yet */
1199  if (!(*Buffer))
1200  {
1201  /* Set defaults */
1202  Remaining = sizeof(Buffer);
1203  RcEnd = Buffer;
1204  }
1205  else
1206  {
1207  /* Add comma and space */
1208  Status = RtlStringCbCatExA(Buffer,
1209  sizeof(Buffer),
1210  ", ",
1211  &RcEnd,
1212  &Remaining,
1213  0);
1214  if (!NT_SUCCESS(Status))
1215  {
1216  /* Fail */
1217  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1218  }
1219  }
1220 
1221  /* Add the version format string */
1222  Status = RtlStringCbPrintfA(RcEnd,
1223  Remaining,
1224  "v.%u",
1225  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1226  if (!NT_SUCCESS(Status))
1227  {
1228  /* Fail */
1229  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1230  }
1231  }
1232 
1233  /* Now setup the final string */
1234  RtlInitAnsiString(&CSDString, Buffer);
1236  &CSDString,
1237  TRUE);
1238  if (!NT_SUCCESS(Status))
1239  {
1240  /* Fail */
1241  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1242  }
1243 
1244  /* Add our version */
1245  Status = RtlStringCbPrintfA(VersionBuffer,
1246  sizeof(VersionBuffer),
1247  "%u.%u",
1250  if (!NT_SUCCESS(Status))
1251  {
1252  /* Fail */
1253  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1254  }
1255 
1256  /* Build the final version string */
1258 
1259  /* Check if the user wants a kernel stack trace database */
1261  {
1262  /* FIXME: TODO */
1263  DPRINT1("Kernel-mode stack trace support not yet present."
1264  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1265  }
1266 
1267  /* Check if he wanted exception logging */
1269  {
1270  /* FIXME: TODO */
1271  DPRINT1("Kernel-mode exception logging support not yet present."
1272  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1273  }
1274 
1275  /* Initialize the Handle Table */
1277 
1278 #if DBG
1279  /* On checked builds, allocate the system call count table */
1282  KiServiceLimit * sizeof(ULONG),
1283  'llaC');
1284 
1285  /* Use it for the shadow table too */
1287 
1288  /* Make sure allocation succeeded */
1290  {
1291  /* Zero the call counts to 0 */
1293  KiServiceLimit * sizeof(ULONG));
1294  }
1295 #endif
1296 
1297  /* Create the Basic Object Manager Types to allow new Object Types */
1298  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1299 
1300  /* Load basic Security for other Managers */
1301  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1302 
1303  /* Initialize the Process Manager */
1304  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1305 
1306  /* Initialize the PnP Manager */
1307  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1308 
1309  /* Initialize the User-Mode Debugging Subsystem */
1310  DbgkInitialize();
1311 
1312  /* Calculate the tick count multiplier */
1314  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1315 
1316  /* Set the OS Version */
1317  SharedUserData->NtMajorVersion = NtMajorVersion;
1318  SharedUserData->NtMinorVersion = NtMinorVersion;
1319 
1320  /* Set the machine type */
1321  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1322  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1323 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
#define VER_PRODUCTBETA_STR
Definition: ieverp.h:10
ULONG KeMaximumIncrement
Definition: clock.c:20
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1731
#define TRUE
Definition: types.h:120
UNICODE_STRING NtSystemRoot
Definition: init.c:72
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:84
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG KiServiceLimit
Definition: krnlinit.c:26
VOID NTAPI INIT_FUNCTION ExpInitializeHandleTables(VOID)
Definition: handle.c:27
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:626
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:3614
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char CHAR
Definition: xmlstorage.h:175
void __cdecl _enable(void)
Definition: intrin_arm.h:373
NTSTRSAFEAPI RtlStringCbCatExA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc, _Outptr_opt_result_bytebuffer_(*pcbRemaining) NTSTRSAFE_PSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags)
Definition: ntstrsafe.h:700
#define SETUPLDR_REMOTE_BOOT
Definition: setupblk.h:8
NTSTRSAFEAPI RtlStringCbCopyExA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc, _Outptr_opt_result_bytebuffer_(*pcbRemaining) STRSAFE_LPSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags)
Definition: ntstrsafe.h:270
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD
Definition: pstypes.h:74
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define FLG_ENABLE_CLOSE_EXCEPTIONS
Definition: pstypes.h:82
ULONG NTAPI INIT_FUNCTION ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
Definition: init.c:602
VOID NTAPI INIT_FUNCTION HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
#define VER_PRODUCTBUILD_QFE
Definition: ntverp.h:20
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2028
ULONG CmNtCSDReleaseType
Definition: init.c:57
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:42
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:64
PVOID DllBase
Definition: ldrtypes.h:139
#define sprintf(buf, format,...)
Definition: sprintf.c:55
BOOLEAN NTAPI INIT_FUNCTION ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:761
INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[]
Definition: cmdata.c:139
#define FALSE
Definition: types.h:117
#define ANSI_NULL
Definition: arc.h:130
VOID NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:368
_Check_return_ _CRTIMP int __cdecl _memicmp(_In_reads_bytes_opt_(_Size) const void *_Buf1, _In_reads_bytes_opt_(_Size) const void *_Buf2, _In_ size_t _Size)
VOID INIT_FUNCTION NTAPI DbgkInitialize(VOID)
Definition: dbgkobj.c:1498
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES]
Definition: procobj.c:24
smooth NULL
Definition: ftsmooth.c:513
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
Definition: bufpool.h:45
BOOLEAN NTAPI INIT_FUNCTION ExInitSystem(VOID)
Definition: init.c:735
ULONG CmNtSpBuildNumber
Definition: init.c:55
PVOID OemCodePageData
Definition: arc.h:277
VOID NTAPI INIT_FUNCTION ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:63
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1735
PVOID ExpNlsTableBase
Definition: init.c:81
ULONG NtMinorVersion
Definition: init.c:43
VOID NTAPI INIT_FUNCTION ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:209
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
VOID NTAPI INIT_FUNCTION ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:787
UINTN VOID * Buffer
Definition: acefiex.h:370
BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:199
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
PVOID MmHighestUserAddress
Definition: init.c:51
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:83
UNICODE_STRING CmCSDVersionString
Definition: init.c:59
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
Definition: ntddk_ex.h:202
ULONG ExpInitializationPhase
Definition: init.c:65
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:83
UNICODE_STRING CmVersionString
Definition: init.c:58
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define MM_SYSTEM_RANGE_START_WOW64
Definition: mm.h:29
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
VOID NTAPI INIT_FUNCTION CmGetSystemControlValues(IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
Definition: cmcontrl.c:104
ULONG ExpOemCodePageDataOffset
Definition: init.c:82
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
BOOLEAN ExpInTextModeSetup
Definition: init.c:66
LONG NTSTATUS
Definition: DriverTester.h:11
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
BOOLEAN NTAPI SeInitSystem(VOID)
Definition: semgr.c:192
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
VOID NTAPI INIT_FUNCTION ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:868
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:28
#define DPRINT1
Definition: precomp.h:8
#define DBG_STATUS_CONTROL_C
Definition: kdtypes.h:39
signed char * PCHAR
Definition: retypes.h:7
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[SSDT_MAX_ENTRIES]
Definition: procobj.c:23
ULONG CmNtCSDVersion
Definition: init.c:56
ULONG ExpTickCountMultiplier
Definition: time.c:26
PVOID MmSystemRangeStart
Definition: init.c:52
unsigned int ULONG
Definition: retypes.h:1
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define FLG_KERNEL_STACK_TRACE_DB
Definition: pstypes.h:69
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
ULONG NtGlobalFlag
Definition: init.c:51
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
static __inline NTSTATUS RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1099
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
PVOID UnicodeCodePageData
Definition: arc.h:278
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:82
BOOLEAN KdBreakAfterSymbolLoad
Definition: kdmain.c:19
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:90
BOOLEAN IoRemoteBootClient
Definition: init.c:67
VOID NTAPI ExpInitializeHandleTables ( VOID  )

Definition at line 27 of file handle.c.

Referenced by ExpInitializeExecutive().

28 {
29  /* Initialize the list of handle tables and the lock */
32 }
#define ExInitializePushLock
Definition: ex.h:943
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
LIST_ENTRY HandleTableListHead
Definition: handle.c:18
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation ( VOID  )

Referenced by ExpInitSystemPhase1().

BOOLEAN NTAPI ExpInitializeMutantImplementation ( VOID  )

Definition at line 56 of file mutant.c.

Referenced by ExpInitSystemPhase1().

57 {
58  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
61  DPRINT("Creating Mutant Object Type\n");
62 
63  /* Create the Event Pair Object Type */
64  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
65  RtlInitUnicodeString(&Name, L"Mutant");
66  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
67  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KMUTANT);
68  ObjectTypeInitializer.GenericMapping = ExpMutantMapping;
69  ObjectTypeInitializer.PoolType = NonPagedPool;
70  ObjectTypeInitializer.DeleteProcedure = ExpDeleteMutant;
71  ObjectTypeInitializer.ValidAccessMask = MUTANT_ALL_ACCESS;
72  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
73  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExMutantObjectType);
74  if (!NT_SUCCESS(Status)) return FALSE;
75  return TRUE;
76 }
struct _KMUTANT KMUTANT
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
#define OBJ_OPENLINK
Definition: winternl.h:230
#define FALSE
Definition: types.h:117
#define MUTANT_ALL_ACCESS
Definition: extypes.h:110
VOID NTAPI ExpDeleteMutant(PVOID ObjectBody)
Definition: mutant.c:42
smooth NULL
Definition: ftsmooth.c:513
POBJECT_TYPE ExMutantObjectType
Definition: mutant.c:22
void DPRINT(...)
Definition: polytest.cpp:61
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
GENERIC_MAPPING ExpMutantMapping
Definition: mutant.c:24
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
BOOLEAN NTAPI ExpInitializeProfileImplementation ( VOID  )

Definition at line 68 of file profile.c.

Referenced by ExpInitSystemPhase1().

69 {
70  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
73  DPRINT("Creating Profile Object Type\n");
74 
75  /* Initialize the Mutex to lock the States */
77 
78  /* Create the Event Pair Object Type */
79  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
80  RtlInitUnicodeString(&Name, L"Profile");
81  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
82  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KPROFILE);
83  ObjectTypeInitializer.GenericMapping = ExpProfileMapping;
84  ObjectTypeInitializer.PoolType = NonPagedPool;
85  ObjectTypeInitializer.DeleteProcedure = ExpDeleteProfile;
86  ObjectTypeInitializer.ValidAccessMask = PROFILE_ALL_ACCESS;
87  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
88  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExProfileObjectType);
89  if (!NT_SUCCESS(Status)) return FALSE;
90  return TRUE;
91 }
KMUTEX ExpProfileMutex
Definition: profile.c:25
POBJECT_TYPE ExProfileObjectType
Definition: profile.c:24
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
#define OBJ_OPENLINK
Definition: winternl.h:230
#define FALSE
Definition: types.h:117
VOID NTAPI ExpDeleteProfile(PVOID ObjectBody)
Definition: profile.c:39
smooth NULL
Definition: ftsmooth.c:513
void DPRINT(...)
Definition: polytest.cpp:61
GENERIC_MAPPING ExpProfileMapping
Definition: profile.c:27
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define PROFILE_ALL_ACCESS
Definition: extypes.h:131
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
struct _KPROFILE KPROFILE
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
VOID NTAPI ExpInitializePushLocks ( VOID  )

Definition at line 45 of file pushlock.c.

Referenced by ExpInitSystemPhase1().

46 {
47 #ifdef CONFIG_SMP
48  /* Initialize an internal 1024-iteration spin for MP CPUs */
49  if (KeNumberProcessors > 1)
50  ExPushLockSpinCount = 1024;
51 #endif
52 }
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
ULONG ExPushLockSpinCount
Definition: pushlock.c:17
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation ( VOID  )

Definition at line 43 of file sem.c.

Referenced by ExpInitSystemPhase1().

44 {
45  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
48  DPRINT("Creating Semaphore Object Type\n");
49 
50  /* Create the Event Pair Object Type */
51  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
52  RtlInitUnicodeString(&Name, L"Semaphore");
53  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
54  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KSEMAPHORE);
55  ObjectTypeInitializer.GenericMapping = ExSemaphoreMapping;
56  ObjectTypeInitializer.PoolType = NonPagedPool;
57  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
58  ObjectTypeInitializer.ValidAccessMask = SEMAPHORE_ALL_ACCESS;
59  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExSemaphoreObjectType);
60  if (!NT_SUCCESS(Status)) return FALSE;
61  return TRUE;
62 }
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
#define OBJ_OPENLINK
Definition: winternl.h:230
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
void DPRINT(...)
Definition: polytest.cpp:61
GENERIC_MAPPING ExSemaphoreMapping
Definition: sem.c:24
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
struct _KSEMAPHORE KSEMAPHORE
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:158
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:22
BOOLEAN NTAPI ExpInitializeTimerImplementation ( VOID  )

Definition at line 223 of file timer.c.

Referenced by ExpInitSystemPhase1().

224 {
225  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
228 
229  /* Create the Timer Object Type */
230  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
231  RtlInitUnicodeString(&Name, L"Timer");
232  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
233  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
234  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(ETIMER);
235  ObjectTypeInitializer.GenericMapping = ExpTimerMapping;
236  ObjectTypeInitializer.PoolType = NonPagedPool;
237  ObjectTypeInitializer.ValidAccessMask = TIMER_ALL_ACCESS;
238  ObjectTypeInitializer.DeleteProcedure = ExpDeleteTimer;
239  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExTimerType);
240  if (!NT_SUCCESS(Status)) return FALSE;
241 
242  /* Initialize the Wait List and Lock */
245  return TRUE;
246 }
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
#define OBJ_OPENLINK
Definition: winternl.h:230
static GENERIC_MAPPING ExpTimerMapping
Definition: timer.c:24
#define FALSE
Definition: types.h:117
LIST_ENTRY ExpWakeList
Definition: timer.c:21
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:513
VOID NTAPI ExpDeleteTimer(IN PVOID ObjectBody)
Definition: timer.c:108
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
POBJECT_TYPE ExTimerType
Definition: timer.c:18
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
struct _ETIMER ETIMER
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
KSPIN_LOCK ExpWakeListLock
Definition: timer.c:20
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
VOID NTAPI ExpInitializeWorkerThreads ( VOID  )

Definition at line 520 of file work.c.

Referenced by ExpInitSystemPhase1().

521 {
522  ULONG WorkQueueType;
523  ULONG CriticalThreads, DelayedThreads;
524  HANDLE ThreadHandle;
526  ULONG i;
527 
528  /* Setup the stack swap support */
532 
533  /* Set the number of critical and delayed threads. We shouldn't hardcode */
534  DelayedThreads = EX_DELAYED_WORK_THREADS;
535  CriticalThreads = EX_CRITICAL_WORK_THREADS;
536 
537  /* Protect against greedy registry modifications */
542 
543  /* Calculate final count */
544  DelayedThreads += ExpAdditionalDelayedWorkerThreads;
545  CriticalThreads += ExpAdditionalCriticalWorkerThreads;
546 
547  /* Initialize the Array */
548  for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++)
549  {
550  /* Clear the structure and initialize the queue */
551  RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE));
552  KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0);
553  }
554 
555  /* Dynamic threads are only used for the critical queue */
557 
558  /* Initialize the balance set manager events */
562  FALSE);
563 
564  /* Create the built-in worker threads for the critical queue */
565  for (i = 0; i < CriticalThreads; i++)
566  {
567  /* Create the thread */
570  }
571 
572  /* Create the built-in worker threads for the delayed queue */
573  for (i = 0; i < DelayedThreads; i++)
574  {
575  /* Create the thread */
578  }
579 
580  /* Create the built-in worker thread for the hypercritical queue */
582 
583  /* Create the balance set manager thread */
584  PsCreateSystemThread(&ThreadHandle,
586  NULL,
587  0,
588  NULL,
590  NULL);
591 
592  /* Get a pointer to it for the shutdown process */
593  ObReferenceObjectByHandle(ThreadHandle,
595  NULL,
596  KernelMode,
597  (PVOID*)&Thread,
598  NULL);
600 
601  /* Close the handle and return */
602  ObCloseHandle(ThreadHandle, KernelMode);
603 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define TRUE
Definition: types.h:120
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:253
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:50
PETHREAD ExpWorkerThreadBalanceManagerPtr
Definition: work.c:53
GLenum GLclampf GLint i
Definition: glfuncs.h:14
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:388
#define FALSE
Definition: types.h:117
#define EX_CRITICAL_WORK_THREADS
Definition: work.c:24
smooth NULL
Definition: ftsmooth.c:513
LIST_ENTRY ExpWorkerListHead
Definition: work.c:45
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3369
ULONG ExpCriticalWorkerThreads
Definition: work.c:38
KEVENT ExpThreadSetManagerEvent
Definition: work.c:49
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:46
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
#define EX_DELAYED_WORK_THREADS
Definition: work.c:23
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
ULONG ExpDelayedWorkerThreads
Definition: work.c:39
#define min(a, b)
Definition: monoChain.cc:55
ULONG MakeThreadsAsNecessary
Definition: extypes.h:400
VOID NTAPI KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL)
Definition: queue.c:148
ULONG ExpAdditionalCriticalWorkerThreads
Definition: work.c:40
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOLEAN ExpWorkersCanSwap
Definition: work.c:44
EX_QUEUE_WORKER_INFO Info
Definition: extypes.h:412
ULONG ExpAdditionalDelayedWorkerThreads
Definition: work.c:41
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
Definition: work.c:423
VOID NTAPI ExpInitLookasideLists ( VOID  )

Definition at line 93 of file lookas.c.

94 {
95  ULONG i;
96 
97  /* Initialize locks and lists */
104 
105  /* Initialize the system lookaside lists */
106  for (i = 0; i < MAXIMUM_PROCESSORS; i++)
107  {
108  /* Initialize the non-paged list */
110  NonPagedPool,
111  (i + 1) * 8,
112  'looP',
113  256,
115 
116  /* Initialize the paged list */
118  PagedPool,
119  (i + 1) * 8,
120  'looP',
121  256,
123  }
124 }
#define MAXIMUM_PROCESSORS
Definition: rwlock.h:5
LIST_ENTRY ExPoolLookasideListHead
Definition: lookas.c:26
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:27
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:21
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:28
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:24
VOID NTAPI INIT_FUNCTION 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
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:22
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int ULONG
Definition: retypes.h:1
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:23
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:25
VOID NTAPI ExpInitUuids ( VOID  )

Definition at line 51 of file uuid.c.

Referenced by ExpInitSystemPhase1().

52 {
54 
57 
60 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
static UCHAR UuidSeed[SEED_BUFFER_SIZE]
Definition: uuid.c:41
static FAST_MUTEX UuidMutex
Definition: uuid.c:36
static ULARGE_INTEGER UuidLastTime
Definition: uuid.c:37
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
static ULONG UuidCount
Definition: uuid.c:42
#define TICKS_15_OCT_1582_TO_1601
Definition: uuid.c:27
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define TICKS_PER_CLOCK_TICK
Definition: uuid.c:21
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define SEED_BUFFER_SIZE
Definition: uuid.c:17
BOOLEAN NTAPI ExpLockHandleTableEntry ( IN PHANDLE_TABLE  HandleTable,
IN PHANDLE_TABLE_ENTRY  HandleTableEntry 
)

Definition at line 844 of file handle.c.

Referenced by ExChangeHandle(), ExDestroyHandle(), ExDupHandleTable(), ExEnumHandleTable(), ExMapHandleToPointer(), ExSweepHandleTable(), and QSI_DEF().

846 {
847  LONG_PTR NewValue, OldValue;
848 
849  /* Sanity check */
850  ASSERT((KeGetCurrentThread()->CombinedApcDisable != 0) ||
851  (KeGetCurrentIrql() == APC_LEVEL));
852 
853  /* Start lock loop */
854  for (;;)
855  {
856  /* Get the current value and check if it's locked */
857  OldValue = *(volatile LONG_PTR *)&HandleTableEntry->Object;
858  if (OldValue & EXHANDLE_TABLE_ENTRY_LOCK_BIT)
859  {
860  /* It's not locked, remove the lock bit to lock it */
861  NewValue = OldValue & ~EXHANDLE_TABLE_ENTRY_LOCK_BIT;
862  if (InterlockedCompareExchangePointer(&HandleTableEntry->Object,
863  (PVOID)NewValue,
864  (PVOID)OldValue) == (PVOID)OldValue)
865  {
866  /* We locked it, get out */
867  return TRUE;
868  }
869  }
870  else
871  {
872  /* We couldn't lock it, bail out if it's been freed */
873  if (!OldValue) return FALSE;
874  }
875 
876  /* It's locked, wait for it to be unlocked */
877  ExpBlockOnLockedHandleEntry(HandleTable, HandleTableEntry);
878  }
879 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define TRUE
Definition: types.h:120
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
VOID NTAPI ExpBlockOnLockedHandleEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:818
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
#define FALSE
Definition: types.h:117
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
if(!(yy_init))
Definition: macro.lex.yy.c:704
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:131
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define KeGetCurrentThread
Definition: hal.h:44
#define APC_LEVEL
Definition: env_spec_w32.h:695
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry ( IN PHANDLE_TABLE  HandleTable,
IN EXHANDLE  Handle 
)

Definition at line 36 of file handle.c.

Referenced by ExChangeHandle(), ExDestroyHandle(), ExDupHandleTable(), ExEnumHandleTable(), ExMapHandleToPointer(), ExpAllocateHandleTableEntry(), ExpFreeHandleTableEntry(), ExSweepHandleTable(), and QSI_DEF().

38 {
39  ULONG TableLevel;
40  ULONG_PTR TableBase;
41  PHANDLE_TABLE_ENTRY HandleArray, Entry;
42  PVOID *PointerArray;
43 
44  /* Clear the tag bits */
45  Handle.TagBits = 0;
46 
47  /* Check if the handle is in the allocated range */
48  if (Handle.Value >= HandleTable->NextHandleNeedingPool)
49  {
50  return NULL;
51  }
52 
53  /* Get the table code */
54  TableBase = HandleTable->TableCode;
55 
56  /* Extract the table level and actual table base */
57  TableLevel = (ULONG)(TableBase & 3);
58  TableBase &= ~3;
59 
60  PointerArray = (PVOID*)TableBase;
61  HandleArray = (PHANDLE_TABLE_ENTRY)TableBase;
62 
63  /* Check what level we're running at */
64  switch (TableLevel)
65  {
66  case 2:
67 
68  /* Get the mid level pointer array */
69  PointerArray = PointerArray[Handle.HighIndex];
70 
71  /* Fall through */
72  case 1:
73 
74  /* Get the handle array */
75  HandleArray = PointerArray[Handle.MidIndex];
76 
77  /* Fall through */
78  case 0:
79 
80  /* Get the entry using the low index */
81  Entry = &HandleArray[Handle.LowIndex];
82 
83  /* All done */
84  break;
85 
86  default:
87 
88  ASSERT(FALSE);
89  Entry = NULL;
90  }
91 
92  /* Return the handle entry */
93  return Entry;
94 }
DWORD *typedef PVOID
Definition: winlogon.h:52
struct _Entry Entry
Definition: kefuncs.h:640
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
static EMS_HANDLE HandleTable[EMS_MAX_HANDLES]
Definition: emsdrv.c:40
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define FALSE
Definition: types.h:117
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:513
struct _HANDLE_TABLE_ENTRY * PHANDLE_TABLE_ENTRY
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExpResourceInitialization ( VOID  )

Definition at line 169 of file resource.c.

Referenced by ExpInitSystemPhase0().

170 {
171  /* Setup the timeout */
172  ExpTimeout.QuadPart = Int32x32To64(4, -10000000);
175 }
KSPIN_LOCK ExpResourceSpinLock
Definition: resource.c:75
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
LARGE_INTEGER ExpTimeout
Definition: resource.c:73
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ExpSystemResourcesList
Definition: resource.c:76
#define Int32x32To64(a, b)
LONGLONG QuadPart
Definition: typedefs.h:113
NTSTATUS ExpSetTimeZoneInformation ( IN PTIME_ZONE_INFORMATION  TimeZoneInformation)
BOOLEAN NTAPI ExpWin32kInit ( VOID  )

Definition at line 263 of file win32k.c.

Referenced by ExpInitSystemPhase1().

264 {
265  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
268  DPRINT("Creating Win32 Object Types\n");
269 
270  /* Create the window station Object Type */
271  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
272  RtlInitUnicodeString(&Name, L"WindowStation");
273  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
274  ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping;
275  ObjectTypeInitializer.PoolType = NonPagedPool;
276  ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete;
277  ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse;
278  ObjectTypeInitializer.OkayToCloseProcedure = ExpWindowStationOkToClose;
279  ObjectTypeInitializer.SecurityRequired = TRUE;
280  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK |
281  OBJ_PERMANENT |
283  ObjectTypeInitializer.ValidAccessMask = STANDARD_RIGHTS_REQUIRED;
284  Status = ObCreateObjectType(&Name,
285  &ObjectTypeInitializer,
286  NULL,
288  if (!NT_SUCCESS(Status)) return FALSE;
289 
290  /* Create desktop object type */
291  RtlInitUnicodeString(&Name, L"Desktop");
292  ObjectTypeInitializer.GenericMapping = ExpDesktopMapping;
293  ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete;
294  ObjectTypeInitializer.ParseProcedure = NULL;
295  ObjectTypeInitializer.OkayToCloseProcedure = ExpDesktopOkToClose;
296  ObjectTypeInitializer.OpenProcedure = ExpDesktopOpen;
297  ObjectTypeInitializer.CloseProcedure = ExpDesktopClose;
298  Status = ObCreateObjectType(&Name,
299  &ObjectTypeInitializer,
300  NULL,
302  if (!NT_SUCCESS(Status)) return FALSE;
303 
304  return TRUE;
305 }
NTSTATUS NTAPI ExpWinStaObjectParse(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: win32k.c:175
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1034
#define TRUE
Definition: types.h:120
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
Definition: bidi.c:75
OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure
Definition: obtypes.h:373
#define OBJ_OPENLINK
Definition: winternl.h:230
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
#define OBJ_PERMANENT
Definition: winternl.h:226
#define FALSE
Definition: types.h:117
VOID NTAPI ExpDesktopClose(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
Definition: win32k.c:241
smooth NULL
Definition: ftsmooth.c:513
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
void DPRINT(...)
Definition: polytest.cpp:61
OB_CLOSE_METHOD CloseProcedure
Definition: obtypes.h:368
GENERIC_MAPPING ExpWindowStationMapping
Definition: win32k.c:28
OB_PARSE_METHOD ParseProcedure
Definition: obtypes.h:370
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
BOOLEAN NTAPI ExpDesktopOkToClose(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: win32k.c:117
VOID NTAPI ExpDesktopDelete(PVOID DeletedObject)
Definition: win32k.c:206
OB_OPEN_METHOD OpenProcedure
Definition: obtypes.h:367
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING ExpDesktopMapping
Definition: win32k.c:36
VOID NTAPI ExpWinStaObjectDelete(PVOID DeletedObject)
Definition: win32k.c:161
#define NT_SUCCESS(StatCode)
Definition: cmd.c:149
BOOLEAN NTAPI ExpWindowStationOkToClose(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: win32k.c:139
LONG NTSTATUS
Definition: DriverTester.h:11
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSTATUS NTAPI ExpDesktopOpen(IN OB_OPEN_REASON Reason, IN PEPROCESS Process OPTIONAL, IN PVOID ObjectBody, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount)
Definition: win32k.c:220
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock ( IN OUT PEX_CALLBACK  CallBack)

Definition at line 122 of file callback.c.

Referenced by ExDoCallBack(), PsRemoveCreateThreadNotifyRoutine(), PsRemoveLoadImageNotifyRoutine(), and PsSetCreateProcessNotifyRoutine().

123 {
124  EX_FAST_REF OldValue;
126  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
127 
128  /* Acquire a reference */
129  OldValue = ExAcquireFastReference(&CallBack->RoutineBlock);
130  Count = ExGetCountFastReference(OldValue);
131 
132  /* Fail if there isn't any object */
133  if (!ExGetObjectFastReference(OldValue)) return NULL;
134 
135  /* Check if we don't have a reference */
136  if (!Count)
137  {
138  /* FIXME: Race */
139  DPRINT1("Unhandled callback race condition\n");
140  ASSERT(FALSE);
141  return NULL;
142  }
143 
144  /* Get the callback block */
145  CallbackBlock = ExGetObjectFastReference(OldValue);
146 
147  /* Check if this is the last reference */
148  if (Count == 1)
149  {
150  /* Acquire rundown protection */
151  if (ExfAcquireRundownProtectionEx(&CallbackBlock->RundownProtect,
152  MAX_FAST_REFS))
153  {
154  /* Insert references */
155  if (!ExInsertFastReference(&CallBack->RoutineBlock, CallbackBlock))
156  {
157  /* Backdown the rundown acquire */
159  MAX_FAST_REFS);
160  }
161  }
162  }
163 
164  /* Return the callback block */
165  return CallbackBlock;
166 }
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:520
FORCEINLINE BOOLEAN ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:586
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
uint32_t ULONG_PTR
Definition: typedefs.h:64
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:557
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:528
VOID FASTCALL ExfReleaseRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:259
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:77
EX_RUNDOWN_REF RundownProtect
Definition: extypes.h:537
#define DPRINT1
Definition: precomp.h:8
#define MAX_FAST_REFS
Definition: ex.h:118
BOOLEAN NTAPI ExRefreshTimeZoneInformation ( IN PLARGE_INTEGER  SystemBootTime)

Definition at line 226 of file time.c.

Referenced by Phase1InitializationDiscard().

227 {
228  LARGE_INTEGER CurrentTime;
230 
231  /* Read time zone information from the registry */
233  if (!NT_SUCCESS(Status))
234  {
235  /* Failed, clear all data */
239  }
240  else
241  {
242  /* FIXME: Calculate transition dates */
243 
244  /* Set bias and ID */
249  }
250 
251  /* Change it for user-mode applications */
252  SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
253  SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
254  SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
255  SharedUserData->TimeZoneId = ExpTimeZoneId;
256 
257  /* Convert boot time from local time to UTC */
259 
260  /* Convert system time from local time to UTC */
261  do
262  {
263  CurrentTime.u.HighPart = SharedUserData->SystemTime.High1Time;
264  CurrentTime.u.LowPart =