ReactOS  0.4.15-dev-5496-g599ba9c
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 InterlockedExchangeSizeT(Target, Value)   (SIZE_T)InterlockedExchange((PLONG)Target, (LONG)Value)
 
#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
 
ERESOURCE ExpTimeRefreshLock
 
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 134 of file ex.h.

◆ ExfInterlockedCompareExchange64UL

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

Definition at line 1549 of file ex.h.

◆ ExGetPreviousMode

#define ExGetPreviousMode   KeGetPreviousMode

Definition at line 139 of file ex.h.

◆ EXHANDLE_TABLE_ENTRY_LOCK_BIT

#define EXHANDLE_TABLE_ENTRY_LOCK_BIT   1

Definition at line 145 of file ex.h.

◆ ExInitializePushLock

#define ExInitializePushLock   _ExInitializePushLock

Definition at line 1012 of file ex.h.

◆ ExInitializeRundownProtection

#define ExInitializeRundownProtection   _ExInitializeRundownProtection

Definition at line 136 of file ex.h.

◆ ExpChangePushlock

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

Definition at line 163 of file ex.h.

◆ ExpChangeRundown

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

Definition at line 162 of file ex.h.

◆ ExpSetRundown

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

Definition at line 164 of file ex.h.

◆ ExReleaseRundownProtection

#define ExReleaseRundownProtection   _ExReleaseRundownProtection

Definition at line 135 of file ex.h.

◆ ExRundownCompleted

#define ExRundownCompleted   _ExRundownCompleted

Definition at line 138 of file ex.h.

◆ ExWaitForRundownProtectionRelease

#define ExWaitForRundownProtectionRelease   _ExWaitForRundownProtectionRelease

Definition at line 137 of file ex.h.

◆ FREE_HANDLE_MASK

#define FREE_HANDLE_MASK   -1

Definition at line 146 of file ex.h.

◆ HANDLE_HIGH_BITS

#define HANDLE_HIGH_BITS   (PAGE_SHIFT - 2)

Definition at line 79 of file ex.h.

◆ HANDLE_INDEX_BITS

#define HANDLE_INDEX_BITS   (HANDLE_LOW_BITS + 2*HANDLE_HIGH_BITS)

Definition at line 82 of file ex.h.

◆ HANDLE_LOW_BITS

#define HANDLE_LOW_BITS   (PAGE_SHIFT - 3)

Definition at line 78 of file ex.h.

◆ HANDLE_TAG_BITS

#define HANDLE_TAG_BITS   (2)

Definition at line 81 of file ex.h.

◆ HIGH_LEVEL_ENTRIES

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

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

◆ InterlockedCompareExchangeUL

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

Definition at line 1535 of file ex.h.

◆ InterlockedDecrementUL

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

Definition at line 1523 of file ex.h.

◆ InterlockedExchangeAddUL

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

Definition at line 1532 of file ex.h.

◆ InterlockedExchangeSizeT

#define InterlockedExchangeSizeT (   Target,
  Value 
)    (SIZE_T)InterlockedExchange((PLONG)Target, (LONG)Value)

Definition at line 1545 of file ex.h.

◆ InterlockedExchangeUL

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

Definition at line 1529 of file ex.h.

◆ InterlockedIncrementUL

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

Definition at line 1526 of file ex.h.

◆ KERNEL_FLAG_BITS

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

Definition at line 83 of file ex.h.

◆ LOW_LEVEL_ENTRIES

#define LOW_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))

Definition at line 151 of file ex.h.

◆ MAX_FAST_REFS

#define MAX_FAST_REFS   7

Definition at line 132 of file ex.h.

◆ MAX_HIGH_INDEX

Definition at line 160 of file ex.h.

◆ MAX_LOW_INDEX

#define MAX_LOW_INDEX   LOW_LEVEL_ENTRIES

Definition at line 158 of file ex.h.

◆ MAX_MID_INDEX

#define MAX_MID_INDEX   (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)

Definition at line 159 of file ex.h.

◆ MID_LEVEL_ENTRIES

#define MID_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))

Definition at line 152 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 448 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 440 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 433 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 59 of file ex.h.

60 {
61  WinKdWorkerReady = 0,
enum _WINKD_WORKER_STATE WINKD_WORKER_STATE

Function Documentation

◆ _ExAcquireFastMutex()

FORCEINLINE VOID _ExAcquireFastMutex ( IN PFAST_MUTEX  FastMutex)

Definition at line 1374 of file ex.h.

1375 {
1376  KIRQL OldIrql;
1378 
1379  /* Raise IRQL to APC */
1381 
1382  /* Decrease the count */
1383  if (InterlockedDecrement(&FastMutex->Count))
1384  {
1385  /* Someone is still holding it, use slow path */
1386  KiAcquireFastMutex(FastMutex);
1387  }
1388 
1389  /* Set the owner and IRQL */
1390  FastMutex->Owner = KeGetCurrentThread();
1391  FastMutex->OldIrql = OldIrql;
1392 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:44
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
VOID FASTCALL KiAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: wait.c:107
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define KeGetCurrentThread
Definition: hal.h:55
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by ExAcquireFastMutex().

◆ _ExAcquireFastMutexUnsafe()

FORCEINLINE VOID _ExAcquireFastMutexUnsafe ( IN PFAST_MUTEX  FastMutex)

Definition at line 1329 of file ex.h.

1330 {
1332 
1333  /* Sanity check */
1335  (Thread->CombinedApcDisable != 0) ||
1336  (Thread->Teb == NULL) ||
1337  (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1338  ASSERT(FastMutex->Owner != Thread);
1339 
1340  /* Decrease the count */
1341  if (InterlockedDecrement(&FastMutex->Count))
1342  {
1343  /* Someone is still holding it, use slow path */
1344  KiAcquireFastMutex(FastMutex);
1345  }
1346 
1347  /* Set the owner */
1348  FastMutex->Owner = Thread;
1349 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define ASSERT(a)
Definition: mode.c:44
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#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:835
#define NULL
Definition: types.h:112
#define KeGetCurrentThread
Definition: hal.h:55
#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 819 of file ex.h.

820 {
821  ULONG_PTR Value, NewValue;
822 
823  /* Get the current value and mask the active bit */
824  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
825 
826  /* Add a reference */
827  NewValue = Value + EX_RUNDOWN_COUNT_INC;
828 
829  /* Change the value */
830  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
831  if (NewValue != Value)
832  {
833  /* Rundown was active, use long path */
834  return ExfAcquireRundownProtection(RunRef);
835  }
836 
837  /* Success */
838  return TRUE;
839 }
#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:162
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 1445 of file ex.h.

1446 {
1447  /* Enter the Critical Region */
1449 
1450  /* Acquire the mutex unsafely */
1451  _ExAcquireFastMutexUnsafe(FastMutex);
1452 }
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
FORCEINLINE VOID _ExAcquireFastMutexUnsafe(IN PFAST_MUTEX FastMutex)
Definition: ex.h:1329

Referenced by ExEnterCriticalRegionAndAcquireFastMutexUnsafe().

◆ _ExInitializePushLock()

FORCEINLINE VOID _ExInitializePushLock ( OUT PEX_PUSH_LOCK  PushLock)

Definition at line 1007 of file ex.h.

1008 {
1009  /* Set the value to 0 */
1010  PushLock->Ptr = 0;
1011 }

◆ _ExInitializeRundownProtection()

FORCEINLINE VOID _ExInitializeRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 903 of file ex.h.

904 {
905  /* Set the count to zero */
906  RunRef->Count = 0;
907 }

Referenced by ExAllocateCacheAwareRundownProtection(), and ExInitializeRundownProtectionCacheAware().

◆ _ExReleaseFastMutex()

FORCEINLINE VOID _ExReleaseFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1396 of file ex.h.

1397 {
1398  KIRQL OldIrql;
1400 
1401  /* Erase the owner */
1402  FastMutex->Owner = NULL;
1403  OldIrql = (KIRQL)FastMutex->OldIrql;
1404 
1405  /* Increase the count */
1406  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1407  {
1408  /* Someone was waiting for it, signal the waiter */
1409  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1410  }
1411 
1412  /* Lower IRQL back */
1414 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
if(dx==0 &&dy==0)
Definition: linetemp.h:174
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:44
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
#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
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by ExReleaseFastMutex().

◆ _ExReleaseFastMutexUnsafe()

FORCEINLINE VOID _ExReleaseFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1353 of file ex.h.

1354 {
1356  (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1357  (KeGetCurrentThread()->Teb == NULL) ||
1359  ASSERT(FastMutex->Owner == KeGetCurrentThread());
1360 
1361  /* Erase the owner */
1362  FastMutex->Owner = NULL;
1363 
1364  /* Increase the count */
1365  if (InterlockedIncrement(&FastMutex->Count) <= 0)
1366  {
1367  /* Someone was waiting for it, signal the waiter */
1368  KeSetEventBoostPriority(&FastMutex->Event, NULL);
1369  }
1370 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define ASSERT(a)
Definition: mode.c:44
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
Definition: compat.h:835
#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:55
#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 1456 of file ex.h.

1457 {
1458  /* Release the mutex unsafely */
1459  _ExReleaseFastMutexUnsafe(FastMutex);
1460 
1461  /* Leave the critical region */
1463 }
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
FORCEINLINE VOID _ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
Definition: ex.h:1353

Referenced by ExReleaseFastMutexUnsafeAndLeaveCriticalRegion().

◆ _ExReleaseRundownProtection()

FORCEINLINE VOID _ExReleaseRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 860 of file ex.h.

861 {
862  ULONG_PTR Value, NewValue;
863 
864  /* Get the current value and mask the active bit */
865  Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
866 
867  /* Remove a reference */
868  NewValue = Value - EX_RUNDOWN_COUNT_INC;
869 
870  /* Change the value */
871  NewValue = ExpChangeRundown(RunRef, NewValue, Value);
872 
873  /* Check if the rundown was active */
874  if (NewValue != Value)
875  {
876  /* Rundown was active, use long path */
878  }
879  else
880  {
881  /* Sanity check */
883  }
884 }
#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:44
#define ExpChangeRundown(x, y, z)
Definition: ex.h:162
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 957 of file ex.h.

958 {
959  /* Sanity check */
960  ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
961 
962  /* Mark the counter as active */
964 }
#define ExpSetRundown(x, y)
Definition: ex.h:164
#define ASSERT(a)
Definition: mode.c:44
#define EX_RUNDOWN_ACTIVE

◆ _ExTryToAcquireFastMutex()

FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1418 of file ex.h.

1419 {
1420  KIRQL OldIrql;
1422 
1423  /* Raise to APC_LEVEL */
1425 
1426  /* Check if we can quickly acquire it */
1427  if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1428  {
1429  /* We have, set us as owners */
1430  FastMutex->Owner = KeGetCurrentThread();
1431  FastMutex->OldIrql = OldIrql;
1432  return TRUE;
1433  }
1434  else
1435  {
1436  /* Acquire attempt failed */
1438  YieldProcessor();
1439  return FALSE;
1440  }
1441 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#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:44
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
VOID NTAPI KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
Definition: spinlock.c:27
#define KeGetCurrentThread
Definition: hal.h:55
VOID NTAPI KeLowerIrql(KIRQL NewIrql)
Definition: spinlock.c:39
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by ExTryToAcquireFastMutex().

◆ _ExWaitForRundownProtectionRelease()

FORCEINLINE VOID _ExWaitForRundownProtectionRelease ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 927 of file ex.h.

928 {
930 
931  /* Set the active bit */
933  if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
934  {
935  /* If the the rundown wasn't already active, then take the long path */
937  }
938 }
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:162
#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 616 of file ex.h.

617 {
618  EX_FAST_REF OldValue, NewValue;
619 
620  /* Start reference loop */
621  for (;;)
622  {
623  /* Get the current reference count */
624  OldValue = *FastRef;
625  if (OldValue.RefCnt)
626  {
627  /* Increase the reference count */
628  NewValue.Value = OldValue.Value - 1;
629  NewValue.Object = ExpChangePushlock(&FastRef->Object,
630  NewValue.Object,
631  OldValue.Object);
632  if (NewValue.Object != OldValue.Object) continue;
633  }
634 
635  /* We are done */
636  break;
637  }
638 
639  /* Return the old value */
640  return OldValue;
641 }
ULONG_PTR RefCnt
Definition: extypes.h:423
PVOID Object
Definition: extypes.h:422
#define ExpChangePushlock(x, y, z)
Definition: ex.h:163
ULONG_PTR Value
Definition: extypes.h:424

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

◆ ExAcquirePushLockExclusive()

FORCEINLINE VOID ExAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 1035 of file ex.h.

1036 {
1037  /* Try acquiring the lock */
1039  {
1040  /* Someone changed it, use the slow path */
1041  ExfAcquirePushLockExclusive(PushLock);
1042  }
1043 
1044  /* Sanity check */
1045  ASSERT(PushLock->Locked);
1046 }
#define InterlockedBitTestAndSet
Definition: interlocked.h:30
#define ASSERT(a)
Definition: mode.c:44
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 1104 of file ex.h.

1105 {
1106  EX_PUSH_LOCK NewValue;
1107 
1108  /* Try acquiring the lock */
1110  if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1111  {
1112  /* Someone changed it, use the slow path */
1113  ExfAcquirePushLockShared(PushLock);
1114  }
1115 
1116  /* Sanity checks */
1117  ASSERT(PushLock->Locked);
1118 }
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:44
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:163
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:1038
#define TAG_CALLBACK_ROUTINE_BLOCK
Definition: tag.h:21

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

◆ ExAllocateLocallyUniqueId()

VOID NTAPI ExAllocateLocallyUniqueId ( OUT LUID LocallyUniqueId)

Definition at line 335 of file uuid.c.

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

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

◆ 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 1189 of file handle.c.

1193 {
1194  EXHANDLE ExHandle;
1195  PHANDLE_TABLE_ENTRY HandleTableEntry;
1196  BOOLEAN Result = FALSE;
1197  PAGED_CODE();
1198 
1199  /* Set the handle value */
1200  ExHandle.GenericHandleOverlay = Handle;
1201 
1202  /* Find the entry for this handle */
1203  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1204 
1205  /* Make sure that we found an entry, and that it's valid */
1206  if (!(HandleTableEntry) ||
1207  !(HandleTableEntry->Object) ||
1208  (HandleTableEntry->NextFreeTableEntry == -2))
1209  {
1210  /* It isn't, fail */
1211  return FALSE;
1212  }
1213 
1214  /* Enter a critical region */
1216 
1217  /* Try locking the handle entry */
1218  if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1219  {
1220  /* Call the change routine and unlock the entry */
1221  Result = ChangeRoutine(HandleTableEntry, Context);
1222  ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
1223  }
1224 
1225  /* Leave the critical region and return the callback result */
1227  return Result;
1228 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
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:923
#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:101
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
Definition: ex.h:85
#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:579
#define TRUE
Definition: types.h:120
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1177
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:587
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:746
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:132

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

749 {
750  EX_FAST_REF OldValue, NewValue;
751 
752  /* Sanity check and start swap loop */
754  for (;;)
755  {
756  /* Get the current value */
757  OldValue = *FastRef;
758 
759  /* Make sure there's enough references to swap */
760  if (!((OldValue.Value ^ (ULONG_PTR)OldObject) <= MAX_FAST_REFS)) break;
761 
762  /* Check if we have an object to swap */
763  if (Object)
764  {
765  /* Set up the value with maximum fast references */
766  NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
767  }
768  else
769  {
770  /* Write the object address itself (which is empty) */
771  NewValue.Value = (ULONG_PTR)Object;
772  }
773 
774  /* Do the actual compare exchange */
775  NewValue.Object = ExpChangePushlock(&FastRef->Object,
776  NewValue.Object,
777  OldValue.Object);
778  if (NewValue.Object != OldValue.Object) continue;
779 
780  /* All done */
781  break;
782  }
783 
784  /* Return the old value */
785  return OldValue;
786 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID Object
Definition: extypes.h:422
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define ULONG_PTR
Definition: config.h:101
#define MAX_FAST_REFS
Definition: ex.h:132
#define ExpChangePushlock(x, y, z)
Definition: ex.h:163
ULONG_PTR Value
Definition: extypes.h:424

Referenced by ExCompareExchangeCallBack(), and ObSetSecurityDescriptorInfo().

◆ ExConvertPushLockSharedToExclusive()

FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive ( IN PEX_PUSH_LOCK  PushLock)

Definition at line 1138 of file ex.h.

1139 {
1140  EX_PUSH_LOCK OldValue;
1141 
1142  /* Set the expected old value */
1144 
1145  /* Try converting the lock */
1146  if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1147  OldValue.Ptr)
1148  {
1149  /* Conversion failed */
1150  return FALSE;
1151  }
1152 
1153  /* Sanity check */
1154  ASSERT(PushLock->Locked);
1155  return TRUE;
1156 }
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:44
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define ExpChangePushlock(x, y, z)
Definition: ex.h:163

Referenced by CmpTryToConvertKcbSharedToExclusive(), MiConvertSharedWorkingSetLockToExclusive(), and ObpLookupEntryDirectory().

◆ ExCreateHandle()

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

Definition at line 827 of file handle.c.

829 {
831  PHANDLE_TABLE_ENTRY NewEntry;
832  PAGED_CODE();
833 
834  /* Start with a clean handle */
835  Handle.GenericHandleOverlay = NULL;
836 
837  /* Allocate a new entry */
839  if (NewEntry)
840  {
841  /* Enter a critical region */
843 
844  /* Write the entry */
845  *NewEntry = *HandleTableEntry;
846 
847  /* Unlock it and leave the critical region */
850  }
851 
852  /* Return the handle value */
853  return Handle.GenericHandleOverlay;
854 }
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:923
Definition: extypes.h:595
PHANDLE_TABLE_ENTRY NTAPI ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, OUT PEXHANDLE NewHandle)
Definition: handle.c:683
Definition: ex.h:85
#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 801 of file handle.c.

802 {
804  PAGED_CODE();
805 
806  /* Allocate the handle table */
808  if (!HandleTable) return NULL;
809 
810  /* Acquire the handle table lock */
813 
814  /* Insert it into the list */
815  InsertTailList(&HandleTableListHead, &HandleTable->HandleTableList);
816 
817  /* Release the lock */
820 
821  /* Return the handle table */
822  return HandleTable;
823 }
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:331
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1035
#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:1251
#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:684

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 984 of file handle.c.

987 {
988  EXHANDLE ExHandle;
989  PVOID Object;
990  PAGED_CODE();
991 
992  /* Setup the actual handle value */
993  ExHandle.GenericHandleOverlay = Handle;
994 
995  /* Enter a critical region and check if we have to lookup the handle */
997  if (!HandleTableEntry)
998  {
999  /* Lookup the entry */
1000  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1001 
1002  /* Make sure that we found an entry, and that it's valid */
1003  if (!(HandleTableEntry) ||
1004  !(HandleTableEntry->Object) ||
1005  (HandleTableEntry->NextFreeTableEntry == -2))
1006  {
1007  /* Invalid handle, fail */
1009  return FALSE;
1010  }
1011 
1012  /* Lock the entry */
1013  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1014  {
1015  /* Couldn't lock, fail */
1017  return FALSE;
1018  }
1019  }
1020  else
1021  {
1022  /* Make sure the handle is locked */
1023  ASSERT((HandleTableEntry->Value & EXHANDLE_TABLE_ENTRY_LOCK_BIT) == 0);
1024  }
1025 
1026  /* Clear the handle */
1027  Object = InterlockedExchangePointer((PVOID*)&HandleTableEntry->Object, NULL);
1028 
1029  /* Sanity checks */
1030  ASSERT(Object != NULL);
1032 
1033  /* Unblock the pushlock */
1034  ExfUnblockPushLock(&HandleTable->HandleContentionEvent, NULL);
1035 
1036  /* Free the actual entry */
1037  ExpFreeHandleTableEntry(HandleTable, ExHandle, HandleTableEntry);
1038 
1039  /* If we got here, return success */
1041  return TRUE;
1042 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
#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:44
HANDLE GenericHandleOverlay
Definition: ex.h:101
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
Definition: ex.h:85
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:145
_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:279
#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 963 of file handle.c.

965 {
966  PAGED_CODE();
967 
968  /* Remove the handle from the list */
970 
971  /* Check if we have a destroy callback */
972  if (DestroyHandleProcedure)
973  {
974  /* FIXME: */
975  ASSERT(FALSE);
976  }
977 
978  /* Free the handle table */
980 }
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI ExRemoveHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:944
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:202
#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 552 of file ex.h.

556 {
557  PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
559 
560  /* Reference the block */
561  CallbackBlock = ExReferenceCallBackBlock(Callback);
562  if (CallbackBlock)
563  {
564  /* Get the function */
565  Function = ExGetCallBackBlockRoutine(CallbackBlock);
566 
567  /* Do the callback */
569 
570  /* Now dereference it */
571  ExDereferenceCallBackBlock(Callback, CallbackBlock);
572  }
573 }
_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 1072 of file handle.c.

1076 {
1077  PHANDLE_TABLE NewTable;
1078  EXHANDLE Handle;
1079  PHANDLE_TABLE_ENTRY HandleTableEntry, NewEntry;
1080  BOOLEAN Failed = FALSE;
1081  PAGED_CODE();
1082 
1083  /* Allocate the duplicated copy */
1084  NewTable = ExpAllocateHandleTable(Process, FALSE);
1085  if (!NewTable) return NULL;
1086 
1087  /* Loop each entry */
1088  while (NewTable->NextHandleNeedingPool <
1089  HandleTable->NextHandleNeedingPool)
1090  {
1091  /* Insert it into the duplicated copy */
1092  if (!ExpAllocateHandleTableEntrySlow(NewTable, FALSE))
1093  {
1094  /* Insert failed, free the new copy and return */
1095  ExpFreeHandleTable(NewTable);
1096  return NULL;
1097  }
1098  }
1099 
1100  /* Setup the initial handle table data */
1101  NewTable->HandleCount = 0;
1102  NewTable->ExtraInfoPages = 0;
1103  NewTable->FirstFree = 0;
1104 
1105  /* Setup the first handle value */
1106  Handle.Value = INDEX_TO_HANDLE_VALUE(1);
1107 
1108  /* Enter a critical region and lookup the new entry */
1110  while ((NewEntry = ExpLookupHandleTableEntry(NewTable, Handle)))
1111  {
1112  /* Lookup the old entry */
1113  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle);
1114 
1115  /* Loop each entry */
1116  do
1117  {
1118  /* Check if it doesn't match the audit mask */
1119  if (!(HandleTableEntry->Value & Mask))
1120  {
1121  /* Free it since we won't use it */
1122  Failed = TRUE;
1123  }
1124  else
1125  {
1126  /* Lock the entry */
1127  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1128  {
1129  /* Free it since we can't lock it, so we won't use it */
1130  Failed = TRUE;
1131  }
1132  else
1133  {
1134  /* Copy the handle value */
1135  *NewEntry = *HandleTableEntry;
1136 
1137  /* Call the duplicate callback */
1138  if (DupHandleProcedure(Process,
1139  HandleTable,
1140  HandleTableEntry,
1141  NewEntry))
1142  {
1143  /* Clear failure flag */
1144  Failed = FALSE;
1145 
1146  /* Lock the entry, increase the handle count */
1147  NewEntry->Value |= EXHANDLE_TABLE_ENTRY_LOCK_BIT;
1148  NewTable->HandleCount++;
1149  }
1150  else
1151  {
1152  /* Duplication callback refused, fail */
1153  Failed = TRUE;
1154  }
1155  }
1156  }
1157 
1158  /* Check if we failed earlier and need to free */
1159  if (Failed)
1160  {
1161  /* Free this entry */
1162  NewEntry->Object = NULL;
1163  NewEntry->NextFreeTableEntry = NewTable->FirstFree;
1164  NewTable->FirstFree = (ULONG)Handle.Value;
1165  }
1166 
1167  /* Increase the handle value and move to the next entry */
1168  Handle.Value += INDEX_TO_HANDLE_VALUE(1);
1169  NewEntry++;
1170  HandleTableEntry++;
1171  } while (Handle.Value % INDEX_TO_HANDLE_VALUE(LOW_LEVEL_ENTRIES));
1172 
1173  /* We're done, skip the last entry */
1175  }
1176 
1177  /* Acquire the table lock and insert this new table into the list */
1181 
1182  /* Leave the critical region we entered previously and return the table */
1184  return NewTable;
1185 }
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:331
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1035
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
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:502
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1251
Definition: extypes.h:595
unsigned char BOOLEAN
LONG HandleCount
Definition: extypes.h:644
Definition: arc.h:79
unsigned int Mask
Definition: fpcontrol.c:82
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
#define INDEX_TO_HANDLE_VALUE(x)
Definition: handle.c:21
Definition: ex.h:85
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:145
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
ULONG_PTR Value
Definition: extypes.h:602
#define LOW_LEVEL_ENTRIES
Definition: ex.h:151
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:202
#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:21
#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 587 of file ex.h.

588 {
589  /* Return the reference count */
590  return (ULONG)FastRef.RefCnt;
591 }
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 579 of file ex.h.

580 {
581  /* Return the unbiased pointer */
582  return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
583 }
#define MAX_FAST_REFS
Definition: ex.h:132

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:377
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:44
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:376
SIZE_T PagedBytes
Definition: miarm.h:380
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:984
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
LONG NonPagedAllocs
Definition: miarm.h:375
struct tagContext Context
Definition: acpixf.h:1038
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327
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:595
_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 595 of file ex.h.

597 {
598  /* Sanity check */
599  ASSERT((((ULONG_PTR)Object) & MAX_FAST_REFS) == 0);
600 
601  /* Check if an object is being set */
602  if (!Object)
603  {
604  /* Clear the field */
605  FastRef->Object = NULL;
606  }
607  else
608  {
609  /* Otherwise, we assume the object was referenced and is ready */
610  FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
611  }
612 }
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ASSERT(a)
Definition: mode.c:44
_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:132

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:3351
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 < NUMBER_POOL_LOOKASIDE_LISTS; 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 }
GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:630
struct _Entry Entry
Definition: kefuncs.h:629
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1080
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:3351
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[MAXIMUM_PROCESSORS]
Definition: lookas.c:24
#define NUMBER_POOL_LOOKASIDE_LISTS
Definition: ketypes.h:291
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:631

Referenced by ExpInitializeExecutive(), and KiSystemStartupBootStack().

◆ ExInsertFastReference()

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

Definition at line 645 of file ex.h.

647 {
648  EX_FAST_REF OldValue, NewValue;
649 
650  /* Sanity checks */
652 
653  /* Start update loop */
654  for (;;)
655  {
656  /* Get the current reference count */
657  OldValue = *FastRef;
658 
659  /* Check if the current count is too high or if the pointer changed */
660  if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
661  ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
662  {
663  /* Fail */
664  return FALSE;
665  }
666 
667  /* Update the reference count */
668  NewValue.Value = OldValue.Value + MAX_FAST_REFS;
669  NewValue.Object = ExpChangePushlock(&FastRef->Object,
670  NewValue.Object,
671  OldValue.Object);
672  if (NewValue.Object != OldValue.Object) continue;
673 
674  /* We are done */
675  break;
676  }
677 
678  /* Return success */
679  return TRUE;
680 }
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:44
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define MAX_FAST_REFS
Definition: ex.h:132
#define ExpChangePushlock(x, y, z)
Definition: ex.h:163
ULONG_PTR Value
Definition: extypes.h:424

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

◆ ExLuidInitialization()

BOOLEAN NTAPI ExLuidInitialization ( VOID  )

Definition at line 325 of file uuid.c.

326 {
327  return TRUE;
328 }
#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 1046 of file handle.c.

1048 {
1049  EXHANDLE ExHandle;
1050  PHANDLE_TABLE_ENTRY HandleTableEntry;
1051  PAGED_CODE();
1052 
1053  /* Set the handle value */
1054  ExHandle.GenericHandleOverlay = Handle;
1055 
1056  /* Fail if we got an invalid index */
1057  if (!(ExHandle.Index & (LOW_LEVEL_ENTRIES - 1))) return NULL;
1058 
1059  /* Do the lookup */
1060  HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, ExHandle);
1061  if (!HandleTableEntry) return NULL;
1062 
1063  /* Lock it */
1064  if (!ExpLockHandleTableEntry(HandleTable, HandleTableEntry)) return NULL;
1065 
1066  /* Return the entry */
1067  return HandleTableEntry;
1068 }
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
ULONG_PTR Index
Definition: ex.h:90
Definition: extypes.h:595
HANDLE GenericHandleOverlay
Definition: ex.h:101
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
Definition: ex.h:85
#define LOW_LEVEL_ENTRIES
Definition: ex.h:151
#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 }
_SEH2_TRY
Definition: create.c:4226
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:27
KAPC_STATE
Definition: ketypes.h:1285
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_SEH2_END
Definition: create.c:4400
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:26
#define DBG_STATUS_WORKER
Definition: kdtypes.h:45
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
#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
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1727
#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
#define L(x)
Definition: ntvdm.h:50
PSECURITY_DESCRIPTOR SePublicDefaultSd
Definition: sd.c:16
#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:3402
#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:765
#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:121
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 L(x)
Definition: ntvdm.h:50
#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
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 L(x)
Definition: ntvdm.h:50
#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
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 922 of file init.c.

924 {
925  PNLS_DATA_BLOCK NlsData;
926  CHAR Buffer[256];
927  ANSI_STRING AnsiPath;
929  PCHAR CommandLine, PerfMem;
930  ULONG PerfMemUsed;
931  PLDR_DATA_TABLE_ENTRY NtosEntry;
932  PMESSAGE_RESOURCE_ENTRY MsgEntry;
933  ANSI_STRING CSDString;
934  size_t Remaining = 0;
935  PCHAR RcEnd = NULL;
936  CHAR VersionBuffer[65];
937 
938  /* Validate Loader */
939  if (!ExpIsLoaderValid(LoaderBlock))
940  {
941  /* Invalid loader version */
942  KeBugCheckEx(MISMATCHED_HAL,
943  3,
944  LoaderBlock->Extension->Size,
945  LoaderBlock->Extension->MajorVersion,
946  LoaderBlock->Extension->MinorVersion);
947  }
948 
949  /* Initialize PRCB pool lookaside pointers */
951 
952  /* Check if this is an application CPU */
953  if (Cpu)
954  {
955  /* Then simply initialize it with HAL */
956  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
957  {
958  /* Initialization failed */
959  KeBugCheck(HAL_INITIALIZATION_FAILED);
960  }
961 
962  /* We're done */
963  return;
964  }
965 
966  /* Assume no text-mode or remote boot */
969 
970  /* Check if we have a setup loader block */
971  if (LoaderBlock->SetupLdrBlock)
972  {
973  /* Check if this is text-mode setup */
974  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
976 
977  /* Check if this is network boot */
978  if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
979  {
980  /* Set variable */
982 
983  /* Make sure we're actually booting off the network */
984  ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
985  }
986  }
987 
988  /* Set phase to 0 */
990 
991  /* Get boot command line */
992  CommandLine = LoaderBlock->LoadOptions;
993  if (CommandLine)
994  {
995  /* Upcase it for comparison and check if we're in performance mode */
996  _strupr(CommandLine);
997  PerfMem = strstr(CommandLine, "PERFMEM");
998  if (PerfMem)
999  {
1000  /* Check if the user gave a number of bytes to use */
1001  PerfMem = strstr(PerfMem, "=");
1002  if (PerfMem)
1003  {
1004  /* Read the number of pages we'll use */
1005  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1006  if (PerfMemUsed)
1007  {
1008  /* FIXME: TODO */
1009  DPRINT1("BBT performance mode not yet supported."
1010  "/PERFMEM option ignored.\n");
1011  }
1012  }
1013  }
1014 
1015  /* Check if we're burning memory */
1016  PerfMem = strstr(CommandLine, "BURNMEMORY");
1017  if (PerfMem)
1018  {
1019  /* Check if the user gave a number of bytes to use */
1020  PerfMem = strstr(PerfMem, "=");
1021  if (PerfMem)
1022  {
1023  /* Read the number of pages we'll use */
1024  PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1025  if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1026  }
1027  }
1028  }
1029 
1030  /* Setup NLS Base and offsets */
1031  NlsData = LoaderBlock->NlsData;
1032  ExpNlsTableBase = NlsData->AnsiCodePageData;
1035  (ULONG_PTR)NlsData->AnsiCodePageData);
1037  (ULONG_PTR)NlsData->AnsiCodePageData);
1038 
1039  /* Initialize the NLS Tables */
1046  &ExpNlsTableInfo);
1048 
1049  /* Now initialize the HAL */
1050  if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1051  {
1052  /* HAL failed to initialize, bugcheck */
1053  KeBugCheck(HAL_INITIALIZATION_FAILED);
1054  }
1055 
1056  /* Make sure interrupts are active now */
1057  _enable();
1058 
1059  /* Clear the crypto exponent */
1060  SharedUserData->CryptoExponent = 0;
1061 
1062  /* Set global flags for the checked build */
1063 #if DBG
1066 #endif
1067 
1068  /* Setup NT System Root Path */
1069  sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1070 
1071  /* Convert to ANSI_STRING and null-terminate it */
1072  RtlInitString(&AnsiPath, Buffer);
1073  Buffer[--AnsiPath.Length] = ANSI_NULL;
1074 
1075  /* Get the string from KUSER_SHARED_DATA's buffer */
1076  RtlInitEmptyUnicodeString(&NtSystemRoot,
1077  SharedUserData->NtSystemRoot,
1078  sizeof(SharedUserData->NtSystemRoot));
1079 
1080  /* Now fill it in */
1082  if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1083 
1084  /* Setup bugcheck messages */
1086 
1087  /* Setup initial system settings */
1088  CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1089 
1090  /* Set the Service Pack Number and add it to the CSD Version number if needed */
1092  if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1093  {
1095  }
1096 
1097  /* Add loaded CmNtGlobalFlag value */
1099 
1100  /* Initialize the executive at phase 0 */
1101  if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1102 
1103  /* Initialize the memory manager at phase 0 */
1104  if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1105 
1106  /* Load boot symbols */
1107  ExpLoadBootSymbols(LoaderBlock);
1108 
1109  /* Check if we should break after symbol load */
1111 
1112  /* Check if this loader is compatible with NT 5.2 */
1113  if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1114  {
1115  /* Setup headless terminal settings */
1116  HeadlessInit(LoaderBlock);
1117  }
1118 
1119  /* Set system ranges */
1120 #ifdef _M_AMD64
1123 #else
1126 #endif
1127 
1128  /* Make a copy of the NLS Tables */
1129  ExpInitNls(LoaderBlock);
1130 
1131  /* Get the kernel's load entry */
1132  NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1134  InLoadOrderLinks);
1135 
1136  /* Check if this is a service pack */
1137  if (CmNtCSDVersion & 0xFFFF)
1138  {
1139  /* Get the service pack string */
1140  Status = RtlFindMessage(NtosEntry->DllBase,
1141  11,
1142  0,
1143  WINDOWS_NT_CSD_STRING,
1144  &MsgEntry);
1145  if (NT_SUCCESS(Status))
1146  {
1147  /* Setup the string */
1148  RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1149 
1150  /* Remove trailing newline */
1151  while ((CSDString.Length > 0) &&
1152  ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1153  (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1154  {
1155  /* Skip the trailing character */
1156  CSDString.Length--;
1157  }
1158 
1159  /* Fill the buffer with version information */
1161  sizeof(Buffer),
1162  "%Z %u%c",
1163  &CSDString,
1164  (CmNtCSDVersion & 0xFF00) >> 8,
1165  (CmNtCSDVersion & 0xFF) ?
1166  'A' + (CmNtCSDVersion & 0xFF) - 1 :
1167  ANSI_NULL);
1168  }
1169  else
1170  {
1171  /* Build default string */
1173  sizeof(Buffer),
1174  "CSD %04x",
1175  CmNtCSDVersion);
1176  }
1177 
1178  /* Check for success */
1179  if (!NT_SUCCESS(Status))
1180  {
1181  /* Fail */
1182  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1183  }
1184  }
1185  else
1186  {
1187  /* Then this is a beta */
1189  sizeof(Buffer),
1191  NULL,
1192  &Remaining,
1193  0);
1194  if (!NT_SUCCESS(Status))
1195  {
1196  /* Fail */
1197  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1198  }
1199 
1200  /* Update length */
1201  CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1202  }
1203 
1204  /* Check if we have an RC number */
1205  if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1206  {
1207  /* Check if we have no version data yet */
1208  if (!(*Buffer))
1209  {
1210  /* Set defaults */
1211  Remaining = sizeof(Buffer);
1212  RcEnd = Buffer;
1213  }
1214  else
1215  {
1216  /* Add comma and space */
1218  sizeof(Buffer),
1219  ", ",
1220  &RcEnd,
1221  &Remaining,
1222  0);
1223  if (!NT_SUCCESS(Status))
1224  {
1225  /* Fail */
1226  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1227  }
1228  }
1229 
1230  /* Add the version format string */
1231  Status = RtlStringCbPrintfA(RcEnd,
1232  Remaining,
1233  "v.%u",
1234  (CmNtCSDVersion & 0xFFFF0000) >> 16);
1235  if (!NT_SUCCESS(Status))
1236  {
1237  /* Fail */
1238  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1239  }
1240  }
1241 
1242  /* Now setup the final string */
1243  RtlInitAnsiString(&CSDString, Buffer);
1245  &CSDString,
1246  TRUE);
1247  if (!NT_SUCCESS(Status))
1248  {
1249  /* Fail */
1250  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1251  }
1252 
1253  /* Add our version */
1254  Status = RtlStringCbPrintfA(VersionBuffer,
1255  sizeof(VersionBuffer),
1256  "%u.%u",
1259  if (!NT_SUCCESS(Status))
1260  {
1261  /* Fail */
1262  KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1263  }
1264 
1265  /* Build the final version string */
1267 
1268  /* Check if the user wants a kernel stack trace database */
1270  {
1271  /* FIXME: TODO */
1272  DPRINT1("Kernel-mode stack trace support not yet present."
1273  "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1274  }
1275 
1276  /* Check if he wanted exception logging */
1278  {
1279  /* FIXME: TODO */
1280  DPRINT1("Kernel-mode exception logging support not yet present."
1281  "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1282  }
1283 
1284  /* Initialize the Handle Table */
1286 
1287 #if DBG
1288  /* On checked builds, allocate the system call count table */
1291  KiServiceLimit * sizeof(ULONG),
1292  'llaC');
1293 
1294  /* Use it for the shadow table too */
1296 
1297  /* Make sure allocation succeeded */
1299  {
1300  /* Zero the call counts to 0 */
1302  KiServiceLimit * sizeof(ULONG));
1303  }
1304 #endif
1305 
1306  /* Create the Basic Object Manager Types to allow new Object Types */
1307  if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1308 
1309  /* Load basic Security for other Managers */
1310  if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1311 
1312  /* Initialize the Process Manager */
1313  if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1314 
1315  /* Initialize the PnP Manager */
1316  if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1317 
1318  /* Initialize the User-Mode Debugging Subsystem */
1319  DbgkInitialize();
1320 
1321  /* Calculate the tick count multiplier */
1323  SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1324 
1325  /* Set the OS Version */
1326  SharedUserData->NtMajorVersion = NtMajorVersion;
1327  SharedUserData->NtMinorVersion = NtMinorVersion;
1328 
1329  /* Set the machine type */
1330  SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1331  SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1332 }
#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:212
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
Definition: rtltypes.h:1895
UNICODE_STRING NtSystemRoot
Definition: init.c:75
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:87
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:1712
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:795
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:60
PVOID AnsiCodePageData
Definition: arc.h:276
ULONG NtMajorVersion
Definition: init.c:45
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65
PVOID DllBase
Definition: btrfs_drv.h:1880
#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:296
_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:58
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:1899
#define ASSERT(a)
Definition: mode.c:44
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:34
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID ExpNlsTableBase
Definition: init.c:84
ULONG NtMinorVersion
Definition: init.c:46
#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:86
UNICODE_STRING CmCSDVersionString
Definition: init.c:62
VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:876
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
Definition: btrfs_drv.h:1876
ULONG ExpInitializationPhase
Definition: init.c:68
UNICODE_STRING CmVersionString
Definition: init.c:61
#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:85
BOOLEAN ExpInTextModeSetup
Definition: init.c:69
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
BOOLEAN NTAPI SeInitSystem(VOID)
Main security manager initialization function.
Definition: semgr.c:285
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:743
#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:59
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:54
#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:769
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:85
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:605
BOOLEAN IoRemoteBootClient
Definition: init.c:70

Referenced by KiInitializeKernel().

◆ ExpInitializeHandleTables()

VOID NTAPI ExpInitializeHandleTables ( VOID  )

Definition at line 34 of file handle.c.

35 {
36  /* Initialize the list of handle tables and the lock */
39 }
#define ExInitializePushLock
Definition: ex.h:1012
#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 L(x)
Definition: ntvdm.h:50
#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
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 62 of file profile.c.

63 {
64  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
67  DPRINT("Creating Profile Object Type\n");
68 
69  /* Initialize the Mutex to lock the States */
71 
72  /* Create the Event Pair Object Type */
73  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
74  RtlInitUnicodeString(&Name, L"Profile");
75  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
76  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KPROFILE);
77  ObjectTypeInitializer.GenericMapping = ExpProfileMapping;
78  ObjectTypeInitializer.PoolType = NonPagedPool;
79  ObjectTypeInitializer.DeleteProcedure = ExpDeleteProfile;
80  ObjectTypeInitializer.ValidAccessMask = PROFILE_ALL_ACCESS;
81  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
82  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExProfileObjectType);
83  if (!NT_SUCCESS(Status)) return FALSE;
84  return TRUE;
85 }
#define OBJ_OPENLINK
Definition: winternl.h:230
KMUTEX ExpProfileMutex
Definition: profile.c:19
POBJECT_TYPE ExProfileObjectType
Definition: profile.c:18
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 L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
VOID NTAPI ExpDeleteProfile(PVOID ObjectBody)
Definition: profile.c:33
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING ExpProfileMapping
Definition: profile.c:21
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
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 43 of file sem.c.

44 {
45  OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
48  DPRINT("Creating Semaphore Object Type\n");
49 
50  /* Create the Event Pair Object Type */
51  RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
52  RtlInitUnicodeString(&Name, L"Semaphore");
53  ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
54  ObjectTypeInitializer.DefaultNonPagedPoolCharge = sizeof(KSEMAPHORE);
55  ObjectTypeInitializer.GenericMapping = ExSemaphoreMapping;
56  ObjectTypeInitializer.PoolType = NonPagedPool;
57  ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK;
58  ObjectTypeInitializer.ValidAccessMask = SEMAPHORE_ALL_ACCESS;
59  Status = ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &ExSemaphoreObjectType);
60  if (!NT_SUCCESS(Status)) return FALSE;
61  return TRUE;
62 }
#define OBJ_OPENLINK
Definition: winternl.h:230
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1048
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
struct NameRec_ * Name
Definition: cdprocs.h:459
Status
Definition: gdiplustypes.h:24
GENERIC_MAPPING ExSemaphoreMapping
Definition: sem.c:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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:22

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
#define L(x)
Definition: ntvdm.h:50
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:240
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
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 522 of file work.c.

523 {
524  ULONG WorkQueueType;
525  ULONG CriticalThreads, DelayedThreads;
526  HANDLE ThreadHandle;
528  ULONG i;
530 
531  /* Setup the stack swap support */
535 
536  /* Set the number of critical and delayed threads. We shouldn't hardcode */
537  DelayedThreads = EX_DELAYED_WORK_THREADS;
538  CriticalThreads = EX_CRITICAL_WORK_THREADS;
539 
540  /* Protect against greedy registry modifications */
545 
546  /* Calculate final count */
547  DelayedThreads += ExpAdditionalDelayedWorkerThreads;
548  CriticalThreads += ExpAdditionalCriticalWorkerThreads;
549 
550  /* Initialize the Array */
551  for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++)
552  {
553  /* Clear the structure and initialize the queue */
554  RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE));
555  KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0);
556  }
557 
558  /* Dynamic threads are only used for the critical queue */
560 
561  /* Initialize the balance set manager events */
565  FALSE);
566 
567  /* Create the built-in worker threads for the critical queue */
568  for (i = 0; i < CriticalThreads; i++)
569  {
570  /* Create the thread */
573  }
574 
575  /* Create the built-in worker threads for the delayed queue */
576  for (i = 0; i < DelayedThreads; i++)
577  {
578  /* Create the thread */
581  }
582 
583  /* Create the built-in worker thread for the hypercritical queue */
585 
586  /* Create the balance set manager thread */
587  Status = PsCreateSystemThread(&ThreadHandle,
589  NULL,
590  0,
591  NULL,
593  NULL);
594  if (!NT_SUCCESS(Status))
595  {
596  KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
597  }
598 
599  /* Get a pointer to it for the shutdown process */
600  ObReferenceObjectByHandle(ThreadHandle,
602  NULL,
603  KernelMode,
604  (PVOID*)&Thread,
605  NULL);
607 
608  /* Close the handle and return */
609  ObCloseHandle(ThreadHandle, KernelMode);
610 }
#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
LONG NTSTATUS
Definition: precomp.h:26
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
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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:2652
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
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 KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
Definition: work.c:427

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:240
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 884 of file handle.c.

886 {
887  LONG_PTR NewValue, OldValue;
888 
889  /* Sanity check */
890  ASSERT((KeGetCurrentThread()->CombinedApcDisable != 0) ||
891  (KeGetCurrentIrql() == APC_LEVEL));
892 
893  /* Start lock loop */
894  for (;;)
895  {
896  /* Get the current value and check if it's locked */
897  OldValue = *(volatile LONG_PTR *)&HandleTableEntry->Object;
898  if (OldValue & EXHANDLE_TABLE_ENTRY_LOCK_BIT)
899  {
900  /* It's not locked, remove the lock bit to lock it */
901  NewValue = OldValue & ~EXHANDLE_TABLE_ENTRY_LOCK_BIT;
902  if (InterlockedCompareExchangePointer(&HandleTableEntry->Object,
903  (PVOID)NewValue,
904  (PVOID)OldValue) == (PVOID)OldValue)
905  {
906  /* We locked it, get out */
907  return TRUE;
908  }
909  }
910  else
911  {
912  /* We couldn't lock it, bail out if it's been freed */
913  if (!OldValue) return FALSE;
914  }
915 
916  /* It's locked, wait for it to be unlocked */
917  ExpBlockOnLockedHandleEntry(HandleTable, HandleTableEntry);
918  }
919 }
#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:858
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:44
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:145
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define KeGetCurrentThread
Definition: hal.h:55
#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 43 of file handle.c.

45 {
46  ULONG TableLevel;
47  ULONG_PTR TableBase;
48  PHANDLE_TABLE_ENTRY HandleArray, Entry;
49  PVOID *PointerArray;
50 
51  /* Clear the tag bits */
52  Handle.TagBits = 0;
53 
54  /* Check if the handle is in the allocated range */
55  if (Handle.Value >= HandleTable->NextHandleNeedingPool)
56  {
57  return NULL;
58  }
59 
60  /* Get the table code */
61  TableBase = HandleTable->TableCode;
62 
63  /* Extract the table level and actual table base */
64  TableLevel = (ULONG)(TableBase & 3);
65  TableBase &= ~3;
66 
67  PointerArray = (PVOID*)TableBase;
68  HandleArray = (PHANDLE_TABLE_ENTRY)TableBase;
69 
70  /* Check what level we're running at */
71  switch (TableLevel)
72  {
73  case 2:
74 
75  /* Get the mid level pointer array */
76  PointerArray = PointerArray[Handle.HighIndex];
77  ASSERT(PointerArray != NULL);
78 
79  /* Fall through */
80  case 1:
81 
82  /* Get the handle array */
83  HandleArray = PointerArray[Handle.MidIndex];
84  ASSERT(HandleArray != NULL);
85 
86  /* Fall through */
87  case 0:
88 
89  /* Get the entry using the low index */
90  Entry = &HandleArray[Handle.LowIndex];
91 
92  /* All done */
93  break;
94 
95  default:
96 
97  ASSERT(FALSE);
98  Entry = NULL;
99  }
100 
101  /* Return the handle entry */
102  return Entry;
103 }
struct _Entry Entry
Definition: kefuncs.h:629
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:44
#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:240
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 53 of file uuid.c.

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

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