ReactOS  0.4.15-dev-2522-g9e0a3cd
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)
 
 C_ASSERT (RTL_FIELD_SIZE(UUID_CACHED_VALUES_STRUCT, GuidInit)==RTL_FIELD_SIZE(UUID, Data4))
 
BOOLEAN NTAPI ExpWin32kInit (VOID)
 
VOID NTAPI ExInit2 (VOID)
 
VOID NTAPI Phase1Initialization (IN PVOID Context)
 
VOID NTAPI ExpInitializePushLocks (VOID)
 
BOOLEAN NTAPI ExRefreshTimeZoneInformation (IN PLARGE_INTEGER SystemBootTime)
 
VOID NTAPI ExpInitializeWorkerThreads (VOID)
 
VOID NTAPI ExSwapinWorkerThreads (IN BOOLEAN AllowSwap)
 
VOID NTAPI ExpInitLookasideLists (VOID)
 
VOID NTAPI ExInitializeSystemLookasideList (IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
 
BOOLEAN NTAPI ExpInitializeCallbacks (VOID)
 
BOOLEAN NTAPI ExpUuidInitialization (VOID)
 
BOOLEAN NTAPI ExLuidInitialization (VOID)
 
VOID NTAPI ExpInitializeExecutive (IN ULONG Cpu, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID NTAPI ExShutdownSystem (VOID)
 
BOOLEAN NTAPI ExpInitializeEventImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeKeyedEventImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeEventPairImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeSemaphoreImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeMutantImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeTimerImplementation (VOID)
 
BOOLEAN NTAPI ExpInitializeProfileImplementation (VOID)
 
VOID NTAPI ExpResourceInitialization (VOID)
 
VOID NTAPI ExInitPoolLookasidePointers (VOID)
 
VOID NTAPI ExInitializeCallBack (IN OUT PEX_CALLBACK Callback)
 
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack (IN PEX_CALLBACK_FUNCTION Function, IN PVOID Context)
 
VOID NTAPI ExFreeCallBack (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
BOOLEAN NTAPI ExCompareExchangeCallBack (IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK NewBlock, IN PEX_CALLBACK_ROUTINE_BLOCK OldBlock)
 
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock (IN OUT PEX_CALLBACK CallBack)
 
VOID NTAPI ExDereferenceCallBackBlock (IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
PEX_CALLBACK_FUNCTION NTAPI ExGetCallBackBlockRoutine (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
PVOID NTAPI ExGetCallBackBlockContext (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
VOID NTAPI ExWaitForCallBacks (IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
 
VOID FASTCALL ExfInitializeRundownProtection (OUT PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExfReInitializeRundownProtection (OUT PEX_RUNDOWN_REF RunRef)
 
BOOLEAN FASTCALL ExfAcquireRundownProtection (IN OUT PEX_RUNDOWN_REF RunRef)
 
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx (IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
 
VOID FASTCALL ExfReleaseRundownProtection (IN OUT PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExfReleaseRundownProtectionEx (IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count)
 
VOID FASTCALL ExfRundownCompleted (OUT PEX_RUNDOWN_REF RunRef)
 
VOID FASTCALL ExfWaitForRundownProtectionRelease (IN OUT PEX_RUNDOWN_REF RunRef)
 
VOID NTAPI ExpInitializeHandleTables (VOID)
 
PHANDLE_TABLE NTAPI ExCreateHandleTable (IN PEPROCESS Process OPTIONAL)
 
VOID NTAPI ExUnlockHandleTableEntry (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 
HANDLE NTAPI ExCreateHandle (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 
VOID NTAPI ExDestroyHandleTable (IN PHANDLE_TABLE HandleTable, IN PVOID DestroyHandleProcedure OPTIONAL)
 
BOOLEAN NTAPI ExDestroyHandle (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
 
PHANDLE_TABLE_ENTRY NTAPI ExMapHandleToPointer (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
 
PHANDLE_TABLE NTAPI ExDupHandleTable (IN PEPROCESS Process, IN PHANDLE_TABLE HandleTable, IN PEX_DUPLICATE_HANDLE_CALLBACK DupHandleProcedure, IN ULONG_PTR Mask)
 
BOOLEAN NTAPI ExChangeHandle (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PEX_CHANGE_HANDLE_CALLBACK ChangeRoutine, IN ULONG_PTR Context)
 
VOID NTAPI ExSweepHandleTable (IN PHANDLE_TABLE HandleTable, IN PEX_SWEEP_HANDLE_CALLBACK EnumHandleProcedure, IN PVOID Context)
 
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry (IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
 
BOOLEAN NTAPI ExpLockHandleTableEntry (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 
LONG NTAPI ExSystemExceptionFilter (VOID)
 
FORCEINLINE VOID ExDoCallBack (IN OUT PEX_CALLBACK Callback, IN PVOID Context, IN PVOID Argument1, IN PVOID Argument2)
 
FORCEINLINE PVOID ExGetObjectFastReference (IN EX_FAST_REF FastRef)
 
FORCEINLINE ULONG ExGetCountFastReference (IN EX_FAST_REF FastRef)
 
FORCEINLINE VOID ExInitializeFastReference (OUT PEX_FAST_REF FastRef, IN OPTIONAL PVOID Object)
 
FORCEINLINE EX_FAST_REF ExAcquireFastReference (IN OUT PEX_FAST_REF FastRef)
 
FORCEINLINE BOOLEAN ExInsertFastReference (IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
 
FORCEINLINE BOOLEAN ExReleaseFastReference (IN PEX_FAST_REF FastRef, IN PVOID Object)
 
FORCEINLINE EX_FAST_REF ExSwapFastReference (IN PEX_FAST_REF FastRef, IN PVOID Object)
 
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference (IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
 
FORCEINLINE 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)
 
VOID NTAPI HeadlessInit (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
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 133 of file ex.h.

◆ ExfInterlockedCompareExchange64UL

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

Definition at line 1519 of file ex.h.

◆ ExGetPreviousMode

#define ExGetPreviousMode   KeGetPreviousMode

Definition at line 138 of file ex.h.

◆ EXHANDLE_TABLE_ENTRY_LOCK_BIT

#define EXHANDLE_TABLE_ENTRY_LOCK_BIT   1

Definition at line 144 of file ex.h.

◆ ExInitializePushLock

#define ExInitializePushLock   _ExInitializePushLock

Definition at line 992 of file ex.h.

◆ ExInitializeRundownProtection

#define ExInitializeRundownProtection   _ExInitializeRundownProtection

Definition at line 135 of file ex.h.

◆ ExpChangePushlock

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

Definition at line 162 of file ex.h.

◆ ExpChangeRundown

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

Definition at line 161 of file ex.h.

◆ ExpSetRundown

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

Definition at line 163 of file ex.h.

◆ ExReleaseRundownProtection

#define ExReleaseRundownProtection   _ExReleaseRundownProtection

Definition at line 134 of file ex.h.

◆ ExRundownCompleted

#define ExRundownCompleted   _ExRundownCompleted

Definition at line 137 of file ex.h.

◆ ExWaitForRundownProtectionRelease

#define ExWaitForRundownProtectionRelease   _ExWaitForRundownProtectionRelease

Definition at line 136 of file ex.h.

◆ FREE_HANDLE_MASK

#define FREE_HANDLE_MASK   -1

Definition at line 145 of file ex.h.

◆ HANDLE_HIGH_BITS

#define HANDLE_HIGH_BITS   (PAGE_SHIFT - 2)

Definition at line 78 of file ex.h.

◆ HANDLE_INDEX_BITS

#define HANDLE_INDEX_BITS   (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)

Definition at line 81 of file ex.h.

◆ HANDLE_LOW_BITS

#define HANDLE_LOW_BITS   (PAGE_SHIFT - 3)

Definition at line 77 of file ex.h.

◆ HANDLE_TAG_BITS

#define HANDLE_TAG_BITS   (2)

Definition at line 80 of file ex.h.

◆ HIGH_LEVEL_ENTRIES

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

Definition at line 152 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 1516 of file ex.h.

◆ InterlockedCompareExchangeUL

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

Definition at line 1513 of file ex.h.

◆ InterlockedDecrementUL

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

Definition at line 1501 of file ex.h.

◆ InterlockedExchangeAddUL

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

Definition at line 1510 of file ex.h.

◆ InterlockedExchangeUL

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

Definition at line 1507 of file ex.h.

◆ InterlockedIncrementUL

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

Definition at line 1504 of file ex.h.

◆ KERNEL_FLAG_BITS

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

Definition at line 82 of file ex.h.

◆ LOW_LEVEL_ENTRIES

#define LOW_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))

Definition at line 150 of file ex.h.

◆ MAX_FAST_REFS

#define MAX_FAST_REFS   7

Definition at line 131 of file ex.h.

◆ MAX_HIGH_INDEX

Definition at line 159 of file ex.h.

◆ MAX_LOW_INDEX

#define MAX_LOW_INDEX   LOW_LEVEL_ENTRIES

Definition at line 157 of file ex.h.

◆ MAX_MID_INDEX

#define MAX_MID_INDEX   (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)

Definition at line 158 of file ex.h.

◆ MID_LEVEL_ENTRIES

#define MID_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))

Definition at line 151 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 429 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 421 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 414 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 58 of file ex.h.

59 {
60  WinKdWorkerReady = 0,
enum _WINKD_WORKER_STATE WINKD_WORKER_STATE

Function Documentation

◆ _ExAcquireFastMutex()

FORCEINLINE VOID _ExAcquireFastMutex ( IN PFAST_MUTEX  FastMutex)

Definition at line 1354 of file ex.h.

1355 {
1356  KIRQL OldIrql;
1358 
1359  /* Raise IRQL to APC */
1361 
1362  /* Decrease the count */
1363  if (InterlockedDecrement(&FastMutex->Count))
1364  {
1365  /* Someone is still holding it, use slow path */
1366  KiAcquireFastMutex(FastMutex);
1367  }
1368 
1369  /* Set the owner and IRQL */
1370  FastMutex->Owner = KeGetCurrentThread();
1371  FastMutex->OldIrql = OldIrql;
1372 }
#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
#define ASSERT(a)
Definition: mode.c:45
#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:49
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by ExAcquireFastMutex().

◆ _ExAcquireFastMutexUnsafe()

FORCEINLINE VOID _ExAcquireFastMutexUnsafe ( IN PFAST_MUTEX  FastMutex)

Definition at line 1309 of file ex.h.

1310 {
1312 
1313  /* Sanity check */
1315  (Thread->CombinedApcDisable != 0) ||
1316  (Thread->Teb == NULL) ||
1317  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1318  ASSERT(FastMutex->Owner != Thread);
1319 
1320  /* Decrease the count */
1321  if (InterlockedDecrement(&FastMutex->Count))
1322  {
1323  /* Someone is still holding it, use slow path */
1324  KiAcquireFastMutex(FastMutex);
1325  }
1326 
1327  /* Set the owner */
1328  FastMutex->Owner = Thread;
1329 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define ASSERT(a)
Definition: mode.c:45
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define InterlockedDecrement
Definition: armddk.h:52
VOID FASTCALL KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: wait.c:107
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:694
#define NULL
Definition: types.h:112
#define KeGetCurrentThread
Definition: hal.h:49
#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 799 of file ex.h.

800 {
801  ULONG_PTR Value, NewValue;
802 
803  /* Get the current value and mask the active bit */
804  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
805 
806  /* Add a reference */
807  NewValue = Value + EX_RUNDOWN_COUNT_INC;
808 
809  /* Change the value */
810  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
811  if (NewValue != Value)
812  {
813  /* Rundown was active, use long path */
814  return ExfAcquireRundownProtection(RunRef);
815  }
816 
817  /* Success */
818  return TRUE;
819 }
#define TRUE
Definition: types.h:120
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define ExpChangeRundown(x, y, z)
Definition: ex.h:161
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 1425 of file ex.h.

1426 {
1427  /* Enter the Critical Region */
1429 
1430  /* Acquire the mutex unsafely */
1431  _ExAcquireFastMutexUnsafe(FastMutex);
1432 }
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1309

Referenced by ExEnterCriticalRegionAndAcquireFastMutexUnsafe().

◆ _ExInitializePushLock()

FORCEINLINE VOID _ExInitializePushLock ( OUT PEX_PUSH_LOCK  PushLock)

Definition at line 987 of file ex.h.

988 {
989  /* Set the value to 0 */
990  PushLock->Ptr = 0;
991 }

◆ _ExInitializeRundownProtection()

FORCEINLINE VOID _ExInitializeRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 883 of file ex.h.

884 {
885  /* Set the count to zero */
886  RunRef->Count = 0;
887 }

Referenced by ExAllocateCacheAwareRundownProtection(), and ExInitializeRundownProtectionCacheAware().

◆ _ExReleaseFastMutex()

FORCEINLINE VOID _ExReleaseFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1376 of file ex.h.

1377 {
1378  KIRQL OldIrql;
1380 
1381  /* Erase the owner */
1382  FastMutex->Owner = NULL;
1383  OldIrql = (KIRQL)FastMutex->OldIrql;
1384 
1385  /* Increase the count */
1386  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1387  {
1388  /* Someone was waiting for it, signal the waiter */
1389  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1390  }
1391 
1392  /* Lower IRQL back */
1394 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
if(dx==0 &&dy==0)
Definition: linetemp.h:174
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:45
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define InterlockedIncrement
Definition: armddk.h:53
#define NULL
Definition: types.h:112
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 1333 of file ex.h.

1334 {
1336  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1337  (KeGetCurrentThread()->Teb == NULL) ||
1339  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1340 
1341  /* Erase the owner */
1342  FastMutex->Owner = NULL;
1343 
1344  /* Increase the count */
1345  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1346  {
1347  /* Someone was waiting for it, signal the waiter */
1348  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1349  }
1350 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define ASSERT(a)
Definition: mode.c:45
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:694
#define InterlockedIncrement
Definition: armddk.h:53
#define NULL
Definition: types.h:112
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
Definition: eventobj.c:229
#define KeGetCurrentThread
Definition: hal.h:49
#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 1436 of file ex.h.

1437 {
1438  /* Release the mutex unsafely */
1439  _ExReleaseFastMutexUnsafe(FastMutex);
1440 
1441  /* Leave the critical region */
1443 }
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1333

Referenced by ExReleaseFastMutexUnsafeAndLeaveCriticalRegion().

◆ _ExReleaseRundownProtection()

FORCEINLINE VOID _ExReleaseRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 840 of file ex.h.

841 {
842  ULONG_PTR Value, NewValue;
843 
844  /* Get the current value and mask the active bit */
845  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
846 
847  /* Remove a reference */
848  NewValue = Value - EX_RUNDOWN_COUNT_INC;
849 
850  /* Change the value */
851  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
852 
853  /* Check if the rundown was active */
854  if (NewValue != Value)
855  {
856  /* Rundown was active, use long path */
858  }
859  else
860  {
861  /* Sanity check */
863  }
864 }
#define EX_RUNDOWN_COUNT_INC
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define ASSERT(a)
Definition: mode.c:45
#define ExpChangeRundown(x, y, z)
Definition: ex.h:161
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 937 of file ex.h.

938 {
939  /* Sanity check */
940  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
941 
942  /* Mark the counter as active */
944 }
#define ExpSetRundown(x, y)
Definition: ex.h:163
#define ASSERT(a)
Definition: mode.c:45
#define EX_RUNDOWN_ACTIVE

◆ _ExTryToAcquireFastMutex()

FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1398 of file ex.h.

1399 {
1400  KIRQL OldIrql;
1402 
1403  /* Raise to APC_LEVEL */
1405 
1406  /* Check if we can quickly acquire it */
1407  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1408  {
1409  /* We have, set us as owners */
1410  FastMutex->Owner = KeGetCurrentThread();
1411  FastMutex->OldIrql = OldIrql;
1412  return TRUE;
1413  }
1414  else
1415  {
1416  /* Acquire attempt failed */
1418  YieldProcessor();
1419  return FALSE;
1420  }
1421 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define TRUE
Definition: types.h:120
#define InterlockedCompareExchange
Definition: interlocked.h:104
FORCEINLINE VOID YieldProcessor(VOID)
Definition: ke.h:32
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define KeGetCurrentThread
Definition: hal.h:49
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by ExTryToAcquireFastMutex().

◆ _ExWaitForRundownProtectionRelease()

FORCEINLINE VOID _ExWaitForRundownProtectionRelease ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 907 of file ex.h.

908 {
910 
911  /* Set the active bit */
913  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
914  {
915  /* If the the rundown wasn't already active, then take the long path */
917  }
918 }
VOID FASTCALL ExfWaitForRundownProtectionRelease(IN OUT PEX_RUNDOWN_REF RunRef)
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define ExpChangeRundown(x, y, z)
Definition: ex.h:161
#define EX_RUNDOWN_ACTIVE

◆ C_ASSERT()

C_ASSERT ( RTL_FIELD_SIZE(UUID_CACHED_VALUES_STRUCT, GuidInit)  = =RTL_FIELD_SIZE(UUID, Data4))

◆ ExAcquireFastReference()

FORCEINLINE EX_FAST_REF ExAcquireFastReference ( IN OUT PEX_FAST_REF  FastRef)

Definition at line 596 of file ex.h.

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

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

◆ ExAcquirePushLockExclusive()

FORCEINLINE VOID ExAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 1015 of file ex.h.

1016 {
1017  /* Try acquiring the lock */
1019  {
1020  /* Someone changed it, use the slow path */
1021  ExfAcquirePushLockExclusive(PushLock);
1022  }
1023 
1024  /* Sanity check */
1025  ASSERT(PushLock->Locked);
1026 }
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
#define ASSERT(a)
Definition: mode.c:45
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 1084 of file ex.h.

1085 {
1086  EX_PUSH_LOCK NewValue;
1087 
1088  /* Try acquiring the lock */
1090  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1091  {
1092  /* Someone changed it, use the slow path */
1093  ExfAcquirePushLockShared(PushLock);
1094  }
1095 
1096  /* Sanity checks */
1097  ASSERT(PushLock->Locked);
1098 }
ULONG_PTR Value
Definition: extypes.h:465
PVOID Ptr
Definition: extypes.h:466
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
#define ASSERT(a)
Definition: mode.c:45
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:162
ULONG_PTR Locked
Definition: extypes.h:459

Referenced by CmpDoFlushAll(), CmpDoFlushNextHive(), ExpAllocateHandleTableEntry(), MiLockProcessWorkingSetShared(), MiLockWorkingSetShared(), 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
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define FALSE
Definition: types.h:117
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27

Referenced by ExSetTimerResolution(), and KdpTimeSlipWork().

◆ ExAllocateCallBack()

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

Definition at line 54 of file callback.c.

56 {
57  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
58 
59  /* Allocate a callback */
60  CallbackBlock = ExAllocatePoolWithTag(PagedPool,
63  if (CallbackBlock)
64  {
65  /* Initialize it */
66  CallbackBlock->Function = Function;
67  CallbackBlock->Context = Context;
69  }
70 
71  /* Return it */
72  return CallbackBlock;
73 }
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1154
NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection(_Out_ PEX_RUNDOWN_REF RunRef)
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
EX_RUNDOWN_REF RundownProtect
Definition: extypes.h:537
struct tagContext Context
Definition: acpixf.h: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 334 of file uuid.c.

335 {
336  /* Atomically increment the luid */
337  *(LONG64*)LocallyUniqueId = InterlockedExchangeAdd64(&ExpLuid.QuadPart,
339 }
LARGE_INTEGER ExpLuid
Definition: uuid.c:42
int64_t LONG64
Definition: typedefs.h:68
#define InterlockedExchangeAdd64
Definition: interlocked.h:186
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG ExpLuidIncrement
Definition: uuid.c:41

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

◆ ExBlockPushLock()

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

◆ ExChangeHandle()

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

Definition at line 1153 of file handle.c.

1157 {
1158  EXHANDLE ExHandle;
1159  PHANDLE_TABLE_ENTRY HandleTableEntry;
1160  BOOLEAN Result = FALSE;
1161  PAGED_CODE();
1162 
1163  /* Set the handle value */
1164  ExHandle.GenericHandleOverlay = Handle;
1165 
1166  /* Find the entry for this handle */
1167  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1168 
1169  /* Make sure that we found an entry, and that it's valid */
1170  if (!(HandleTableEntry) ||
1171  !(HandleTableEntry->Object) ||
1172  (HandleTableEntry->NextFreeTableEntry == -2))
1173  {
1174  /* It isn't, fail */
1175  return FALSE;
1176  }
1177 
1178  /* Enter a critical region */
1180 
1181  /* Try locking the handle entry */
1182  if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1183  {
1184  /* Call the change routine and unlock the entry */
1185  Result = ChangeRoutine(HandleTableEntry, Context);
1186  ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
1187  }
1188 
1189  /* Leave the critical region and return the callback result */
1191  return Result;
1192 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
#define FALSE
Definition: types.h:117
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
HANDLE GenericHandleOverlay
Definition: ex.h:100
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
Definition: ex.h:84
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
LONG NextFreeTableEntry
Definition: extypes.h:612
_In_ HANDLE Handle
Definition: extypes.h:390
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:559
#define TRUE
Definition: types.h:120
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1157
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
int Count
Definition: noreturn.cpp:7
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:567
VOID FASTCALL ExfReleaseRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:260
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:726
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:78
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
EX_RUNDOWN_REF RundownProtect
Definition: extypes.h:537
unsigned int ULONG
Definition: retypes.h:1
#define MAX_FAST_REFS
Definition: ex.h:131

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

729 {
730  EX_FAST_REF OldValue, NewValue;
731 
732  /* Sanity check and start swap loop */
734  for (;;)
735  {
736  /* Get the current value */
737  OldValue = *FastRef;
738 
739  /* Make sure there's enough references to swap */
740  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
741 
742  /* Check if we have an object to swap */
743  if (Object)
744  {
745  /* Set up the value with maximum fast references */
746  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
747  }
748  else
749  {
750  /* Write the object address itself (which is empty) */
751  NewValue.Value = (ULONG_PTR)Object;
752  }
753 
754  /* Do the actual compare exchange */
755  NewValue.Object = ExpChangePushlock(&FastRef->Object,
756  NewValue.Object,
757  OldValue.Object);
758  if (NewValue.Object != OldValue.Object) continue;
759 
760  /* All done */
761  break;
762  }
763 
764  /* Return the old value */
765  return OldValue;
766 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID Object
Definition: extypes.h:422
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:131
#define ExpChangePushlock(x, y, z)
Definition: ex.h:162
ULONG_PTR Value
Definition: extypes.h:424

Referenced by ExCompareExchangeCallBack(), and ObSetSecurityDescriptorInfo().

◆ ExConvertPushLockSharedToExclusive()

FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive ( IN PEX_PUSH_LOCK  PushLock)

Definition at line 1118 of file ex.h.

1119 {
1120  EX_PUSH_LOCK OldValue;
1121 
1122  /* Set the expected old value */
1124 
1125  /* Try converting the lock */
1126  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1127  OldValue.Ptr)
1128  {
1129  /* Conversion failed */
1130  return FALSE;
1131  }
1132 
1133  /* Sanity check */
1134  ASSERT(PushLock->Locked);
1135  return TRUE;
1136 }
ULONG_PTR Value
Definition: extypes.h:465
#define TRUE
Definition: types.h:120
PVOID Ptr
Definition: extypes.h:466
#define FALSE
Definition: types.h:117
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
#define ASSERT(a)
Definition: mode.c:45
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define ExpChangePushlock(x, y, z)
Definition: ex.h:162

Referenced by CmpTryToConvertKcbSharedToExclusive(), MiConvertSharedWorkingSetLockToExclusive(), 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
PHANDLE_TABLE_ENTRY NTAPI ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, OUT PEXHANDLE NewHandle)
Definition: handle.c:647
Definition: ex.h:84
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define NULL
Definition: types.h:112
_In_ HANDLE Handle
Definition: extypes.h:390
#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:1015
#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:1231
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define NULL
Definition: types.h:112
_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:664

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:65
#define FALSE
Definition: types.h:117
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define ASSERT(a)
Definition: mode.c:45
HANDLE GenericHandleOverlay
Definition: ex.h:100
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
Definition: ex.h:84
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:144
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define NULL
Definition: types.h:112
VOID FASTCALL ExfUnblockPushLock(PEX_PUSH_LOCK PushLock, PVOID CurrentWaitBlock)
Definition: pushlock.c:1205
_In_ HANDLE Handle
Definition: extypes.h:390
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
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:45
VOID NTAPI ExRemoveHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:908
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 532 of file ex.h.

536 {
537  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
539 
540  /* Reference the block */
541  CallbackBlock = ExReferenceCallBackBlock(Callback);
542  if (CallbackBlock)
543  {
544  /* Get the function */
545  Function = ExGetCallBackBlockRoutine(CallbackBlock);
546 
547  /* Do the callback */
549 
550  /* Now dereference it */
551  ExDereferenceCallBackBlock(Callback, CallbackBlock);
552  }
553 }
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1154
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
VOID NTAPI 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
_In_ PVOID Argument2
Definition: classpnp.h:721
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:698

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:1015
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
ULONG NextHandleNeedingPool
Definition: extypes.h:645
#define TRUE
Definition: types.h:120
LONG ExtraInfoPages
Definition: extypes.h:635
LIST_ENTRY HandleTableList
Definition: extypes.h:627
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define InsertTailList(ListHead, Entry)
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI ExpAllocateHandleTableEntrySlow(IN PHANDLE_TABLE HandleTable, IN BOOLEAN DoInit)
Definition: handle.c:466
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1231
Definition: extypes.h:595
unsigned char BOOLEAN
LONG HandleCount
Definition: extypes.h:644
Definition: arc.h:79
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:84
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
processorSet Mask
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:144
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
ULONG_PTR Value
Definition: extypes.h:602
#define LOW_LEVEL_ENTRIES
Definition: ex.h:150
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:181
#define NULL
Definition: types.h:112
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
_In_ HANDLE Handle
Definition: extypes.h:390
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 567 of file ex.h.

568 {
569  /* Return the reference count */
570  return (ULONG)FastRef.RefCnt;
571 }
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 559 of file ex.h.

560 {
561  /* Return the unbiased pointer */
562  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
563 }
#define MAX_FAST_REFS
Definition: ex.h:131

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 1353 of file expool.c.

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

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:575
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
#define NULL
Definition: types.h:112

Referenced by CmpInitCallback(), and PspInitPhase0().

◆ ExInitializeFastReference()

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

Definition at line 575 of file ex.h.

577 {
578  /* Sanity check */
579  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
580 
581  /* Check if an object is being set */
582  if (!Object)
583  {
584  /* Clear the field */
585  FastRef->Object = NULL;
586  }
587  else
588  {
589  /* Otherwise, we assume the object was referenced and is ready */
590  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
591  }
592 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:131

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

◆ ExInitializeSystemLookasideList()

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 31 of file lookas.c.

37 {
38  /* Initialize the list */
39  List->Tag = Tag;
40  List->Type = Type;
41  List->Size = Size;
42  InsertHeadList(ListHead, &List->ListEntry);
43  List->MaximumDepth = MaximumDepth;
44  List->Depth = 2;
45  List->Allocate = ExAllocatePoolWithTag;
46  List->Free = ExFreePool;
47  InitializeSListHead(&List->ListHead);
48  List->TotalAllocates = 0;
49  List->AllocateHits = 0;
50  List->TotalFrees = 0;
51  List->FreeHits = 0;
52  List->LastTotalAllocates = 0;
53  List->LastAllocateHits = 0;
54 }
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
Type
Definition: Type.h:6
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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

◆ ExInitPoolLookasidePointers()

VOID NTAPI ExInitPoolLookasidePointers ( VOID  )

Definition at line 59 of file lookas.c.

60 {
61  ULONG i;
62  PKPRCB Prcb = KeGetCurrentPrcb();
64 
65  /* Loop for all pool lists */
66  for (i = 0; i < MAXIMUM_PROCESSORS; i++)
67  {
68  /* Initialize the non-paged list */
70  InitializeSListHead(&Entry->ListHead);
71 
72  /* Bind to PRCB */
73  Prcb->PPNPagedLookasideList[i].P = Entry;
74  Prcb->PPNPagedLookasideList[i].L = Entry;
75 
76  /* Initialize the paged list */
78  InitializeSListHead(&Entry->ListHead);
79 
80  /* Bind to PRCB */
81  Prcb->PPPagedLookasideList[i].P = Entry;
82  Prcb->PPPagedLookasideList[i].L = Entry;
83  }
84 }
#define MAXIMUM_PROCESSORS
Definition: rwlock.h:5
GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:629
struct _Entry Entry
Definition: kefuncs.h:627
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1079
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:23
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:24
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
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:630

Referenced by ExpInitializeExecutive(), and KiSystemStartupBootStack().

◆ ExInsertFastReference()

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

Definition at line 625 of file ex.h.

627 {
628  EX_FAST_REF OldValue, NewValue;
629 
630  /* Sanity checks */
632 
633  /* Start update loop */
634  for (;;)
635  {
636  /* Get the current reference count */
637  OldValue = *FastRef;
638 
639  /* Check if the current count is too high or if the pointer changed */
640  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
641  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
642  {
643  /* Fail */
644  return FALSE;
645  }
646 
647  /* Update the reference count */
648  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
649  NewValue.Object = ExpChangePushlock(&FastRef->Object,
650  NewValue.Object,
651  OldValue.Object);
652  if (NewValue.Object != OldValue.Object) continue;
653 
654  /* We are done */
655  break;
656  }
657 
658  /* Return success */
659  return TRUE;
660 }
ULONG_PTR RefCnt
Definition: extypes.h:423
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
PVOID Object
Definition: extypes.h:422
#define ASSERT(a)
Definition: mode.c:45
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define MAX_FAST_REFS
Definition: ex.h:131
#define ExpChangePushlock(x, y, z)
Definition: ex.h:162
ULONG_PTR Value
Definition: extypes.h:424

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

◆ ExLuidInitialization()

BOOLEAN NTAPI ExLuidInitialization ( VOID  )

Definition at line 324 of file uuid.c.

325 {
326  return TRUE;
327 }
#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:89
Definition: extypes.h:595
HANDLE GenericHandleOverlay
Definition: ex.h:100
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
Definition: ex.h:84
#define LOW_LEVEL_ENTRIES
Definition: ex.h:150
#define NULL
Definition: types.h:112
_In_ HANDLE Handle
Definition: extypes.h:390
#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 52 of file dbgctrl.c.

53 {
54  PEPROCESS ProcessToAttach, ProcessToKill;
55  ULONG_PTR PageInAddress;
58 
60 
61  /* Be sure we were started in an initialized state */
62  ASSERTMSG("ExpDebuggerWorker being entered in non-initialized state!\n",
65  {
66  /* An error happened, so get a chance to restart proper */
68  return;
69  }
70 
71  /* Get the processes to be attached or killed, and the address to page in */
72  ProcessToAttach = ExpDebuggerProcessAttach;
73  ProcessToKill = ExpDebuggerProcessKill;
74  PageInAddress = ExpDebuggerPageIn;
75 
76  /* Reset the state machine to its ready state */
81 
82  /* Default to the current process if we don't find the process to be attached or killed */
83  Process = NULL;
84 
85  /* Check if we need to attach or kill some process */
86  if (ProcessToAttach != NULL || ProcessToKill != NULL)
87  {
88  /* Find the process in the list */
90  while (Process)
91  {
92  /* Is this the process we want to attach to? */
93  if (Process == ProcessToAttach)
94  {
95  /* Yes, attach ourselves to it */
97  break;
98  }
99  /* Or is this the process we want to kill? */
100  else if (Process == ProcessToKill)
101  {
102  /* Yes, kill and dereference it, then return */
105  return;
106  }
107 
108  /* Get the next process */
110  }
111 
112  /* We either have found a process, or we default to the current process */
113  }
114 
115  /* If we have an address to page in... */
116  if (PageInAddress)
117  {
118  /* ... try to do it by attempting to read at this address */
119  _SEH2_TRY
120  {
121  ProbeForReadUchar(PageInAddress);
122  }
124  {
125  DPRINT1("Failed to page in address 0x%p, Status 0x%08lx\n", PageInAddress, _SEH2_GetExceptionCode());
126  }
127  _SEH2_END;
128  }
129 
130  /* Break into the process (or the current one if Process == NULL) */
132 
133  /* If we are attached to a process, not the current one... */
134  if (Process)
135  {
136  /* ... we can detach from the process */
138  /* Dereference the process which was referenced for us by PsGetNextProcess */
140  }
141 }
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:27
KAPC_STATE
Definition: ketypes.h:1280
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:26
#define DBG_STATUS_WORKER
Definition: kdtypes.h:45
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
NTSTATUS NTAPI PsTerminateProcess(IN PEPROCESS Process, IN NTSTATUS ExitStatus)
Definition: kill.c:129
#define ObDereferenceObject
Definition: obfuncs.h:203
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:28
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:1606
#define NULL
Definition: types.h:112
#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:25
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165

Referenced by ExpWorkerThreadBalanceManager().

◆ ExpInitializeCallbacks()

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 OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
POBJECT_TYPE ExCallbackObjectType
Definition: callback.c:38
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE DirectoryHandle
Definition: ObType.c:48
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
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
PSECURITY_DESCRIPTOR SePublicDefaultSd
Definition: sd.c:18
#define FALSE
Definition: types.h:117
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
static const WCHAR L[]
Definition: oid.c:1250
#define OBJ_PERMANENT
Definition: winternl.h:226
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
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
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
#define NULL
Definition: types.h:112
PCALLBACK_OBJECT * CallbackObject
Definition: ex.h:120
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ PFCB _In_ PCD_NAME DirName
Definition: cdprocs.h:736
#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()

BOOLEAN NTAPI ExpInitializeEventImplementation ( VOID  )

Definition at line 39 of file event.c.

40 {
41  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
44  DPRINT("Creating Event Object Type\n");
45 
46  /* Create the Event Object Type */
47  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
48  RtlInitUnicodeString(&Name, L"Event");
49  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
50  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT);
51  ObjectTypeInitializer.GenericMapping = ExpEventMapping;
52  ObjectTypeInitializer.PoolType = NonPagedPool;
53  ObjectTypeInitializer.ValidAccessMask = EVENT_ALL_ACCESS;
54  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
55  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventObjectType);
56  if (!NT_SUCCESS(Status)) return FALSE;
57  return TRUE;
58 }
#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:18
#define FALSE
Definition: types.h:117
GENERIC_MAPPING ExpEventMapping
Definition: event.c:20
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEVENT KEVENT
static const WCHAR L[]
Definition: oid.c:1250
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DPRINT
Definition: sndvol32.h:71
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeEventPairImplementation()

BOOLEAN NTAPI ExpInitializeEventPairImplementation ( VOID  )

Definition at line 33 of file evtpair.c.

34 {
35  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
38  DPRINT("Creating Event Pair Object Type\n");
39 
40  /* Create the Event Pair Object Type */
41  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
42  RtlInitUnicodeString(&Name, L"EventPair");
43  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
44  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KEVENT_PAIR);
45  ObjectTypeInitializer.GenericMapping = ExEventPairMapping;
46  ObjectTypeInitializer.PoolType = NonPagedPool;
47  ObjectTypeInitializer.ValidAccessMask = EVENT_PAIR_ALL_ACCESS;
48  ObjectTypeInitializer.UseDefaultObject = TRUE;
49  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
50  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExEventPairObjectType);
51  if (!NT_SUCCESS(Status)) return FALSE;
52  return TRUE;
53 }
#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
#define FALSE
Definition: types.h:117
struct NameRec_ * Name
Definition: cdprocs.h:459
#define EVENT_PAIR_ALL_ACCESS
Definition: extypes.h:125
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
GENERIC_MAPPING ExEventPairMapping
Definition: evtpair.c:20
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:18
#define DPRINT
Definition: sndvol32.h:71
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeExecutive()

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
VOID NTAPI ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:210
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1891
UNICODE_STRING NtSystemRoot
Definition: init.c:73
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:85
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG KiServiceLimit
Definition: krnlinit.c:26
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:624
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:1713
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char CHAR
Definition: xmlstorage.h:175
void __cdecl _enable(void)
Definition: intrin_arm.h:373
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
VOID NTAPI ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:792
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
#define VER_PRODUCTBUILD_QFE
Definition: ntverp.h:20
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:82
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2046
ULONG CmNtCSDReleaseType
Definition: init.c:58
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:43
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1926
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define FALSE
Definition: types.h:117
#define ANSI_NULL
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
Definition: arc.h:130
VOID NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:297
_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
VOID NTAPI DbgkInitialize(VOID)
Definition: dbgkobj.c:1498
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
Status
Definition: gdiplustypes.h:24
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
int Count
Definition: noreturn.cpp:7
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1895
#define ASSERT(a)
Definition: mode.c:45
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:28
#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
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
CM_SYSTEM_CONTROL_VECTOR CmControlVector[]
BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:203
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SharedUserData
PVOID MmHighestUserAddress
Definition: init.c:51
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:84
UNICODE_STRING CmCSDVersionString
Definition: init.c:60
VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:873
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
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
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
BOOLEAN NTAPI SeInitSystem(VOID)
Definition: semgr.c:251
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:59
BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:740
#define NULL
Definition: types.h:112
VOID NTAPI CmGetSystemControlValues(IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
Definition: cmcontrl.c:104
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD
Definition: pstypes.h:73
BOOLEAN KdBreakAfterSymbolLoad
Definition: kddata.c:80
#define FLG_KERNEL_STACK_TRACE_DB
Definition: pstypes.h:68
VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:35
#define DPRINT1
Definition: precomp.h:8
#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:262
#define ULONG_PTR
Definition: config.h:101
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
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
BOOLEAN NTAPI ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:766
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
ULONG NTAPI ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
Definition: init.c:603
BOOLEAN IoRemoteBootClient
Definition: init.c:68

Referenced by KiInitializeKernel().

◆ ExpInitializeHandleTables()

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:992
#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()

BOOLEAN NTAPI ExpInitializeKeyedEventImplementation ( VOID  )

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeMutantImplementation()

BOOLEAN NTAPI ExpInitializeMutantImplementation ( VOID  )

Definition at line 52 of file mutant.c.

53 {
54  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
57  DPRINT("Creating Mutant Object Type\n");
58 
59  /* Create the Event Pair Object Type */
60  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
61  RtlInitUnicodeString(&Name, L"Mutant");
62  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
63  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KMUTANT);
64  ObjectTypeInitializer.GenericMapping = ExpMutantMapping;
65  ObjectTypeInitializer.PoolType = NonPagedPool;
66  ObjectTypeInitializer.DeleteProcedure = ExpDeleteMutant;
67  ObjectTypeInitializer.ValidAccessMask = MUTANT_ALL_ACCESS;
68  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
69  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExMutantObjectType);
70  if (!NT_SUCCESS(Status)) return FALSE;
71  return TRUE;
72 }
#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 FALSE
Definition: types.h:117
#define MUTANT_ALL_ACCESS
Definition: extypes.h:110
VOID NTAPI ExpDeleteMutant(PVOID ObjectBody)
Definition: mutant.c:38
struct NameRec_ * Name
Definition: cdprocs.h:459
POBJECT_TYPE ExMutantObjectType
Definition: mutant.c:18
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GENERIC_MAPPING ExpMutantMapping
Definition: mutant.c:20
static const WCHAR L[]
Definition: oid.c:1250
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DPRINT
Definition: sndvol32.h:71
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeProfileImplementation()

BOOLEAN NTAPI ExpInitializeProfileImplementation ( VOID  )

Definition at line 64 of file profile.c.

65 {
66  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
69  DPRINT("Creating Profile Object Type\n");
70 
71  /* Initialize the Mutex to lock the States */
73 
74  /* Create the Event Pair Object Type */
75  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
76  RtlInitUnicodeString(&Name, L"Profile");
77  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
78  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KPROFILE);
79  ObjectTypeInitializer.GenericMapping = ExpProfileMapping;
80  ObjectTypeInitializer.PoolType = NonPagedPool;
81  ObjectTypeInitializer.DeleteProcedure = ExpDeleteProfile;
82  ObjectTypeInitializer.ValidAccessMask = PROFILE_ALL_ACCESS;
83  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
84  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExProfileObjectType);
85  if (!NT_SUCCESS(Status)) return FALSE;
86  return TRUE;
87 }
#define OBJ_OPENLINK
Definition: winternl.h:230
KMUTEX ExpProfileMutex
Definition: profile.c:21
POBJECT_TYPE ExProfileObjectType
Definition: profile.c:20
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 FALSE
Definition: types.h:117
VOID NTAPI ExpDeleteProfile(PVOID ObjectBody)
Definition: profile.c:35
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING ExpProfileMapping
Definition: profile.c:23
#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
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DPRINT
Definition: sndvol32.h:71
#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()

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()

BOOLEAN NTAPI ExpInitializeSemaphoreImplementation ( VOID  )

Definition at line 39 of file sem.c.

40 {
41  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
44  DPRINT("Creating Semaphore Object Type\n");
45 
46  /* Create the Event Pair Object Type */
47  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
48  RtlInitUnicodeString(&Name, L"Semaphore");
49  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
50  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KSEMAPHORE);
51  ObjectTypeInitializer.GenericMapping = ExSemaphoreMapping;
52  ObjectTypeInitializer.PoolType = NonPagedPool;
53  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
54  ObjectTypeInitializer.ValidAccessMask = SEMAPHORE_ALL_ACCESS;
55  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExSemaphoreObjectType);
56  if (!NT_SUCCESS(Status)) return FALSE;
57  return TRUE;
58 }
#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
#define FALSE
Definition: types.h:117
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING ExSemaphoreMapping
Definition: sem.c:20
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
struct _KSEMAPHORE KSEMAPHORE
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DPRINT
Definition: sndvol32.h:71
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:160
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:18

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeTimerImplementation()

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
#define FALSE
Definition: types.h:117
LIST_ENTRY ExpWakeList
Definition: timer.c:21
struct NameRec_ * Name
Definition: cdprocs.h:459
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
VOID NTAPI ExpDeleteTimer(IN PVOID ObjectBody)
Definition: timer.c:108
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
static const WCHAR L[]
Definition: oid.c:1250
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
POBJECT_TYPE ExTimerType
Definition: timer.c:18
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
struct _ETIMER ETIMER
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
KSPIN_LOCK ExpWakeListLock
Definition: timer.c:20
ULONG DefaultNonPagedPoolCharge
Definition: obtypes.h:365

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeWorkerThreads()

VOID NTAPI ExpInitializeWorkerThreads ( VOID  )

Definition at line 515 of file work.c.

516 {
517  ULONG WorkQueueType;
518  ULONG CriticalThreads, DelayedThreads;
519  HANDLE ThreadHandle;
521  ULONG i;
522 
523  /* Setup the stack swap support */
527 
528  /* Set the number of critical and delayed threads. We shouldn't hardcode */
529  DelayedThreads = EX_DELAYED_WORK_THREADS;
530  CriticalThreads = EX_CRITICAL_WORK_THREADS;
531 
532  /* Protect against greedy registry modifications */
537 
538  /* Calculate final count */
539  DelayedThreads += ExpAdditionalDelayedWorkerThreads;
540  CriticalThreads += ExpAdditionalCriticalWorkerThreads;
541 
542  /* Initialize the Array */
543  for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++)
544  {
545  /* Clear the structure and initialize the queue */
546  RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE));
547  KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0);
548  }
549 
550  /* Dynamic threads are only used for the critical queue */
552 
553  /* Initialize the balance set manager events */
557  FALSE);
558 
559  /* Create the built-in worker threads for the critical queue */
560  for (i = 0; i < CriticalThreads; i++)
561  {
562  /* Create the thread */
565  }
566 
567  /* Create the built-in worker threads for the delayed queue */
568  for (i = 0; i < DelayedThreads; i++)
569  {
570  /* Create the thread */
573  }
574 
575  /* Create the built-in worker thread for the hypercritical queue */
577 
578  /* Create the balance set manager thread */
579  PsCreateSystemThread(&ThreadHandle,
581  NULL,
582  0,
583  NULL,
585  NULL);
586 
587  /* Get a pointer to it for the shutdown process */
588  ObReferenceObjectByHandle(ThreadHandle,
590  NULL,
591  KernelMode,
592  (PVOID*)&Thread,
593  NULL);
595 
596  /* Close the handle and return */
597  ObCloseHandle(ThreadHandle, KernelMode);
598 }
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:250
#define TRUE
Definition: types.h:120
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:46
PETHREAD ExpWorkerThreadBalanceManagerPtr
Definition: work.c:49
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:494
#define FALSE
Definition: types.h:117
#define EX_CRITICAL_WORK_THREADS
Definition: work.c:20
LIST_ENTRY ExpWorkerListHead
Definition: work.c:41
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:3375
KEVENT ExpThreadSetManagerEvent
Definition: work.c:45
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:42
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
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_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:31
#define EX_DELAYED_WORK_THREADS
Definition: work.c:19
#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:35
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
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:36
unsigned int ULONG
Definition: retypes.h:1
ULONG ExCriticalWorkerThreads
Definition: work.c:34
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOLEAN ExpWorkersCanSwap
Definition: work.c:40
EX_QUEUE_WORKER_INFO Info
Definition: extypes.h:412
ULONG ExpAdditionalDelayedWorkerThreads
Definition: work.c:37
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
Definition: work.c:420

Referenced by ExpInitSystemPhase1().

◆ ExpInitLookasideLists()

VOID NTAPI ExpInitLookasideLists ( VOID  )

Definition at line 89 of file lookas.c.

90 {
91  ULONG i;
92 
93  /* Initialize locks and lists */
100 
101  /* Initialize the system lookaside lists */
102  for (i = 0; i < MAXIMUM_PROCESSORS; i++)
103  {
104  /* Initialize the non-paged list */
106  NonPagedPool,
107  (i + 1) * 8,
108  'looP',
109  256,
111 
112  /* Initialize the paged list */
114  PagedPool,
115  (i + 1) * 8,
116  'looP',
117  256,
119  }
120 }
#define MAXIMUM_PROCESSORS
Definition: rwlock.h:5
LIST_ENTRY ExPoolLookasideListHead
Definition: lookas.c:22
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:23
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
VOID NTAPI ExInitializeSystemLookasideList(IN PGENERAL_LOOKASIDE List, IN POOL_TYPE Type, IN ULONG Size, IN ULONG Tag, IN USHORT MaximumDepth, IN PLIST_ENTRY ListHead)
Definition: lookas.c:31
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:17
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:24
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:20
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:18
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
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned int ULONG
Definition: retypes.h:1
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:19
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:21

◆ 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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define FALSE
Definition: types.h:117
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
void * PVOID
Definition: retypes.h:9
#define ASSERT(a)
Definition: mode.c:45
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:144
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define KeGetCurrentThread
Definition: hal.h:49
#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:65
#define FALSE
Definition: types.h:117
Definition: extypes.h:595
struct _HANDLE_TABLE_ENTRY * PHANDLE_TABLE_ENTRY
#define ASSERT(a)
Definition: mode.c:45
#define NULL
Definition: types.h:112
_In_ HANDLE Handle
Definition: extypes.h:390
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()

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

Referenced by ExpInitSystemPhase0().

◆ ExpSetTimeZoneInformation()

NTSTATUS ExpSetTimeZoneInformation ( IN PRTL_TIME_ZONE_INFORMATION  TimeZoneInformation)

◆ ExpUuidInitialization()

BOOLEAN NTAPI ExpUuidInitialization ( VOID  )

Definition at line 52 of file uuid.c.

53 {
55 
58 
59  return TRUE;
60 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define TRUE
Definition: types.h:120
FAST_MUTEX ExpUuidLock
Definition: uuid.c:34
#define FALSE
Definition: types.h:117
LARGE_INTEGER ExpUuidLastTimeAllocated
Definition: uuid.c:35
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
BOOLEAN ExpUuidSequenceNumberValid
Definition: uuid.c:37

Referenced by ExpInitSystemPhase1().

◆ ExpWin32kInit()

BOOLEAN NTAPI ExpWin32kInit ( VOID  )

Definition at line 259 of file win32k.c.

260 {
261  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
264  DPRINT("Creating Win32 Object Types\n");
265 
266  /* Create the window station Object Type */
267  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
268  RtlInitUnicodeString(&Name, L"WindowStation");
269  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
270  ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping;
271  ObjectTypeInitializer.PoolType = NonPagedPool;
272  ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete;
273  ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse;
274  ObjectTypeInitializer.OkayToCloseProcedure = ExpWindowStationOkToClose;
275  ObjectTypeInitializer.SecurityRequired = TRUE;
276  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK |
277  OBJ_PERMANENT |
279  ObjectTypeInitializer.ValidAccessMask = STANDARD_RIGHTS_REQUIRED;
281  &ObjectTypeInitializer,
282  NULL,
284  if (!NT_SUCCESS(Status)) return FALSE;
285 
286  /* Create desktop object type */