ReactOS  0.4.12-dev-418-g3df31a8
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 HANDLE_TAG_BITS   (2)
 
#define HANDLE_INDEX_BITS   (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)
 
#define KERNEL_FLAG_BITS   (sizeof(PVOID)*8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)
 
#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 InterlockedCompareExchangeSizeT(Destination, Exchange, Comperand)   (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(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_PARAMETERSPHARDERROR_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)
 
INIT_FUNCTION BOOLEAN NTAPI ExpWin32kInit (VOID)
 
VOID NTAPI ExInit2 (VOID)
 
VOID NTAPI Phase1Initialization (IN PVOID Context)
 
INIT_FUNCTION VOID NTAPI ExpInitializePushLocks (VOID)
 
BOOLEAN NTAPI ExRefreshTimeZoneInformation (IN PLARGE_INTEGER SystemBootTime)
 
INIT_FUNCTION VOID NTAPI ExpInitializeWorkerThreads (VOID)
 
VOID NTAPI ExSwapinWorkerThreads (IN BOOLEAN AllowSwap)
 
INIT_FUNCTION VOID NTAPI ExpInitLookasideLists (VOID)
 
INIT_FUNCTION VOID NTAPI ExInitializeSystemLookasideList (IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeCallbacks (VOID)
 
INIT_FUNCTION VOID NTAPI ExpInitUuids (VOID)
 
INIT_FUNCTION VOID NTAPI ExpInitializeExecutive (IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI ExShutdownSystem (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeEventImplementation (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeKeyedEventImplementation (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeEventPairImplementation (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeSemaphoreImplementation (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeMutantImplementation (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeTimerImplementation (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExpInitializeProfileImplementation (VOID)
 
INIT_FUNCTION VOID NTAPI ExpResourceInitialization (VOID)
 
INIT_FUNCTION 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)
 
INIT_FUNCTION 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 PEX_RUNDOWN_REF ExGetRunRefForGivenProcessor (IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, IN ULONG ProcNumber)
 
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 PRTL_TIME_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)
 
INIT_FUNCTION VOID NTAPI HeadlessInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION VOID NTAPI XIPInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 

Variables

RTL_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 ExCriticalWorkerThreads
 
ULONG ExDelayedWorkerThreads
 
PVOID ExpDefaultErrorPort
 
PEPROCESS ExpDefaultErrorPortProcess
 
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

◆ ExAcquireRundownProtection

#define ExAcquireRundownProtection   _ExAcquireRundownProtection

Definition at line 130 of file ex.h.

◆ ExfInterlockedCompareExchange64UL

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

Definition at line 1514 of file ex.h.

◆ ExGetPreviousMode

#define ExGetPreviousMode   KeGetPreviousMode

Definition at line 135 of file ex.h.

◆ EXHANDLE_TABLE_ENTRY_LOCK_BIT

#define EXHANDLE_TABLE_ENTRY_LOCK_BIT   1

Definition at line 141 of file ex.h.

◆ ExInitializePushLock

#define ExInitializePushLock   _ExInitializePushLock

Definition at line 985 of file ex.h.

◆ ExInitializeRundownProtection

#define ExInitializeRundownProtection   _ExInitializeRundownProtection

Definition at line 132 of file ex.h.

◆ ExpChangePushlock

#define ExpChangePushlock (   x,
  y,
  z 
)    InterlockedCompareExchangePointer((PVOID*)x, (PVOID)y, (PVOID)z)

Definition at line 159 of file ex.h.

◆ ExpChangeRundown

#define ExpChangeRundown (   x,
  y,
  z 
)    (ULONG_PTR)InterlockedCompareExchangePointer(&x->Ptr, (PVOID)y, (PVOID)z)

Definition at line 158 of file ex.h.

◆ ExpSetRundown

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

Definition at line 160 of file ex.h.

◆ ExReleaseRundownProtection

#define ExReleaseRundownProtection   _ExReleaseRundownProtection

Definition at line 131 of file ex.h.

◆ ExRundownCompleted

#define ExRundownCompleted   _ExRundownCompleted

Definition at line 134 of file ex.h.

◆ ExWaitForRundownProtectionRelease

#define ExWaitForRundownProtectionRelease   _ExWaitForRundownProtectionRelease

Definition at line 133 of file ex.h.

◆ FREE_HANDLE_MASK

#define FREE_HANDLE_MASK   -1

Definition at line 142 of file ex.h.

◆ HANDLE_HIGH_BITS

#define HANDLE_HIGH_BITS   (PAGE_SHIFT - 2)

Definition at line 75 of file ex.h.

◆ HANDLE_INDEX_BITS

#define HANDLE_INDEX_BITS   (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)

Definition at line 78 of file ex.h.

◆ HANDLE_LOW_BITS

#define HANDLE_LOW_BITS   (PAGE_SHIFT - 3)

Definition at line 74 of file ex.h.

◆ HANDLE_TAG_BITS

#define HANDLE_TAG_BITS   (2)

Definition at line 77 of file ex.h.

◆ HIGH_LEVEL_ENTRIES

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

Definition at line 149 of file ex.h.

◆ InterlockedCompareExchangeSizeT

#define InterlockedCompareExchangeSizeT (   Destination,
  Exchange,
  Comperand 
)    (SIZE_T)InterlockedCompareExchangePointer((PVOID*)(Destination), (PVOID)(SIZE_T)(Exchange), (PVOID)(SIZE_T)(Comperand))

Definition at line 1511 of file ex.h.

◆ InterlockedCompareExchangeUL

#define InterlockedCompareExchangeUL (   Destination,
  Exchange,
  Comperand 
)    (ULONG)InterlockedCompareExchange((PLONG)(Destination), (LONG)(Exchange), (LONG)(Comperand))

Definition at line 1508 of file ex.h.

◆ InterlockedDecrementUL

#define InterlockedDecrementUL (   Addend)    (ULONG)InterlockedDecrement((PLONG)(Addend))

Definition at line 1496 of file ex.h.

◆ InterlockedExchangeAddUL

#define InterlockedExchangeAddUL (   Addend,
  Value 
)    (ULONG)InterlockedExchangeAdd((PLONG)(Addend), (LONG)(Value))

Definition at line 1505 of file ex.h.

◆ InterlockedExchangeUL

#define InterlockedExchangeUL (   Target,
  Value 
)    (ULONG)InterlockedExchange((PLONG)(Target), (LONG)(Value))

Definition at line 1502 of file ex.h.

◆ InterlockedIncrementUL

#define InterlockedIncrementUL (   Addend)    (ULONG)InterlockedIncrement((PLONG)(Addend))

Definition at line 1499 of file ex.h.

◆ KERNEL_FLAG_BITS

#define KERNEL_FLAG_BITS   (sizeof(PVOID)*8 - HANDLE_INDEX_BITS - HANDLE_TAG_BITS)

Definition at line 79 of file ex.h.

◆ LOW_LEVEL_ENTRIES

#define LOW_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))

Definition at line 147 of file ex.h.

◆ MAX_FAST_REFS

#define MAX_FAST_REFS   7

Definition at line 128 of file ex.h.

◆ MAX_HIGH_INDEX

Definition at line 156 of file ex.h.

◆ MAX_LOW_INDEX

#define MAX_LOW_INDEX   LOW_LEVEL_ENTRIES

Definition at line 154 of file ex.h.

◆ MAX_MID_INDEX

#define MAX_MID_INDEX   (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)

Definition at line 155 of file ex.h.

◆ MID_LEVEL_ENTRIES

#define MID_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))

Definition at line 148 of file ex.h.

Typedef Documentation

◆ ETIMER

◆ EXHANDLE

typedef union _EXHANDLE EXHANDLE

◆ HARDERROR_USER_PARAMETERS

◆ PETIMER

typedef struct _ETIMER * PETIMER

◆ PEX_CHANGE_HANDLE_CALLBACK

typedef BOOLEAN(NTAPI * PEX_CHANGE_HANDLE_CALLBACK) (PHANDLE_TABLE_ENTRY HandleTableEntry, ULONG_PTR Context)

Definition at line 421 of file ex.h.

◆ PEX_DUPLICATE_HANDLE_CALLBACK

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 413 of file ex.h.

◆ PEX_SWEEP_HANDLE_CALLBACK

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

Definition at line 406 of file ex.h.

◆ PEXHANDLE

typedef union _EXHANDLE * PEXHANDLE

◆ PHARDERROR_USER_PARAMETERS

◆ WINKD_WORKER_STATE

Enumeration Type Documentation

◆ _WINKD_WORKER_STATE

Enumerator
WinKdWorkerReady 
WinKdWorkerStart 
WinKdWorkerInitialized 

Definition at line 54 of file ex.h.

55 {
56  WinKdWorkerReady = 0,
enum _WINKD_WORKER_STATE WINKD_WORKER_STATE

Function Documentation

◆ _ExAcquireFastMutex()

FORCEINLINE VOID _ExAcquireFastMutex ( IN PFAST_MUTEX  FastMutex)

Definition at line 1347 of file ex.h.

1348 {
1349  KIRQL OldIrql;
1351 
1352  /* Raise IRQL to APC */
1354 
1355  /* Decrease the count */
1356  if (InterlockedDecrement(&FastMutex->Count))
1357  {
1358  /* Someone is still holding it, use slow path */
1359  KiAcquireFastMutex(FastMutex);
1360  }
1361 
1362  /* Set the owner and IRQL */
1363  FastMutex->Owner = KeGetCurrentThread();
1364  FastMutex->OldIrql = OldIrql;
1365 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
UCHAR KIRQL
Definition: env_spec_w32.h:591
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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

Referenced by ExAcquireFastMutex().

◆ _ExAcquireFastMutexUnsafe()

FORCEINLINE VOID _ExAcquireFastMutexUnsafe ( IN PFAST_MUTEX  FastMutex)

Definition at line 1302 of file ex.h.

1303 {
1305 
1306  /* Sanity check */
1308  (Thread->CombinedApcDisable != 0) ||
1309  (Thread->Teb == NULL) ||
1310  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1311  ASSERT(FastMutex->Owner != Thread);
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 */
1321  FastMutex->Owner = Thread;
1322 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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

Referenced by _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(), and ExAcquireFastMutexUnsafe().

◆ _ExAcquireRundownProtection()

FORCEINLINE BOOLEAN _ExAcquireRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 792 of file ex.h.

793 {
794  ULONG_PTR Value, NewValue;
795 
796  /* Get the current value and mask the active bit */
797  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
798 
799  /* Add a reference */
800  NewValue = Value + EX_RUNDOWN_COUNT_INC;
801 
802  /* Change the value */
803  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
804  if (NewValue != Value)
805  {
806  /* Rundown was active, use long path */
807  return ExfAcquireRundownProtection(RunRef);
808  }
809 
810  /* Success */
811  return TRUE;
812 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define TRUE
Definition: types.h:120
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ExpChangeRundown(x, y, z)
Definition: ex.h:158
BOOLEAN FASTCALL ExfAcquireRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
#define EX_RUNDOWN_ACTIVE

Referenced by ExfAcquireRundownProtectionCacheAware().

◆ _ExEnterCriticalRegionAndAcquireFastMutexUnsafe()

FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1418 of file ex.h.

1419 {
1420  /* Enter the Critical Region */
1422 
1423  /* Acquire the mutex unsafely */
1424  _ExAcquireFastMutexUnsafe(FastMutex);
1425 }
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1302

Referenced by ExEnterCriticalRegionAndAcquireFastMutexUnsafe().

◆ _ExInitializePushLock()

FORCEINLINE VOID _ExInitializePushLock ( OUT PEX_PUSH_LOCK  PushLock)

Definition at line 980 of file ex.h.

981 {
982  /* Set the value to 0 */
983  PushLock->Ptr = 0;
984 }

◆ _ExInitializeRundownProtection()

FORCEINLINE VOID _ExInitializeRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 876 of file ex.h.

877 {
878  /* Set the count to zero */
879  RunRef->Count = 0;
880 }

Referenced by ExAllocateCacheAwareRundownProtection(), and ExInitializeRundownProtectionCacheAware().

◆ _ExReleaseFastMutex()

FORCEINLINE VOID _ExReleaseFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1369 of file ex.h.

1370 {
1371  KIRQL OldIrql;
1373 
1374  /* Erase the owner */
1375  FastMutex->Owner = NULL;
1376  OldIrql = (KIRQL)FastMutex->OldIrql;
1377 
1378  /* Increase the count */
1379  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1380  {
1381  /* Someone was waiting for it, signal the waiter */
1382  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1383  }
1384 
1385  /* Lower IRQL back */
1387 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:717
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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

Referenced by ExReleaseFastMutex().

◆ _ExReleaseFastMutexUnsafe()

FORCEINLINE VOID _ExReleaseFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1326 of file ex.h.

1327 {
1329  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1330  (KeGetCurrentThread()->Teb == NULL) ||
1332  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1333 
1334  /* Erase the owner */
1335  FastMutex->Owner = NULL;
1336 
1337  /* Increase the count */
1338  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1339  {
1340  /* Someone was waiting for it, signal the waiter */
1341  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1342  }
1343 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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

Referenced by _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(), and ExReleaseFastMutexUnsafe().

◆ _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion()

FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1429 of file ex.h.

1430 {
1431  /* Release the mutex unsafely */
1432  _ExReleaseFastMutexUnsafe(FastMutex);
1433 
1434  /* Leave the critical region */
1436 }
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1326

Referenced by ExReleaseFastMutexUnsafeAndLeaveCriticalRegion().

◆ _ExReleaseRundownProtection()

FORCEINLINE VOID _ExReleaseRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 833 of file ex.h.

834 {
835  ULONG_PTR Value, NewValue;
836 
837  /* Get the current value and mask the active bit */
838  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
839 
840  /* Remove a reference */
841  NewValue = Value - EX_RUNDOWN_COUNT_INC;
842 
843  /* Change the value */
844  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
845 
846  /* Check if the rundown was active */
847  if (NewValue != Value)
848  {
849  /* Rundown was active, use long path */
851  }
852  else
853  {
854  /* Sanity check */
856  }
857 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ExpChangeRundown(x, y, z)
Definition: ex.h:158
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
VOID FASTCALL ExfReleaseRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
#define EX_RUNDOWN_ACTIVE

Referenced by ExfReleaseRundownProtectionCacheAware().

◆ _ExRundownCompleted()

FORCEINLINE VOID _ExRundownCompleted ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 930 of file ex.h.

931 {
932  /* Sanity check */
933  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
934 
935  /* Mark the counter as active */
937 }
#define ExpSetRundown(x, y)
Definition: ex.h:160
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define EX_RUNDOWN_ACTIVE

◆ _ExTryToAcquireFastMutex()

FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1391 of file ex.h.

1392 {
1393  KIRQL OldIrql;
1395 
1396  /* Raise to APC_LEVEL */
1398 
1399  /* Check if we can quickly acquire it */
1400  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1401  {
1402  /* We have, set us as owners */
1403  FastMutex->Owner = KeGetCurrentThread();
1404  FastMutex->OldIrql = OldIrql;
1405  return TRUE;
1406  }
1407  else
1408  {
1409  /* Acquire attempt failed */
1411  YieldProcessor();
1412  return FALSE;
1413  }
1414 }
#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
#define InterlockedCompareExchange
Definition: interlocked.h:104
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
UCHAR KIRQL
Definition: env_spec_w32.h:591
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_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

Referenced by ExTryToAcquireFastMutex().

◆ _ExWaitForRundownProtectionRelease()

FORCEINLINE VOID _ExWaitForRundownProtectionRelease ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 900 of file ex.h.

901 {
903 
904  /* Set the active bit */
906  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
907  {
908  /* If the the rundown wasn't already active, then take the long path */
910  }
911 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
VOID FASTCALL ExfWaitForRundownProtectionRelease(IN OUT PEX_RUNDOWN_REF RunRef)
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ExpChangeRundown(x, y, z)
Definition: ex.h:158
#define EX_RUNDOWN_ACTIVE

◆ ExAcquireFastReference()

FORCEINLINE EX_FAST_REF ExAcquireFastReference ( IN OUT PEX_FAST_REF  FastRef)

Definition at line 589 of file ex.h.

590 {
591  EX_FAST_REF OldValue, NewValue;
592 
593  /* Start reference loop */
594  for (;;)
595  {
596  /* Get the current reference count */
597  OldValue = *FastRef;
598  if (OldValue.RefCnt)
599  {
600  /* Increase the reference count */
601  NewValue.Value = OldValue.Value - 1;
602  NewValue.Object = ExpChangePushlock(&FastRef->Object,
603  NewValue.Object,
604  OldValue.Object);
605  if (NewValue.Object != OldValue.Object) continue;
606  }
607 
608  /* We are done */
609  break;
610  }
611 
612  /* Return the old value */
613  return OldValue;
614 }
ULONG_PTR RefCnt
Definition: extypes.h:423
PVOID Object
Definition: extypes.h:422
#define ExpChangePushlock(x, y, z)
Definition: ex.h:159
ULONG_PTR Value
Definition: extypes.h:424

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

◆ ExAcquirePushLockExclusive()

FORCEINLINE VOID ExAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 1008 of file ex.h.

1009 {
1010  /* Try acquiring the lock */
1012  {
1013  /* Someone changed it, use the slow path */
1014  ExfAcquirePushLockExclusive(PushLock);
1015  }
1016 
1017  /* Sanity check */
1018  ASSERT(PushLock->Locked);
1019 }
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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

Referenced by CmLoadKey(), CmpAcquireKcbLockExclusiveByIndex(), 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().

◆ ExAcquirePushLockShared()

FORCEINLINE VOID ExAcquirePushLockShared ( PEX_PUSH_LOCK  PushLock)

Definition at line 1077 of file ex.h.

1078 {
1079  EX_PUSH_LOCK NewValue;
1080 
1081  /* Try acquiring the lock */
1083  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1084  {
1085  /* Someone changed it, use the slow path */
1086  ExfAcquirePushLockShared(PushLock);
1087  }
1088 
1089  /* Sanity checks */
1090  ASSERT(PushLock->Locked);
1091 }
ULONG_PTR Value
Definition: extypes.h:465
PVOID Ptr
Definition: extypes.h:466
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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:159
ULONG_PTR Locked
Definition: extypes.h:459

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

◆ ExAcquireTimeRefreshLock()

BOOLEAN NTAPI ExAcquireTimeRefreshLock ( IN BOOLEAN  Wait)

Definition at line 51 of file time.c.

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 KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by ExSetTimerResolution(), and KdpTimeSlipWork().

◆ ExAllocateCallBack()

PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack ( IN PEX_CALLBACK_FUNCTION  Function,
IN PVOID  Context 
)

Definition at line 54 of file callback.c.

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 }
NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection(_Out_ PEX_RUNDOWN_REF RunRef)
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
#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:1020
#define TAG_CALLBACK_ROUTINE_BLOCK
Definition: tag.h:11

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

◆ ExAllocateLocallyUniqueId()

VOID NTAPI ExAllocateLocallyUniqueId ( OUT LUID LocallyUniqueId)

Definition at line 231 of file uuid.c.

232 {
233  LARGE_INTEGER NewLuid, PrevLuid;
234 
235  /* atomically increment the luid */
236  do
237  {
238  PrevLuid = LuidValue;
239  NewLuid = RtlLargeIntegerAdd(PrevLuid,
240  LuidIncrement);
242  &NewLuid.QuadPart,
243  &PrevLuid.QuadPart,
244  NULL) != PrevLuid.QuadPart);
245 
246  LocallyUniqueId->LowPart = NewLuid.u.LowPart;
247  LocallyUniqueId->HighPart = NewLuid.u.HighPart;
248 }
NTSYSAPI LONGLONG WINAPI RtlLargeIntegerAdd(LONGLONG, LONGLONG)
static LARGE_INTEGER LuidValue
Definition: uuid.c:43
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:416
struct _LARGE_INTEGER::@2184 u
static LARGE_INTEGER LuidIncrement
Definition: uuid.c:42
LONGLONG QuadPart
Definition: typedefs.h:112

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

◆ ExBlockPushLock()

VOID FASTCALL ExBlockPushLock ( IN PEX_PUSH_LOCK  PushLock,
IN PVOID  WaitBlock 
)

◆ ExChangeHandle()

BOOLEAN NTAPI ExChangeHandle ( IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle,
IN PEX_CHANGE_HANDLE_CALLBACK  ChangeRoutine,
IN ULONG_PTR  Context 
)

Definition at line 1153 of file handle.c.

1157 {
1158  EXHANDLE ExHandle;
1159  PHANDLE_TABLE_ENTRY HandleTableEntry;
1160  BOOLEAN Result = FALSE;
1161  PAGED_CODE();
1162 
1163  /* Set the handle value */
1164  ExHandle.GenericHandleOverlay = Handle;
1165 
1166  /* Find the entry for this handle */
1167  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1168 
1169  /* Make sure that we found an entry, and that it's valid */
1170  if (!(HandleTableEntry) ||
1171  !(HandleTableEntry->Object) ||
1172  (HandleTableEntry->NextFreeTableEntry == -2))
1173  {
1174  /* It isn't, fail */
1175  return FALSE;
1176  }
1177 
1178  /* Enter a critical region */
1180 
1181  /* Try locking the handle entry */
1182  if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1183  {
1184  /* Call the change routine and unlock the entry */
1185  Result = ChangeRoutine(HandleTableEntry, Context);
1186  ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
1187  }
1188 
1189  /* Leave the critical region and return the callback result */
1191  return Result;
1192 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
#define PAGED_CODE()
Definition: video.h:57
Definition: extypes.h:595
unsigned char BOOLEAN
_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
_In_ HANDLE Handle
Definition: extypes.h:390
HANDLE GenericHandleOverlay
Definition: ex.h:97
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
Definition: ex.h:81
#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

Referenced by NtSetInformationObject(), and ObSetHandleAttributes().

◆ ExCompareExchangeCallBack()

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.

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\n", 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:552
#define TRUE
Definition: types.h:120
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1150
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:560
VOID FASTCALL ExfReleaseRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:260
#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:719
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:78
#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:128

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

◆ ExCompareSwapFastReference()

FORCEINLINE EX_FAST_REF ExCompareSwapFastReference ( IN PEX_FAST_REF  FastRef,
IN PVOID  Object,
IN PVOID  OldObject 
)

Definition at line 719 of file ex.h.

722 {
723  EX_FAST_REF OldValue, NewValue;
724 
725  /* Sanity check and start swap loop */
727  for (;;)
728  {
729  /* Get the current value */
730  OldValue = *FastRef;
731 
732  /* Make sure there's enough references to swap */
733  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
734 
735  /* Check if we have an object to swap */
736  if (Object)
737  {
738  /* Set up the value with maximum fast references */
739  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
740  }
741  else
742  {
743  /* Write the object address itself (which is empty) */
744  NewValue.Value = (ULONG_PTR)Object;
745  }
746 
747  /* Do the actual compare exchange */
748  NewValue.Object = ExpChangePushlock(&FastRef->Object,
749  NewValue.Object,
750  OldValue.Object);
751  if (NewValue.Object != OldValue.Object) continue;
752 
753  /* All done */
754  break;
755  }
756 
757  /* Return the old value */
758  return OldValue;
759 }
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID Object
Definition: extypes.h:422
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:128
#define ExpChangePushlock(x, y, z)
Definition: ex.h:159
ULONG_PTR Value
Definition: extypes.h:424

Referenced by ExCompareExchangeCallBack(), and ObSetSecurityDescriptorInfo().

◆ ExConvertPushLockSharedToExclusive()

FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive ( IN PEX_PUSH_LOCK  PushLock)

Definition at line 1111 of file ex.h.

1112 {
1113  EX_PUSH_LOCK OldValue;
1114 
1115  /* Set the expected old value */
1117 
1118  /* Try converting the lock */
1119  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1120  OldValue.Ptr)
1121  {
1122  /* Conversion failed */
1123  return FALSE;
1124  }
1125 
1126  /* Sanity check */
1127  ASSERT(PushLock->Locked);
1128  return TRUE;
1129 }
ULONG_PTR Value
Definition: extypes.h:465
#define TRUE
Definition: types.h:120
PVOID Ptr
Definition: extypes.h:466
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define ExpChangePushlock(x, y, z)
Definition: ex.h:159

Referenced by CmpTryToConvertKcbSharedToExclusive(), and ObpLookupEntryDirectory().

◆ ExCreateHandle()

HANDLE NTAPI ExCreateHandle ( IN PHANDLE_TABLE  HandleTable,
IN PHANDLE_TABLE_ENTRY  HandleTableEntry 
)

Definition at line 791 of file handle.c.

793 {
795  PHANDLE_TABLE_ENTRY NewEntry;
796  PAGED_CODE();
797 
798  /* Start with a clean handle */
799  Handle.GenericHandleOverlay = NULL;
800 
801  /* Allocate a new entry */
803  if (NewEntry)
804  {
805  /* Enter a critical region */
807 
808  /* Write the entry */
809  *NewEntry = *HandleTableEntry;
810 
811  /* Unlock it and leave the critical region */
814  }
815 
816  /* Return the handle value */
817  return Handle.GenericHandleOverlay;
818 }
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
#define PAGED_CODE()
Definition: video.h:57
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
PHANDLE_TABLE_ENTRY NTAPI ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, OUT PEXHANDLE NewHandle)
Definition: handle.c:647
Definition: ex.h:81
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114

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

◆ ExCreateHandleTable()

PHANDLE_TABLE NTAPI ExCreateHandleTable ( IN PEPROCESS Process  OPTIONAL)

Definition at line 765 of file handle.c.

766 {
768  PAGED_CODE();
769 
770  /* Allocate the handle table */
772  if (!HandleTable) return NULL;
773 
774  /* Acquire the handle table lock */
777 
778  /* Insert it into the list */
779  InsertTailList(&HandleTableListHead, &HandleTable->HandleTableList);
780 
781  /* Release the lock */
784 
785  /* Return the handle table */
786  return HandleTable;
787 }
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:309
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1008
#define TRUE
Definition: types.h:120
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define InsertTailList(ListHead, Entry)
#define PAGED_CODE()
Definition: video.h:57
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1224
smooth NULL
Definition: ftsmooth.c:416
#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

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

◆ ExDereferenceCallBackBlock()

VOID NTAPI ExDereferenceCallBackBlock ( IN OUT PEX_CALLBACK  CallBack,
IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock 
)

Definition at line 109 of file callback.c.

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:657

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

◆ ExDestroyHandle()

BOOLEAN NTAPI ExDestroyHandle ( IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle,
IN PHANDLE_TABLE_ENTRY HandleTableEntry  OPTIONAL 
)

Definition at line 948 of file handle.c.

951 {
952  EXHANDLE ExHandle;
953  PVOID Object;
954  PAGED_CODE();
955 
956  /* Setup the actual handle value */
957  ExHandle.GenericHandleOverlay = Handle;
958 
959  /* Enter a critical region and check if we have to lookup the handle */
961  if (!HandleTableEntry)
962  {
963  /* Lookup the entry */
964  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
965 
966  /* Make sure that we found an entry, and that it's valid */
967  if (!(HandleTableEntry) ||
968  !(HandleTableEntry->Object) ||
969  (HandleTableEntry->NextFreeTableEntry == -2))
970  {
971  /* Invalid handle, fail */
973  return FALSE;
974  }
975 
976  /* Lock the entry */
977  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
978  {
979  /* Couldn't lock, fail */
981  return FALSE;
982  }
983  }
984  else
985  {
986  /* Make sure the handle is locked */
987  ASSERT((HandleTableEntry->Value & EXHANDLE_TABLE_ENTRY_LOCK_BIT) == 0);
988  }
989 
990  /* Clear the handle */
991  Object = InterlockedExchangePointer((PVOID*)&HandleTableEntry->Object, NULL);
992 
993  /* Sanity checks */
994  ASSERT(Object != NULL);
996 
997  /* Unblock the pushlock */
998  ExfUnblockPushLock(&HandleTable->HandleContentionEvent, NULL);
999 
1000  /* Free the actual entry */
1001  ExpFreeHandleTableEntry(HandleTable, ExHandle, HandleTableEntry);
1002 
1003  /* If we got here, return success */
1005  return TRUE;
1006 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
#define TRUE
Definition: types.h:120
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define PAGED_CODE()
Definition: video.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
HANDLE GenericHandleOverlay
Definition: ex.h:97
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ex.h:81
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:141
#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:257

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

◆ ExDestroyHandleTable()

VOID NTAPI ExDestroyHandleTable ( IN PHANDLE_TABLE  HandleTable,
IN PVOID DestroyHandleProcedure  OPTIONAL 
)

Definition at line 927 of file handle.c.

929 {
930  PAGED_CODE();
931 
932  /* Remove the handle from the list */
934 
935  /* Check if we have a destroy callback */
936  if (DestroyHandleProcedure)
937  {
938  /* FIXME: */
939  ASSERT(FALSE);
940  }
941 
942  /* Free the handle table */
944 }
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI ExRemoveHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:908
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:181

Referenced by ObKillProcess(), and RtlpDestroyAtomHandleTable().

◆ ExDoCallBack()

FORCEINLINE VOID ExDoCallBack ( IN OUT PEX_CALLBACK  Callback,
IN PVOID  Context,
IN PVOID  Argument1,
IN PVOID  Argument2 
)

Definition at line 525 of file ex.h.

529 {
530  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
532 
533  /* Reference the block */
534  CallbackBlock = ExReferenceCallBackBlock(Callback);
535  if (CallbackBlock)
536  {
537  /* Get the function */
538  Function = ExGetCallBackBlockRoutine(CallbackBlock);
539 
540  /* Do the callback */
542 
543  /* Now dereference it */
544  ExDereferenceCallBackBlock(Callback, CallbackBlock);
545  }
546 }
_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
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
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
_In_ PVOID Argument2
Definition: classpnp.h:680
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:696
LPFNPSPCALLBACK Callback
Definition: desk.c:111

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

◆ ExDupHandleTable()

PHANDLE_TABLE NTAPI ExDupHandleTable ( IN PEPROCESS  Process,
IN PHANDLE_TABLE  HandleTable,
IN PEX_DUPLICATE_HANDLE_CALLBACK  DupHandleProcedure,
IN ULONG_PTR  Mask 
)

Definition at line 1036 of file handle.c.

1040 {
1041  PHANDLE_TABLE NewTable;
1042  EXHANDLE Handle;
1043  PHANDLE_TABLE_ENTRY HandleTableEntry, NewEntry;
1044  BOOLEAN Failed = FALSE;
1045  PAGED_CODE();
1046 
1047  /* Allocate the duplicated copy */
1048  NewTable = ExpAllocateHandleTable(Process, FALSE);
1049  if (!NewTable) return NULL;
1050 
1051  /* Loop each entry */
1052  while (NewTable->NextHandleNeedingPool <
1053  HandleTable->NextHandleNeedingPool)
1054  {
1055  /* Insert it into the duplicated copy */
1056  if (!ExpAllocateHandleTableEntrySlow(NewTable, FALSE))
1057  {
1058  /* Insert failed, free the new copy and return */
1059  ExpFreeHandleTable(NewTable);
1060  return NULL;
1061  }
1062  }
1063 
1064  /* Setup the initial handle table data */
1065  NewTable->HandleCount = 0;
1066  NewTable->ExtraInfoPages = 0;
1067  NewTable->FirstFree = 0;
1068 
1069  /* Setup the first handle value */
1070  Handle.Value = INDEX_TO_HANDLE_VALUE(1);
1071 
1072  /* Enter a critical region and lookup the new entry */
1074  while ((NewEntry = ExpLookupHandleTableEntry(NewTable, Handle)))
1075  {
1076  /* Lookup the old entry */
1077  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle);
1078 
1079  /* Loop each entry */
1080  do
1081  {
1082  /* Check if it doesn't match the audit mask */
1083  if (!(HandleTableEntry->Value & Mask))
1084  {
1085  /* Free it since we won't use it */
1086  Failed = TRUE;
1087  }
1088  else
1089  {
1090  /* Lock the entry */
1091  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1092  {
1093  /* Free it since we can't lock it, so we won't use it */
1094  Failed = TRUE;
1095  }
1096  else
1097  {
1098  /* Copy the handle value */
1099  *NewEntry = *HandleTableEntry;
1100 
1101  /* Call the duplicate callback */
1102  if (DupHandleProcedure(Process,
1103  HandleTable,
1104  HandleTableEntry,
1105  NewEntry))
1106  {
1107  /* Clear failure flag */
1108  Failed = FALSE;
1109 
1110  /* Lock the entry, increase the handle count */
1111  NewEntry->Value |= EXHANDLE_TABLE_ENTRY_LOCK_BIT;
1112  NewTable->HandleCount++;
1113  }
1114  else
1115  {
1116  /* Duplication callback refused, fail */
1117  Failed = TRUE;
1118  }
1119  }
1120  }
1121 
1122  /* Check if we failed earlier and need to free */
1123  if (Failed)
1124  {
1125  /* Free this entry */
1126  NewEntry->Object = NULL;
1127  NewEntry->NextFreeTableEntry = NewTable->FirstFree;
1128  NewTable->FirstFree = (ULONG)Handle.Value;
1129  }
1130 
1131  /* Increase the handle value and move to the next entry */
1132  Handle.Value += INDEX_TO_HANDLE_VALUE(1);
1133  NewEntry++;
1134  HandleTableEntry++;
1135  } while (Handle.Value % INDEX_TO_HANDLE_VALUE(LOW_LEVEL_ENTRIES));
1136 
1137  /* We're done, skip the last entry */
1139  }
1140 
1141  /* Acquire the table lock and insert this new table into the list */
1145 
1146  /* Leave the critical region we entered previously and return the table */
1148  return NewTable;
1149 }
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:309
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1008
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
#define TRUE
Definition: types.h:120
ULONG NextHandleNeedingPool
Definition: extypes.h:645
LONG ExtraInfoPages
Definition: extypes.h:635
LIST_ENTRY HandleTableList
Definition: extypes.h:627
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define InsertTailList(ListHead, Entry)
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExpAllocateHandleTableEntrySlow(IN PHANDLE_TABLE HandleTable, IN BOOLEAN DoInit)
Definition: handle.c:466
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1224
Definition: extypes.h:595
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
LONG HandleCount
Definition: extypes.h:644
Definition: arc.h:79
_In_ HANDLE Handle
Definition: extypes.h:390
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
#define INDEX_TO_HANDLE_VALUE(x)
Definition: handle.c:21
Definition: ex.h:81
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:141
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
ULONG_PTR Value
Definition: extypes.h:602
#define LOW_LEVEL_ENTRIES
Definition: ex.h:147
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:181
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

Referenced by ObInitProcess().

◆ ExfAcquireRundownProtection()

BOOLEAN FASTCALL ExfAcquireRundownProtection ( IN OUT PEX_RUNDOWN_REF  RunRef)

◆ ExfAcquireRundownProtectionEx()

BOOLEAN FASTCALL ExfAcquireRundownProtectionEx ( IN OUT PEX_RUNDOWN_REF  RunRef,
IN ULONG  Count 
)

◆ ExfInitializeRundownProtection()

VOID FASTCALL ExfInitializeRundownProtection ( OUT PEX_RUNDOWN_REF  RunRef)

◆ ExFreeCallBack()

VOID NTAPI ExFreeCallBack ( IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock)

Definition at line 77 of file callback.c.

78 {
79  /* Just free it from memory */
81 }
#define TAG_CALLBACK_ROUTINE_BLOCK
Definition: tag.h:11
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

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

◆ ExfReInitializeRundownProtection()

VOID FASTCALL ExfReInitializeRundownProtection ( OUT PEX_RUNDOWN_REF  RunRef)

◆ ExfReleaseRundownProtection()

VOID FASTCALL ExfReleaseRundownProtection ( IN OUT PEX_RUNDOWN_REF  RunRef)

◆ ExfReleaseRundownProtectionEx()

VOID FASTCALL ExfReleaseRundownProtectionEx ( IN OUT PEX_RUNDOWN_REF  RunRef,
IN ULONG  Count 
)

◆ ExfRundownCompleted()

VOID FASTCALL ExfRundownCompleted ( OUT PEX_RUNDOWN_REF  RunRef)

◆ ExfUnblockPushLock()

VOID FASTCALL ExfUnblockPushLock ( IN PEX_PUSH_LOCK  PushLock,
IN PVOID  CurrentWaitBlock 
)

◆ ExfWaitForRundownProtectionRelease()

VOID FASTCALL ExfWaitForRundownProtectionRelease ( IN OUT PEX_RUNDOWN_REF  RunRef)

◆ ExGetCallBackBlockContext()

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 }

◆ ExGetCallBackBlockRoutine()

PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine ( IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock)

Definition at line 93 of file callback.c.

94 {
95  /* Return the function */
96  return CallbackBlock->Function;
97 }

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

◆ ExGetCountFastReference()

FORCEINLINE ULONG ExGetCountFastReference ( IN EX_FAST_REF  FastRef)

Definition at line 560 of file ex.h.

561 {
562  /* Return the reference count */
563  return (ULONG)FastRef.RefCnt;
564 }
unsigned int ULONG
Definition: retypes.h:1

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

◆ ExGetObjectFastReference()

FORCEINLINE PVOID ExGetObjectFastReference ( IN EX_FAST_REF  FastRef)

Definition at line 552 of file ex.h.

553 {
554  /* Return the unbiased pointer */
555  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
556 }
#define MAX_FAST_REFS
Definition: ex.h:128

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

◆ ExGetPoolTagInfo()

NTSTATUS NTAPI ExGetPoolTagInfo ( IN PSYSTEM_POOLTAG_INFORMATION  SystemInformation,
IN ULONG  SystemInformationLength,
IN OUT PULONG ReturnLength  OPTIONAL 
)

Definition at line 1352 of file expool.c.

1355 {
1356  ULONG TableSize, CurrentLength;
1357  ULONG EntryCount;
1359  PSYSTEM_POOLTAG TagEntry;
1360  PPOOL_TRACKER_TABLE Buffer, TrackerEntry;
1363 
1364  //
1365  // Keep track of how much data the caller's buffer must hold
1366  //
1367  CurrentLength = FIELD_OFFSET(SYSTEM_POOLTAG_INFORMATION, TagInfo);
1368 
1369  //
1370  // Initialize the caller's buffer
1371  //
1372  TagEntry = &SystemInformation->TagInfo[0];
1373  SystemInformation->Count = 0;
1374 
1375  //
1376  // Capture the number of entries, and the total size needed to make a copy
1377  // of the table
1378  //
1379  EntryCount = (ULONG)PoolTrackTableSize;
1380  TableSize = EntryCount * sizeof(POOL_TRACKER_TABLE);
1381 
1382  //
1383  // Allocate the "Generic DPC" temporary buffer
1384  //
1387 
1388  //
1389  // Do a "Generic DPC" to atomically retrieve the tag and allocation data
1390  //
1391  Context.PoolTrackTable = Buffer;
1392  Context.PoolTrackTableSize = PoolTrackTableSize;
1393  Context.PoolTrackTableExpansion = NULL;
1394  Context.PoolTrackTableSizeExpansion = 0;
1396 
1397  //
1398  // Now parse the results
1399  //
1400  for (TrackerEntry = Buffer; TrackerEntry < (Buffer + EntryCount); TrackerEntry++)
1401  {
1402  //
1403  // If the entry is empty, skip it
1404  //
1405  if (!TrackerEntry->Key) continue;
1406 
1407  //
1408  // Otherwise, add one more entry to the caller's buffer, and ensure that
1409  // enough space has been allocated in it
1410  //
1411  SystemInformation->Count++;
1412  CurrentLength += sizeof(*TagEntry);
1413  if (SystemInformationLength < CurrentLength)
1414  {
1415  //
1416  // The caller's buffer is too small, so set a failure code. The
1417  // caller will know the count, as well as how much space is needed.
1418  //
1419  // We do NOT break out of the loop, because we want to keep incrementing
1420  // the Count as well as CurrentLength so that the caller can know the
1421  // final numbers
1422  //
1424  }
1425  else
1426  {
1427  //
1428  // Small sanity check that our accounting is working correctly
1429  //
1430  ASSERT(TrackerEntry->PagedAllocs >= TrackerEntry->PagedFrees);
1431  ASSERT(TrackerEntry->NonPagedAllocs >= TrackerEntry->NonPagedFrees);
1432 
1433  //
1434  // Return the data into the caller's buffer
1435  //
1436  TagEntry->TagUlong = TrackerEntry->Key;
1437  TagEntry->PagedAllocs = TrackerEntry->PagedAllocs;
1438  TagEntry->PagedFrees = TrackerEntry->PagedFrees;
1439  TagEntry->PagedUsed = TrackerEntry->PagedBytes;
1440  TagEntry->NonPagedAllocs = TrackerEntry->NonPagedAllocs;
1441  TagEntry->NonPagedFrees = TrackerEntry->NonPagedFrees;
1442  TagEntry->NonPagedUsed = TrackerEntry->NonPagedBytes;
1443  TagEntry++;
1444  }
1445  }
1446 
1447  //
1448  // Free the "Generic DPC" temporary buffer, return the buffer length and status
1449  //
1450  ExFreePoolWithTag(Buffer, 'ofnI');
1451  if (ReturnLength) *ReturnLength = CurrentLength;
1452  return Status;
1453 }
#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:1857
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
LONG NTSTATUS
Definition: precomp.h:26
SIZE_T PoolTrackTableSize
Definition: expool.c:38
ULONG NonPagedFrees
Definition: extypes.h:1133
smooth NULL
Definition: ftsmooth.c:416
SIZE_T NonPagedBytes
Definition: miarm.h:386
Definition: bufpool.h:45
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:1317
SIZE_T PagedUsed
Definition: extypes.h:1131
LONG NonPagedFrees
Definition: miarm.h:385
SIZE_T PagedBytes
Definition: miarm.h:389
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG PagedFrees
Definition: extypes.h:1130
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
VOID NTAPI KeGenericCallDpc(IN PKDEFERRED_ROUTINE Routine, IN PVOID Context)
Definition: dpc.c:983
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
LONG NonPagedAllocs
Definition: miarm.h:384
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:3970
struct tagContext Context
Definition: acpixf.h:1020
unsigned int ULONG
Definition: retypes.h:1
ULONG TagUlong
Definition: extypes.h:1127
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
VOID NTAPI ExFreePoolWithTag(IN PVOID P, IN ULONG TagToFree)
Definition: expool.c:2441
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by QSI_DEF().

◆ ExGetRunRefForGivenProcessor()

FORCEINLINE PEX_RUNDOWN_REF ExGetRunRefForGivenProcessor ( IN PEX_RUNDOWN_REF_CACHE_AWARE  RunRefCacheAware,
IN ULONG  ProcNumber 
)

◆ ExInit2()

VOID NTAPI ExInit2 ( VOID  )

◆ ExInitializeCallBack()

VOID NTAPI ExInitializeCallBack ( IN OUT PEX_CALLBACK  Callback)

Definition at line 46 of file callback.c.

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:568
smooth NULL
Definition: ftsmooth.c:416
LPFNPSPCALLBACK Callback
Definition: desk.c:111

Referenced by CmpInitCallback(), and PspInitPhase0().

◆ ExInitializeFastReference()

FORCEINLINE VOID ExInitializeFastReference ( OUT PEX_FAST_REF  FastRef,
IN OPTIONAL PVOID  Object 
)

Definition at line 568 of file ex.h.

570 {
571  /* Sanity check */
572  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
573 
574  /* Check if an object is being set */
575  if (!Object)
576  {
577  /* Clear the field */
578  FastRef->Object = NULL;
579  }
580  else
581  {
582  /* Otherwise, we assume the object was referenced and is ready */
583  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
584  }
585 }
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:128

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

◆ ExInitializeSystemLookasideList()

INIT_FUNCTION VOID NTAPI ExInitializeSystemLookasideList ( IN PGENERAL_LOOKASIDE  List,
IN POOL_TYPE  Type,
IN ULONG  Size,
IN ULONG  Tag,
IN USHORT  MaximumDepth,
IN PLIST_ENTRY  ListHead 
)

Definition at line 35 of file lookas.c.

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
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
LIST_ENTRY List
Definition: psmgr.c:57
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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

◆ ExInitPoolLookasidePointers()

INIT_FUNCTION VOID NTAPI ExInitPoolLookasidePointers ( VOID  )

Definition at line 63 of file lookas.c.

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:1062
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:27
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:28
unsigned int ULONG
Definition: retypes.h:1
base of all file and directory entries
Definition: entries.h:82
GENERAL_LOOKASIDE_POOL PPPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:626

Referenced by ExpInitializeExecutive(), and KiSystemStartupBootStack().

◆ ExInsertFastReference()

FORCEINLINE BOOLEAN ExInsertFastReference ( IN OUT PEX_FAST_REF  FastRef,
IN PVOID  Object 
)

Definition at line 618 of file ex.h.

620 {
621  EX_FAST_REF OldValue, NewValue;
622 
623  /* Sanity checks */
625 
626  /* Start update loop */
627  for (;;)
628  {
629  /* Get the current reference count */
630  OldValue = *FastRef;
631 
632  /* Check if the current count is too high or if the pointer changed */
633  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
634  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
635  {
636  /* Fail */
637  return FALSE;
638  }
639 
640  /* Update the reference count */
641  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
642  NewValue.Object = ExpChangePushlock(&FastRef->Object,
643  NewValue.Object,
644  OldValue.Object);
645  if (NewValue.Object != OldValue.Object) continue;
646 
647  /* We are done */
648  break;
649  }
650 
651  /* Return success */
652  return TRUE;
653 }
#define TRUE
Definition: types.h:120
ULONG_PTR RefCnt
Definition: extypes.h:423
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID Object
Definition: extypes.h:422
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MAX_FAST_REFS
Definition: ex.h:128
#define ExpChangePushlock(x, y, z)
Definition: ex.h:159
ULONG_PTR Value
Definition: extypes.h:424

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

◆ ExMapHandleToPointer()

PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer ( IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle 
)

Definition at line 1010 of file handle.c.

1012 {
1013  EXHANDLE ExHandle;
1014  PHANDLE_TABLE_ENTRY HandleTableEntry;
1015  PAGED_CODE();
1016 
1017  /* Set the handle value */
1018  ExHandle.GenericHandleOverlay = Handle;
1019 
1020  /* Fail if we got an invalid index */
1021  if (!(ExHandle.Index & (LOW_LEVEL_ENTRIES - 1))) return NULL;
1022 
1023  /* Do the lookup */
1024  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1025  if (!HandleTableEntry) return NULL;
1026 
1027  /* Lock it */
1028  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry)) return NULL;
1029 
1030  /* Return the entry */
1031  return HandleTableEntry;
1032 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
ULONG_PTR Index
Definition: ex.h:86
#define PAGED_CODE()
Definition: video.h:57
Definition: extypes.h:595
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
HANDLE GenericHandleOverlay
Definition: ex.h:97
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
Definition: ex.h:81
#define LOW_LEVEL_ENTRIES
Definition: ex.h:147

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

◆ ExpDebuggerWorker()

VOID NTAPI ExpDebuggerWorker ( IN PVOID  Context)

Definition at line 55 of file dbgctrl.c.

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 */
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 */
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 */
108  return;
109  }
110 
111  /* Get the next 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 */
141  /* Dereference the process which was referenced for us by PsGetNextProcess */
143  }
144 }
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:28
KAPC_STATE
Definition: ketypes.h:1273
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:27
#define DBG_STATUS_WORKER
Definition: kdtypes.h:45
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
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
_SEH2_END
Definition: create.c:4424
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:753
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
#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

Referenced by ExpWorkerThreadBalanceManager().

◆ ExpInitializeCallbacks()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeCallbacks ( VOID  )

Definition at line 256 of file callback.c.

257 {
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;
280  &ObjectTypeInitializer,
281  NULL,
283  if (!NT_SUCCESS(Status)) return FALSE;
284 
285  /* Initialize the Object */
287  &DirName,
289  NULL,
291 
292  /* Create the Object Directory */
296  if (!NT_SUCCESS(Status)) return FALSE;
297 
298  /* Close Handle... */
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 */
309 
310  /* Initialize the Object Attributes Structure */
312  &CallbackName,
314  NULL,
315  NULL);
316 
317  /* Create the Callback Object */
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:1048
#define TRUE
Definition: types.h:120
POBJECT_TYPE ExCallbackObjectType
Definition: callback.c:38
LONG NTSTATUS
Definition: precomp.h:26
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
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
PSECURITY_DESCRIPTOR SePublicDefaultSd
Definition: sd.c:22
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3393
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1087
Status
Definition: gdiplustypes.h:24
VOID NTAPI ExpDeleteCallback(IN PVOID Object)
Definition: callback.c:236
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:731
#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:117
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ PFCB _In_ PCD_NAME DirName
Definition: cdprocs.h:741
#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

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeEventImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeEventImplementation ( VOID  )

Definition at line 43 of file event.c.

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:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENLINK
Definition: winternl.h:230
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
GENERIC_MAPPING ExpEventMapping
Definition: event.c:24
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
struct _KEVENT KEVENT
static const WCHAR L[]
Definition: oid.c:1087
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeEventPairImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeEventPairImplementation ( VOID  )

Definition at line 37 of file evtpair.c.

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:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENLINK
Definition: winternl.h:230
struct _KEVENT_PAIR KEVENT_PAIR
struct NameRec_ * Name
Definition: cdprocs.h:464
#define EVENT_PAIR_ALL_ACCESS
Definition: extypes.h:125
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
static const WCHAR L[]
Definition: oid.c:1087
GENERIC_MAPPING ExEventPairMapping
Definition: evtpair.c:24
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:22
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeExecutive()

INIT_FUNCTION VOID NTAPI ExpInitializeExecutive ( IN ULONG  Cpu,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 914 of file init.c.

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)
968 
969  /* Check if this is network boot */
970  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
971  {
972  /* Set variable */
974 
975  /* Make sure we're actually booting off the network */
976  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
977  }
978  }
979 
980  /* Set phase to 0 */
982 
983  /* Get boot command line */
984  CommandLine = LoaderBlock->LoadOptions;
985  if (CommandLine)
986  {
987  /* Upcase it for comparison and check if we're in performance mode */
988  _strupr(CommandLine);
989  PerfMem = strstr(CommandLine, "PERFMEM");
990  if (PerfMem)
991  {
992  /* Check if the user gave a number of bytes to use */
993  PerfMem = strstr(PerfMem, "=");
994  if (PerfMem)
995  {
996  /* Read the number of pages we'll use */
997  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
998  if (PerfMem)
999  {
1000  /* FIXME: TODO */
1001  DPRINT1("BBT performance mode not yet supported."
1002  "/PERFMEM option ignored.\n");
1003  }
1004  }
1005  }
1006 
1007  /* Check if we're burning memory */
1008  PerfMem = strstr(CommandLine, "BURNMEMORY");
1009  if (PerfMem)
1010  {
1011  /* Check if the user gave a number of bytes to use */
1012  PerfMem = strstr(PerfMem, "=");
1013  if (PerfMem)
1014  {
1015  /* Read the number of pages we'll use */
1016  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1017  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1018  }
1019  }
1020  }
1021 
1022  /* Setup NLS Base and offsets */
1023  NlsData = LoaderBlock->NlsData;
1024  ExpNlsTableBase = NlsData->AnsiCodePageData;
1027  (ULONG_PTR)NlsData->AnsiCodePageData);
1029  (ULONG_PTR)NlsData->AnsiCodePageData);
1030 
1031  /* Initialize the NLS Tables */
1038  &ExpNlsTableInfo);
1040 
1041  /* Now initialize the HAL */
1042  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1043  {
1044  /* HAL failed to initialize, bugcheck */
1045  KeBugCheck(HAL_INITIALIZATION_FAILED);
1046  }
1047 
1048  /* Make sure interrupts are active now */
1049  _enable();
1050 
1051  /* Clear the crypto exponent */
1052  SharedUserData->CryptoExponent = 0;
1053 
1054  /* Set global flags for the checked build */
1055 #if DBG
1058 #endif
1059 
1060  /* Setup NT System Root Path */
1061  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1062 
1063  /* Convert to ANSI_STRING and null-terminate it */
1064  RtlInitString(&AnsiPath, Buffer);
1065  Buffer[--AnsiPath.Length] = ANSI_NULL;
1066 
1067  /* Get the string from KUSER_SHARED_DATA's buffer */
1068  RtlInitEmptyUnicodeString(&NtSystemRoot,
1069  SharedUserData->NtSystemRoot,
1070  sizeof(SharedUserData->NtSystemRoot));
1071 
1072  /* Now fill it in */
1074  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1075 
1076  /* Setup bugcheck messages */
1078 
1079  /* Setup initial system settings */
1080  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1081 
1082  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1084  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1085  {
1087  }
1088 
1089  /* Add loaded CmNtGlobalFlag value */
1091 
1092  /* Initialize the executive at phase 0 */
1093  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1094 
1095  /* Initialize the memory manager at phase 0 */
1096  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1097 
1098  /* Load boot symbols */
1099  ExpLoadBootSymbols(LoaderBlock);
1100 
1101  /* Check if we should break after symbol load */
1103 
1104  /* Check if this loader is compatible with NT 5.2 */
1105  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1106  {
1107  /* Setup headless terminal settings */
1108  HeadlessInit(LoaderBlock);
1109  }
1110 
1111  /* Set system ranges */
1112 #ifdef _M_AMD64
1115 #else
1118 #endif
1119 
1120  /* Make a copy of the NLS Tables */
1121  ExpInitNls(LoaderBlock);
1122 
1123  /* Get the kernel's load entry */
1124  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1126  InLoadOrderLinks);
1127 
1128  /* Check if this is a service pack */
1129  if (CmNtCSDVersion & 0xFFFF)
1130  {
1131  /* Get the service pack string */
1132  Status = RtlFindMessage(NtosEntry->DllBase,
1133  11,
1134  0,
1135  WINDOWS_NT_CSD_STRING,
1136  &MsgEntry);
1137  if (NT_SUCCESS(Status))
1138  {
1139  /* Setup the string */
1140  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1141 
1142  /* Remove trailing newline */
1143  while ((CSDString.Length > 0) &&
1144  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1145  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1146  {
1147  /* Skip the trailing character */
1148  CSDString.Length--;
1149  }
1150 
1151  /* Fill the buffer with version information */
1153  sizeof(Buffer),
1154  "%Z %u%c",
1155  &CSDString,
1156  (CmNtCSDVersion & 0xFF00) >> 8,
1157  (CmNtCSDVersion & 0xFF) ?
1158  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1159  ANSI_NULL);
1160  }
1161  else
1162  {
1163  /* Build default string */
1165  sizeof(Buffer),
1166  "CSD %04x",
1167  CmNtCSDVersion);
1168  }
1169 
1170  /* Check for success */
1171  if (!NT_SUCCESS(Status))
1172  {
1173  /* Fail */
1174  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1175  }
1176  }
1177  else
1178  {
1179  /* Then this is a beta */
1181  sizeof(Buffer),
1183  NULL,
1184  &Remaining,
1185  0);
1186  if (!NT_SUCCESS(Status))
1187  {
1188  /* Fail */
1189  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1190  }
1191 
1192  /* Update length */
1193  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1194  }
1195 
1196  /* Check if we have an RC number */
1197  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1198  {
1199  /* Check if we have no version data yet */
1200  if (!(*Buffer))
1201  {
1202  /* Set defaults */
1203  Remaining = sizeof(Buffer);
1204  RcEnd = Buffer;
1205  }
1206  else
1207  {
1208  /* Add comma and space */
1210  sizeof(Buffer),
1211  ", ",
1212  &RcEnd,
1213  &Remaining,
1214  0);
1215  if (!NT_SUCCESS(Status))
1216  {
1217  /* Fail */
1218  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1219  }
1220  }
1221 
1222  /* Add the version format string */
1223  Status = RtlStringCbPrintfA(RcEnd,
1224  Remaining,
1225  "v.%u",
1226  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1227  if (!NT_SUCCESS(Status))
1228  {
1229  /* Fail */
1230  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1231  }
1232  }
1233 
1234  /* Now setup the final string */
1235  RtlInitAnsiString(&CSDString, Buffer);
1237  &CSDString,
1238  TRUE);
1239  if (!NT_SUCCESS(Status))
1240  {
1241  /* Fail */
1242  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1243  }
1244 
1245  /* Add our version */
1246  Status = RtlStringCbPrintfA(VersionBuffer,
1247  sizeof(VersionBuffer),
1248  "%u.%u",
1251  if (!NT_SUCCESS(Status))
1252  {
1253  /* Fail */
1254  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1255  }
1256 
1257  /* Build the final version string */
1259 
1260  /* Check if the user wants a kernel stack trace database */
1262  {
1263  /* FIXME: TODO */
1264  DPRINT1("Kernel-mode stack trace support not yet present."
1265  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1266  }
1267 
1268  /* Check if he wanted exception logging */
1270  {
1271  /* FIXME: TODO */
1272  DPRINT1("Kernel-mode exception logging support not yet present."
1273  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1274  }
1275 
1276  /* Initialize the Handle Table */
1278 
1279 #if DBG
1280  /* On checked builds, allocate the system call count table */
1283  KiServiceLimit * sizeof(ULONG),
1284  'llaC');
1285 
1286  /* Use it for the shadow table too */
1288 
1289  /* Make sure allocation succeeded */
1291  {
1292  /* Zero the call counts to 0 */
1294  KiServiceLimit * sizeof(ULONG));
1295  }
1296 #endif
1297 
1298  /* Create the Basic Object Manager Types to allow new Object Types */
1299  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1300 
1301  /* Load basic Security for other Managers */
1302  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1303 
1304  /* Initialize the Process Manager */
1305  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1306 
1307  /* Initialize the PnP Manager */
1308  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1309 
1310  /* Initialize the User-Mode Debugging Subsystem */
1311  DbgkInitialize();
1312 
1313  /* Calculate the tick count multiplier */
1315  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1316 
1317  /* Set the OS Version */
1318  SharedUserData->NtMajorVersion = NtMajorVersion;
1319  SharedUserData->NtMinorVersion = NtMinorVersion;
1320 
1321  /* Set the machine type */
1322  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1323  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1324 }
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
signed char * PCHAR
Definition: retypes.h:7
#define VER_PRODUCTBETA_STR
Definition: ieverp.h:10
ULONG KeMaximumIncrement
Definition: clock.c:20
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1827
#define TRUE
Definition: types.h:120
UNICODE_STRING NtSystemRoot
Definition: init.c:72
INIT_FUNCTION VOID NTAPI ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:787
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:84
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG KiServiceLimit
Definition: krnlinit.c:26
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:3919
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
INIT_FUNCTION BOOLEAN NTAPI SeInitSystem(VOID)
Definition: semgr.c:239
char CHAR
Definition: xmlstorage.h:175
void __cdecl _enable(void)
Definition: intrin_arm.h:373
LONG NTSTATUS
Definition: precomp.h:26
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)
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define VER_PRODUCTBUILD_QFE
Definition: ntverp.h:20
INIT_FUNCTION VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:82
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2043
ULONG CmNtCSDReleaseType
Definition: init.c:57
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:42
INIT_FUNCTION BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:199
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID DllBase
Definition: btrfs_drv.h:1805
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ANSI_NULL
Definition: arc.h:130
_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:416
INIT_FUNCTION VOID NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:368
INIT_FUNCTION BOOLEAN NTAPI ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:761
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ULONG CmNtSpBuildNumber
Definition: init.c:55
PVOID OemCodePageData
Definition: arc.h:277
INIT_FUNCTION VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:868
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1831
INIT_FUNCTION BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:735
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
PVOID ExpNlsTableBase
Definition: init.c:81
ULONG NtMinorVersion
Definition: init.c:43
#define FLG_ENABLE_CLOSE_EXCEPTIONS
Definition: pstypes.h:81
INIT_FUNCTION BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:626
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
INIT_FUNCTION VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:63
#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: btrfs_drv.h:1801
ULONG ExpInitializationPhase
Definition: init.c:65
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:36
INIT_FUNCTION VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
Status
Definition: gdiplustypes.h:24
ULONG ExpOemCodePageDataOffset
Definition: init.c:82
BOOLEAN ExpInTextModeSetup
Definition: init.c:66
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
unsigned short USHORT
Definition: pedump.c:61
INIT_FUNCTION VOID NTAPI CmGetSystemControlValues(IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
Definition: cmcontrl.c:104
INIT_FUNCTION VOID NTAPI ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:209
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD
Definition: pstypes.h:73
INIT_FUNCTION ULONG NTAPI ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
Definition: init.c:602
#define FLG_KERNEL_STACK_TRACE_DB
Definition: pstypes.h:68
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:35
#define DPRINT1
Definition: precomp.h:8
INIT_SECTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[]
Definition: cmdata.c:139
#define DBG_STATUS_CONTROL_C
Definition: kdtypes.h:39
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 RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
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:107
BOOLEAN IoRemoteBootClient
Definition: init.c:67

Referenced by KiInitializeKernel().

◆ ExpInitializeHandleTables()

INIT_FUNCTION VOID NTAPI ExpInitializeHandleTables ( VOID  )

Definition at line 28 of file handle.c.

29 {
30  /* Initialize the list of handle tables and the lock */
33 }
#define ExInitializePushLock
Definition: ex.h:985
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
LIST_ENTRY HandleTableListHead
Definition: handle.c:18

Referenced by ExpInitializeExecutive().

◆ ExpInitializeKeyedEventImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeKeyedEventImplementation ( VOID  )

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeMutantImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeMutantImplementation ( VOID  )

Definition at line 56 of file mutant.c.

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:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENLINK
Definition: winternl.h:230
#define MUTANT_ALL_ACCESS
Definition: extypes.h:110
VOID NTAPI ExpDeleteMutant(PVOID ObjectBody)
Definition: mutant.c:42
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
POBJECT_TYPE ExMutantObjectType
Definition: mutant.c:22
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
GENERIC_MAPPING ExpMutantMapping
Definition: mutant.c:24
static const WCHAR L[]
Definition: oid.c:1087
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeProfileImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeProfileImplementation ( VOID  )

Definition at line 68 of file profile.c.

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:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENLINK
Definition: winternl.h:230
VOID NTAPI ExpDeleteProfile(PVOID ObjectBody)
Definition: profile.c:39
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
GENERIC_MAPPING ExpProfileMapping
Definition: profile.c:27
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
static const WCHAR L[]
Definition: oid.c:1087
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#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

Referenced by ExpInitSystemPhase1().

◆ ExpInitializePushLocks()

INIT_FUNCTION VOID NTAPI ExpInitializePushLocks ( VOID  )

Definition at line 45 of file pushlock.c.

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

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeSemaphoreImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeSemaphoreImplementation ( VOID  )

Definition at line 43 of file sem.c.

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:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENLINK
Definition: winternl.h:230
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
GENERIC_MAPPING ExSemaphoreMapping
Definition: sem.c:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
static const WCHAR L[]
Definition: oid.c:1087
struct _KSEMAPHORE KSEMAPHORE
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:160
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:22

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeTimerImplementation()

INIT_FUNCTION BOOLEAN NTAPI ExpInitializeTimerImplementation ( VOID  )

Definition at line 223 of file timer.c.

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:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_OPENLINK
Definition: winternl.h:230
static GENERIC_MAPPING ExpTimerMapping
Definition: timer.c:24
LIST_ENTRY ExpWakeList
Definition: timer.c:21
struct NameRec_ * Name
Definition: cdprocs.h:464
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ExpDeleteTimer(IN PVOID ObjectBody)
Definition: timer.c:108
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
static const WCHAR L[]
Definition: oid.c:1087
Status
Definition: gdiplustypes.h:24
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:261
struct _ETIMER ETIMER
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
KSPIN_LOCK ExpWakeListLock
Definition: timer.c:20
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeWorkerThreads()

INIT_FUNCTION VOID NTAPI ExpInitializeWorkerThreads ( VOID  )

Definition at line 521 of file work.c.

522 {
523  ULONG WorkQueueType;
524  ULONG CriticalThreads, DelayedThreads;
525  HANDLE ThreadHandle;
527  ULONG i;
528 
529  /* Setup the stack swap support */
533 
534  /* Set the number of critical and delayed threads. We shouldn't hardcode */
535  DelayedThreads = EX_DELAYED_WORK_THREADS;
536  CriticalThreads = EX_CRITICAL_WORK_THREADS;
537 
538  /* Protect against greedy registry modifications */
543 
544  /* Calculate final count */
545  DelayedThreads += ExpAdditionalDelayedWorkerThreads;
546  CriticalThreads += ExpAdditionalCriticalWorkerThreads;
547 
548  /* Initialize the Array */
549  for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++)
550  {
551  /* Clear the structure and initialize the queue */
552  RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE));
553  KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0);
554  }
555 
556  /* Dynamic threads are only used for the critical queue */
558 
559  /* Initialize the balance set manager events */
563  FALSE);
564 
565  /* Create the built-in worker threads for the critical queue */
566  for (i = 0; i < CriticalThreads; i++)
567  {
568  /* Create the thread */
571  }
572 
573  /* Create the built-in worker threads for the delayed queue */
574  for (i = 0; i < DelayedThreads; i++)
575  {
576  /* Create the thread */
579  }
580 
581  /* Create the built-in worker thread for the hypercritical queue */
583 
584  /* Create the balance set manager thread */
585  PsCreateSystemThread(&ThreadHandle,
587  NULL,
588  0,
589  NULL,
591  NULL);
592 
593  /* Get a pointer to it for the shutdown process */
594  ObReferenceObjectByHandle(ThreadHandle,
596  NULL,
597  KernelMode,
598  (PVOID*)&Thread,
599  NULL);
601 
602  /* Close the handle and return */
603  ObCloseHandle(ThreadHandle, KernelMode);
604 }
#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:254
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:50
PETHREAD ExpWorkerThreadBalanceManagerPtr
Definition: work.c:53
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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:496
#define EX_CRITICAL_WORK_THREADS
Definition: work.c:24
smooth NULL
Definition: ftsmooth.c:416
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:3370
KEVENT ExpThreadSetManagerEvent
Definition: work.c:49
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:46
#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 ExDelayedWorkerThreads
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
ULONG ExCriticalWorkerThreads
Definition: work.c:38
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
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:424

Referenced by ExpInitSystemPhase1().

◆ ExpInitLookasideLists()

INIT_FUNCTION 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
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:27
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
INIT_FUNCTION VOID NTAPI ExInitializeSystemLookasideList(IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
Definition: lookas.c:35
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:21
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:28
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:24
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

◆ ExpInitUuids()

INIT_FUNCTION VOID NTAPI ExpInitUuids ( VOID  )

Definition at line 50 of file uuid.c.

51 {
53 
56 
59 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
static UCHAR UuidSeed[SEED_BUFFER_SIZE]
Definition: uuid.c:40
static FAST_MUTEX UuidMutex
Definition: uuid.c:35
static ULARGE_INTEGER UuidLastTime
Definition: uuid.c:36
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
static ULONG UuidCount
Definition: uuid.c:41
#define TICKS_15_OCT_1582_TO_1601
Definition: uuid.c:26
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define TICKS_PER_CLOCK_TICK
Definition: uuid.c:20
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SEED_BUFFER_SIZE
Definition: uuid.c:16

Referenced by ExpInitSystemPhase1().

◆ ExpLockHandleTableEntry()

BOOLEAN NTAPI ExpLockHandleTableEntry ( IN PHANDLE_TABLE  HandleTable,
IN PHANDLE_TABLE_ENTRY  HandleTableEntry 
)

Definition at line 848 of file handle.c.

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

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

◆ ExpLookupHandleTableEntry()

PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry ( IN PHANDLE_TABLE  HandleTable,
IN EXHANDLE  Handle 
)

Definition at line 37 of file handle.c.

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

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

◆ ExpResourceInitialization()

INIT_FUNCTION VOID NTAPI ExpResourceInitialization ( VOID  )

Definition at line 169 of file resource.c.

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:112

Referenced by ExpInitSystemPhase0().

◆ ExpSetTimeZoneInformation()

NTSTATUS ExpSetTimeZoneInformation ( IN PRTL_TIME_ZONE_INFORMATION  TimeZoneInformation)

◆ ExpWin32kInit()

INIT_FUNCTION BOOLEAN NTAPI ExpWin32kInit ( VOID  )

Definition at line 263 of file win32k.c.

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;
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;
299  &ObjectTypeInitializer,
300  NULL,
301  &<