ReactOS 0.4.15-dev-8116-gf69e256
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(ULONG_PTR) * 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
 
ULONG ExpResourceTimeoutCount
 
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 135 of file ex.h.

◆ ExfInterlockedCompareExchange64UL

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

Definition at line 1550 of file ex.h.

◆ ExGetPreviousMode

#define ExGetPreviousMode   KeGetPreviousMode

Definition at line 140 of file ex.h.

◆ EXHANDLE_TABLE_ENTRY_LOCK_BIT

#define EXHANDLE_TABLE_ENTRY_LOCK_BIT   1

Definition at line 146 of file ex.h.

◆ ExInitializePushLock

#define ExInitializePushLock   _ExInitializePushLock

Definition at line 1013 of file ex.h.

◆ ExInitializeRundownProtection

#define ExInitializeRundownProtection   _ExInitializeRundownProtection

Definition at line 137 of file ex.h.

◆ ExpChangePushlock

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

Definition at line 164 of file ex.h.

◆ ExpChangeRundown

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

Definition at line 163 of file ex.h.

◆ ExpSetRundown

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

Definition at line 165 of file ex.h.

◆ ExReleaseRundownProtection

#define ExReleaseRundownProtection   _ExReleaseRundownProtection

Definition at line 136 of file ex.h.

◆ ExRundownCompleted

#define ExRundownCompleted   _ExRundownCompleted

Definition at line 139 of file ex.h.

◆ ExWaitForRundownProtectionRelease

#define ExWaitForRundownProtectionRelease   _ExWaitForRundownProtectionRelease

Definition at line 138 of file ex.h.

◆ FREE_HANDLE_MASK

#define FREE_HANDLE_MASK   -1

Definition at line 147 of file ex.h.

◆ HANDLE_HIGH_BITS

#define HANDLE_HIGH_BITS   (PAGE_SHIFT - 2)

Definition at line 80 of file ex.h.

◆ HANDLE_INDEX_BITS

#define HANDLE_INDEX_BITS   (HANDLE_LOW_BITS + 2 * HANDLE_HIGH_BITS)

Definition at line 83 of file ex.h.

◆ HANDLE_LOW_BITS

#define HANDLE_LOW_BITS   (PAGE_SHIFT - 3)

Definition at line 79 of file ex.h.

◆ HANDLE_TAG_BITS

#define HANDLE_TAG_BITS   2

Definition at line 82 of file ex.h.

◆ HIGH_LEVEL_ENTRIES

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

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

◆ InterlockedCompareExchangeUL

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

Definition at line 1536 of file ex.h.

◆ InterlockedDecrementUL

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

Definition at line 1524 of file ex.h.

◆ InterlockedExchangeAddUL

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

Definition at line 1533 of file ex.h.

◆ InterlockedExchangeSizeT

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

Definition at line 1546 of file ex.h.

◆ InterlockedExchangeUL

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

Definition at line 1530 of file ex.h.

◆ InterlockedIncrementUL

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

Definition at line 1527 of file ex.h.

◆ KERNEL_FLAG_BITS

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

Definition at line 84 of file ex.h.

◆ LOW_LEVEL_ENTRIES

#define LOW_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(HANDLE_TABLE_ENTRY))

Definition at line 152 of file ex.h.

◆ MAX_FAST_REFS

#define MAX_FAST_REFS   7

Definition at line 133 of file ex.h.

◆ MAX_HIGH_INDEX

Definition at line 161 of file ex.h.

◆ MAX_LOW_INDEX

#define MAX_LOW_INDEX   LOW_LEVEL_ENTRIES

Definition at line 159 of file ex.h.

◆ MAX_MID_INDEX

#define MAX_MID_INDEX   (MID_LEVEL_ENTRIES * LOW_LEVEL_ENTRIES)

Definition at line 160 of file ex.h.

◆ MID_LEVEL_ENTRIES

#define MID_LEVEL_ENTRIES   (PAGE_SIZE / sizeof(PHANDLE_TABLE_ENTRY))

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

61{
enum _WINKD_WORKER_STATE WINKD_WORKER_STATE
@ WinKdWorkerStart
Definition: ex.h:63
@ WinKdWorkerReady
Definition: ex.h:62
@ WinKdWorkerInitialized
Definition: ex.h:64

Function Documentation

◆ _ExAcquireFastMutex()

FORCEINLINE VOID _ExAcquireFastMutex ( IN PFAST_MUTEX  FastMutex)

Definition at line 1375 of file ex.h.

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

Referenced by ExAcquireFastMutex().

◆ _ExAcquireFastMutexUnsafe()

FORCEINLINE VOID _ExAcquireFastMutexUnsafe ( IN PFAST_MUTEX  FastMutex)

Definition at line 1330 of file ex.h.

1331{
1333
1334 /* Sanity check */
1336 (Thread->CombinedApcDisable != 0) ||
1337 (Thread->Teb == NULL) ||
1338 (Thread->Teb >= (PTEB)MM_SYSTEM_RANGE_START));
1339 ASSERT(FastMutex->Owner != Thread);
1340
1341 /* Decrease the count */
1342 if (InterlockedDecrement(&FastMutex->Count))
1343 {
1344 /* Someone is still holding it, use slow path */
1345 KiAcquireFastMutex(FastMutex);
1346 }
1347
1348 /* Set the owner */
1349 FastMutex->Owner = Thread;
1350}
#define MM_SYSTEM_RANGE_START
Definition: armddk.h:18
#define NULL
Definition: types.h:112
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Definition: compat.h:836

Referenced by _ExEnterCriticalRegionAndAcquireFastMutexUnsafe(), and ExAcquireFastMutexUnsafe().

◆ _ExAcquireRundownProtection()

FORCEINLINE BOOLEAN _ExAcquireRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 820 of file ex.h.

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

Referenced by ExfAcquireRundownProtectionCacheAware().

◆ _ExEnterCriticalRegionAndAcquireFastMutexUnsafe()

FORCEINLINE VOID _ExEnterCriticalRegionAndAcquireFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1446 of file ex.h.

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

Referenced by ExEnterCriticalRegionAndAcquireFastMutexUnsafe().

◆ _ExInitializePushLock()

FORCEINLINE VOID _ExInitializePushLock ( OUT PEX_PUSH_LOCK  PushLock)

Definition at line 1008 of file ex.h.

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

◆ _ExInitializeRundownProtection()

FORCEINLINE VOID _ExInitializeRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 904 of file ex.h.

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

Referenced by ExAllocateCacheAwareRundownProtection(), and ExInitializeRundownProtectionCacheAware().

◆ _ExReleaseFastMutex()

FORCEINLINE VOID _ExReleaseFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1397 of file ex.h.

1398{
1399 KIRQL OldIrql;
1401
1402 /* Erase the owner */
1403 FastMutex->Owner = NULL;
1404 OldIrql = (KIRQL)FastMutex->OldIrql;
1405
1406 /* Increase the count */
1407 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1408 {
1409 /* Someone was waiting for it, signal the waiter */
1410 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1411 }
1412
1413 /* Lower IRQL back */
1415}
#define InterlockedIncrement
Definition: armddk.h:53
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
Definition: eventobj.c:229
if(dx< 0)
Definition: linetemp.h:194

Referenced by ExReleaseFastMutex().

◆ _ExReleaseFastMutexUnsafe()

FORCEINLINE VOID _ExReleaseFastMutexUnsafe ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1354 of file ex.h.

1355{
1357 (KeGetCurrentThread()->CombinedApcDisable != 0) ||
1358 (KeGetCurrentThread()->Teb == NULL) ||
1360 ASSERT(FastMutex->Owner == KeGetCurrentThread());
1361
1362 /* Erase the owner */
1363 FastMutex->Owner = NULL;
1364
1365 /* Increase the count */
1366 if (InterlockedIncrement(&FastMutex->Count) <= 0)
1367 {
1368 /* Someone was waiting for it, signal the waiter */
1369 KeSetEventBoostPriority(&FastMutex->Event, NULL);
1370 }
1371}

Referenced by _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(), and ExReleaseFastMutexUnsafe().

◆ _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion()

FORCEINLINE VOID _ExReleaseFastMutexUnsafeAndLeaveCriticalRegion ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1457 of file ex.h.

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

Referenced by ExReleaseFastMutexUnsafeAndLeaveCriticalRegion().

◆ _ExReleaseRundownProtection()

FORCEINLINE VOID _ExReleaseRundownProtection ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 861 of file ex.h.

862{
863 ULONG_PTR Value, NewValue;
864
865 /* Get the current value and mask the active bit */
866 Value = RunRef->Count &~ EX_RUNDOWN_ACTIVE;
867
868 /* Remove a reference */
869 NewValue = Value - EX_RUNDOWN_COUNT_INC;
870
871 /* Change the value */
872 NewValue = ExpChangeRundown(RunRef, NewValue, Value);
873
874 /* Check if the rundown was active */
875 if (NewValue != Value)
876 {
877 /* Rundown was active, use long path */
879 }
880 else
881 {
882 /* Sanity check */
884 }
885}
VOID FASTCALL ExfReleaseRundownProtection(IN OUT PEX_RUNDOWN_REF RunRef)
CCHAR KeNumberProcessors
Definition: krnlinit.c:35

Referenced by ExfReleaseRundownProtectionCacheAware().

◆ _ExRundownCompleted()

FORCEINLINE VOID _ExRundownCompleted ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 958 of file ex.h.

959{
960 /* Sanity check */
961 ASSERT((RunRef->Count & EX_RUNDOWN_ACTIVE) != 0);
962
963 /* Mark the counter as active */
965}
#define ExpSetRundown(x, y)
Definition: ex.h:165
#define EX_RUNDOWN_ACTIVE

◆ _ExTryToAcquireFastMutex()

FORCEINLINE BOOLEAN _ExTryToAcquireFastMutex ( IN OUT PFAST_MUTEX  FastMutex)

Definition at line 1419 of file ex.h.

1420{
1421 KIRQL OldIrql;
1423
1424 /* Raise to APC_LEVEL */
1426
1427 /* Check if we can quickly acquire it */
1428 if (InterlockedCompareExchange(&FastMutex->Count, 0, 1) == 1)
1429 {
1430 /* We have, set us as owners */
1431 FastMutex->Owner = KeGetCurrentThread();
1432 FastMutex->OldIrql = OldIrql;
1433 return TRUE;
1434 }
1435 else
1436 {
1437 /* Acquire attempt failed */
1440 return FALSE;
1441 }
1442}
#define FALSE
Definition: types.h:117
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define YieldProcessor
Definition: ke.h:48

Referenced by ExTryToAcquireFastMutex().

◆ _ExWaitForRundownProtectionRelease()

FORCEINLINE VOID _ExWaitForRundownProtectionRelease ( IN PEX_RUNDOWN_REF  RunRef)

Definition at line 928 of file ex.h.

929{
931
932 /* Set the active bit */
934 if ((Value) && (Value != EX_RUNDOWN_ACTIVE))
935 {
936 /* If the the rundown wasn't already active, then take the long path */
938 }
939}
VOID FASTCALL ExfWaitForRundownProtectionRelease(IN OUT PEX_RUNDOWN_REF RunRef)

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

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

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

◆ ExAcquirePushLockExclusive()

FORCEINLINE VOID ExAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

◆ ExAcquirePushLockShared()

FORCEINLINE VOID ExAcquirePushLockShared ( PEX_PUSH_LOCK  PushLock)

Definition at line 1105 of file ex.h.

1106{
1107 EX_PUSH_LOCK NewValue;
1108
1109 /* Try acquiring the lock */
1111 if (ExpChangePushlock(PushLock, NewValue.Ptr, 0))
1112 {
1113 /* Someone changed it, use the slow path */
1114 ExfAcquirePushLockShared(PushLock);
1115 }
1116
1117 /* Sanity checks */
1118 ASSERT(PushLock->Locked);
1119}
#define EX_PUSH_LOCK_SHARE_INC
Definition: Object.c:33
#define EX_PUSH_LOCK_LOCK
Definition: Object.c:29
VOID FASTCALL ExfAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:645
ULONG_PTR Value
Definition: extypes.h:465
PVOID Ptr
Definition: extypes.h:466
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 145 of file time.c.

146{
147 /* Block APCs */
149
150 /* Attempt lock acquisition */
152 {
153 /* Lock was not acquired, enable APCs and fail */
155 return FALSE;
156 }
157
158 /* Lock has been acquired */
159 return TRUE;
160}
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
ERESOURCE ExpTimeRefreshLock
Definition: time.c:27
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170

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:1156
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ExInitializeRundownProtection
Definition: ex.h:137
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
EX_RUNDOWN_REF RundownProtect
Definition: extypes.h:537
#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}
#define InterlockedExchangeAdd64
Definition: interlocked.h:186
ULONG ExpLuidIncrement
Definition: uuid.c:42
LARGE_INTEGER ExpLuid
Definition: uuid.c:43
int64_t LONG64
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114

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;
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}
#define PAGED_CODE()
unsigned char BOOLEAN
ULONG Handle
Definition: gdb_input.c:15
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:923
Definition: extypes.h:596
PVOID Object
Definition: extypes.h:599
LONG NextFreeTableEntry
Definition: extypes.h:612
Definition: ex.h:87
HANDLE GenericHandleOverlay
Definition: ex.h:102
_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:409

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}
#define MAX_FAST_REFS
Definition: ex.h:133
FORCEINLINE ULONG ExGetCountFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:588
FORCEINLINE EX_FAST_REF ExCompareSwapFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object, IN PVOID OldObject)
Definition: ex.h:747
FORCEINLINE PVOID ExGetObjectFastReference(IN EX_FAST_REF FastRef)
Definition: ex.h:580
FORCEINLINE VOID ExWaitOnPushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1178
int Count
Definition: noreturn.cpp:7
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
EX_PUSH_LOCK ExpCallBackFlush
Definition: callback.c:40
BOOLEAN FASTCALL ExfAcquireRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:78
VOID FASTCALL ExfReleaseRundownProtectionEx(IN PEX_RUNDOWN_REF RunRef, IN ULONG Count)
Definition: rundown.c:260
uint32_t ULONG
Definition: typedefs.h:59

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

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

Referenced by ExCompareExchangeCallBack(), and ObSetSecurityDescriptorInfo().

◆ ExConvertPushLockSharedToExclusive()

FORCEINLINE BOOLEAN ExConvertPushLockSharedToExclusive ( IN PEX_PUSH_LOCK  PushLock)

Definition at line 1139 of file ex.h.

1140{
1141 EX_PUSH_LOCK OldValue;
1142
1143 /* Set the expected old value */
1145
1146 /* Try converting the lock */
1147 if (ExpChangePushlock(PushLock, EX_PUSH_LOCK_LOCK, OldValue.Value) !=
1148 OldValue.Ptr)
1149 {
1150 /* Conversion failed */
1151 return FALSE;
1152 }
1153
1154 /* Sanity check */
1155 ASSERT(PushLock->Locked);
1156 return TRUE;
1157}

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}
PHANDLE_TABLE_ENTRY NTAPI ExpAllocateHandleTableEntry(IN PHANDLE_TABLE HandleTable, OUT PEXHANDLE NewHandle)
Definition: handle.c:683

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 */
816
817 /* Release the lock */
820
821 /* Return the handle table */
822 return HandleTable;
823}
#define InsertTailList(ListHead, Entry)
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1036
FORCEINLINE VOID ExReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1252
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
PHANDLE_TABLE NTAPI ExpAllocateHandleTable(IN PEPROCESS Process OPTIONAL, IN BOOLEAN NewTable)
Definition: handle.c:331
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
LIST_ENTRY HandleTableListHead
Definition: handle.c:18

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

◆ ExDereferenceCallBackBlock()

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

Definition at line 109 of file callback.c.

111{
112 /* Release a fast reference */
113 if (!ExReleaseFastReference(&CallBack->RoutineBlock, CallbackBlock))
114 {
115 /* Take slow path */
116 ExReleaseRundownProtection(&CallbackBlock->RundownProtect);
117 }
118}
FORCEINLINE BOOLEAN ExReleaseFastReference(IN PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:685
#define ExReleaseRundownProtection
Definition: ex.h:136

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;
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}
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define EXHANDLE_TABLE_ENTRY_LOCK_BIT
Definition: ex.h:146
VOID NTAPI ExpFreeHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:279
VOID FASTCALL ExfUnblockPushLock(PEX_PUSH_LOCK PushLock, PVOID CurrentWaitBlock)
Definition: pushlock.c:1205

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}
VOID NTAPI ExRemoveHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:944
VOID NTAPI ExpFreeHandleTable(IN PHANDLE_TABLE HandleTable)
Definition: handle.c:202

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

557{
558 PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
560
561 /* Reference the block */
562 CallbackBlock = ExReferenceCallBackBlock(Callback);
563 if (CallbackBlock)
564 {
565 /* Get the function */
566 Function = ExGetCallBackBlockRoutine(CallbackBlock);
567
568 /* Do the callback */
570
571 /* Now dereference it */
572 ExDereferenceCallBackBlock(Callback, CallbackBlock);
573 }
574}
_In_ PVOID Argument2
Definition: classpnp.h:721
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
VOID NTAPI ExDereferenceCallBackBlock(IN OUT PEX_CALLBACK CallBack, IN PEX_CALLBACK_ROUTINE_BLOCK CallbackRoutineBlock)
Definition: callback.c:109
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
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;
1079 PHANDLE_TABLE_ENTRY HandleTableEntry, NewEntry;
1081 PAGED_CODE();
1082
1083 /* Allocate the duplicated copy */
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,
1140 HandleTableEntry,
1141 NewEntry))
1142 {
1143 /* Clear failure flag */
1144 Failed = FALSE;
1145
1146 /* Lock the entry, increase the handle count */
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++;
1172
1173 /* We're done, skip the last entry */
1174 Handle.Value += INDEX_TO_HANDLE_VALUE(1);
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}
#define LOW_LEVEL_ENTRIES
Definition: ex.h:152
unsigned int Mask
Definition: fpcontrol.c:82
BOOLEAN NTAPI ExpAllocateHandleTableEntrySlow(IN PHANDLE_TABLE HandleTable, IN BOOLEAN DoInit)
Definition: handle.c:502
#define INDEX_TO_HANDLE_VALUE(x)
Definition: handle.c:21
@ Failed
Definition: arc.h:79
ULONG_PTR Value
Definition: extypes.h:602
LONG HandleCount
Definition: extypes.h:644
LONG ExtraInfoPages
Definition: extypes.h:635
ULONG NextHandleNeedingPool
Definition: extypes.h:645
LIST_ENTRY HandleTableList
Definition: extypes.h:627

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)

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

589{
590 /* Return the reference count */
591 return (ULONG)FastRef.RefCnt;
592}

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

◆ ExGetObjectFastReference()

FORCEINLINE PVOID ExGetObjectFastReference ( IN EX_FAST_REF  FastRef)

Definition at line 580 of file ex.h.

581{
582 /* Return the unbiased pointer */
583 return (PVOID)(FastRef.Value & ~MAX_FAST_REFS);
584}

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

1359{
1360 ULONG TableSize, CurrentLength;
1361 ULONG EntryCount;
1363 PSYSTEM_POOLTAG TagEntry;
1364 PPOOL_TRACKER_TABLE Buffer, TrackerEntry;
1367
1368 //
1369 // Keep track of how much data the caller's buffer must hold
1370 //
1371 CurrentLength = FIELD_OFFSET(SYSTEM_POOLTAG_INFORMATION, TagInfo);
1372
1373 //
1374 // Initialize the caller's buffer
1375 //
1376 TagEntry = &SystemInformation->TagInfo[0];
1377 SystemInformation->Count = 0;
1378
1379 //
1380 // Capture the number of entries, and the total size needed to make a copy
1381 // of the table
1382 //
1383 EntryCount = (ULONG)PoolTrackTableSize;
1384 TableSize = EntryCount * sizeof(POOL_TRACKER_TABLE);
1385
1386 //
1387 // Allocate the "Generic DPC" temporary buffer
1388 //
1391
1392 //
1393 // Do a "Generic DPC" to atomically retrieve the tag and allocation data
1394 //
1395 Context.PoolTrackTable = Buffer;
1396 Context.PoolTrackTableSize = PoolTrackTableSize;
1397 Context.PoolTrackTableExpansion = NULL;
1398 Context.PoolTrackTableSizeExpansion = 0;
1400
1401 //
1402 // Now parse the results
1403 //
1404 for (TrackerEntry = Buffer; TrackerEntry < (Buffer + EntryCount); TrackerEntry++)
1405 {
1406 //
1407 // If the entry is empty, skip it
1408 //
1409 if (!TrackerEntry->Key) continue;
1410
1411 //
1412 // Otherwise, add one more entry to the caller's buffer, and ensure that
1413 // enough space has been allocated in it
1414 //
1415 SystemInformation->Count++;
1416 CurrentLength += sizeof(*TagEntry);
1417 if (SystemInformationLength < CurrentLength)
1418 {
1419 //
1420 // The caller's buffer is too small, so set a failure code. The
1421 // caller will know the count, as well as how much space is needed.
1422 //
1423 // We do NOT break out of the loop, because we want to keep incrementing
1424 // the Count as well as CurrentLength so that the caller can know the
1425 // final numbers
1426 //
1428 }
1429 else
1430 {
1431 //
1432 // Small sanity check that our accounting is working correctly
1433 //
1434 ASSERT(TrackerEntry->PagedAllocs >= TrackerEntry->PagedFrees);
1435 ASSERT(TrackerEntry->NonPagedAllocs >= TrackerEntry->NonPagedFrees);
1436
1437 //
1438 // Return the data into the caller's buffer
1439 //
1440 TagEntry->TagUlong = TrackerEntry->Key;
1441 TagEntry->PagedAllocs = TrackerEntry->PagedAllocs;
1442 TagEntry->PagedFrees = TrackerEntry->PagedFrees;
1443 TagEntry->PagedUsed = TrackerEntry->PagedBytes;
1444 TagEntry->NonPagedAllocs = TrackerEntry->NonPagedAllocs;
1445 TagEntry->NonPagedFrees = TrackerEntry->NonPagedFrees;
1446 TagEntry->NonPagedUsed = TrackerEntry->NonPagedBytes;
1447 TagEntry++;
1448 }
1449 }
1450
1451 //
1452 // Free the "Generic DPC" temporary buffer, return the buffer length and status
1453 //
1454 ExFreePoolWithTag(Buffer, 'ofnI');
1455 if (ReturnLength) *ReturnLength = CurrentLength;
1456 return Status;
1457}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
VOID NTAPI KeGenericCallDpc(IN PKDEFERRED_ROUTINE Routine, IN PVOID Context)
Definition: dpc.c:984
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NonPagedPool
Definition: env_spec_w32.h:307
VOID NTAPI ExpGetPoolTagInfoTarget(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: expool.c:1321
SIZE_T PoolTrackTableSize
Definition: expool.c:46
Status
Definition: gdiplustypes.h:25
struct _POOL_TRACKER_TABLE POOL_TRACKER_TABLE
#define STATUS_SUCCESS
Definition: shellext.h:65
LONG NonPagedAllocs
Definition: miarm.h:370
SIZE_T NonPagedBytes
Definition: miarm.h:372
LONG NonPagedFrees
Definition: miarm.h:371
SIZE_T PagedBytes
Definition: miarm.h:375
SIZE_T PagedUsed
Definition: extypes.h:1143
ULONG TagUlong
Definition: extypes.h:1139
ULONG PagedFrees
Definition: extypes.h:1142
ULONG PagedAllocs
Definition: extypes.h:1141
ULONG NonPagedAllocs
Definition: extypes.h:1144
SIZE_T NonPagedUsed
Definition: extypes.h:1146
ULONG NonPagedFrees
Definition: extypes.h:1145
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327

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 */
50}
FORCEINLINE VOID ExInitializeFastReference(OUT PEX_FAST_REF FastRef, IN OPTIONAL PVOID Object)
Definition: ex.h:596

Referenced by CmpInitCallback(), and PspInitPhase0().

◆ ExInitializeFastReference()

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

Definition at line 596 of file ex.h.

598{
599 /* Sanity check */
601
602 /* Check if an object is being set */
603 if (!Object)
604 {
605 /* Clear the field */
606 FastRef->Object = NULL;
607 }
608 else
609 {
610 /* Otherwise, we assume the object was referenced and is ready */
611 FastRef->Value = (ULONG_PTR)Object | MAX_FAST_REFS;
612 }
613}

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}
Type
Definition: Type.h:7
#define InsertHeadList(ListHead, Entry)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3351

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}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GENERAL_LOOKASIDE ExpSmallNPagedPoolLookasideLists[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: lookas.c:23
GENERAL_LOOKASIDE ExpSmallPagedPoolLookasideLists[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: lookas.c:24
#define NUMBER_POOL_LOOKASIDE_LISTS
Definition: ketypes.h:371
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1161
base of all file and directory entries
Definition: entries.h:83
GENERAL_LOOKASIDE_POOL PPNPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:709
GENERAL_LOOKASIDE_POOL PPPagedLookasideList[NUMBER_POOL_LOOKASIDE_LISTS]
Definition: ketypes.h:710
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE

Referenced by ExpInitializeExecutive(), and KiSystemStartupBootStack().

◆ ExInsertFastReference()

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

Definition at line 646 of file ex.h.

648{
649 EX_FAST_REF OldValue, NewValue;
650
651 /* Sanity checks */
653
654 /* Start update loop */
655 for (;;)
656 {
657 /* Get the current reference count */
658 OldValue = *FastRef;
659
660 /* Check if the current count is too high or if the pointer changed */
661 if (((OldValue.RefCnt + MAX_FAST_REFS) > MAX_FAST_REFS) ||
662 ((OldValue.Value &~ MAX_FAST_REFS) != (ULONG_PTR)Object))
663 {
664 /* Fail */
665 return FALSE;
666 }
667
668 /* Update the reference count */
669 NewValue.Value = OldValue.Value + MAX_FAST_REFS;
670 NewValue.Object = ExpChangePushlock(&FastRef->Object,
671 NewValue.Object,
672 OldValue.Object);
673 if (NewValue.Object != OldValue.Object) continue;
674
675 /* We are done */
676 break;
677 }
678
679 /* Return success */
680 return TRUE;
681}

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

◆ ExLuidInitialization()

BOOLEAN NTAPI ExLuidInitialization ( VOID  )

Definition at line 325 of file uuid.c.

326{
327 return TRUE;
328}

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}
ULONG_PTR Index
Definition: ex.h:91

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 */
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}
#define DPRINT1
Definition: precomp.h:8
PEPROCESS ExpDebuggerProcessAttach
Definition: dbgctrl.c:26
PEPROCESS ExpDebuggerProcessKill
Definition: dbgctrl.c:27
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:25
ULONG_PTR ExpDebuggerPageIn
Definition: dbgctrl.c:28
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define DBG_STATUS_WORKER
Definition: kdtypes.h:45
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1765
#define DBG_TERMINATE_PROCESS
Definition: ntstatus.h:51
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
NTSTATUS NTAPI PsTerminateProcess(IN PEPROCESS Process, IN NTSTATUS ExitStatus)
Definition: kill.c:126
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define ProbeForReadUchar(Ptr)
Definition: probe.h:61
__analysis_noreturn NTSYSAPI VOID NTAPI DbgBreakPointWithStatus(_In_ ULONG Status)
KAPC_STATE
Definition: ketypes.h:1409
#define ObDereferenceObject
Definition: obfuncs.h:203

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. */
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}
static HANDLE DirectoryHandle
Definition: ObType.c:48
struct NameRec_ * Name
Definition: cdprocs.h:460
_In_ PFCB _In_ PCD_NAME DirName
Definition: cdprocs.h:737
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define OBJ_OPENLINK
Definition: winternl.h:230
#define OBJ_PERMANENT
Definition: winternl.h:226
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define CALLBACK_ALL_ACCESS
Definition: extypes.h:90
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
@ NotificationEvent
VOID NTAPI ExpDeleteCallback(IN PVOID Object)
Definition: callback.c:236
KEVENT ExpCallbackEvent
Definition: callback.c:39
GENERIC_MAPPING ExpCallbackMapping
Definition: callback.c:18
NTSTATUS NTAPI ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
Definition: callback.c:361
POBJECT_TYPE ExCallbackObjectType
Definition: callback.c:38
SYSTEM_CALLBACKS ExpInitializeCallback[]
Definition: callback.c:30
PSECURITY_DESCRIPTOR SePublicDefaultSd
Definition: sd.c:16
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI NtCreateDirectoryObject(OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: obdir.c:765
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1136
PCALLBACK_OBJECT * CallbackObject
Definition: ex.h:122
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:358
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

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 KEVENT
Definition: env_spec_w32.h:69
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
GENERIC_MAPPING ExpEventMapping
Definition: event.c:20
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
#define DPRINT
Definition: sndvol32.h:73
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}
POBJECT_TYPE ExEventPairObjectType
Definition: evtpair.c:18
GENERIC_MAPPING ExEventPairMapping
Definition: evtpair.c:20
#define EVENT_PAIR_ALL_ACCESS
Definition: extypes.h:125
struct _KEVENT_PAIR KEVENT_PAIR

Referenced by ExpInitSystemPhase1().

◆ ExpInitializeExecutive()

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

Definition at line 923 of file init.c.

925{
926 PNLS_DATA_BLOCK NlsData;
927 CHAR Buffer[256];
928 ANSI_STRING AnsiPath;
930 PCHAR CommandLine, PerfMem;
931 ULONG PerfMemUsed;
932 PLDR_DATA_TABLE_ENTRY NtosEntry;
934 ANSI_STRING CSDString;
935 size_t Remaining = 0;
936 PCHAR RcEnd = NULL;
937 CHAR VersionBuffer[65];
938
939 /* Validate Loader */
940 if (!ExpIsLoaderValid(LoaderBlock))
941 {
942 /* Invalid loader version */
943 KeBugCheckEx(MISMATCHED_HAL,
944 3,
945 LoaderBlock->Extension->Size,
946 LoaderBlock->Extension->MajorVersion,
947 LoaderBlock->Extension->MinorVersion);
948 }
949
950 /* Initialize PRCB pool lookaside pointers */
952
953 /* Check if this is an application CPU */
954 if (Cpu)
955 {
956 /* Then simply initialize it with HAL */
957 if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
958 {
959 /* Initialization failed */
960 KeBugCheck(HAL_INITIALIZATION_FAILED);
961 }
962
963 /* We're done */
964 return;
965 }
966
967 /* Assume no text-mode or remote boot */
970
971 /* Check if we have a setup loader block */
972 if (LoaderBlock->SetupLdrBlock)
973 {
974 /* Check if this is text-mode setup */
975 if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
977
978 /* Check if this is network boot */
979 if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
980 {
981 /* Set variable */
983
984 /* Make sure we're actually booting off the network */
985 ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
986 }
987 }
988
989 /* Set phase to 0 */
991
992 /* Get boot command line */
993 CommandLine = LoaderBlock->LoadOptions;
994 if (CommandLine)
995 {
996 /* Upcase it for comparison and check if we're in performance mode */
997 _strupr(CommandLine);
998 PerfMem = strstr(CommandLine, "PERFMEM");
999 if (PerfMem)
1000 {
1001 /* Check if the user gave a number of bytes to use */
1002 PerfMem = strstr(PerfMem, "=");
1003 if (PerfMem)
1004 {
1005 /* Read the number of pages we'll use */
1006 PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1007 if (PerfMemUsed)
1008 {
1009 /* FIXME: TODO */
1010 DPRINT1("BBT performance mode not yet supported."
1011 "/PERFMEM option ignored.\n");
1012 }
1013 }
1014 }
1015
1016 /* Check if we're burning memory */
1017 PerfMem = strstr(CommandLine, "BURNMEMORY");
1018 if (PerfMem)
1019 {
1020 /* Check if the user gave a number of bytes to use */
1021 PerfMem = strstr(PerfMem, "=");
1022 if (PerfMem)
1023 {
1024 /* Read the number of pages we'll use */
1025 PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
1026 if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
1027 }
1028 }
1029 }
1030
1031 /* Setup NLS Base and offsets */
1032 NlsData = LoaderBlock->NlsData;
1036 (ULONG_PTR)NlsData->AnsiCodePageData);
1038 (ULONG_PTR)NlsData->AnsiCodePageData);
1039
1040 /* Initialize the NLS Tables */
1049
1050 /* Now initialize the HAL */
1051 if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
1052 {
1053 /* HAL failed to initialize, bugcheck */
1054 KeBugCheck(HAL_INITIALIZATION_FAILED);
1055 }
1056
1057 /* Make sure interrupts are active now */
1058 _enable();
1059
1060 /* Clear the crypto exponent */
1061 SharedUserData->CryptoExponent = 0;
1062
1063 /* Set global flags for the checked build */
1064#if DBG
1067#endif
1068
1069 /* Setup NT System Root Path */
1070 sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
1071
1072 /* Convert to ANSI_STRING and null-terminate it */
1073 RtlInitString(&AnsiPath, Buffer);
1074 Buffer[--AnsiPath.Length] = ANSI_NULL;
1075
1076 /* Get the string from KUSER_SHARED_DATA's buffer */
1077 RtlInitEmptyUnicodeString(&NtSystemRoot,
1078 SharedUserData->NtSystemRoot,
1079 sizeof(SharedUserData->NtSystemRoot));
1080
1081 /* Now fill it in */
1083 if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
1084
1085 /* Setup bugcheck messages */
1087
1088 /* Setup initial system settings */
1089 CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
1090
1091 /* Set the Service Pack Number and add it to the CSD Version number if needed */
1093 if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
1094 {
1096 }
1097
1098 /* Add loaded CmNtGlobalFlag value */
1100
1101 /* Initialize the executive at phase 0 */
1102 if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1103
1104 /* Initialize the memory manager at phase 0 */
1105 if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
1106
1107 /* Load boot symbols */
1108 ExpLoadBootSymbols(LoaderBlock);
1109
1110 /* Check if we should break after symbol load */
1112
1113 /* Check if this loader is compatible with NT 5.2 */
1114 if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
1115 {
1116 /* Setup headless terminal settings */
1117 HeadlessInit(LoaderBlock);
1118 }
1119
1120 /* Set system ranges */
1121#ifdef _M_AMD64
1124#else
1127#endif
1128
1129 /* Make a copy of the NLS Tables */
1130 ExpInitNls(LoaderBlock);
1131
1132 /* Get the kernel's load entry */
1133 NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
1135 InLoadOrderLinks);
1136
1137 /* Check if this is a service pack */
1138 if (CmNtCSDVersion & 0xFFFF)
1139 {
1140 /* Get the service pack string */
1141 Status = RtlFindMessage(NtosEntry->DllBase,
1142 11,
1143 0,
1144 WINDOWS_NT_CSD_STRING,
1145 &MsgEntry);
1146 if (NT_SUCCESS(Status))
1147 {
1148 /* Setup the string */
1149 RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
1150
1151 /* Remove trailing newline */
1152 while ((CSDString.Length > 0) &&
1153 ((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
1154 (CSDString.Buffer[CSDString.Length - 1] == '\n')))
1155 {
1156 /* Skip the trailing character */
1157 CSDString.Length--;
1158 }
1159
1160 /* Fill the buffer with version information */
1162 sizeof(Buffer),
1163 "%Z %u%c",
1164 &CSDString,
1165 (CmNtCSDVersion & 0xFF00) >> 8,
1166 (CmNtCSDVersion & 0xFF) ?
1167 'A' + (CmNtCSDVersion & 0xFF) - 1 :
1168 ANSI_NULL);
1169 }
1170 else
1171 {
1172 /* Build default string */
1174 sizeof(Buffer),
1175 "CSD %04x",
1177 }
1178
1179 /* Check for success */
1180 if (!NT_SUCCESS(Status))
1181 {
1182 /* Fail */
1183 KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1184 }
1185 }
1186 else
1187 {
1188 /* Then this is a beta */
1190 sizeof(Buffer),
1192 NULL,
1193 &Remaining,
1194 0);
1195 if (!NT_SUCCESS(Status))
1196 {
1197 /* Fail */
1198 KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1199 }
1200
1201 /* Update length */
1202 CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
1203 }
1204
1205 /* Check if we have an RC number */
1206 if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
1207 {
1208 /* Check if we have no version data yet */
1209 if (!(*Buffer))
1210 {
1211 /* Set defaults */
1212 Remaining = sizeof(Buffer);
1213 RcEnd = Buffer;
1214 }
1215 else
1216 {
1217 /* Add comma and space */
1219 sizeof(Buffer),
1220 ", ",
1221 &RcEnd,
1222 &Remaining,
1223 0);
1224 if (!NT_SUCCESS(Status))
1225 {
1226 /* Fail */
1227 KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1228 }
1229 }
1230
1231 /* Add the version format string */
1232 Status = RtlStringCbPrintfA(RcEnd,
1233 Remaining,
1234 "v.%u",
1235 (CmNtCSDVersion & 0xFFFF0000) >> 16);
1236 if (!NT_SUCCESS(Status))
1237 {
1238 /* Fail */
1239 KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1240 }
1241 }
1242
1243 /* Now setup the final string */
1244 RtlInitAnsiString(&CSDString, Buffer);
1246 &CSDString,
1247 TRUE);
1248 if (!NT_SUCCESS(Status))
1249 {
1250 /* Fail */
1251 KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1252 }
1253
1254 /* Add our version */
1255 Status = RtlStringCbPrintfA(VersionBuffer,
1256 sizeof(VersionBuffer),
1257 "%u.%u",
1260 if (!NT_SUCCESS(Status))
1261 {
1262 /* Fail */
1263 KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
1264 }
1265
1266 /* Build the final version string */
1268
1269 /* Check if the user wants a kernel stack trace database */
1271 {
1272 /* FIXME: TODO */
1273 DPRINT1("Kernel-mode stack trace support not yet present."
1274 "FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
1275 }
1276
1277 /* Check if he wanted exception logging */
1279 {
1280 /* FIXME: TODO */
1281 DPRINT1("Kernel-mode exception logging support not yet present."
1282 "FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
1283 }
1284
1285 /* Initialize the Handle Table */
1287
1288#if DBG
1289 /* On checked builds, allocate the system call count table */
1292 KiServiceLimit * sizeof(ULONG),
1293 'llaC');
1294
1295 /* Use it for the shadow table too */
1297
1298 /* Make sure allocation succeeded */
1300 {
1301 /* Zero the call counts to 0 */
1303 KiServiceLimit * sizeof(ULONG));
1304 }
1305#endif
1306
1307 /* Create the Basic Object Manager Types to allow new Object Types */
1308 if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
1309
1310 /* Load basic Security for other Managers */
1311 if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
1312
1313 /* Initialize the Process Manager */
1314 if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
1315
1316 /* Initialize the PnP Manager */
1317 if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
1318
1319 /* Initialize the User-Mode Debugging Subsystem */
1321
1322 /* Calculate the tick count multiplier */
1324 SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
1325
1326 /* Set the OS Version */
1327 SharedUserData->NtMajorVersion = NtMajorVersion;
1328 SharedUserData->NtMinorVersion = NtMinorVersion;
1329
1330 /* Set the machine type */
1331 SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
1332 SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
1333}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1430
CM_SYSTEM_CONTROL_VECTOR CmControlVector[]
VOID NTAPI CmGetSystemControlValues(IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
Definition: cmcontrl.c:104
ULONG CmNtGlobalFlag
Definition: cmdata.c:19
VOID NTAPI DbgkInitialize(VOID)
Definition: dbgkobj.c:1498
#define PAGE_SIZE
Definition: env_spec_w32.h:49
BOOLEAN NTAPI HalInitSystem(IN ULONG BootPhase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: halinit.c:43
VOID NTAPI HeadlessInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: hdlsterm.c:189
#define VER_PRODUCTBETA_STR
Definition: ieverp.h:10
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
#define FLG_KERNEL_STACK_TRACE_DB
Definition: pstypes.h:68
#define FLG_ENABLE_EXCEPTION_LOGGING
Definition: pstypes.h:82
#define FLG_ENABLE_CLOSE_EXCEPTIONS
Definition: pstypes.h:81
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD
Definition: pstypes.h:73
void __cdecl _enable(void)
Definition: intrin_arm.h:373
BOOLEAN KdBreakAfterSymbolLoad
Definition: kddata.c:79
VOID NTAPI ExInitPoolLookasidePointers(VOID)
Definition: lookas.c:59
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define DBG_STATUS_CONTROL_C
Definition: kdtypes.h:39
NTSYSAPI VOID NTAPI RtlInitNlsTables(_In_ PUSHORT AnsiTableBase, _In_ PUSHORT OemTableBase, _In_ PUSHORT CaseTableBase, _Out_ PNLSTABLEINFO NlsTable)
NTSYSAPI VOID NTAPI RtlResetRtlTranslations(_In_ PNLSTABLEINFO NlsTable)
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define ANSI_NULL
VOID NTAPI ExpInitializeHandleTables(VOID)
Definition: handle.c:34
ULONG ExpInitializationPhase
Definition: init.c:68
VOID NTAPI ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN ULONG_PTR PagesToDestroy, IN TYPE_OF_MEMORY MemoryType)
Definition: init.c:877
ULONG CmNtCSDReleaseType
Definition: init.c:60
PVOID ExpNlsTableBase
Definition: init.c:85
ULONG NTAPI ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
Definition: init.c:606
BOOLEAN IoRemoteBootClient
Definition: init.c:70
UNICODE_STRING NtSystemRoot
Definition: init.c:76
ULONG ExpOemCodePageDataOffset
Definition: init.c:86
NLSTABLEINFO ExpNlsTableInfo
Definition: init.c:88
BOOLEAN NTAPI ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:770
ULONG NtMajorVersion
Definition: init.c:45
ULONG ExpUnicodeCaseTableDataOffset
Definition: init.c:87
BOOLEAN NTAPI MmArmInitSystem(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: mminit.c:2046
ULONG NtGlobalFlag
Definition: init.c:54
UNICODE_STRING CmVersionString
Definition: init.c:61
ULONG CmNtSpBuildNumber
Definition: init.c:58
BOOLEAN ExpInTextModeSetup
Definition: init.c:69
ULONG ExpAnsiCodePageDataOffset
Definition: init.c:86
ULONG NtMinorVersion
Definition: init.c:46
VOID NTAPI ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:796
ULONG CmNtCSDVersion
Definition: init.c:59
VOID NTAPI ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:213
UNICODE_STRING CmCSDVersionString
Definition: init.c:62
BOOLEAN NTAPI ExInitSystem(VOID)
Definition: init.c:744
ULONG ExpTickCountMultiplier
Definition: time.c:26
#define MM_HIGHEST_USER_ADDRESS_WOW64
Definition: mm.h:35
#define MM_SYSTEM_RANGE_START_WOW64
Definition: mm.h:36
#define MmSystemRangeStart
Definition: mm.h:32
BOOLEAN NTAPI PpInitSystem(VOID)
Definition: pnpmgr.c:1142
VOID NTAPI KiInitializeBugCheck(VOID)
Definition: bug.c:300
ULONG KiServiceLimit
Definition: krnlinit.c:26
BOOLEAN NTAPI SeInitSystem(VOID)
Main security manager initialization function.
Definition: semgr.c:285
ULONG KeMaximumIncrement
Definition: clock.c:20
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
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
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
#define VER_PRODUCTMAJORVERSION
Definition: ntverp.h:25
#define VER_PRODUCTBUILD_QFE
Definition: ntverp.h:20
#define VER_PRODUCTMINORVERSION
Definition: ntverp.h:26
BOOLEAN NTAPI ObInitSystem(VOID)
Definition: obinit.c:203
unsigned short USHORT
Definition: pedump.c:61
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTable[SSDT_MAX_ENTRIES]
Definition: procobj.c:23
KSERVICE_TABLE_DESCRIPTOR KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES]
Definition: procobj.c:24
BOOLEAN NTAPI PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: psmgr.c:532
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
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
_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)
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
@ LoaderBad
Definition: arc.h:177
#define SharedUserData
#define SETUPLDR_REMOTE_BOOT
Definition: setupblk.h:8
#define SETUPLDR_TEXT_MODE
Definition: setupblk.h:7
Definition: btrfs_drv.h:1876
PVOID DllBase
Definition: btrfs_drv.h:1880
Definition: rtltypes.h:1896
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1899
PVOID UnicodeCodePageData
Definition: arc.h:325
PVOID AnsiCodePageData
Definition: arc.h:323
PVOID OemCodePageData
Definition: arc.h:324
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
char * PCHAR
Definition: typedefs.h:51
char CHAR
Definition: xmlstorage.h:175

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 InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ExInitializePushLock
Definition: ex.h:1013

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}
VOID NTAPI ExpDeleteMutant(PVOID ObjectBody)
Definition: mutant.c:38
GENERIC_MAPPING ExpMutantMapping
Definition: mutant.c:20
POBJECT_TYPE ExMutantObjectType
Definition: mutant.c:18
#define MUTANT_ALL_ACCESS
Definition: extypes.h:110
struct _KMUTANT KMUTANT

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 PROFILE_ALL_ACCESS
Definition: extypes.h:131
struct _KPROFILE KPROFILE
POBJECT_TYPE ExProfileObjectType
Definition: profile.c:18
VOID NTAPI ExpDeleteProfile(PVOID ObjectBody)
Definition: profile.c:33
KMUTEX ExpProfileMutex
Definition: profile.c:19
GENERIC_MAPPING ExpProfileMapping
Definition: profile.c:21
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67

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)
51#endif
52}
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}
GENERIC_MAPPING ExSemaphoreMapping
Definition: sem.c:24
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:22
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:160
struct _KSEMAPHORE KSEMAPHORE

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 KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
struct _ETIMER ETIMER
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
POBJECT_TYPE ExTimerType
Definition: timer.c:18
VOID NTAPI ExpDeleteTimer(IN PVOID ObjectBody)
Definition: timer.c:108
static GENERIC_MAPPING ExpTimerMapping
Definition: timer.c:24
LIST_ENTRY ExpWakeList
Definition: timer.c:21
KSPIN_LOCK ExpWakeListLock
Definition: timer.c:20

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,
604 (PVOID*)&Thread,
605 NULL);
607
608 /* Close the handle and return */
609 ObCloseHandle(ThreadHandle, KernelMode);
610}
#define min(a, b)
Definition: monoChain.cc:55
#define KernelMode
Definition: asm.h:34
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
@ SynchronizationEvent
VOID NTAPI KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL)
Definition: queue.c:148
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
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
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
ULONG MakeThreadsAsNecessary
Definition: extypes.h:400
EX_QUEUE_WORKER_INFO Info
Definition: extypes.h:412
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
Definition: work.c:427
ULONG ExCriticalWorkerThreads
Definition: work.c:34
KEVENT ExpThreadSetManagerEvent
Definition: work.c:45
PETHREAD ExpWorkerThreadBalanceManagerPtr
Definition: work.c:49
BOOLEAN ExpWorkersCanSwap
Definition: work.c:40
ULONG ExDelayedWorkerThreads
Definition: work.c:35
ULONG ExpAdditionalCriticalWorkerThreads
Definition: work.c:36
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:250
#define EX_DELAYED_WORK_THREADS
Definition: work.c:19
#define EX_CRITICAL_WORK_THREADS
Definition: work.c:20
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:46
ULONG ExpAdditionalDelayedWorkerThreads
Definition: work.c:37
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:42
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:31
LIST_ENTRY ExpWorkerListHead
Definition: work.c:41
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
@ DelayedWorkQueue
Definition: extypes.h:190
@ CriticalWorkQueue
Definition: extypes.h:189
@ HyperCriticalWorkQueue
Definition: extypes.h:191
@ MaximumWorkQueue
Definition: extypes.h:192

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 < NUMBER_POOL_LOOKASIDE_LISTS; i++)
103 {
104 /* Initialize the non-paged list */
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}
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:20
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 ExPoolLookasideListHead
Definition: lookas.c:22
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:18
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:19
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:21
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:17

◆ 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) ||
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;
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 InterlockedCompareExchangePointer
Definition: interlocked.h:129
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
VOID NTAPI ExpBlockOnLockedHandleEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:858
void * PVOID
Definition: typedefs.h:50

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
98 Entry = NULL;
99 }
100
101 /* Return the handle entry */
102 return Entry;
103}
struct _HANDLE_TABLE_ENTRY * PHANDLE_TABLE_ENTRY

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

◆ ExpResourceInitialization()

VOID NTAPI ExpResourceInitialization ( VOID  )

Definition at line 173 of file resource.c.

174{
175 /* Setup the timeout */
176 ExpTimeout.QuadPart = Int32x32To64(4, -10000000);
179}
#define Int32x32To64(a, b)
KSPIN_LOCK ExpResourceSpinLock
Definition: resource.c:79
LARGE_INTEGER ExpTimeout
Definition: resource.c:74
LIST_ENTRY ExpSystemResourcesList
Definition: resource.c:80

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
FAST_MUTEX ExpUuidLock
Definition: uuid.c:35
BOOLEAN ExpUuidSequenceNumberValid
Definition: uuid.c:38
LARGE_INTEGER ExpUuidLastTimeAllocated
Definition: uuid.c:36

Referenced by ExpInitSystemPhase1().

◆ ExpWin32kInit()

BOOLEAN NTAPI ExpWin32kInit ( VOID  )

Definition at line 259 of file win32k.c.

260{
261 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
264 DPRINT("Creating Win32 Object Types\n");
265
266 /* Create the window station Object Type */
267 RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
268 RtlInitUnicodeString(&Name, L"WindowStation");
269 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
270 ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping;
271 ObjectTypeInitializer.PoolType = NonPagedPool;
272 ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete;
273 ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse;
274 ObjectTypeInitializer.OkayToCloseProcedure = ExpWindowStationOkToClose;
275 ObjectTypeInitializer.SecurityRequired = TRUE;
276 ObjectTypeInitializer.InvalidAttributes = OBJ_OPENLINK |
279 ObjectTypeInitializer.ValidAccessMask = STANDARD_RIGHTS_REQUIRED;
281 &ObjectTypeInitializer,
282 NULL,
284 if (!NT_SUCCESS(Status)) return FALSE;
285
286 /* Create desktop object type */
287 RtlInitUnicodeString(&Name, L"Desktop");
288 ObjectTypeInitializer.GenericMapping = ExpDesktopMapping;
289 ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete;
290 ObjectTypeInitializer.ParseProcedure = NULL;
291 ObjectTypeInitializer.OkayToCloseProcedure = ExpDesktopOkToClose;
292 ObjectTypeInitializer.OpenProcedure = ExpDesktopOpen;
293 ObjectTypeInitializer.CloseProcedure = ExpDesktopClose;
295 &ObjectTypeInitializer,
296 NULL,
298 if (!NT_SUCCESS(Status)) return FALSE;
299
300 return TRUE;
301}
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
OB_CLOSE_METHOD CloseProcedure
Definition: obtypes.h:368
OB_OPEN_METHOD OpenProcedure
Definition: obtypes.h:367
OB_PARSE_METHOD ParseProcedure
Definition: obtypes.h:370
OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure
Definition: obtypes.h:373
GENERIC_MAPPING ExpWindowStationMapping
Definition: win32k.c:24
BOOLEAN NTAPI ExpWindowStationOkToClose(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: win32k.c:135
GENERIC_MAPPING ExpDesktopMapping
Definition: win32k.c:32
NTSTATUS NTAPI ExpWinStaObjectParse(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: win32k.c:171
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:22
VOID NTAPI ExpWinStaObjectDelete(PVOID DeletedObject)
Definition: win32k.c:157
BOOLEAN NTAPI ExpDesktopOkToClose(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: win32k.c:113
VOID NTAPI ExpDesktopClose(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
Definition: win32k.c:237
NTSTATUS NTAPI ExpDesktopOpen(IN OB_OPEN_REASON Reason, IN PEPROCESS Process OPTIONAL, IN PVOID ObjectBody, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount)
Definition: win32k.c:216
VOID NTAPI ExpDesktopDelete(PVOID DeletedObject)
Definition: win32k.c:202
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:21

Referenced by ExpInitSystemPhase1().

◆ ExReferenceCallBackBlock()

PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExReferenceCallBackBlock ( IN OUT PEX_CALLBACK  CallBack)

Definition at line 122 of file callback.c.

123{
124 EX_FAST_REF OldValue;
126 PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
127
128 /* Acquire a reference */
129 OldValue = ExAcquireFastReference(&CallBack->RoutineBlock);
130 Count = ExGetCountFastReference(OldValue);
131
132 /* Fail if there isn't any object */
133 if (!ExGetObjectFastReference(OldValue)) return NULL;
134
135 /* Check if we don't have a reference */
136 if (!Count)
137 {
138 /* FIXME: Race */
139 DPRINT1("Unhandled callback race condition\n");
140 ASSERT(FALSE);
141 return NULL;
142 }
143
144 /* Get the callback block */
145 CallbackBlock = ExGetObjectFastReference(OldValue);
146
147 /* Check if this is the last reference */
148 if (Count == 1)
149 {
150 /* Acquire rundown protection */
153 {
154 /* Insert references */
155 if (!ExInsertFastReference(&CallBack->RoutineBlock, CallbackBlock))
156 {
157 /* Backdown the rundown acquire */
160 }
161 }
162 }
163
164 /* Return the callback block */
165 return CallbackBlock;
166}
FORCEINLINE BOOLEAN ExInsertFastReference(IN OUT PEX_FAST_REF FastRef, IN PVOID Object)
Definition: ex.h:646
FORCEINLINE EX_FAST_REF ExAcquireFastReference(IN OUT PEX_FAST_REF FastRef)
Definition: ex.h:617

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

◆ ExRefreshTimeZoneInformation()

BOOLEAN NTAPI ExRefreshTimeZoneInformation ( IN PLARGE_INTEGER  SystemBootTime)

Definition at line 320 of file time.c.

321{
322 LARGE_INTEGER CurrentTime, NewTimeZoneBias;
324
325 DPRINT("ExRefreshTimeZoneInformation\n");
326
327 /* Set the global data for ExpTimeZoneBias and the Time Zone ID */
328 Success = ExpGetTimeZoneId(CurrentBootTime, &ExpTimeZoneId, &NewTimeZoneBias);
329 if (!Success)
330 {
331 DPRINT1("ExpGetTimeZoneId failed\n");
332 return FALSE;
333 }
334 DPRINT("ExpTimeZoneId is %lu\n", ExpTimeZoneId);
335
336 ExpTimeZoneBias = NewTimeZoneBias;
337
338 /* Change SharedUserData->TimeZoneBias for user-mode applications */
339 SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.u.HighPart;
340 SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.u.LowPart;
341 SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.u.HighPart;
342 SharedUserData->TimeZoneId = ExpTimeZoneId;
343
344 /* Convert boot time from local time to UTC */
346
347 /* Convert system time from local time to UTC */
348 KeQuerySystemTime(&CurrentTime);;
349
350 /* Change it for user-mode applications */
351 CurrentTime.QuadPart += ExpTimeZoneBias.QuadPart;
352 SharedUserData->SystemTime.High2Time = CurrentTime.u.HighPart;
353 SharedUserData->SystemTime.LowPart = CurrentTime.u.LowPart;
354 SharedUserData->SystemTime.High1Time = CurrentTime.u.HighPart;
355
356 /* Return success */
357 return TRUE;
358}
@ Success
Definition: eventcreate.c:712
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
static BOOLEAN ExpGetTimeZoneId(_In_ PLARGE_INTEGER TimeNow, _Out_ PULONG TimeZoneId, _Out_ PLARGE_INTEGER NewTimeZoneBias)
Definition: time.c:39
ULONG ExpTimeZoneId
Definition: time.c:25
LARGE_INTEGER KeBootTime
Definition: clock.c:17
struct _LARGE_INTEGER::@2300 u

Referenced by Phase1InitializationDiscard().

◆ ExReleaseFastReference()

FORCEINLINE BOOLEAN ExReleaseFastReference ( IN PEX_FAST_REF  FastRef,
IN PVOID  Object 
)

Definition at line 685 of file ex.h.

687{
688 EX_FAST_REF OldValue, NewValue;
689
690 /* Sanity checks */
691 ASSERT(Object != NULL);
693
694 /* Start reference loop */
695 for (;;)
696 {
697 /* Get the current reference count */
698 OldValue = *FastRef;
699
700 /* Check if we're full if if the pointer changed */
701 if ((OldValue.Value ^ (ULONG_PTR)Object) >= MAX_FAST_REFS) return FALSE;
702
703 /* Decrease the reference count */
704 NewValue.Value = OldValue.Value + 1;
705 NewValue.Object = ExpChangePushlock(&FastRef->Object,
706 NewValue.Object,
707 OldValue.Object);
708 if (NewValue.Object != OldValue.Object) continue;
709
710 /* We are done */
711 break;
712 }
713
714 /* Return success */
715 return TRUE;
716}

Referenced by ExDereferenceCallBackBlock(), and ObFastDereferenceObject().

◆ ExReleasePushLock()

FORCEINLINE VOID ExReleasePushLock ( PEX_PUSH_LOCK  PushLock)

Definition at line 1296 of file ex.h.

1297{
1298 EX_PUSH_LOCK OldValue = *PushLock;
1299 EX_PUSH_LOCK NewValue;
1300
1301 /* Sanity checks */
1302 ASSERT(OldValue.Locked);
1303
1304 /* Check if the pushlock is shared */
1305 if (OldValue.Shared > 1)
1306 {
1307 /* Decrease the share count */
1308 NewValue.Value = OldValue.Value - EX_PUSH_LOCK_SHARE_INC;
1309 }
1310 else
1311 {
1312 /* Clear the pushlock entirely */
1313 NewValue.Value = 0;
1314 }
1315
1316 /* Check if nobody is waiting on us and try clearing the lock here */
1317 if ((OldValue.Waiting) ||
1318 (ExpChangePushlock(PushLock, NewValue.Ptr, OldValue.Ptr) !=
1319 OldValue.Ptr))
1320 {
1321 /* We have waiters, use the long path */
1322 ExfReleasePushLock(PushLock);
1323 }
1324}
VOID FASTCALL ExfReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:810
ULONG_PTR Waiting
Definition: extypes.h:460
ULONG_PTR Shared
Definition: extypes.h:463

Referenced by CmLoadKey(), CmpDestroyHive(), CmpDoFlushAll(), CmpDoFlushNextHive(), CmpInitializeHive(), CmpReleaseKcbLockByIndex(), CmpUnlinkHiveFromMaster(), ObpReleaseDirectoryLock(), and ObpSdReleaseLockShared().

◆ ExReleasePushLockExclusive()

FORCEINLINE VOID ExReleasePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 1252 of file ex.h.

1253{
1254 EX_PUSH_LOCK OldValue;
1255
1256 /* Sanity checks */
1257 ASSERT(PushLock->Locked);
1258
1259 /* Unlock the pushlock */
1260 OldValue.Value = InterlockedExchangeAddSizeT((PSIZE_T)PushLock,
1262
1263 /* Sanity checks */
1264 ASSERT(OldValue.Locked);
1265 ASSERT(OldValue.Waiting || OldValue.Shared == 0);
1266
1267 /* Check if anyone is waiting on it and it's not already waking*/
1268 if ((OldValue.Waiting) && !(OldValue.Waking))
1269 {
1270 /* Wake it up */
1271 ExfTryToWakePushLock(PushLock);
1272 }
1273}
LONG_PTR SSIZE_T
Definition: basetsd.h:181
#define InterlockedExchangeAddSizeT(a, b)
Definition: interlocked.h:196
VOID FASTCALL ExfTryToWakePushLock(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1165
ULONG_PTR Waking
Definition: extypes.h:461
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80

Referenced by CmUnloadKey(), ExCreateHandleTable(), ExDupHandleTable(), ExpAllocateHandleTableEntry(), ExRemoveHandleTable(), GDIOBJ_vDeleteObject(), GDIOBJ_vUnlockObject(), GdiPoolAllocate(), GdiPoolFree(), MiUnlockProcessWorkingSet(), MiUnlockProcessWorkingSetUnsafe(), MiUnlockWorkingSet(), NtUnloadKey2(), ObpSdReleaseLock(), PspCreateThread(), PspDeleteThread(), PspExitThread(), PspUnlockProcessSecurityExclusive(), PspUnlockThreadSecurityExclusive(), PsSetProcessWin32Process(), and TEXTOBJ_UnlockText().

◆ ExReleasePushLockShared()

FORCEINLINE VOID ExReleasePushLockShared ( PEX_PUSH_LOCK  PushLock)

Definition at line 1213 of file ex.h.

1214{
1215 EX_PUSH_LOCK OldValue;
1216
1217 /* Sanity checks */
1218 ASSERT(PushLock->Locked);
1219
1220 /* Try to clear the pushlock */
1222 if (ExpChangePushlock(PushLock, 0, OldValue.Ptr) != OldValue.Ptr)
1223 {
1224 /* There are still other people waiting on it */
1225 ExfReleasePushLockShared(PushLock);
1226 }
1227}
VOID FASTCALL ExfReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:956

Referenced by ExpAllocateHandleTableEntry(), MiUnlockProcessWorkingSetShared(), MiUnlockWorkingSetShared(), NtSetInformationProcess(), NtSetInformationThread(), PsGetNextProcessThread(), PspUnlockProcessSecurityShared(), PspUnlockThreadSecurityShared(), and QSI_DEF().

◆ ExReleaseTimeRefreshLock()

VOID NTAPI ExReleaseTimeRefreshLock ( VOID  )

Definition at line 177 of file time.c.

178{
179 /* Release the lock and re-enable APCs */
182}
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822

Referenced by ExSetTimerResolution(), and KdpTimeSlipWork().

◆ ExShutdownSystem()

VOID NTAPI ExShutdownSystem ( VOID  )

Definition at line 21 of file shutdown.c.

22{
23 /* Dereference the hard-error port and process objects */
25 {
28 }
30 {
33 }
34}
PVOID ExpDefaultErrorPort
Definition: harderr.c:18
PEPROCESS ExpDefaultErrorPortProcess
Definition: harderr.c:19

Referenced by PopGracefulShutdown().

◆ ExSwapFastReference()

FORCEINLINE EX_FAST_REF ExSwapFastReference ( IN PEX_FAST_REF  FastRef,
IN PVOID  Object 
)

Definition at line 720 of file ex.h.

722{
723 EX_FAST_REF NewValue, OldValue;
724
725 /* Sanity check */
727
728 /* Check if an object is being set */
729 if (!Object)
730 {
731 /* Clear the field */
732 NewValue.Object = NULL;
733 }
734 else
735 {
736 /* Otherwise, we assume the object was referenced and is ready */
737 NewValue.Value = (ULONG_PTR)Object | MAX_FAST_REFS;
738 }
739
740 /* Update the object */
741 OldValue.Object = InterlockedExchangePointer(&FastRef->Object, NewValue.Object);
742 return OldValue;
743}

Referenced by ObFastReplaceObject().

◆ ExSwapinWorkerThreads()

VOID NTAPI ExSwapinWorkerThreads ( IN BOOLEAN  AllowSwap)

Definition at line 637 of file work.c.

638{
640 PETHREAD CurrentThread = PsGetCurrentThread(), Thread;
642 KAPC Apc;
643 PAGED_CODE();
644
645 /* Initialize an event so we know when we're done */
647
648 /* Lock this routine */
650
651 /* New threads cannot swap anymore */
652 ExpWorkersCanSwap = AllowSwap;
653
654 /* Loop all threads in the system process */
656 while (Thread)
657 {
658 /* Skip threads with explicit permission to do this */
659 if (Thread->ExWorkerCanWaitUser) goto Next;
660
661 /* Check if we reached ourselves */
662 if (Thread == CurrentThread)
663 {
664 /* Do it inline */
666 }
667 else
668 {
669 /* Queue an APC */
670 KeInitializeApc(&Apc,
671 &Thread->Tcb,
674 NULL,
675 NULL,
677 &AllowSwap);
678 if (KeInsertQueueApc(&Apc, &Event, NULL, 3))
679 {
680 /* Wait for the APC to run */
683 }
684 }
685
686 /* Next thread */
687Next:
689 }
690
691 /* Release the lock */
693}
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
@ InsertApcEnvironment
Definition: ketypes.h:770
BOOLEAN NTAPI KeInsertQueueApc(IN PKAPC Apc, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN KPRIORITY PriorityBoost)
Definition: apc.c:735
VOID NTAPI KeInitializeApc(IN PKAPC Apc, IN PKTHREAD Thread, IN KAPC_ENVIRONMENT TargetEnvironment, IN PKKERNEL_ROUTINE KernelRoutine, IN PKRUNDOWN_ROUTINE RundownRoutine OPTIONAL, IN PKNORMAL_ROUTINE NormalRoutine, IN KPROCESSOR_MODE Mode, IN PVOID Context)
Definition: apc.c:651
PETHREAD NTAPI PsGetNextProcessThread(IN PEPROCESS Process, IN PETHREAD Thread OPTIONAL)
Definition: process.c:75
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
KTHREAD Tcb
Definition: pstypes.h:1103
ULONG ExWorkerCanWaitUser
Definition: pstypes.h:1201
Definition: ketypes.h:547
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:988
VOID NTAPI ExpSetSwappingKernelApc(IN PKAPC Apc, OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
Definition: work.c:614
@ Executive
Definition: ketypes.h:415

Referenced by NtSetSystemPowerState().

◆ ExSweepHandleTable()

VOID NTAPI ExSweepHandleTable ( IN PHANDLE_TABLE  HandleTable,
IN PEX_SWEEP_HANDLE_CALLBACK  EnumHandleProcedure,
IN PVOID  Context 
)

Definition at line 1232 of file handle.c.

1235{
1237 PHANDLE_TABLE_ENTRY HandleTableEntry;
1238 PAGED_CODE();
1239
1240 /* Set the initial value and loop the entries */
1241 Handle.Value = INDEX_TO_HANDLE_VALUE(1);
1242 while ((HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle)))
1243 {
1244 /* Loop each handle */
1245 do
1246 {
1247 /* Lock the entry */
1248 if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1249 {
1250 /* Notify the callback routine */
1251 EnumHandleProcedure(HandleTableEntry,
1252 Handle.GenericHandleOverlay,
1253 Context);
1254 }
1255
1256 /* Go to the next handle and entry */
1257 Handle.Value += INDEX_TO_HANDLE_VALUE(1);
1258 HandleTableEntry++;
1260
1261 /* Skip past the last entry */
1262 Handle.Value += INDEX_TO_HANDLE_VALUE(1);
1263 }
1264}

Referenced by ObClearProcessHandleTable(), ObKillProcess(), and RtlpDestroyAtomHandleTable().

◆ ExSystemExceptionFilter()

LONG NTAPI ExSystemExceptionFilter ( VOID  )

Definition at line 349 of file harderr.c.

350{
351 return KeGetPreviousMode() != KernelMode ?
353}
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
#define KeGetPreviousMode()
Definition: ketypes.h:1115

Referenced by _IRQL_requires_max_(), NtAddAtom(), NtAllocateUuids(), NtCancelTimer(), NtCompareTokens(), NtCreateDebugObject(), NtCreateDirectoryObject(), NtCreateEvent(), NtCreateEventPair(), NtCreateIoCompletion(), NtCreateMutant(), NtCreateProfile(), NtCreateSemaphore(), NtCreateSymbolicLinkObject(), NtCreateTimer(), NtFindAtom(), NtOpenDirectoryObject(), NtOpenEvent(), NtOpenEventPair(), NtOpenIoCompletion(), NtOpenMutant(), NtOpenSemaphore(), NtOpenSymbolicLinkObject(), NtOpenTimer(), NtPulseEvent(), NtQueryDefaultLocale(), NtQueryDefaultUILanguage(), NtQueryDirectoryObject(), NtQueryEvent(), NtQueryInformationAtom(), NtQueryInstallUILanguage(), NtQueryIntervalProfile(), NtQueryIoCompletion(), NtQueryMutant(), NtQueryObject(), NtQueryPerformanceCounter(), NtQuerySecurityObject(), NtQuerySemaphore(), NtQuerySymbolicLinkObject(), NtQuerySystemEnvironmentValue(), NtQuerySystemInformation(), NtQueryTimer(), NtReleaseMutant(), NtReleaseSemaphore(), NtRemoveIoCompletion(), NtResetEvent(), NtSetEvent(), NtSetInformationDebugObject(), NtSetSystemTime(), NtSetThreadExecutionState(), NtSetTimer(), NtStartProfile(), NtWaitForDebugEvent(), ObpCaptureObjectCreateInformation(), ObpCaptureObjectName(), ObQueryTypeInfo(), and ProbeAndCaptureObjectAttributes().

◆ ExTimerRundown()

VOID NTAPI ExTimerRundown ( VOID  )

Definition at line 43 of file timer.c.

44{
47 PLIST_ENTRY CurrentEntry;
49 ULONG DerefsToDo;
50
51 /* Lock the Thread's Active Timer List and loop it */
53 CurrentEntry = Thread->ActiveTimerListHead.Flink;
54 while (CurrentEntry != &Thread->ActiveTimerListHead)
55 {
56 /* Get the timer */
57 Timer = CONTAINING_RECORD(CurrentEntry, ETIMER, ActiveTimerListEntry);
58
59 /* Reference it */
61 DerefsToDo = 1;
62
63 /* Unlock the list */
65
66 /* Lock the Timer */
68
69 /* Lock the list again */
71
72 /* Make sure that the timer is valid */
73 if ((Timer->ApcAssociated) && (&Thread->Tcb == Timer->TimerApc.Thread))
74 {
75 /* Remove it from the list */
76 RemoveEntryList(&Timer->ActiveTimerListEntry);
77 Timer->ApcAssociated = FALSE;
78
79 /* Cancel the timer and remove its DPC and APC */
80 KeCancelTimer(&Timer->KeTimer);
81 KeRemoveQueueDpc(&Timer->TimerDpc);
82 if (KeRemoveQueueApc(&Timer->TimerApc)) DerefsToDo++;
83
84 /* Add another dereference to do */
85 DerefsToDo++;
86 }
87
88 /* Unlock the list */
90
91 /* Unlock the Timer */
93
94 /* Dereference it */
95 ObDereferenceObjectEx(Timer, DerefsToDo);
96
97 /* Loop again */
99 CurrentEntry = Thread->ActiveTimerListHead.Flink;
100 }
101
102 /* Release lock and return */
104}
BOOLEAN NTAPI KeRemoveQueueDpc(IN PKDPC Dpc)
Definition: dpc.c:878
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
BOOLEAN NTAPI KeRemoveQueueApc(PKAPC Apc)
LONG FASTCALL ObDereferenceObjectEx(IN PVOID Object, IN LONG Count)
Definition: obref.c:88
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
LIST_ENTRY ActiveTimerListHead
Definition: pstypes.h:1127
KSPIN_LOCK ActiveTimerListLock
Definition: pstypes.h:1126
Definition: ex.h:108
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by PspExitThread().

◆ ExTryToAcquirePushLockExclusive()

FORCEINLINE BOOLEAN ExTryToAcquirePushLockExclusive ( PEX_PUSH_LOCK  PushLock)

Definition at line 1070 of file ex.h.

1071{
1072 /* Try acquiring the lock */
1074 {
1075 /* Can't acquire */
1076 return FALSE;
1077 }
1078
1079 /* Got acquired */
1080 ASSERT (PushLock->Locked);
1081 return TRUE;
1082}

◆ ExTryToAcquireResourceExclusiveLite()

BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite ( IN PERESOURCE  Resource)

Definition at line 2134 of file resource.c.

2135{
2138 BOOLEAN Acquired = FALSE;
2139
2140 /* Sanity check */
2141 ASSERT((Resource->Flag & ResourceNeverExclusive) == 0);
2142
2143 /* Get the thread */
2145
2146 /* Sanity check and validation */
2149
2150 /* Acquire the lock */
2152
2153 /* Check if there is an owner */
2154 if (!Resource->ActiveCount)
2155 {
2156 /* No owner, give exclusive access */
2158 Resource->OwnerEntry.OwnerThread = Thread;
2159 Resource->OwnerEntry.OwnerCount = 1;
2160 Resource->ActiveCount = 1;
2161 Resource->ActiveEntries = 1;
2162 Acquired = TRUE;
2163 }
2164 else if ((IsOwnedExclusive(Resource)) &&
2165 (Resource->OwnerEntry.OwnerThread == Thread))
2166 {
2167 /* Do a recursive acquire */
2168 Resource->OwnerEntry.OwnerCount++;
2169 Acquired = TRUE;
2170 }
2171
2172 /* Release the resource */
2174 return Acquired;
2175}
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define ResourceOwnedExclusive
Definition: dldetect.h:32
BOOLEAN NTAPI KeIsExecutingDpc(VOID)
Definition: dpc.c:947
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
FORCEINLINE VOID ExReleaseResourceLock(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:37
#define ExpVerifyResource(r)
Definition: resource.c:154
FORCEINLINE VOID ExAcquireResourceLock(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: resource.c:25
#define IsOwnedExclusive(r)
Definition: resource.c:18
#define ResourceNeverExclusive
Definition: extypes.h:245
ULONG_PTR ERESOURCE_THREAD
Definition: extypes.h:208
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717

Referenced by ApphelpCacheTryAcquireLock().

◆ ExUnlockHandleTableEntry()

VOID NTAPI ExUnlockHandleTableEntry ( IN PHANDLE_TABLE  HandleTable,
IN PHANDLE_TABLE_ENTRY  HandleTableEntry 
)

Definition at line 923 of file handle.c.

925{
926 LONG_PTR OldValue;
927 PAGED_CODE();
928
929 /* Sanity check */
930 ASSERT((KeGetCurrentThread()->CombinedApcDisable != 0) ||
932
933 /* Set the lock bit and make sure it wasn't earlier */
934 OldValue = InterlockedOr((PLONG) &HandleTableEntry->Value,
936 ASSERT((OldValue & EXHANDLE_TABLE_ENTRY_LOCK_BIT) == 0);
937
938 /* Unblock any waiters */
939 ExfUnblockPushLock(&HandleTable->HandleContentionEvent, NULL);
940}
#define InterlockedOr
Definition: interlocked.h:224

Referenced by ExChangeHandle(), ExCreateHandle(), ExEnumHandleTable(), NtWaitForMultipleObjects(), ObpCloseHandleTableEntry(), ObpDuplicateHandleCallback(), ObpReferenceProcessObjectByHandle(), ObQueryObjectAuditingByHandle(), ObReferenceFileObjectForWrite(), ObReferenceObjectByHandle(), PsLookupProcessByProcessId(), PsLookupProcessThreadByCid(), PsLookupThreadByThreadId(), QSI_DEF(), and RtlpGetAtomEntry().

◆ ExUpdateSystemTimeFromCmos()

VOID NTAPI ExUpdateSystemTimeFromCmos ( IN BOOLEAN  UpdateInterruptTime,
IN ULONG  MaxSepInSeconds 
)

Definition at line 311 of file time.c.

313{
314 /* FIXME: TODO */
315 return;
316}

Referenced by KdpTimeSlipWork().

◆ ExWaitForCallBacks()

VOID NTAPI ExWaitForCallBacks ( IN PEX_CALLBACK_ROUTINE_BLOCK  CallbackRoutineBlock)

Definition at line 85 of file callback.c.

86{
87 /* Wait on the rundown */
88 ExWaitForRundownProtectionRelease(&CallbackBlock->RundownProtect);
89}
#define ExWaitForRundownProtectionRelease
Definition: ex.h:138

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

◆ ExWaitForUnblockPushLock()

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

Definition at line 395 of file pushlock.c.

397{
398 /* Call the timed function with no timeout */
399 ExTimedWaitForUnblockPushLock(PushLock, WaitBlock, NULL);
400}
NTSTATUS FASTCALL ExTimedWaitForUnblockPushLock(IN PEX_PUSH_LOCK PushLock, IN PVOID WaitBlock, IN PLARGE_INTEGER Timeout)
Definition: pushlock.c:319

Referenced by ExfUnblockPushLock(), and ExpBlockOnLockedHandleEntry().

◆ ExWaitOnPushLock()

FORCEINLINE VOID ExWaitOnPushLock ( PEX_PUSH_LOCK  PushLock)

Definition at line 1178 of file ex.h.

1179{
1180 /* Check if we're locked */
1181 if (PushLock->Locked)
1182 {
1183 /* Acquire the lock */
1185 ASSERT(PushLock->Locked);
1186
1187 /* Release it */
1189 }
1190}
VOID FASTCALL ExfReleasePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: pushlock.c:1091

Referenced by ExCompareExchangeCallBack(), and ExpMoveFreeHandles().

◆ HeadlessInit()

VOID NTAPI HeadlessInit ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 189 of file hdlsterm.c.

190{
191 PHEADLESS_LOADER_BLOCK HeadlessBlock;
192
193 /* Only initialize further if the loader found EMS enabled */
194 HeadlessBlock = LoaderBlock->Extension->HeadlessLoaderBlock;
195 if (!HeadlessBlock) return;
196
197 /* Ignore invalid EMS settings */
198 if ((HeadlessBlock->PortNumber > 4) && (HeadlessBlock->UsedBiosSettings)) return;
199
200 /* Allocate the global headless data */
202 sizeof(*HeadlessGlobals),
203 'sldH');
204 if (!HeadlessGlobals) return;
205
206 /* Zero and copy loader data */
210 HeadlessGlobals->TerminalBaudRate = HeadlessBlock->BaudRate;
211 HeadlessGlobals->TerminalParity = HeadlessBlock->Parity;
212 HeadlessGlobals->TerminalStopBits = HeadlessBlock->StopBits;
214 HeadlessGlobals->IsMMIODevice = HeadlessBlock->IsMMIODevice;
215 HeadlessGlobals->TerminalType = HeadlessBlock->TerminalType;
216 HeadlessGlobals->SystemGUID = HeadlessBlock->SystemGUID;
217 DPRINT1("EMS on Port %lu (0x%p) at %lu bps\n",
221
222 /* These two are opposites of each other */
224
225 /* Check for a PCI device, warn that this isn't supported */
226 if (HeadlessBlock->PciDeviceId != PCI_INVALID_VENDORID)
227 {
228 DPRINT1("PCI Serial Ports not supported\n");
229 }
230
231 /* Log entries are not yet supported */
232 DPRINT1("FIXME: No Headless logging support\n");
233
234 /* Allocate temporary buffer */
236 if (!HeadlessGlobals->TmpBuffer) return;
237
238 /* Windows seems to apply some special hacks for 9600 bps */
240 {
241 DPRINT1("Please use other baud rate than 9600bps for now\n");
242 }
243
244 /* Enable the terminal */
246}
PHEADLESS_GLOBALS HeadlessGlobals
Definition: hdlsterm.c:16
NTSTATUS NTAPI HdlspEnableTerminal(IN BOOLEAN Enable)
Definition: hdlsterm.c:148
GUID SystemGUID
Definition: hdl.h:119
ULONG IsNonLegacyDevice
Definition: hdl.h:106
PUCHAR TerminalPortAddress
Definition: hdl.h:112
ULONG TerminalPortNumber
Definition: hdl.h:105
ULONG UsedBiosSettings
Definition: hdl.h:99
ULONG TerminalStopBits
Definition: hdl.h:104
BOOLEAN IsMMIODevice
Definition: hdl.h:120
UCHAR TerminalType
Definition: hdl.h:115
ULONG TerminalBaudRate
Definition: hdl.h:110
ULONG TerminalParity
Definition: hdl.h:103
PUCHAR TmpBuffer
Definition: hdl.h:89
UCHAR IsMMIODevice
Definition: arc.h:367
UCHAR UsedBiosSettings
Definition: arc.h:353
PUCHAR PortAddress
Definition: arc.h:359
USHORT PciDeviceId
Definition: arc.h:360
UCHAR TerminalType
Definition: arc.h:368
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601

Referenced by ExpInitializeExecutive().

◆ Phase1Initialization()

VOID NTAPI Phase1Initialization ( IN PVOID  Context)

Definition at line 2023 of file init.c.

2024{
2025 /* Do the .INIT part of Phase 1 which we can free later */
2027
2028 /* Jump into zero page thread */
2030}
VOID NTAPI Phase1InitializationDiscard(IN PVOID Context)
Definition: init.c:1342
VOID NTAPI MmZeroPageThread(VOID)
Definition: zeropage.c:36

Referenced by PspInitPhase0().

◆ XIPInit()

VOID NTAPI XIPInit ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 55 of file xipdisp.c.

56{
57 PCHAR CommandLine, XipBoot, XipRom, XipMegs, XipVerbose, XipRam;
59
60 /* Get the command line */
61 CommandLine = LoaderBlock->LoadOptions;
62 if (!CommandLine) return;
63
64 /* Get XIP settings */
65 XipBoot = strstr(CommandLine, "XIPBOOT");
66 XipRam = strstr(CommandLine, "XIPRAM=");
67 XipRom = strstr(CommandLine, "XIPROM=");
68 XipMegs = strstr(CommandLine, "XIPMEGS=");
69 XipVerbose = strstr(CommandLine, "XIPVERBOSE");
70
71 /* Check if this is a verbose boot */
72 if (XipVerbose)
73 {
74 /* Print out our header */
75 DbgPrint("\n\nXIP: debug timestamp at line %d in %s: <<<%s %s>>>\n\n",
76 __LINE__,
77 __FILE__,
78 __DATE__,
79 __TIME__);
80 }
81
82 /* Find the XIP memory descriptor */
83 XipDescriptor = XIPpFindMemoryDescriptor(LoaderBlock);
84