ReactOS  0.4.15-dev-448-gd6c4411
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
 
struct  _UUID_CACHED_VALUES_STRUCT
 

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 struct _UUID_CACHED_VALUES_STRUCT UUID_CACHED_VALUES_STRUCT
 
typedef struct _UUID_CACHED_VALUES_STRUCTPUUID_CACHED_VALUES_STRUCT
 
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 BOOLEAN NTAPI ExpUuidInitialization (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI ExLuidInitialization (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 1528 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 999 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 1525 of file ex.h.

◆ InterlockedCompareExchangeUL

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

Definition at line 1522 of file ex.h.

◆ InterlockedDecrementUL

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

Definition at line 1510 of file ex.h.

◆ InterlockedExchangeAddUL

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

Definition at line 1519 of file ex.h.

◆ InterlockedExchangeUL

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

Definition at line 1516 of file ex.h.

◆ InterlockedIncrementUL

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

Definition at line 1513 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 435 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 427 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 420 of file ex.h.

◆ PEXHANDLE

typedef union _EXHANDLE * PEXHANDLE

◆ PHARDERROR_USER_PARAMETERS

◆ PUUID_CACHED_VALUES_STRUCT

◆ UUID_CACHED_VALUES_STRUCT

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

1362 {
1363  KIRQL OldIrql;
1365 
1366  /* Raise IRQL to APC */
1368 
1369  /* Decrease the count */
1370  if (InterlockedDecrement(&FastMutex->Count))
1371  {
1372  /* Someone is still holding it, use slow path */
1373  KiAcquireFastMutex(FastMutex);
1374  }
1375 
1376  /* Set the owner and IRQL */
1377  FastMutex->Owner = KeGetCurrentThread();
1378  FastMutex->OldIrql = OldIrql;
1379 }
#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:790
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 1316 of file ex.h.

1317 {
1319 
1320  /* Sanity check */
1322  (Thread->CombinedApcDisable != 0) ||
1323  (Thread->Teb == NULL) ||
1324  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1325  ASSERT(FastMutex->Owner != Thread);
1326 
1327  /* Decrease the count */
1328  if (InterlockedDecrement(&FastMutex->Count))
1329  {
1330  /* Someone is still holding it, use slow path */
1331  KiAcquireFastMutex(FastMutex);
1332  }
1333 
1334  /* Set the owner */
1335  FastMutex->Owner = Thread;
1336 }
#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:493
#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 806 of file ex.h.

807 {
808  ULONG_PTR Value, NewValue;
809 
810  /* Get the current value and mask the active bit */
811  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
812 
813  /* Add a reference */
814  NewValue = Value + EX_RUNDOWN_COUNT_INC;
815 
816  /* Change the value */
817  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
818  if (NewValue != Value)
819  {
820  /* Rundown was active, use long path */
821  return ExfAcquireRundownProtection(RunRef);
822  }
823 
824  /* Success */
825  return TRUE;
826 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
#define TRUE
Definition: types.h:120
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ExpChangeRundown(x, y, z)
Definition: ex.h: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 1432 of file ex.h.

1433 {
1434  /* Enter the Critical Region */
1436 
1437  /* Acquire the mutex unsafely */
1438  _ExAcquireFastMutexUnsafe(FastMutex);
1439 }
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1316

Referenced by ExEnterCriticalRegionAndAcquireFastMutexUnsafe().

◆ _ExInitializePushLock()

FORCEINLINE VOID _ExInitializePushLock ( OUT PEX_PUSH_LOCK  PushLock)

Definition at line 994 of file ex.h.

995 {
996  /* Set the value to 0 */
997  PushLock->Ptr = 0;
998 }

◆ _ExInitializeRundownProtection()

FORCEINLINE VOID _ExInitializeRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 890 of file ex.h.

891 {
892  /* Set the count to zero */
893  RunRef->Count = 0;
894 }

Referenced by ExAllocateCacheAwareRundownProtection(), and ExInitializeRundownProtectionCacheAware().

◆ _ExReleaseFastMutex()

FORCEINLINE VOID _ExReleaseFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1383 of file ex.h.

1384 {
1385  KIRQL OldIrql;
1387 
1388  /* Erase the owner */
1389  FastMutex->Owner = NULL;
1390  OldIrql = (KIRQL)FastMutex->OldIrql;
1391 
1392  /* Increase the count */
1393  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1394  {
1395  /* Someone was waiting for it, signal the waiter */
1396  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1397  }
1398 
1399  /* Lower IRQL back */
1401 }
#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:714
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#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 1340 of file ex.h.

1341 {
1343  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1344  (KeGetCurrentThread()->Teb == NULL) ||
1346  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1347 
1348  /* Erase the owner */
1349  FastMutex->Owner = NULL;
1350 
1351  /* Increase the count */
1352  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1353  {
1354  /* Someone was waiting for it, signal the waiter */
1355  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1356  }
1357 }
#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:493
#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 1443 of file ex.h.

1444 {
1445  /* Release the mutex unsafely */
1446  _ExReleaseFastMutexUnsafe(FastMutex);
1447 
1448  /* Leave the critical region */
1450 }
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1340

Referenced by ExReleaseFastMutexUnsafeAndLeaveCriticalRegion().

◆ _ExReleaseRundownProtection()

FORCEINLINE VOID _ExReleaseRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 847 of file ex.h.

848 {
849  ULONG_PTR Value, NewValue;
850 
851  /* Get the current value and mask the active bit */
852  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
853 
854  /* Remove a reference */
855  NewValue = Value - EX_RUNDOWN_COUNT_INC;
856 
857  /* Change the value */
858  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
859 
860  /* Check if the rundown was active */
861  if (NewValue != Value)
862  {
863  /* Rundown was active, use long path */
865  }
866  else
867  {
868  /* Sanity check */
870  }
871 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:64
#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 944 of file ex.h.

945 {
946  /* Sanity check */
947  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
948 
949  /* Mark the counter as active */
951 }
#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 1405 of file ex.h.

1406 {
1407  KIRQL OldIrql;
1409 
1410  /* Raise to APC_LEVEL */
1412 
1413  /* Check if we can quickly acquire it */
1414  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1415  {
1416  /* We have, set us as owners */
1417  FastMutex->Owner = KeGetCurrentThread();
1418  FastMutex->OldIrql = OldIrql;
1419  return TRUE;
1420  }
1421  else
1422  {
1423  /* Acquire attempt failed */
1425  YieldProcessor();
1426  return FALSE;
1427  }
1428 }
#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:790
#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 914 of file ex.h.

915 {
917 
918  /* Set the active bit */
920  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
921  {
922  /* If the the rundown wasn't already active, then take the long path */
924  }
925 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2373
VOID FASTCALL ExfWaitForRundownProtectionRelease(IN OUT PEX_RUNDOWN_REF RunRef)
uint32_t ULONG_PTR
Definition: typedefs.h:64
#define ExpChangeRundown(x, y, z)
Definition: ex.h:158
#define EX_RUNDOWN_ACTIVE

◆ ExAcquireFastReference()

FORCEINLINE EX_FAST_REF ExAcquireFastReference ( IN OUT PEX_FAST_REF  FastRef)

Definition at line 603 of file ex.h.

604 {
605  EX_FAST_REF OldValue, NewValue;
606 
607  /* Start reference loop */
608  for (;;)
609  {
610  /* Get the current reference count */
611  OldValue = *FastRef;
612  if (OldValue.RefCnt)
613  {
614  /* Increase the reference count */
615  NewValue.Value = OldValue.Value - 1;
616  NewValue.Object = ExpChangePushlock(&FastRef->Object,
617  NewValue.Object,
618  OldValue.Object);
619  if (NewValue.Object != OldValue.Object) continue;
620  }
621 
622  /* We are done */
623  break;
624  }
625 
626  /* Return the old value */
627  return OldValue;
628 }
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 1022 of file ex.h.

1023 {
1024  /* Try acquiring the lock */
1026  {
1027  /* Someone changed it, use the slow path */
1028  ExfAcquirePushLockExclusive(PushLock);
1029  }
1030 
1031  /* Sanity check */
1032  ASSERT(PushLock->Locked);
1033 }
#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 1091 of file ex.h.

1092 {
1093  EX_PUSH_LOCK NewValue;
1094 
1095  /* Try acquiring the lock */
1097  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1098  {
1099  /* Someone changed it, use the slow path */
1100  ExfAcquirePushLockShared(PushLock);
1101  }
1102 
1103  /* Sanity checks */
1104  ASSERT(PushLock->Locked);
1105 }
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:1538

Referenced by ExSetTimerResolution().

◆ 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:681
#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:1034
#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 340 of file uuid.c.

341 {
342  /* Atomically increment the luid */
343  *(LONG64*)LocallyUniqueId = InterlockedExchangeAdd64(&ExpLuid.QuadPart,
345 }
LARGE_INTEGER ExpLuid
Definition: uuid.c:48
int64_t LONG64
Definition: typedefs.h:67
#define InterlockedExchangeAdd64
Definition: interlocked.h:186
LONGLONG QuadPart
Definition: typedefs.h:113
ULONG ExpLuidIncrement
Definition: uuid.c:47

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
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
#define PAGED_CODE()

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:566
#define TRUE
Definition: types.h:120
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1164
_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:574
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:733
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 733 of file ex.h.

736 {
737  EX_FAST_REF OldValue, NewValue;
738 
739  /* Sanity check and start swap loop */
741  for (;;)
742  {
743  /* Get the current value */
744  OldValue = *FastRef;
745 
746  /* Make sure there's enough references to swap */
747  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
748 
749  /* Check if we have an object to swap */
750  if (Object)
751  {
752  /* Set up the value with maximum fast references */
753  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
754  }
755  else
756  {
757  /* Write the object address itself (which is empty) */
758  NewValue.Value = (ULONG_PTR)Object;
759  }
760 
761  /* Do the actual compare exchange */
762  NewValue.Object = ExpChangePushlock(&FastRef->Object,
763  NewValue.Object,
764  OldValue.Object);
765  if (NewValue.Object != OldValue.Object) continue;
766 
767  /* All done */
768  break;
769  }
770 
771  /* Return the old value */
772  return OldValue;
773 }
uint32_t ULONG_PTR
Definition: typedefs.h:64
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 1125 of file ex.h.

1126 {
1127  EX_PUSH_LOCK OldValue;
1128 
1129  /* Set the expected old value */
1131 
1132  /* Try converting the lock */
1133  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1134  OldValue.Ptr)
1135  {
1136  /* Conversion failed */
1137  return FALSE;
1138  }
1139 
1140  /* Sanity check */
1141  ASSERT(PushLock->Locked);
1142  return TRUE;
1143 }
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
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
#define PAGED_CODE()

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:1022
#define TRUE
Definition: types.h:120
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define InsertTailList(ListHead, Entry)
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1238
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
#define PAGED_CODE()

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

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
uint32_t ULONG_PTR
Definition: typedefs.h:64
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
#define PAGED_CODE()

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
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
#define PAGED_CODE()

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

543 {
544  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
546 
547  /* Reference the block */
548  CallbackBlock = ExReferenceCallBackBlock(Callback);
549  if (CallbackBlock)
550  {
551  /* Get the function */
552  Function = ExGetCallBackBlockRoutine(CallbackBlock);
553 
554  /* Do the callback */
556 
557  /* Now dereference it */
558  ExDereferenceCallBackBlock(Callback, CallbackBlock);
559  }
560 }
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
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:681
_In_ PVOID Argument2
Definition: classpnp.h:680
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:698
LPFNPSPCALLBACK Callback
Definition: desk.c:112

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:1022
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)
BOOLEAN NTAPI ExpAllocateHandleTableEntrySlow(IN PHANDLE_TABLE HandleTable, IN BOOLEAN DoInit)
Definition: handle.c:466
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1238
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
#define PAGED_CODE()

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

575 {
576  /* Return the reference count */
577  return (ULONG)FastRef.RefCnt;
578 }
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 566 of file ex.h.

567 {
568  /* Return the unbiased pointer */
569  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
570 }
#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 1345 of file expool.c.

1348 {
1349  ULONG TableSize, CurrentLength;
1350  ULONG EntryCount;
1352  PSYSTEM_POOLTAG TagEntry;
1353  PPOOL_TRACKER_TABLE Buffer, TrackerEntry;
1356 
1357  //
1358  // Keep track of how much data the caller's buffer must hold
1359  //
1360  CurrentLength = FIELD_OFFSET(SYSTEM_POOLTAG_INFORMATION, TagInfo);
1361 
1362  //
1363  // Initialize the caller's buffer
1364  //
1365  TagEntry = &SystemInformation->TagInfo[0];
1366  SystemInformation->Count = 0;
1367 
1368  //
1369  // Capture the number of entries, and the total size needed to make a copy
1370  // of the table
1371  //
1372  EntryCount = (ULONG)PoolTrackTableSize;
1373  TableSize = EntryCount * sizeof(POOL_TRACKER_TABLE);
1374 
1375  //
1376  // Allocate the "Generic DPC" temporary buffer
1377  //
1380 
1381  //
1382  // Do a "Generic DPC" to atomically retrieve the tag and allocation data
1383  //
1384  Context.PoolTrackTable = Buffer;
1385  Context.PoolTrackTableSize = PoolTrackTableSize;
1386  Context.PoolTrackTableExpansion = NULL;
1387  Context.PoolTrackTableSizeExpansion = 0;
1389 
1390  //
1391  // Now parse the results
1392  //
1393  for (TrackerEntry = Buffer; TrackerEntry < (Buffer + EntryCount); TrackerEntry++)
1394  {
1395  //
1396  // If the entry is empty, skip it
1397  //
1398  if (!TrackerEntry->Key) continue;
1399 
1400  //
1401  // Otherwise, add one more entry to the caller's buffer, and ensure that
1402  // enough space has been allocated in it
1403  //
1404  SystemInformation->Count++;
1405  CurrentLength += sizeof(*TagEntry);
1406  if (SystemInformationLength < CurrentLength)
1407  {
1408  //
1409  // The caller's buffer is too small, so set a failure code. The
1410  // caller will know the count, as well as how much space is needed.
1411  //
1412  // We do NOT break out of the loop, because we want to keep incrementing
1413  // the Count as well as CurrentLength so that the caller can know the
1414  // final numbers
1415  //
1417  }
1418  else
1419  {
1420  //
1421  // Small sanity check that our accounting is working correctly
1422  //
1423  ASSERT(TrackerEntry->PagedAllocs >= TrackerEntry->PagedFrees);
1424  ASSERT(TrackerEntry->NonPagedAllocs >= TrackerEntry->NonPagedFrees);
1425 
1426  //
1427  // Return the data into the caller's buffer
1428  //
1429  TagEntry->TagUlong = TrackerEntry->Key;
1430  TagEntry->PagedAllocs = TrackerEntry->PagedAllocs;
1431  TagEntry->PagedFrees = TrackerEntry->PagedFrees;
1432  TagEntry->PagedUsed = TrackerEntry->PagedBytes;
1433  TagEntry->NonPagedAllocs = TrackerEntry->NonPagedAllocs;
1434  TagEntry->NonPagedFrees = TrackerEntry->NonPagedFrees;
1435  TagEntry->NonPagedUsed = TrackerEntry->NonPagedBytes;
1436  TagEntry++;
1437  }
1438  }
1439 
1440  //
1441  // Free the "Generic DPC" temporary buffer, return the buffer length and status
1442  //
1443  ExFreePoolWithTag(Buffer, 'ofnI');
1444  if (ReturnLength) *ReturnLength = CurrentLength;
1445  return Status;
1446 }
#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:1850
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:378
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:1310
SIZE_T PagedUsed
Definition: extypes.h:1131
LONG NonPagedFrees
Definition: miarm.h:377
SIZE_T PagedBytes
Definition: miarm.h:381
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:376
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:3971
struct tagContext Context
Definition: acpixf.h:1034
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:2440
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by QSI_DEF().

◆ ExGetRunRefForGivenProcessor()

◆ 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:582
smooth NULL
Definition: ftsmooth.c:416
LPFNPSPCALLBACK Callback
Definition: desk.c:112

Referenced by CmpInitCallback(), and PspInitPhase0().

◆ ExInitializeFastReference()

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

Definition at line 582 of file ex.h.

584 {
585  /* Sanity check */
586  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
587 
588  /* Check if an object is being set */
589  if (!Object)
590  {
591  /* Clear the field */
592  FastRef->Object = NULL;
593  }
594  else
595  {
596  /* Otherwise, we assume the object was referenced and is ready */
597  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
598  }
599 }
uint32_t ULONG_PTR
Definition: typedefs.h:64
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:361
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:627
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1063
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 632 of file ex.h.

634 {
635  EX_FAST_REF OldValue, NewValue;
636 
637  /* Sanity checks */
639 
640  /* Start update loop */
641  for (;;)
642  {
643  /* Get the current reference count */
644  OldValue = *FastRef;
645 
646  /* Check if the current count is too high or if the pointer changed */
647  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
648  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
649  {
650  /* Fail */
651  return FALSE;
652  }
653 
654  /* Update the reference count */
655  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
656  NewValue.Object = ExpChangePushlock(&FastRef->Object,
657  NewValue.Object,
658  OldValue.Object);
659  if (NewValue.Object != OldValue.Object) continue;
660 
661  /* We are done */
662  break;
663  }
664 
665  /* Return success */
666  return TRUE;
667 }
#define TRUE
Definition: types.h:120
ULONG_PTR RefCnt
Definition: extypes.h:423
uint32_t ULONG_PTR
Definition: typedefs.h:64
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().

◆ ExLuidInitialization()

INIT_FUNCTION BOOLEAN NTAPI ExLuidInitialization ( VOID  )

Definition at line 330 of file uuid.c.

331 {
332  return TRUE;
333 }
#define TRUE
Definition: types.h:120

Referenced by SepInitializationPhase0().

◆ 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
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
#define PAGED_CODE()

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:4226
uint32_t ULONG_PTR
Definition: typedefs.h:64
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:4400
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:753
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1492
#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
#define OBJ_OPENLINK
Definition: winternl.h:230
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
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
POBJECT_TYPE ExCallbackObjectType
Definition: callback.c:38
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE DirectoryHandle
Definition: ObType.c:48
NTSTATUS NTAPI ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
Definition: callback.c:361
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:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
#define OBJ_PERMANENT
Definition: winternl.h:226
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:773
#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 }
#define OBJ_OPENLINK
Definition: winternl.h:230
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
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:32
struct _KEVENT KEVENT
static const WCHAR L[]
Definition: oid.c:1250
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 }
#define OBJ_OPENLINK
Definition: winternl.h:230
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
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:32
static const WCHAR L[]
Definition: oid.c:1250
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 919 of file init.c.

921 {
922  PNLS_DATA_BLOCK NlsData;
923  CHAR Buffer[256];
924  ANSI_STRING AnsiPath;
926  PCHAR CommandLine, PerfMem;
927  ULONG PerfMemUsed;
928  PLDR_DATA_TABLE_ENTRY NtosEntry;
929  PMESSAGE_RESOURCE_ENTRY MsgEntry;
930  ANSI_STRING CSDString;
931  size_t Remaining = 0;
932  PCHAR RcEnd = NULL;
933  CHAR VersionBuffer[65];
934 
935  /* Validate Loader */
936  if (!ExpIsLoaderValid(LoaderBlock))
937  {
938  /* Invalid loader version */
939  KeBugCheckEx(MISMATCHED_HAL,
940  3,
941  LoaderBlock->Extension->Size,
942  LoaderBlock->Extension->MajorVersion,
943  LoaderBlock->Extension->MinorVersion);
944  }
945 
946  /* Initialize PRCB pool lookaside pointers */
948 
949  /* Check if this is an application CPU */
950  if (Cpu)
951  {
952  /* Then simply initialize it with HAL */
953  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
954  {
955  /* Initialization failed */
956  KeBugCheck(HAL_INITIALIZATION_FAILED);
957  }
958 
959  /* We're done */
960  return;
961  }
962 
963  /* Assume no text-mode or remote boot */
966 
967  /* Check if we have a setup loader block */
968  if (LoaderBlock->SetupLdrBlock)
969  {
970  /* Check if this is text-mode setup */
971  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
973 
974  /* Check if this is network boot */
975  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
976  {
977  /* Set variable */
979 
980  /* Make sure we're actually booting off the network */
981  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
982  }
983  }
984 
985  /* Set phase to 0 */
987 
988  /* Get boot command line */
989  CommandLine = LoaderBlock->LoadOptions;
990  if (CommandLine)
991  {
992  /* Upcase it for comparison and check if we're in performance mode */
993  _strupr(CommandLine);
994  PerfMem = strstr(CommandLine, "PERFMEM");
995  if (PerfMem)
996  {
997  /* Check if the user gave a number of bytes to use */
998  PerfMem = strstr(PerfMem, "=");
999  if (PerfMem)
1000  {
1001  /* Read the number of pages we'll use */
1002  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1003  if (PerfMemUsed)
1004  {
1005  /* FIXME: TODO */
1006  DPRINT1("BBT performance mode not yet supported."
1007  "/PERFMEM option ignored.\n");
1008  }
1009  }
1010  }
1011 
1012  /* Check if we're burning memory */
1013  PerfMem = strstr(CommandLine, "BURNMEMORY");
1014  if (PerfMem)
1015  {
1016  /* Check if the user gave a number of bytes to use */
1017  PerfMem = strstr(PerfMem, "=");
1018  if (PerfMem)
1019  {
1020  /* Read the number of pages we'll use */
1021  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1022  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1023  }
1024  }
1025  }
1026 
1027  /* Setup NLS Base and offsets */
1028  NlsData = LoaderBlock->NlsData;
1029  ExpNlsTableBase = NlsData->AnsiCodePageData;
1032  (ULONG_PTR)NlsData->AnsiCodePageData);
1034  (ULONG_PTR)NlsData->AnsiCodePageData);
1035 
1036  /* Initialize the NLS Tables */
1043  &ExpNlsTableInfo);
1045 
1046  /* Now initialize the HAL */
1047  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1048  {
1049  /* HAL failed to initialize, bugcheck */
1050  KeBugCheck(HAL_INITIALIZATION_FAILED);
1051  }
1052 
1053  /* Make sure interrupts are active now */
1054  _enable();
1055 
1056  /* Clear the crypto exponent */
1057  SharedUserData->CryptoExponent = 0;
1058 
1059  /* Set global flags for the checked build */
1060 #if DBG
1063 #endif
1064 
1065  /* Setup NT System Root Path */
1066  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1067 
1068  /* Convert to ANSI_STRING and null-terminate it */
1069  RtlInitString(&AnsiPath, Buffer);
1070  Buffer[--AnsiPath.Length] = ANSI_NULL;
1071 
1072  /* Get the string from KUSER_SHARED_DATA's buffer */
1073  RtlInitEmptyUnicodeString(&NtSystemRoot,
1074  SharedUserData->NtSystemRoot,
1075  sizeof(SharedUserData->NtSystemRoot));
1076 
1077  /* Now fill it in */
1079  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1080 
1081  /* Setup bugcheck messages */
1083 
1084  /* Setup initial system settings */
1085  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1086 
1087  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1089  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1090  {
1092  }
1093 
1094  /* Add loaded CmNtGlobalFlag value */
1096 
1097  /* Initialize the executive at phase 0 */
1098  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1099 
1100  /* Initialize the memory manager at phase 0 */
1101  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1102 
1103  /* Load boot symbols */
1104  ExpLoadBootSymbols(LoaderBlock);
1105 
1106  /* Check if we should break after symbol load */
1108 
1109  /* Check if this loader is compatible with NT 5.2 */
1110  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1111  {
1112  /* Setup headless terminal settings */
1113  HeadlessInit(LoaderBlock);
1114  }
1115 
1116  /* Set system ranges */
1117 #ifdef _M_AMD64
1120 #else
1123 #endif
1124 
1125  /* Make a copy of the NLS Tables */
1126  ExpInitNls(LoaderBlock);
1127 
1128  /* Get the kernel's load entry */
1129  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1131  InLoadOrderLinks);
1132 
1133  /* Check if this is a service pack */
1134  if (CmNtCSDVersion & 0xFFFF)
1135  {
1136  /* Get the service pack string */
1137  Status = RtlFindMessage(NtosEntry->DllBase,
1138  11,
1139  0,
1140  WINDOWS_NT_CSD_STRING,
1141  &MsgEntry);
1142  if (NT_SUCCESS(Status))
1143  {
1144  /* Setup the string */
1145  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1146 
1147  /* Remove trailing newline */
1148  while ((CSDString.Length > 0) &&
1149  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1150  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1151  {
1152  /* Skip the trailing character */
1153  CSDString.Length--;
1154  }
1155 
1156  /* Fill the buffer with version information */
1158  sizeof(Buffer),
1159  "%Z %u%c",
1160  &CSDString,
1161  (CmNtCSDVersion & 0xFF00) >> 8,
1162  (CmNtCSDVersion & 0xFF) ?
1163  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1164  ANSI_NULL);
1165  }
1166  else
1167  {
1168  /* Build default string */
1170  sizeof(Buffer),
1171  "CSD %04x",
1172  CmNtCSDVersion);
1173  }
1174 
1175  /* Check for success */
1176  if (!NT_SUCCESS(Status))
1177  {
1178  /* Fail */
1179  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1180  }
1181  }
1182  else
1183  {
1184  /* Then this is a beta */
1186  sizeof(Buffer),
1188  NULL,
1189  &Remaining,
1190  0);
1191  if (!NT_SUCCESS(Status))
1192  {
1193  /* Fail */
1194  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1195  }
1196 
1197  /* Update length */
1198  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1199  }
1200 
1201  /* Check if we have an RC number */
1202  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1203  {
1204  /* Check if we have no version data yet */
1205  if (!(*Buffer))
1206  {
1207  /* Set defaults */
1208  Remaining = sizeof(Buffer);
1209  RcEnd = Buffer;
1210  }
1211  else
1212  {
1213  /* Add comma and space */
1215  sizeof(Buffer),
1216  ", ",
1217  &RcEnd,
1218  &Remaining,
1219  0);
1220  if (!NT_SUCCESS(Status))
1221  {
1222  /* Fail */
1223  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1224  }
1225  }
1226 
1227  /* Add the version format string */
1228  Status = RtlStringCbPrintfA(RcEnd,
1229  Remaining,
1230  "v.%u",
1231  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1232  if (!NT_SUCCESS(Status))
1233  {
1234  /* Fail */
1235  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1236  }
1237  }
1238 
1239  /* Now setup the final string */
1240  RtlInitAnsiString(&CSDString, Buffer);
1242  &CSDString,
1243  TRUE);
1244  if (!NT_SUCCESS(Status))
1245  {
1246  /* Fail */
1247  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1248  }
1249 
1250  /* Add our version */
1251  Status = RtlStringCbPrintfA(VersionBuffer,
1252  sizeof(VersionBuffer),
1253  "%u.%u",
1256  if (!NT_SUCCESS(Status))
1257  {
1258  /* Fail */
1259  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1260  }
1261 
1262  /* Build the final version string */
1264 
1265  /* Check if the user wants a kernel stack trace database */
1267  {
1268  /* FIXME: TODO */
1269  DPRINT1("Kernel-mode stack trace support not yet present."
1270  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1271  }
1272 
1273  /* Check if he wanted exception logging */
1275  {
1276  /* FIXME: TODO */
1277  DPRINT1("Kernel-mode exception logging support not yet present."
1278  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1279  }
1280 
1281  /* Initialize the Handle Table */
1283 
1284 #if DBG
1285  /* On checked builds, allocate the system call count table */
1288  KiServiceLimit * sizeof(ULONG),
1289  'llaC');
1290 
1291  /* Use it for the shadow table too */
1293 
1294  /* Make sure allocation succeeded */
1296  {
1297  /* Zero the call counts to 0 */
1299  KiServiceLimit * sizeof(ULONG));
1300  }
1301 #endif
1302 
1303  /* Create the Basic Object Manager Types to allow new Object Types */
1304  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1305 
1306  /* Load basic Security for other Managers */
1307  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1308 
1309  /* Initialize the Process Manager */
1310  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1311 
1312  /* Initialize the PnP Manager */
1313  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1314 
1315  /* Initialize the User-Mode Debugging Subsystem */
1316  DbgkInitialize();
1317 
1318  /* Calculate the tick count multiplier */
1320  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1321 
1322  /* Set the OS Version */
1323  SharedUserData->NtMajorVersion = NtMajorVersion;
1324  SharedUserData->NtMinorVersion = NtMinorVersion;
1325 
1326  /* Set the machine type */
1327  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1328  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1329 }
#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:1868
#define TRUE
Definition: types.h:120
UNICODE_STRING NtSystemRoot
Definition: init.c:73
INIT_FUNCTION BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2043
INIT_FUNCTION VOID NTAPI ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:792
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:85
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG KiServiceLimit
Definition: krnlinit.c:26
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:1843
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
INIT_FUNCTION BOOLEAN NTAPI SeInitSystem(VOID)
Definition: semgr.c:239
INIT_FUNCTION VOID NTAPI DbgkInitialize(VOID)
Definition: dbgkobj.c:1498
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:718
#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
ULONG CmNtCSDReleaseType
Definition: init.c:58
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:43
INIT_FUNCTION BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:203
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:64
PVOID DllBase
Definition: btrfs_drv.h:1926
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ANSI_NULL
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1431
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)
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:301
INIT_FUNCTION BOOLEAN NTAPI ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:766
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
NTSTRSAFEVAPI 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:1148
ULONG CmNtSpBuildNumber
Definition: init.c:56
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:873
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1872
INIT_FUNCTION BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:740
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:82
ULONG NtMinorVersion
Definition: init.c:44
#define FLG_ENABLE_CLOSE_EXCEPTIONS
Definition: pstypes.h:81
INIT_FUNCTION BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:624
_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:84
UNICODE_STRING CmCSDVersionString
Definition: init.c:60
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
Definition: btrfs_drv.h:1922
ULONG ExpInitializationPhase
Definition: init.c:66
UNICODE_STRING CmVersionString
Definition: init.c:59
#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:83
BOOLEAN ExpInTextModeSetup
Definition: init.c:67
_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:210
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:603
BOOLEAN KdBreakAfterSymbolLoad
Definition: kdmain.c:51
#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:57
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:52
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
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:83
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:108
BOOLEAN IoRemoteBootClient
Definition: init.c:68

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:999
#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 }
#define OBJ_OPENLINK
Definition: winternl.h:230
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 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:32
GENERIC_MAPPING ExpMutantMapping
Definition: mutant.c:24
static const WCHAR L[]
Definition: oid.c:1250
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 }
#define OBJ_OPENLINK
Definition: winternl.h:230
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
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:32
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
static const WCHAR L[]
Definition: oid.c:1250
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 }
#define OBJ_OPENLINK
Definition: winternl.h:230
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
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:32
static const WCHAR L[]
Definition: oid.c:1250
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 }
#define OBJ_OPENLINK
Definition: winternl.h:230
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
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:238
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ExpDeleteTimer(IN PVOID ObjectBody)
Definition: timer.c:108
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
static const WCHAR L[]
Definition: oid.c:1250
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:3376
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:238
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

◆ 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:714
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:627
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
uint32_t ULONG_PTR
Definition: typedefs.h:64
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:238
LARGE_INTEGER ExpTimeout
Definition: resource.c:73
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY ExpSystemResourcesList
Definition: resource.c:76
#define Int32x32To64(a, b)
LONGLONG QuadPart
Definition: typedefs.h:113

Referenced by ExpInitSystemPhase0().

◆ ExpSetTimeZoneInformation()

NTSTATUS ExpSetTimeZoneInformation ( IN PRTL_TIME_ZONE_INFORMATION  TimeZoneInformation)

◆ ExpUuidInitialization()

INIT_FUNCTION BOOLEAN NTAPI ExpUuidInitialization ( VOID  )

Definition at line 58 of file uuid.c.

59 {
61 
64 
65  return TRUE;
66 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define TRUE
Definition: types.h:120
FAST_MUTEX ExpUuidLock
Definition: uuid.c:40
LARGE_INTEGER ExpUuidLastTimeAllocated
Definition: uuid.c:41
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
BOOLEAN ExpUuidSequenceNumberValid
Definition: uuid.c:43

Referenced by ExpInitSystemPhase1().

◆ 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,
302  if (!NT_SUCCESS(Status)) return FALSE;
303 
304  return TRUE;
305 }
#define OBJ_OPENLINK
Definition: winternl.h:230
NTSTATUS NTAPI ExpWinStaObjectParse(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: win32k.c:175
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1048
#define TRUE
Definition: types.h:120