Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ex.h File Reference

Go to the source code of this file.

Classes

struct  _CALL_HASH_ENTRY
struct  _CALL_PERFORMANCE_DATA
struct  _EEVENT_PAIR
struct  _FAST_MUTEX
struct  _GENERAL_LOOKASIDE
struct  _NPAGED_LOOKASIDE_LIST
struct  _PAGED_LOOKASIDE_LIST
struct  _WORK_QUEUE_ITEM
struct  _EX_WORK_QUEUE
struct  _ZONE_SEGMENT_HEADER
struct  _ZONE_HEADER
struct  _OWNER_ENTRY
struct  _ERESOURCE
struct  _RESOURCE_HASH_ENTRY
struct  _RESOURCE_PERFORMANCE_DATA
struct  _NTDDK_ERESOURCE
struct  _EXHANDLE
struct  _HANDLE_TABLE_ENTRY
struct  _HANDLE_TABLE
struct  _EX_DEBUG_LOG_TAG
struct  _EX_DEBUG_LOG_EVENT
struct  _EX_DEBUG_LOG

Defines

#define CALL_HASH_TABLE_SIZE   64
#define RECORD_CALL_DATA(Table)
#define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE   8
#define POOL_RAISE_IF_ALLOCATION_FAILURE   16
#define ExAllocatePoolWithTag(a, b, c)   ExAllocatePool(a,b)
#define ExAllocatePoolWithQuotaTag(a, b, c)   ExAllocatePoolWithQuota(a,b)
#define PROTECTED_POOL   0x80000000
#define ExFreePoolWithTag(a, b)   ExFreePool(a)
#define ExInitializeFastMutex(_FastMutex)
#define ExInitializeSListHead(_listhead_)   (_listhead_)->Alignment = 0
#define ExQueryDepthSList(_listhead_)   (USHORT)(_listhead_)->Depth
#define ProbeForRead(Address, Length, Alignment)
#define ProbeAndReadBoolean(Address)
#define ProbeAndReadChar(Address)
#define ProbeAndReadUchar(Address)
#define ProbeAndReadShort(Address)
#define ProbeAndReadUshort(Address)
#define ProbeAndReadHandle(Address)
#define ProbeAndReadPointer(Address)
#define ProbeAndReadLong(Address)
#define ProbeAndReadUlong(Address)
#define ProbeAndReadUlong_ptr(Address)
#define ProbeAndReadQuad(Address)
#define ProbeAndReadUquad(Address)
#define ProbeAndReadLargeInteger(Source)
#define ProbeAndReadUlargeInteger(Source)
#define ProbeAndReadUnicodeString(Source)
#define ProbeAndReadStructure(Source, STRUCTURE)
#define ProbeForWriteBoolean(Address)
#define ProbeForWriteChar(Address)
#define ProbeForWriteUchar(Address)
#define ProbeForWriteIoStatus(Address)
#define ProbeForWriteIoStatusEx(Address, Cookie)   ProbeForWriteIoStatus(Address)
#define ProbeForWriteShort(Address)
#define ProbeForWriteUshort(Address)
#define ProbeForWriteHandle(Address)
#define ProbeAndZeroHandle(Address)
#define ProbeForWritePointer(Address)
#define ProbeAndNullPointer(Address)
#define ProbeForWriteLong(Address)
#define ProbeForWriteUlong(Address)
#define ProbeForWriteUlong_ptr(Address)
#define ProbeForWriteQuad(Address)
#define ProbeForWriteUquad(Address)
#define ProbeAndWriteBoolean(Address, Value)
#define ProbeAndWriteChar(Address, Value)
#define ProbeAndWriteUchar(Address, Value)
#define ProbeAndWriteShort(Address, Value)
#define ProbeAndWriteUshort(Address, Value)
#define ProbeAndWriteHandle(Address, Value)
#define ProbeAndWriteLong(Address, Value)
#define ProbeAndWriteUlong(Address, Value)
#define ProbeAndWriteQuad(Address, Value)
#define ProbeAndWriteUquad(Address, Value)
#define ProbeAndWriteStructure(Address, Value, STRUCTURE)
#define ExInitializeWorkItem(Item, Routine, Context)
#define ExAllocateFromZone(Zone)
#define ExFreeToZone(Zone, Block)
#define ExIsFullZone(Zone)   ( (Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY)NULL )
#define ExInterlockedAllocateFromZone(Zone, Lock)   (PVOID) ExInterlockedPopEntryList( &(Zone)->FreeList, Lock )
#define ExInterlockedFreeToZone(Zone, Block, Lock)   ExInterlockedPushEntryList( &(Zone)->FreeList, ((PSINGLE_LIST_ENTRY) (Block)), Lock )
#define ExIsObjectInFirstZoneSegment(Zone, Object)
#define ResourceNeverExclusive   0x10
#define ResourceReleaseByOtherThread   0x20
#define ResourceOwnedExclusive   0x80
#define RESOURCE_HASH_TABLE_SIZE   64
#define ExReleaseResource(R)   (ExReleaseResourceLite(R))
#define ExGetCurrentResourceThread()   ((ULONG_PTR)PsGetCurrentThread())
#define ExInitializeResource   ExInitializeResourceLite
#define ExAcquireResourceShared   ExAcquireResourceSharedLite
#define ExAcquireResourceExclusive   ExAcquireResourceExclusiveLite
#define ExReleaseResourceForThread   ExReleaseResourceForThreadLite
#define ExConvertExclusiveToShared   ExConvertExclusiveToSharedLite
#define ExDeleteResource   ExDeleteResourceLite
#define ExIsResourceAcquiredExclusive   ExIsResourceAcquiredExclusiveLite
#define ExIsResourceAcquiredShared   ExIsResourceAcquiredSharedLite
#define ExDisableResourceBoost   ExDisableResourceBoostLite
#define ExSetHandleTableOwner(ht, id)   {(ht)->UniqueProcessId = (id);}
#define ExSetHandleTableOrder(ht, or)   {NOTHING;}
#define ExAllocateLocallyUniqueId(Luid)
#define EX_DEBUG_LOG_FORMAT_NONE   (UCHAR)0
#define EX_DEBUG_LOG_FORMAT_ULONG   (UCHAR)1
#define EX_DEBUG_LOG_FORMAT_PSZ   (UCHAR)2
#define EX_DEBUG_LOG_FORMAT_PWSZ   (UCHAR)3
#define EX_DEBUG_LOG_FORMAT_STRING   (UCHAR)4
#define EX_DEBUG_LOG_FORMAT_USTRING   (UCHAR)5
#define EX_DEBUG_LOG_FORMAT_OBJECT   (UCHAR)6
#define EX_DEBUG_LOG_FORMAT_HANDLE   (UCHAR)7
#define EX_DEBUG_LOG_NUMBER_OF_DATA_VALUES   4
#define EX_DEBUG_LOG_NUMBER_OF_BACK_TRACES   4

Typedefs

typedef _CALL_HASH_ENTRY CALL_HASH_ENTRY
typedef _CALL_HASH_ENTRYPCALL_HASH_ENTRY
typedef _CALL_PERFORMANCE_DATA CALL_PERFORMANCE_DATA
typedef _CALL_PERFORMANCE_DATAPCALL_PERFORMANCE_DATA
typedef _EEVENT_PAIR EEVENT_PAIR
typedef _EEVENT_PAIRPEEVENT_PAIR
typedef enum _POOL_TYPE POOL_TYPE
typedef enum _EX_POOL_PRIORITY EX_POOL_PRIORITY
typedef _FAST_MUTEX FAST_MUTEX
typedef _FAST_MUTEXPFAST_MUTEX
typedef PVOID(* PALLOCATE_FUNCTION )(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
typedef VOID(* PFREE_FUNCTION )(IN PVOID Buffer)
typedef _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
typedef _GENERAL_LOOKASIDEPGENERAL_LOOKASIDE
typedef _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
typedef _NPAGED_LOOKASIDE_LISTPNPAGED_LOOKASIDE_LIST
typedef _PAGED_LOOKASIDE_LIST PAGED_LOOKASIDE_LIST
typedef _PAGED_LOOKASIDE_LISTPPAGED_LOOKASIDE_LIST
typedef enum _PP_NPAGED_LOOKASIDE_NUMBER PP_NPAGED_LOOKASIDE_NUMBER
typedef enum _PP_NPAGED_LOOKASIDE_NUMBERPPP_NPAGED_LOOKASIDE_NUMBER
typedef enum _WORK_QUEUE_TYPE WORK_QUEUE_TYPE
typedef VOID(* PWORKER_THREAD_ROUTINE )(IN PVOID Parameter)
typedef _WORK_QUEUE_ITEM WORK_QUEUE_ITEM
typedef _WORK_QUEUE_ITEMPWORK_QUEUE_ITEM
typedef _EX_WORK_QUEUE EX_WORK_QUEUE
typedef _EX_WORK_QUEUEPEX_WORK_QUEUE
typedef _ZONE_SEGMENT_HEADER ZONE_SEGMENT_HEADER
typedef _ZONE_SEGMENT_HEADERPZONE_SEGMENT_HEADER
typedef _ZONE_HEADER ZONE_HEADER
typedef _ZONE_HEADERPZONE_HEADER
typedef ULONG_PTR ERESOURCE_THREAD
typedef ERESOURCE_THREADPERESOURCE_THREAD
typedef _OWNER_ENTRY OWNER_ENTRY
typedef _OWNER_ENTRYPOWNER_ENTRY
typedef _ERESOURCE ERESOURCE
typedef _ERESOURCEPERESOURCE
typedef _RESOURCE_HASH_ENTRY RESOURCE_HASH_ENTRY
typedef _RESOURCE_HASH_ENTRYPRESOURCE_HASH_ENTRY
typedef _RESOURCE_PERFORMANCE_DATA RESOURCE_PERFORMANCE_DATA
typedef _RESOURCE_PERFORMANCE_DATAPRESOURCE_PERFORMANCE_DATA
typedef _NTDDK_ERESOURCE NTDDK_ERESOURCE
typedef NTDDK_ERESOURCEPNTDDK_ERESOURCE
typedef _EXHANDLE EXHANDLE
typedef _EXHANDLEPEXHANDLE
typedef _HANDLE_TABLE_ENTRY HANDLE_TABLE_ENTRY
typedef _HANDLE_TABLE_ENTRYPHANDLE_TABLE_ENTRY
typedef _HANDLE_TABLE HANDLE_TABLE
typedef _HANDLE_TABLEPHANDLE_TABLE
typedef VOID(* EX_DESTROY_HANDLE_ROUTINE )(IN HANDLE Handle)
typedef BOOLEAN(* EX_ENUMERATE_HANDLE_ROUTINE )(IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN HANDLE Handle, IN PVOID EnumParameter)
typedef BOOLEAN(* EX_DUPLICATE_HANDLE_ROUTINE )(IN struct _EPROCESS *Process OPTIONAL, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
typedef NTSTATUS(* PEX_SNAPSHOT_HANDLE_ENTRY )(IN OUT PSYSTEM_HANDLE_TABLE_ENTRY_INFO *HandleEntryInfo, IN HANDLE UniqueProcessId, IN PHANDLE_TABLE_ENTRY HandleEntry, IN HANDLE Handle, IN ULONG Length, IN OUT PULONG RequiredLength)
typedef BOOLEAN(* PEX_CHANGE_HANDLE_ROUTINE )(IN OUT PHANDLE_TABLE_ENTRY HandleTableEntry, IN ULONG_PTR Parameter)
typedef _EX_DEBUG_LOG_TAG EX_DEBUG_LOG_TAG
typedef _EX_DEBUG_LOG_TAGPEX_DEBUG_LOG_TAG
typedef _EX_DEBUG_LOG_EVENT EX_DEBUG_LOG_EVENT
typedef _EX_DEBUG_LOG_EVENTPEX_DEBUG_LOG_EVENT
typedef _EX_DEBUG_LOG EX_DEBUG_LOG
typedef _EX_DEBUG_LOGPEX_DEBUG_LOG
typedef _CALLBACK_OBJECTPCALLBACK_OBJECT
typedef VOID(* PCALLBACK_FUNCTION )(IN PVOID CallbackContext, IN PVOID Argument1, IN PVOID Argument2)
typedef PVOID(* PKWIN32_GLOBALATOMTABLE_CALLOUT )(void)
typedef GUID UUID

Enumerations

enum  _POOL_TYPE {
  NonPagedPool, PagedPool, NonPagedPoolMustSucceed, DontUseThisType,
  NonPagedPoolCacheAligned, PagedPoolCacheAligned, NonPagedPoolCacheAlignedMustS, MaxPoolType,
  NonPagedPoolSession = 32, PagedPoolSession = NonPagedPoolSession + 1, NonPagedPoolMustSucceedSession = PagedPoolSession + 1, DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1,
  NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1, PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1, NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1
}
enum  _EX_POOL_PRIORITY {
  LowPoolPriority, LowPoolPrioritySpecialPoolOverrun = 8, LowPoolPrioritySpecialPoolUnderrun = 9, NormalPoolPriority = 16,
  NormalPoolPrioritySpecialPoolOverrun = 24, NormalPoolPrioritySpecialPoolUnderrun = 25, HighPoolPriority = 32, HighPoolPrioritySpecialPoolOverrun = 40,
  HighPoolPrioritySpecialPoolUnderrun = 41
}
enum  _PP_NPAGED_LOOKASIDE_NUMBER {
  LookasideSmallIrpList, LookasideLargeIrpList, LookasideMdlList, LookasideCreateInfoList,
  LookasideNameBufferList, LookasideTwilightList, LookasideCompletionList, LookasideMaximumList
}
enum  _WORK_QUEUE_TYPE { CriticalWorkQueue, DelayedWorkQueue, HyperCriticalWorkQueue, MaximumWorkQueue }

Functions

VOID ExInitializeCallData (IN PCALL_PERFORMANCE_DATA CallData)
VOID ExRecordCallerInHashTable (IN PCALL_PERFORMANCE_DATA CallData, IN PVOID CallersAddress, IN PVOID CallersCaller)
NTKERNELAPI BOOLEAN ExInitSystem (VOID)
NTKERNELAPI VOID ExInitSystemPhase2 (VOID)
VOID ExInitPoolLookasidePointers (VOID)
ULONG ExComputeTickCountMultiplier (IN ULONG TimeIncrement)
VOID InitializePool (IN POOL_TYPE PoolType, IN ULONG Threshold)
VOID ExInsertPoolTag (ULONG Tag, PVOID Va, SIZE_T NumberOfBytes, POOL_TYPE PoolType)
VOID ExAllocatePoolSanityChecks (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
VOID ExFreePoolSanityChecks (IN PVOID P)
NTKERNELAPI PVOID ExAllocatePool (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
NTKERNELAPI PVOID ExAllocatePoolWithQuota (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTag (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTagPriority (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag, IN EX_POOL_PRIORITY Priority)
NTKERNELAPI PVOID ExAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
NTKERNELAPI VOID NTAPI ExFreePool (IN PVOID P)
NTKERNELAPI VOID ExFreePoolWithTag (IN PVOID P, IN ULONG Tag)
NTKERNELAPI KIRQL ExLockPool (IN POOL_TYPE PoolType)
NTKERNELAPI VOID ExUnlockPool (IN POOL_TYPE PoolType, IN KIRQL LockHandle)
NTKERNELAPI ULONG ExQueryPoolBlockSize (IN PVOID PoolBlock, OUT PBOOLEAN QuotaCharged)
NTKERNELAPI VOID ExQueryPoolUsage (OUT PULONG PagedPoolPages, OUT PULONG NonPagedPoolPages, OUT PULONG PagedPoolAllocs, OUT PULONG PagedPoolFrees, OUT PULONG PagedPoolLookasideHits, OUT PULONG NonPagedPoolAllocs, OUT PULONG NonPagedPoolFrees, OUT PULONG NonPagedPoolLookasideHits)
VOID ExReturnPoolQuota (IN PVOID P)
NTKERNELAPI VOID FASTCALL ExAcquireFastMutexUnsafe (IN PFAST_MUTEX FastMutex)
NTKERNELAPI VOID FASTCALL ExReleaseFastMutexUnsafe (IN PFAST_MUTEX FastMutex)
NTKERNELAPI VOID FASTCALL ExInterlockedAddLargeStatistic (IN PLARGE_INTEGER Addend, IN ULONG Increment)
NTKERNELAPI LARGE_INTEGER ExInterlockedAddLargeInteger (IN PLARGE_INTEGER Addend, IN LARGE_INTEGER Increment, IN PKSPIN_LOCK Lock)
NTKERNELAPI ULONG FASTCALL ExInterlockedAddUlong (IN PULONG Addend, IN ULONG Increment, IN PKSPIN_LOCK Lock)
NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64 (IN PLONGLONG Destination, IN PLONGLONG Exchange, IN PLONGLONG Comperand, IN PKSPIN_LOCK Lock)
NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList (IN PLIST_ENTRY ListHead, IN PLIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock)
NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList (IN PLIST_ENTRY ListHead, IN PLIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock)
NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList (IN PLIST_ENTRY ListHead, IN PKSPIN_LOCK Lock)
NTKERNELAPI PSINGLE_LIST_ENTRY
FASTCALL 
ExInterlockedPopEntryList (IN PSINGLE_LIST_ENTRY ListHead, IN PKSPIN_LOCK Lock)
NTKERNELAPI PSINGLE_LIST_ENTRY
FASTCALL 
ExInterlockedPushEntryList (IN PSINGLE_LIST_ENTRY ListHead, IN PSINGLE_LIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock)
NTKERNELAPI PSINGLE_LIST_ENTRY
FASTCALL 
ExInterlockedPopEntrySList (IN PSLIST_HEADER ListHead, IN PKSPIN_LOCK Lock)
NTKERNELAPI PSINGLE_LIST_ENTRY
FASTCALL 
ExInterlockedPushEntrySList (IN PSLIST_HEADER ListHead, IN PSINGLE_LIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock)
NTKERNELAPI PSINGLE_LIST_ENTRY
FASTCALL 
ExInterlockedFlushSList (IN PSLIST_HEADER ListHead)
VOID ExAdjustLookasideDepth (VOID)
NTKERNELAPI VOID ExInitializeNPagedLookasideList (IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate, IN PFREE_FUNCTION Free, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
NTKERNELAPI VOID ExDeleteNPagedLookasideList (IN PNPAGED_LOOKASIDE_LIST Lookaside)
__inline PVOID ExAllocateFromNPagedLookasideList (IN PNPAGED_LOOKASIDE_LIST Lookaside)
__inline VOID ExFreeToNPagedLookasideList (IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry)
NTKERNELAPI VOID ExInitializePagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate, IN PFREE_FUNCTION Free, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
NTKERNELAPI VOID ExDeletePagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside)
__inline PVOID ExAllocateFromPagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside)
__inline VOID ExFreeToPagedLookasideList (IN PPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry)
__inline PVOID ExAllocateFromPPNPagedLookasideList (IN PP_NPAGED_LOOKASIDE_NUMBER Number)
__inline VOID ExFreeToPPNPagedLookasideList (IN PP_NPAGED_LOOKASIDE_NUMBER Number, IN PVOID Entry)
NTKERNELAPI PVOID ExLockUserBuffer (IN PVOID Buffer, IN ULONG Length, OUT PVOID *LockVariable)
NTKERNELAPI VOID ExUnlockUserBuffer (IN PVOID LockVariable)
NTKERNELAPI VOID NTAPI ProbeForRead (IN CONST VOID *Address, IN ULONG Length, IN ULONG Alignment)
NTKERNELAPI VOID NTAPI ProbeForWrite (IN PVOID Address, IN ULONG Length, IN ULONG Alignment)
NTKERNELAPI VOID ExTimerRundown (VOID)
NTKERNELAPI VOID ExQueueWorkItem (IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
NTKERNELAPI BOOLEAN ExIsProcessorFeaturePresent (ULONG ProcessorFeature)
NTKERNELAPI NTSTATUS ExInitializeZone (IN PZONE_HEADER Zone, IN ULONG BlockSize, IN PVOID InitialSegment, IN ULONG InitialSegmentSize)
NTKERNELAPI NTSTATUS ExExtendZone (IN PZONE_HEADER Zone, IN PVOID Segment, IN ULONG SegmentSize)
NTKERNELAPI NTSTATUS ExInterlockedExtendZone (IN PZONE_HEADER Zone, IN PVOID Segment, IN ULONG SegmentSize, IN PKSPIN_LOCK Lock)
NTKERNELAPI NTSTATUS ExInitializeResourceLite (IN PERESOURCE Resource)
NTKERNELAPI NTSTATUS ExReinitializeResourceLite (IN PERESOURCE Resource)
NTKERNELAPI BOOLEAN ExAcquireResourceSharedLite (IN PERESOURCE Resource, IN BOOLEAN Wait)
NTKERNELAPI BOOLEAN ExAcquireResourceExclusiveLite (IN PERESOURCE Resource, IN BOOLEAN Wait)
NTKERNELAPI BOOLEAN ExAcquireSharedStarveExclusive (IN PERESOURCE Resource, IN BOOLEAN Wait)
NTKERNELAPI BOOLEAN ExAcquireSharedWaitForExclusive (IN PERESOURCE Resource, IN BOOLEAN Wait)
NTKERNELAPI BOOLEAN ExTryToAcquireResourceExclusiveLite (IN PERESOURCE Resource)
NTKERNELAPI VOID FASTCALL ExReleaseResourceLite (IN PERESOURCE Resource)
NTKERNELAPI VOID ExReleaseResourceForThreadLite (IN PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId)
NTKERNELAPI VOID ExSetResourceOwnerPointer (IN PERESOURCE Resource, IN PVOID OwnerPointer)
NTKERNELAPI VOID ExConvertExclusiveToSharedLite (IN PERESOURCE Resource)
NTKERNELAPI NTSTATUS ExDeleteResourceLite (IN PERESOURCE Resource)
NTKERNELAPI ULONG ExGetExclusiveWaiterCount (IN PERESOURCE Resource)
NTKERNELAPI ULONG ExGetSharedWaiterCount (IN PERESOURCE Resource)
NTKERNELAPI VOID ExDisableResourceBoostLite (IN PERESOURCE Resource)
NTKERNELAPI BOOLEAN ExIsResourceAcquiredExclusiveLite (IN PERESOURCE Resource)
NTKERNELAPI ULONG ExIsResourceAcquiredSharedLite (IN PERESOURCE Resource)
NTKERNELAPI VOID ExLockHandleTableShared (PHANDLE_TABLE HandleTable)
NTKERNELAPI VOID ExLockHandleTableExclusive (PHANDLE_TABLE HandleTable)
NTKERNELAPI VOID ExUnlockHandleTableShared (PHANDLE_TABLE HandleTable)
NTKERNELAPI VOID ExUnlockHandleTableExclusive (PHANDLE_TABLE HandleTable)
NTKERNELAPI BOOLEAN ExLockHandleTableEntry (PHANDLE_TABLE HandleTable, PHANDLE_TABLE_ENTRY HandleTableEntry)
NTKERNELAPI VOID ExUnlockHandleTableEntry (PHANDLE_TABLE HandleTable, PHANDLE_TABLE_ENTRY HandleTableEntry)
NTKERNELAPI VOID ExInitializeHandleTablePackage (VOID)
NTKERNELAPI PHANDLE_TABLE ExCreateHandleTable (IN struct _EPROCESS *Process OPTIONAL)
NTKERNELAPI VOID ExRemoveHandleTable (IN PHANDLE_TABLE HandleTable)
NTKERNELAPI VOID ExDestroyHandleTable (IN PHANDLE_TABLE HandleTable, IN EX_DESTROY_HANDLE_ROUTINE DestroyHandleProcedure)
NTKERNELAPI BOOLEAN ExEnumHandleTable (IN PHANDLE_TABLE HandleTable, IN EX_ENUMERATE_HANDLE_ROUTINE EnumHandleProcedure, IN PVOID EnumParameter, OUT PHANDLE Handle OPTIONAL)
NTKERNELAPI PHANDLE_TABLE ExDupHandleTable (IN struct _EPROCESS *Process OPTIONAL, IN PHANDLE_TABLE OldHandleTable, IN EX_DUPLICATE_HANDLE_ROUTINE DupHandleProcedure OPTIONAL)
NTKERNELAPI NTSTATUS ExSnapShotHandleTables (IN PEX_SNAPSHOT_HANDLE_ENTRY SnapShotHandleEntry, IN OUT PSYSTEM_HANDLE_INFORMATION HandleInformation, IN ULONG Length, IN OUT PULONG RequiredLength)
NTKERNELAPI HANDLE ExCreateHandle (IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
NTKERNELAPI BOOLEAN ExDestroyHandle (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PHANDLE_TABLE_ENTRY HandleTableEntry OPTIONAL)
NTKERNELAPI BOOLEAN ExChangeHandle (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle, IN PEX_CHANGE_HANDLE_ROUTINE ChangeRoutine, IN ULONG_PTR Parameter)
NTKERNELAPI PHANDLE_TABLE_ENTRY ExMapHandleToPointer (IN PHANDLE_TABLE HandleTable, IN HANDLE Handle)
NTKERNELAPI BOOLEAN ExLuidInitialization (VOID)
NTKERNELAPI KPROCESSOR_MODE ExGetPreviousMode (VOID)
NTKERNELAPI VOID NTAPI ExRaiseException (PEXCEPTION_RECORD ExceptionRecord)
NTKERNELAPI VOID NTAPI ExRaiseStatus (IN NTSTATUS Status)
NTKERNELAPI VOID ExRaiseDatatypeMisalignment (VOID)
NTKERNELAPI VOID ExRaiseAccessViolation (VOID)
NTKERNELAPI NTSTATUS ExRaiseHardError (IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
int ExSystemExceptionFilter (VOID)
NTKERNELAPI PEX_DEBUG_LOG ExCreateDebugLog (IN UCHAR MaximumNumberOfTags, IN ULONG MaximumNumberOfEvents)
NTKERNELAPI UCHAR ExCreateDebugLogTag (IN PEX_DEBUG_LOG Log, IN PCHAR Name, IN UCHAR Format1, IN UCHAR Format2, IN UCHAR Format3, IN UCHAR Format4)
NTKERNELAPI VOID ExDebugLogEvent (IN PEX_DEBUG_LOG Log, IN UCHAR Tag, IN ULONG Data1, IN ULONG Data2, IN ULONG Data3, IN ULONG Data4)
VOID ExShutdownSystem (VOID)
VOID ExAcquireTimeRefreshLock (VOID)
VOID ExReleaseTimeRefreshLock (VOID)
VOID ExUpdateSystemTimeFromCmos (IN BOOLEAN UpdateInterruptTime, IN ULONG MaxSepInSeconds)
VOID ExGetNextWakeTime (OUT PULONGLONG DueTime, OUT PTIME_FIELDS TimeFields, OUT PVOID *TimerObject)
NTKERNELAPI ULONG ExSetTimerResolution (IN ULONG DesiredTime, IN BOOLEAN SetResolution)
NTKERNELAPI VOID ExSystemTimeToLocalTime (IN PLARGE_INTEGER SystemTime, OUT PLARGE_INTEGER LocalTime)
NTKERNELAPI VOID ExLocalTimeToSystemTime (IN PLARGE_INTEGER LocalTime, OUT PLARGE_INTEGER SystemTime)
NTKERNELAPI VOID ExInitializeTimeRefresh (VOID)
NTKERNELAPI NTSTATUS ExCreateCallback (OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
NTKERNELAPI PVOID ExRegisterCallback (IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, IN PVOID CallbackContext)
NTKERNELAPI VOID ExUnregisterCallback (IN PVOID CallbackRegistration)
NTKERNELAPI VOID ExNotifyCallback (IN PVOID CallbackObject, IN PVOID Argument1, IN PVOID Argument2)
NTKERNELAPI NTSTATUS ExUuidCreate (OUT UUID *Uuid)
NTKERNELAPI BOOLEAN ExVerifySuite (SUITE_TYPE SuiteType)
NTKERNELAPI ULONG FASTCALL ExInterlockedSetBits (IN OUT PULONG Flags, IN ULONG Flag)
NTKERNELAPI ULONG FASTCALL ExInterlockedClearBits (IN OUT PULONG Flags, IN ULONG Flag)
NTKERNELAPI ULONG FASTCALL ExInterlockedSetClearBits (IN OUT PULONG Flags, IN ULONG sFlag, IN ULONG cFlag)

Variables

EX_WORK_QUEUE ExWorkerQueue []
LARGE_INTEGER ExpLuid
LARGE_INTEGER ExpLuidIncrement
KSPIN_LOCK ExpLuidLock
BOOLEAN ExReadyForErrors
ULONG EvPrSetHigh
ULONG EvPrSetLow
LARGE_INTEGER ExpTimeZoneBias
LONG ExpLastTimeZoneBias
LONG ExpAltTimeZoneBias
ULONG ExpCurrentTimeZoneId
ULONG ExpRealTimeIsUniversal
ULONG ExCriticalWorkerThreads
ULONG ExDelayedWorkerThreads
ULONG ExpTickCountMultiplier
PVOID ExPageLockHandle
PCALLBACK_OBJECT ExCbSetSystemTime
PCALLBACK_OBJECT ExCbSetSystemState
PCALLBACK_OBJECT ExCbPowerState
PKWIN32_GLOBALATOMTABLE_CALLOUT ExGlobalAtomTableCallout


Define Documentation

#define CALL_HASH_TABLE_SIZE   64
 

Definition at line 28 of file ex.h.

Referenced by ExInitializeCallData(), and ExRecordCallerInHashTable().

#define EX_DEBUG_LOG_FORMAT_HANDLE   (UCHAR)7
 

Definition at line 3125 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_NONE   (UCHAR)0
 

Definition at line 3118 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_OBJECT   (UCHAR)6
 

Definition at line 3124 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_PSZ   (UCHAR)2
 

Definition at line 3120 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_PWSZ   (UCHAR)3
 

Definition at line 3121 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_STRING   (UCHAR)4
 

Definition at line 3122 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_ULONG   (UCHAR)1
 

Definition at line 3119 of file ex.h.

#define EX_DEBUG_LOG_FORMAT_USTRING   (UCHAR)5
 

Definition at line 3123 of file ex.h.

#define EX_DEBUG_LOG_NUMBER_OF_BACK_TRACES   4
 

Definition at line 3128 of file ex.h.

#define EX_DEBUG_LOG_NUMBER_OF_DATA_VALUES   4
 

Definition at line 3127 of file ex.h.

#define ExAcquireResourceExclusive   ExAcquireResourceExclusiveLite
 

Definition at line 2475 of file ex.h.

Referenced by CcAcquireByteRangeForWrite(), CcPinFileData(), CcUnpinRepinnedBcb(), CmpLockRegistryExclusive(), ExLockHandleTableExclusive(), ExpAllocateHandleTable(), ExRemoveHandleTable(), ExSnapShotHandleTables(), FsRtlAcquireFileExclusive(), FsRtlAcquireFileForCcFlush(), FsRtlAcquireFileForModWrite(), FsRtlCopyWrite(), FsRtlPrepareMdlWriteDev(), IoGetDeviceInterfaceAlias(), IoGetDeviceProperty(), IoOpenDeviceInterfaceRegistryKey(), IoOpenDeviceRegistryKey(), IopBootLog(), IopBootLogToFile(), IopCopyBootLogRegistryToFile(), IopDeleteLockedDeviceNode(), IopDeviceInterfaceKeysFromSymbolicLink(), IopDoDeferredSetInterfaceState(), IopGetDeviceInterfaces(), IopGetRootDevices(), IopGetSetSecurityObject(), IopInitializeBootLogging(), IopRegisterDeviceInterface(), IopSetDeviceSecurityDescriptors(), IopUnlockDeviceRemovalRelations(), IopUnregisterDeviceInterface(), IoRegisterFileSystem(), IoRegisterFsRegistrationChange(), IoSetDeviceInterfaceState(), IoUnregisterFileSystem(), IoUnregisterFsRegistrationChange(), MiEnablePagingTheExecutive(), MiFindInitializationCode(), MiLoadSystemImage(), MiLookupPsLoadedModule(), MiMapViewOfImageSection(), MmExtendSection(), MmInitSystem(), MmUnloadSystemImage(), NtAssignProcessToJobObject(), NtQuerySystemInformation(), NtSetInformationJobObject(), NtTerminateJobObject(), NtUserUserHandleGrantAccess(), ObpAcquireDescriptorCacheWriteLock(), Ps386GetVdmIoHandler(), PsEnforceExecutionTimeLimits(), Psp386CreateVdmIoListHead(), Psp386InstallIoHandler(), Psp386RemoveIoHandler(), PspAddProcessToJob(), PspExitProcessFromJob(), PspJobClose(), PspJobDelete(), PspRemoveProcessFromJob(), SmbTraceStart(), SmbTraceStop(), UdfAcquireForCreateSection(), UdfAcquireResource(), Writer(), and xxxUserProcessCallout().

#define ExAcquireResourceShared   ExAcquireResourceSharedLite
 

Definition at line 2474 of file ex.h.

Referenced by CmpLockRegistry(), ExLockHandleTableShared(), FsRtlAcquireFileForCcFlush(), FsRtlCopyRead(), FsRtlCopyWrite(), FsRtlMdlReadDev(), FsRtlPrepareMdlWriteDev(), IopCreateMadeupNode(), IopDeleteLegacyKey(), IopDeviceActionWorker(), IopDriverLoadingFailed(), IopGetDriverDeviceList(), IopGetSetSecurityObject(), IopInitializeBootLogging(), IopInvalidateVolumesForDevice(), IopIsFirmwareDisabled(), IopLoadDriver(), IopMakeGloballyUniqueId(), IopMountVolume(), IopParseDevice(), IopPrepareDriverLoading(), IopProcessAssignResources(), IopProcessNewDeviceNode(), IopProcessStartDevices(), IopProcessStartDevicesWorker(), IopReallocateResources(), IopReleaseDeviceResources(), IopStartAndEnumerateDevice(), IopWriteAllocatedResourcesToRegistry(), IoReportDetectedDevice(), IoShutdownSystem(), MiLookupDataTableEntry(), MmGetSectionRange(), MmGetSystemRoutineAddress(), MmLockPagableDataSection(), NtQueryInformationJobObject(), NtSetInformationProcess(), ObpAcquireDescriptorCacheReadLock(), PspSetQuotaLimits(), Reader(), ReaderTurnedWriter(), UdfAcquireForCache(), UdfAcquireResource(), UdfFastQueryBasicInfo(), UdfFastQueryNetworkInfo(), and UdfFastQueryStdInfo().

#define ExAllocateFromZone Zone   ) 
 

Value:

(PVOID)((Zone)->FreeList.Next); \ if ( (Zone)->FreeList.Next ) (Zone)->FreeList.Next = (Zone)->FreeList.Next->Next

Definition at line 2100 of file ex.h.

Referenced by CcAllocateInitializeBcb(), DoZoneTest(), and LpcpAllocateFromPortZone().

#define ExAllocateLocallyUniqueId Luid   ) 
 

Value:

{ \ LARGE_INTEGER _TempLi; \ \ _TempLi = ExInterlockedExchangeAddLargeInteger(&ExpLuid, \ ExpLuidIncrement, \ &ExpLuidLock); \ (Luid)->LowPart = _TempLi.LowPart; \ (Luid)->HighPart = _TempLi.HighPart; \ }

Definition at line 3024 of file ex.h.

Referenced by NtAllocateLocallyUniqueId(), SeCreateAccessState(), SepAccessCheckAndAuditAlarm(), SepCreateToken(), SepDuplicateToken(), and SepFilterToken().

#define ExAllocatePoolWithQuotaTag a,
b,
c   )     ExAllocatePoolWithQuota(a,b)
 

Definition at line 265 of file ex.h.

Referenced by CmpNotifyChangeKey(), ExAllocatePoolWithQuota(), ExLockUserBuffer(), FsRtlAllocatePoolWithQuota(), FsRtlAllocatePoolWithQuotaTag(), IoCreateFile(), IopAllocateIrpPrivate(), IoSetIoCompletion(), NtQueueApcThread(), NtSetValueKey(), VdmQueryDirectoryFile(), and VerifierAllocatePoolWithQuotaTag().

#define ExAllocatePoolWithTag a,
b,
c   )     ExAllocatePool(a,b)
 

Definition at line 253 of file ex.h.

Referenced by ArbAddOrdering(), ArbCopyOrderingList(), ArbInitializeArbiterInstance(), ArbInitializeOrderingList(), ArbpBuildAllocationStack(), ArbpGetRegistryValue(), ArbPruneOrdering(), ArbQueryConflict(), CcAllocateInitializeBcb(), CcCreateVacbArray(), CcDeferWrite(), CcFindBitmapRangeToDirty(), CcInitializeCacheManager(), CcInitializeCacheMap(), CcPrefillVacbLevelZone(), CcWaitOnActiveCount(), CcWriteBehind(), CcZeroData(), CmInitSystem1(), CmpAddInfoAfterParseFailure(), CmpAllocate(), CmpAppendLine(), CmpAppendSection(), CmpAppendStringToMultiSz(), CmpAppendValue(), CmpConstructName(), CmpCreateKeyControlBlock(), CmpFindRSDTTable(), CmpGetAddRegInfData(), CmpGetNameControlBlock(), CmpGetRegistryValue(), CmpGetToken(), CmpGetValueDataFromCache(), CmpGetValueKeyFromCache(), CmpGetValueListFromCache(), CmpInitializeCache(), CmpInitializeHive(), CmpOpenRegKey(), CmpParseInfBuffer(), CmpProcessBitRegLine(), CmpSetValueKeyExisting(), DriverEntry(), ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), ExAcquireSharedWaitForExclusive(), ExAllocatePool(), ExAllocatePoolWithQuotaTag(), ExAllocatePoolWithTagPriority(), ExCreateDebugLog(), ExCreateDebugLogTag(), ExDeleteResourceLite(), ExInitializeNPagedLookasideList(), ExInitializePagedLookasideList(), ExpAcquireResourceExclusiveLite(), ExpAllocateHandleTable(), ExpAllocateHandleTableEntry(), ExpAllocateStringRoutine(), ExpFindCurrentThread(), ExpGetPoolTagInfo(), ExpSystemErrorHandler(), ExRecordCallerInHashTable(), ExRegisterCallback(), FsRecReadBlock(), FsRtlAddToTunnelCache(), FsRtlAllocatePool(), FsRtlAllocatePoolWithTag(), FsRtlGetCompatibilityModeValue(), FsRtlGetTunnelParameterValue(), FsRtlpRegisterProviderWithMUP(), FsRtlRegisterUncProvider(), FstubTranslateRequirement(), HalpGetFullGeometry(), HalpNextMountLetter(), HalpSetMountLetter(), HvpAddBin(), HvpRecoverData(), InitCreateUserCrit(), InitializePool(), IoAcquireRemoveLockEx(), IoAllocateDriverObjectExtension(), IoAllocateMdl(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IoBuildPoDeviceNotifyList(), IoConnectInterrupt(), IoCreateFile(), IoepFireWMIEvent(), IoepGetErrCaseDB(), IoepGetErrMessage(), IoepHandleErrCase(), IoepInitErrLog(), IoepLogErr(), IoepNewErrThread(), IoErrGetErrData(), IoErrRegisterErrHandlers(), IoErrSaveErrData(), IoInitializeTimer(), IoInitSystem(), IoIsValidNameGraftingBuffer(), IoMakeAssociatedIrp(), IopAllocateDeviceNode(), IopAllocateErrorLogEntry(), IopAllocateIrpMustSucceed(), IopAllocateIrpPrivate(), IopCaptureObjectName(), IopConfigureCrashDump(), IopCreateDefaultDeviceSecurityDescriptor(), IopCreateVpb(), IopDeleteSessionSymLinks(), IopDoNameTransmogrify(), IopGetDumpStack(), IopInitializeDCB(), IopLoadDumpDriver(), IopParseDevice(), IopQueryName(), IopRequestHwProfileChangeNotification(), IopSetDefaultGateway(), IopStartNetworkForRemoteBoot(), IopTCPSetInformationEx(), IoQueryDeviceDescription(), IoRaiseHardError(), IoRaiseInformationalHardError(), IoRegisterBootDriverReinitialization(), IoRegisterDriverReinitialization(), IoRegisterFsRegistrationChange(), IoRegisterLastChanceShutdownNotification(), IoRegisterShutdownNotification(), IoSetIoCompletion(), IovpCompleteRequest3(), IovpSessionDataCreate(), IovpTrackingDataCreateAndLock(), Ke386CallBios(), KeI386GetLid(), KeSaveFloatingPointState(), KeStartAllProcessors(), KeStartProfile(), KiAddRange(), KiCloneDescriptor(), KiInitializeKernel(), KiInitializeMTRR(), KiStartEffectiveRangeChange(), LfsAllocateLbcb(), LfsAllocateLcb(), LfsAllocateLfcb(), LpcpExtendPortZone(), LpcpInitializePortQueue(), LpcpInitializePortZone(), MemPrintInitialize(), MiAddMdlTracker(), MiAllocateContiguousMemory(), MiAllocateVad(), MiApplyDriverVerifier(), MiBuildImportsForBootDrivers(), MiCloneProcessAddressSpace(), MiContractPagingFiles(), MiCreateDataFileMap(), MiCreateImageFileMap(), MiCreatePagingFileMap(), MiCreatePebOrTeb(), MiDoPoolCopy(), MiGetEventCounter(), MiGetInPageSupportBlock(), MiGetWorkingSetInfo(), MiInitializeDriverVerifierList(), MiInitializeLoadedModuleList(), MiInitializeSystemSpaceMap(), MiInitMachineDependent(), MiInsertInSystemSpace(), MiLoadSystemImage(), MiMapLockedPagesInUserSpace(), MiMapViewOfDataSection(), MiMapViewOfImageSection(), MiMapViewOfPhysicalSection(), MiModifiedPageWriter(), MiRememberUnloadedDriver(), MiResolveImageReferences(), MiSectionInitialization(), MiSessionInsertImage(), MiSessionWideInsertImageAddress(), MiSnapThunk(), MmAddPhysicalMemory(), MmAddVerifierThunks(), MmAllocatePagesForMdl(), MmCallDllInitialize(), MmCreateMdl(), MmCreateSection(), MmExtendSection(), MmGetFileNameForSection(), MmGetPhysicalMemoryRanges(), MmInitializeProcessAddressSpace(), MmInitSystem(), MmMapIoSpace(), MmMapLockedPagesSpecifyCache(), MmMapVideoDisplay(), MmRemovePhysicalMemory(), MmSecureVirtualMemory(), MmSetBankedSection(), NtAddAtom(), NtAllocateUserPhysicalPages(), NtAllocateVirtualMemory(), NtCloseObjectAuditAlarm(), NtCreatePagingFile(), NtCreateSymbolicLinkObject(), NtDeleteObjectAuditAlarm(), NtFindAtom(), NtFreeVirtualMemory(), NtMapUserPhysicalPages(), NtMapUserPhysicalPagesScatter(), NtOpenObjectAuditAlarm(), NtPrivilegedServiceAuditAlarm(), NtPrivilegeObjectAuditAlarm(), NtQueryDirectoryObject(), NtQuerySystemEnvironmentValue(), NtRaiseHardError(), NtSetInformationFile(), NtSetSystemEnvironmentValue(), NtSetSystemInformation(), NtStartProfile(), NtWaitForMultipleObjects(), ObCreateObjectType(), ObGetObjectSecurity(), ObInitSystem(), ObpAllocateObject(), ObpAllocateObjectNameBuffer(), ObpCreateCacheEntry(), ObpCreateTypeArray(), ObpInitSecurityDescriptorCache(), ObpInsertDirectoryEntry(), ObpInsertHandleCount(), ObpLookupObjectName(), ObpParseSymbolicLink(), ObSetDeviceMap(), pIoQueryBusDescription(), PsImpersonateClient(), PspApplyJobLimitsToProcessSet(), PspCaptureTokenFilter(), RtlAcquireRemoveLockEx(), RtlAllocateRemoveLock(), RtlInitializeExceptionLog(), RtlpAllocateAtom(), RtlpAllocDeallocQueryBuffer(), RtlpComputeMergedAcl(), RtlpConvertAclToAutoInherit(), RtlpConvertToAutoInheritSecurityObject(), RtlpCreateServerAcl(), RtlpInheritAcl(), RtlpNewSecurityObject(), RtlpSetSecurityObject(), SeAccessCheckByType(), SeAppendPrivileges(), SeCaptureAcl(), SeCaptureLuidAndAttributesArray(), SeCaptureObjectTypeList(), SeCaptureSecurityDescriptor(), SeCaptureSid(), SeCaptureSidAndAttributesArray(), SeMakeAnonymousLogonToken(), SeMakeSystemToken(), SepAccessCheckAndAuditAlarm(), SepAdtLogAuditRecord(), SepAdtMarshallAuditRecord(), SepAdtOpenObjectAuditAlarm(), SepAssemblePrivileges(), SepCopyProxyData(), SepCreateLogonSessionTrack(), SepCreateToken(), SepDuplicateToken(), SepFilterToken(), SepInformFileSystemsOfDeletedLogon(), SepInformLsaOfDeletedLogon(), SepInitializePrivilegeSets(), SepInitSystemDacls(), SepProbeAndCaptureString_U(), SepQueryNameString(), SepQueryTypeString(), SePrivilegePolicyCheck(), SepRmDbInitialization(), SepVariableInitialization(), SeRegisterLogonSessionTerminatedRoutine(), SeRmInitPhase1(), SmbTraceCompleteRdr(), SmbTraceCompleteSrv(), SmbTraceDereferenceHeap(), SmbTraceInitialize(), UdfDismountVcb(), UdfInvalidateVolumes(), VdmpDelayInterrupt(), VdmpInitialize(), VerifierAllocatePoolWithTag(), xHalExamineMBR(), xHalGetPartialGeometry(), xHalIoAssignDriveLetters(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

#define ExConvertExclusiveToShared   ExConvertExclusiveToSharedLite
 

Definition at line 2477 of file ex.h.

Referenced by FsRtlAcquireFileForModWrite(), and ReaderTurnedWriter().

#define ExDeleteResource   ExDeleteResourceLite
 

Definition at line 2478 of file ex.h.

Referenced by CcDeallocateBcb(), ExpFreeHandleTable(), LfsDeallocateLfcb(), LfsDeleteLogHandle(), MiDereferenceSession(), MiSessionInitializeWorkingSetList(), PspDeleteVdmObjects(), PspJobDelete(), SmbTraceInitialize(), SmbTraceTerminate(), UdfDeleteFcbNonpaged(), UdfDeleteVcb(), and Win32kNtUserCleanup().

#define ExDisableResourceBoost   ExDisableResourceBoostLite
 

Definition at line 2482 of file ex.h.

Referenced by CcAllocateInitializeBcb().

#define ExFreePoolWithTag a,
 )     ExFreePool(a)
 

Definition at line 291 of file ex.h.

Referenced by CmpAddInfoAfterParseFailure(), CmpCleanUpKcbCacheWithLock(), CmpCleanUpSubKeyInfo(), CmpCreateKeyControlBlock(), CmpDereferenceNameControlBlockWithLock(), CmpGetSymbolicLink(), CmpLoadHiveVolatile(), CmpQueryKeyName(), CmQueryKey(), CmRestoreKey(), ExFreePool(), ObpDestroyTypeArray(), ObpFreeObject(), and VerifierFreePoolWithTag().

#define ExFreeToZone Zone,
Block   ) 
 

Value:

( ((PSINGLE_LIST_ENTRY)(Block))->Next = (Zone)->FreeList.Next, \ (Zone)->FreeList.Next = ((PSINGLE_LIST_ENTRY)(Block)), \ ((PSINGLE_LIST_ENTRY)(Block))->Next \ )

Definition at line 2133 of file ex.h.

Referenced by CcDeallocateBcb(), DoZoneTest(), and LpcpFreeToPortZone().

 
#define ExGetCurrentResourceThread  )     ((ULONG_PTR)PsGetCurrentThread())
 

Definition at line 2455 of file ex.h.

Referenced by ExAcquireResourceExclusive(), IopQueryDeviceRelations(), IopStartDevice(), LfsAllocateSpanningBuffer(), LfsFlushLfcb(), LfsFreeSpanningBuffer(), LfsGetLbcb(), and UdfCommonRead().

#define ExInitializeFastMutex _FastMutex   ) 
 

Value:

(_FastMutex)->Count = 1; \ (_FastMutex)->Contention = 0; \ KeInitializeEvent(&(_FastMutex)->Event, \ SynchronizationEvent, \ FALSE);

Definition at line 367 of file ex.h.

Referenced by CmInitSystem1(), CmpInitializeHive(), ExInitializePagedLookasideList(), ExpUuidInitialization(), FsRtlAllocateOplock(), FsRtlInitializeFileLocks(), FsRtlInitializeLargeMcb(), FsRtlInitializeTunnelCache(), FsRtlNotifyInitializeSync(), InitCreateUserCrit(), InitializeMediaChange(), InitializePool(), InitializePowerRequestList(), IopInitializePlugPlayNotification(), IopInitializePlugPlayServices(), LfsAllocateLfcb(), LfsInitializeLogFileService(), MiInitializeDriverVerifierList(), MiInitializeSessionIds(), MiInitializeSessionPool(), MiInitializeSystemSpaceMap(), MmInitializeProcessAddressSpace(), MmInitSystem(), NtCreateJobObject(), PspCreateProcess(), PspInitPhase0(), RtlpInitializeLockAtomTable(), UdfCreateFcbNonPaged(), UdfInitializeGlobalData(), UdfInitializeVcb(), and VdmpInitialize().

#define ExInitializeResource   ExInitializeResourceLite
 

Definition at line 2473 of file ex.h.

Referenced by CcAllocateInitializeBcb(), CmInitSystem1(), DoResourceTest(), ExInitializeHandleTablePackage(), ExpAllocateHandleTable(), FsRtlInitSystem(), IoInitSystem(), IopInitializeBootLogging(), IopInitializePlugPlayServices(), LfsAllocateLfcb(), MiInitializeLoadedModuleList(), MiSessionInitializeWorkingSetList(), MmInitSystem(), NtCreateJobObject(), ObpInitSecurityDescriptorCache(), Psp386CreateVdmIoListHead(), PspVdmInitialize(), SepInitializeWorkList(), SepRmDbInitialization(), SepTokenInitialization(), SmbTraceInitialize(), UdfCreateFcbNonPaged(), UdfInitializeGlobalData(), and UdfInitializeVcb().

#define ExInitializeSListHead _listhead_   )     (_listhead_)->Alignment = 0
 

Definition at line 611 of file ex.h.

Referenced by ExInitializeNPagedLookasideList(), ExInitializePagedLookasideList(), and ExInitializeRegion().

#define ExInitializeWorkItem Item,
Routine,
Context   ) 
 

Value:

(Item)->WorkerRoutine = (Routine); \ (Item)->Parameter = (Context); \ (Item)->List.Flink = NULL;

Definition at line 1961 of file ex.h.

Referenced by CcInitializeCacheManager(), CmpClaimGlobalQuota(), CmpDiskFullWarning(), CmpWorker(), FsRtlpPostStackOverflow(), IoAllocateWorkItem(), IoInitSystem(), IopChainDereferenceComplete(), IopCompleteUnloadOrDelete(), IopDeviceEjectComplete(), IopEjectDevice(), IopErrorLogDpc(), IopProcessNewProfile(), IopQueueDeviceWorkItem(), IopRequestDeviceAction(), IopSendMessageToTrackService(), IoRaiseHardError(), IoReportTargetDeviceChangeAsynchronous(), IovpInternalDeferredCompletion(), IoWriteErrorLogEntry(), KdInitSystem(), KdpTrap(), MiCheckForCrashDump(), NtLoadDriver(), NtUnloadDriver(), ObfDereferenceObject(), PspInitPhase0(), SepInformFileSystemsOfDeletedLogon(), SepQueueWorkItem(), SmbTraceDereferenceHeap(), UdfAddToWorkque(), and UdfInitializeGlobalData().

#define ExInterlockedAllocateFromZone Zone,
Lock   )     (PVOID) ExInterlockedPopEntryList( &(Zone)->FreeList, Lock )
 

Definition at line 2193 of file ex.h.

#define ExInterlockedFreeToZone Zone,
Block,
Lock   )     ExInterlockedPushEntryList( &(Zone)->FreeList, ((PSINGLE_LIST_ENTRY) (Block)), Lock )
 

Definition at line 2230 of file ex.h.

#define ExIsFullZone Zone   )     ( (Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY)NULL )
 

Definition at line 2161 of file ex.h.

#define ExIsObjectInFirstZoneSegment Zone,
Object   ) 
 

Value:

((BOOLEAN) \ (((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \ ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \ (Zone)->TotalSegmentSize)) \ )

Definition at line 2259 of file ex.h.

#define ExIsResourceAcquiredExclusive   ExIsResourceAcquiredExclusiveLite
 

Definition at line 2479 of file ex.h.

#define ExIsResourceAcquiredShared   ExIsResourceAcquiredSharedLite
 

Definition at line 2480 of file ex.h.

Referenced by FsRtlAcquireFileForCcFlush().

#define ExQueryDepthSList _listhead_   )     (USHORT)(_listhead_)->Depth
 

Definition at line 637 of file ex.h.

Referenced by ExFreePoolWithTag(), ExFreeToNPagedLookasideList(), ExFreeToPagedLookasideList(), ExFreeToPPNPagedLookasideList(), IopFreeIrp(), and IopFreeMiniPacket().

#define ExReleaseResource  )     (ExReleaseResourceLite(R))
 

Definition at line 2393 of file ex.h.

Referenced by CcUnpinFileData(), ChangeAcquireResourceType(), CmpUnlockRegistry(), ExpAllocateHandleTable(), ExRemoveHandleTable(), ExSnapShotHandleTables(), ExUnlockHandleTableExclusive(), ExUnlockHandleTableShared(), FsRtlAcquireFileForModWrite(), FsRtlCopyRead(), FsRtlCopyWrite(), FsRtlMdlReadDev(), FsRtlPrepareMdlWriteDev(), FsRtlReleaseFile(), FsRtlReleaseFileForCcFlush(), FsRtlReleaseFileForModWrite(), IoGetDeviceInterfaceAlias(), IoGetDeviceProperty(), IoOpenDeviceInterfaceRegistryKey(), IoOpenDeviceRegistryKey(), IopBootLog(), IopBootLogToFile(), IopCopyBootLogRegistryToFile(), IopCreateMadeupNode(), IopDeleteLegacyKey(), IopDeleteLockedDeviceNode(), IopDeviceActionWorker(), IopDeviceInterfaceKeysFromSymbolicLink(), IopDoDeferredSetInterfaceState(), IopDriverLoadingFailed(), IopGetDeviceInterfaces(), IopGetDriverDeviceList(), IopGetRootDevices(), IopGetSetSecurityObject(), IopInitializeBootLogging(), IopInvalidateVolumesForDevice(), IopIsFirmwareDisabled(), IopLoadDriver(), IopMakeGloballyUniqueId(), IopMountVolume(), IopParseDevice(), IopPrepareDriverLoading(), IopProcessAssignResources(), IopProcessNewDeviceNode(), IopProcessStartDevices(), IopProcessStartDevicesWorker(), IopReallocateResources(), IopRegisterDeviceInterface(), IopReleaseDeviceResources(), IopSetDeviceSecurityDescriptors(), IopStartAndEnumerateDevice(), IopUnlockDeviceRemovalRelations(), IopUnregisterDeviceInterface(), IopWriteAllocatedResourcesToRegistry(), IoRegisterFileSystem(), IoRegisterFsRegistrationChange(), IoReportDetectedDevice(), IoSetDeviceInterfaceState(), IoUnregisterFileSystem(), IoUnregisterFsRegistrationChange(), LeaveCrit(), MiEnablePagingTheExecutive(), MiFindInitializationCode(), MiLoadSystemImage(), MiLookupDataTableEntry(), MiLookupPsLoadedModule(), MiMapViewOfImageSection(), MmExtendSection(), MmGetSectionRange(), MmGetSystemRoutineAddress(), MmInitSystem(), MmLockPagableDataSection(), MmUnloadSystemImage(), NtAssignProcessToJobObject(), NtQueryInformationJobObject(), NtQuerySystemInformation(), NtSetInformationJobObject(), NtSetInformationProcess(), NtSystemDebugControl(), NtTerminateJobObject(), NtUserUserHandleGrantAccess(), ObpReleaseDescriptorCacheLock(), Ps386GetVdmIoHandler(), PsEnforceExecutionTimeLimits(), Psp386CreateVdmIoListHead(), Psp386InstallIoHandler(), Psp386RemoveIoHandler(), PspAddProcessToJob(), PspExitProcessFromJob(), PspJobClose(), PspJobDelete(), PspRemoveProcessFromJob(), PspSetQuotaLimits(), Reader(), ReaderTurnedWriter(), SmbTraceStart(), SmbTraceStop(), UdfFastQueryBasicInfo(), UdfFastQueryNetworkInfo(), UdfFastQueryStdInfo(), UdfReleaseForCreateSection(), UdfReleaseFromCache(), Writer(), and xxxUserProcessCallout().

#define ExReleaseResourceForThread   ExReleaseResourceForThreadLite
 

Definition at line 2476 of file ex.h.

Referenced by CcUnpinDataForThread(), UdfMultiAsyncCompletionRoutine(), and UdfSingleAsyncCompletionRoutine().

#define ExSetHandleTableOrder ht,
or   )     {NOTHING;}
 

Definition at line 2975 of file ex.h.

Referenced by ObInitProcess2().

#define ExSetHandleTableOwner ht,
id   )     {(ht)->UniqueProcessId = (id);}
 

Definition at line 2973 of file ex.h.

Referenced by PspCreateThread().

#define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE   8
 

Definition at line 143 of file ex.h.

Referenced by CmpNotifyChangeKey(), ExAllocatePoolWithQuotaTag(), InitSMSLookaside(), NtQueueApcThread(), VerifierAllocatePoolWithQuota(), and VerifierAllocatePoolWithQuotaTag().

#define POOL_RAISE_IF_ALLOCATION_FAILURE   16
 

Definition at line 144 of file ex.h.

Referenced by ExAllocatePoolWithTag(), ExpAllocateHandleTable(), ExpAllocateHandleTableEntry(), FsRtlInitializeLargeMcbs(), SepAssemblePrivileges(), SepInitializePrivilegeSets(), SepInitSystemDacls(), SepVariableInitialization(), and VeAllocatePoolWithTagPriority().

#define ProbeAndNullPointer Address   ) 
 

Value:

{ \ if ((PVOID *)(Address) >= (PVOID * const)MM_USER_PROBE_ADDRESS) { \ *(volatile PVOID * const)MM_USER_PROBE_ADDRESS = NULL; \ } \ \ *(volatile PVOID *)(Address) = NULL; \ }

Definition at line 1615 of file ex.h.

Referenced by NtListenChannel(), NtReplyWaitSendChannel(), and NtSendWaitReplyChannel().

#define ProbeAndReadBoolean Address   ) 
 

Value:

(((Address) >= (BOOLEAN * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile BOOLEAN * const)MM_USER_PROBE_ADDRESS) : (*(volatile BOOLEAN *)(Address)))

Definition at line 1235 of file ex.h.

#define ProbeAndReadChar Address   ) 
 

Value:

(((Address) >= (CHAR * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile CHAR * const)MM_USER_PROBE_ADDRESS) : (*(volatile CHAR *)(Address)))

Definition at line 1248 of file ex.h.

Referenced by Ki386CheckDivideByZeroTrap().

#define ProbeAndReadHandle Address   ) 
 

Value:

(((Address) >= (HANDLE * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile HANDLE * const)MM_USER_PROBE_ADDRESS) : (*(volatile HANDLE *)(Address)))

Definition at line 1300 of file ex.h.

#define ProbeAndReadLargeInteger Source   ) 
 

Value:

(((Source) >= (LARGE_INTEGER * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile LARGE_INTEGER * const)MM_USER_PROBE_ADDRESS) : (*(volatile LARGE_INTEGER *)(Source)))

Definition at line 1391 of file ex.h.

Referenced by NtRemoveIoCompletion(), NtReplyWaitReceivePortEx(), NtSetInformationKey(), NtSignalAndWaitForSingleObject(), NtWaitForMultipleObjects(), and NtWaitForSingleObject().

#define ProbeAndReadLong Address   ) 
 

Value:

(((Address) >= (LONG * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile LONG * const)MM_USER_PROBE_ADDRESS) : (*(volatile LONG *)(Address)))

Definition at line 1326 of file ex.h.

Referenced by NtSetInformationThread().

#define ProbeAndReadPointer Address   ) 
 

Value:

(((Address) >= (PVOID * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile PVOID * const)MM_USER_PROBE_ADDRESS) : (*(volatile PVOID *)(Address)))

Definition at line 1313 of file ex.h.

#define ProbeAndReadQuad Address   ) 
 

Value:

(((Address) >= (QUAD * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile QUAD * const)MM_USER_PROBE_ADDRESS) : (*(volatile QUAD *)(Address)))

Definition at line 1365 of file ex.h.

#define ProbeAndReadShort Address   ) 
 

Value:

(((Address) >= (SHORT * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile SHORT * const)MM_USER_PROBE_ADDRESS) : (*(volatile SHORT *)(Address)))

Definition at line 1274 of file ex.h.

#define ProbeAndReadStructure Source,
STRUCTURE   ) 
 

Value:

(((Source) >= (STRUCTURE * const)MM_USER_PROBE_ADDRESS) ? \ (*(STRUCTURE * const)MM_USER_PROBE_ADDRESS) : (*(STRUCTURE *)(Source)))

Definition at line 1431 of file ex.h.

Referenced by ImeCanDestroyDefIME(), ImeCanDestroyDefIMEforChild(), LpcpCreatePort(), NtAcceptConnectPort(), NtSecureConnectPort(), NtUserCreateWindowStation(), NtUserDdeSetQualityOfService(), NtUserFlashWindowEx(), NtUserGetMouseMovePointsEx(), NtUserOpenWindowStation(), NtUserRegisterClassExWOW(), NtUserSetClassLongPtr(), NtUserSystemParametersInfo(), NtUserTestForInteractiveUser(), xxxCheckImeShowStatus(), xxxNotifyImeShowStatus(), and xxxSendMessageToUI().

#define ProbeAndReadUchar Address   ) 
 

Value:

(((Address) >= (UCHAR * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile UCHAR * const)MM_USER_PROBE_ADDRESS) : (*(volatile UCHAR *)(Address)))

Definition at line 1261 of file ex.h.

Referenced by Ki386CheckDivideByZeroTrap(), KiNextIStreamByte(), NtQueryQuotaInformationFile(), SeCaptureSecurityDescriptor(), SeCaptureSid(), and SeCaptureSidAndAttributesArray().

#define ProbeAndReadUlargeInteger Source   ) 
 

Value:

(((Source) >= (ULARGE_INTEGER * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile ULARGE_INTEGER * const)MM_USER_PROBE_ADDRESS) : (*(volatile ULARGE_INTEGER *)(Source)))

Definition at line 1404 of file ex.h.

#define ProbeAndReadUlong Address   ) 
 

Value:

(((Address) >= (ULONG * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile ULONG * const)MM_USER_PROBE_ADDRESS) : (*(volatile ULONG *)(Address)))

Definition at line 1339 of file ex.h.

Referenced by _SetWindowWord(), Ki386CheckDivideByZeroTrap(), KiLocateTriggerPc(), MESSAGECALL(), NtAcceptConnectPort(), NtGetContextThread(), NtQueryEaFile(), NtQueryMultipleValueKey(), NtReadFile(), NtReadFileScatter(), NtSecureConnectPort(), NtSetContextThread(), NtWriteFile(), NtWriteFileGather(), ProbeAndCaptureSoftKbdData(), SeAccessCheckByType(), and xxxSendMessageToUI().

#define ProbeAndReadUlong_ptr Address   ) 
 

Value:

(((Address) >= (ULONG_PTR * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile ULONG_PTR * const)MM_USER_PROBE_ADDRESS) : (*(volatile ULONG_PTR *)(Address)))

Definition at line 1352 of file ex.h.

#define ProbeAndReadUnicodeString Source   ) 
 

Value:

(((Source) >= (UNICODE_STRING * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile UNICODE_STRING * const)MM_USER_PROBE_ADDRESS) : (*(volatile UNICODE_STRING *)(Source)))

Definition at line 1417 of file ex.h.

Referenced by BuildQueryDirectoryIrp(), CmpNameFromAttributes(), CmQueryMultipleValueKey(), GetHmodTableIndex(), NtCreateKey(), NtDeleteValueKey(), NtLoadDriver(), NtLoadKey2(), NtOpenKey(), NtQueryValueKey(), NtSetValueKey(), NtUnloadDriver(), NtUserCreateWindowStation(), NtUserDrawCaptionTemp(), NtUserFindExistingCursorIcon(), NtUserFindWindowEx(), NtUserGetClassInfo(), NtUserGetClassName(), NtUserGetIconInfo(), NtUserGetKeyboardLayoutName(), NtUserGetWOWClass(), NtUserInitTask(), NtUserLoadKeyboardLayoutEx(), NtUserOpenWindowStation(), NtUserRegisterClassExWOW(), NtUserRegisterWindowMessage(), NtUserResolveDesktop(), NtUserResolveDesktopForWOW(), NtUserSetClassLongPtr(), NtUserSetCursorIconData(), NtUserSystemParametersInfo(), NtUserThunkedMenuItemInfo(), NtUserUnregisterClass(), ObpCaptureObjectName(), SepProbeAndCaptureString_U(), SetAppCompatFlags(), and VdmQueryDirectoryFile().

#define ProbeAndReadUquad Address   ) 
 

Value:

(((Address) >= (UQUAD * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile UQUAD * const)MM_USER_PROBE_ADDRESS) : (*(volatile UQUAD *)(Address)))

Definition at line 1378 of file ex.h.

#define ProbeAndReadUshort Address   ) 
 

Value:

(((Address) >= (USHORT * const)MM_USER_PROBE_ADDRESS) ? \ (*(volatile USHORT * const)MM_USER_PROBE_ADDRESS) : (*(volatile USHORT *)(Address)))

Definition at line 1287 of file ex.h.

Referenced by Ki386CheckDivideByZeroTrap(), MESSAGECALL(), SeCaptureAcl(), and SeCaptureSecurityDescriptor().

#define ProbeAndWriteBoolean Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (BOOLEAN * const)MM_USER_PROBE_ADDRESS) { \ *(volatile BOOLEAN * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1721 of file ex.h.

#define ProbeAndWriteChar Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (CHAR * const)MM_USER_PROBE_ADDRESS) { \ *(volatile CHAR * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1739 of file ex.h.

#define ProbeAndWriteHandle Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (HANDLE * const)MM_USER_PROBE_ADDRESS) { \ *(volatile HANDLE * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1811 of file ex.h.

Referenced by IoCreateFile(), NtUserDdeInitialize(), and NtUserResolveDesktop().

#define ProbeAndWriteLong Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (LONG * const)MM_USER_PROBE_ADDRESS) { \ *(volatile LONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1829 of file ex.h.

Referenced by NtSetInformationThread(), and NtUserGetIconSize().

#define ProbeAndWriteQuad Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (QUAD * const)MM_USER_PROBE_ADDRESS) { \ *(volatile LONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1865 of file ex.h.

#define ProbeAndWriteShort Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (SHORT * const)MM_USER_PROBE_ADDRESS) { \ *(volatile SHORT * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1775 of file ex.h.

#define ProbeAndWriteStructure Address,
Value,
STRUCTURE   ) 
 

Value:

{ \ if ((STRUCTURE * const)(Address) >= (STRUCTURE * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1902 of file ex.h.

Referenced by MESSAGECALL(), NtUserBeginPaint(), NtUserGetClipboardData(), NtUserGetMenuItemRect(), NtUserGetMessage(), NtUserGetUpdateRect(), NtUserMNDragOver(), NtUserPeekMessage(), NtUserScrollDC(), NtUserScrollWindowEx(), NtUserSetClassLongPtr(), and NtUserUnregisterClass().

#define ProbeAndWriteUchar Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (UCHAR * const)MM_USER_PROBE_ADDRESS) { \ *(volatile UCHAR * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1757 of file ex.h.

#define ProbeAndWriteUlong Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (ULONG * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1847 of file ex.h.

Referenced by MESSAGECALL(), NtUserCreateLocalMemHandle(), NtUserDdeInitialize(), and NtUserOpenClipboard().

#define ProbeAndWriteUquad Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (UQUAD * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1883 of file ex.h.

#define ProbeAndWriteUshort Address,
Value   ) 
 

Value:

{ \ if ((Address) >= (USHORT * const)MM_USER_PROBE_ADDRESS) { \ *(volatile USHORT * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(Address) = (Value); \ }

Definition at line 1793 of file ex.h.

Referenced by Ki386CheckDelayedNpxTrap().

#define ProbeAndZeroHandle Address   ) 
 

Value:

{ \ if ((Address) >= (HANDLE * const)MM_USER_PROBE_ADDRESS) { \ *(volatile HANDLE * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile HANDLE *)(Address) = 0; \ }

Definition at line 1581 of file ex.h.

Referenced by NtCreateChannel(), NtCreateKey(), NtOpenChannel(), and NtOpenKey().

#define ProbeForRead Address,
Length,
Alignment   ) 
 

Value:

ASSERT(((Alignment) == 1) || ((Alignment) == 2) || \ ((Alignment) == 4) || ((Alignment) == 8) || \ ((Alignment) == 16)); \ \ if ((Length) != 0) { \ if (((ULONG_PTR)(Address) & ((Alignment) - 1)) != 0) { \ ExRaiseDatatypeMisalignment(); \ \ } else if ((((ULONG_PTR)(Address) + (Length)) < (ULONG_PTR)(Address)) || \ (((ULONG_PTR)(Address) + (Length)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { \ ExRaiseAccessViolation(); \ } \ }

Definition at line 1209 of file ex.h.

Referenced by _GetComboBoxInfo(), _GetListBoxInfo(), BuildQueryDirectoryIrp(), CmpNameFromAttributes(), CmQueryMultipleValueKey(), CopyOutputString(), InitAnsiOem(), IoCreateFile(), IopSetEaOrQuotaInformationFile(), IopXxxControlFile(), KdpTrap(), KiContinuePreviousModeUser(), KiEmulateByteWord(), KiEmulateReference(), KiRaiseException(), LpcpCopyRequestData(), LpcpCreatePort(), MESSAGECALL(), MiCheckForUserStackOverflow(), MiDoMappedCopy(), MiDoPoolCopy(), MmCreatePeb(), NtAcceptConnectPort(), NtAddAtom(), NtAdjustGroupsToken(), NtAdjustPrivilegesToken(), NtCreateKey(), NtCreateMailslotFile(), NtCreateNamedPipeFile(), NtCreatePagingFile(), NtCreateSection(), NtCreateSymbolicLinkObject(), NtCreateThread(), NtCreateToken(), NtDelayExecution(), NtDeleteValueKey(), NtFilterToken(), NtFindAtom(), NtFlushInstructionCache(), NtFreeUserPhysicalPages(), NtImpersonateClientOfPort(), NtImpersonateThread(), NtLoadDriver(), NtLoadKey2(), NtLockFile(), NtMapUserPhysicalPages(), NtMapUserPhysicalPagesScatter(), NtOpenKey(), NtOpenObjectAuditAlarm(), NtOpenProcess(), NtOpenThread(), NtPrivilegedServiceAuditAlarm(), NtPrivilegeObjectAuditAlarm(), NtQueryEaFile(), NtQueryQuotaInformationFile(), NtQuerySymbolicLinkObject(), NtQuerySystemEnvironmentValue(), NtQueryValueKey(), NtRaiseHardError(), NtReadFile(), NtReadFileScatter(), NtReplyPort(), NtReplyWaitReceivePort(), NtReplyWaitReceivePortEx(), NtReplyWaitSendChannel(), NtRequestPort(), NtRequestWaitReplyPort(), NtSendWaitReplyChannel(), NtSetContextThread(), NtSetEaFile(), NtSetInformationFile(), NtSetInformationJobObject(), NtSetInformationObject(), NtSetInformationProcess(), NtSetInformationThread(), NtSetInformationToken(), NtSetSystemEnvironmentValue(), NtSetSystemInformation(), NtSetTimer(), NtSetUuidSeed(), NtSetValueKey(), NtSetVolumeInformationFile(), NtSystemDebugControl(), NtUnloadDriver(), NtUnlockFile(), NtUserConvertMemHandle(), NtUserCreateDesktop(), NtUserCreateWindowEx(), NtUserCtxDisplayIOCtl(), NtUserDefSetText(), NtUserDrawCaptionTemp(), NtUserEvent(), NtUserfnHkINLPCBTCREATESTRUCT(), NtUserfnHkINLPDEBUGHOOKSTRUCT(), NtUserInitializeClientPfnArrays(), NtUserLoadKeyboardLayoutEx(), NtUserQueryUserCounters(), NtUserRegisterClassExWOW(), NtUserRemoteConnect(), NtUserSBGetParms(), NtUserSetCursorIconData(), NtUserSetImeInfoEx(), NtUserSetInformationProcess(), NtUserSetInformationThread(), NtUserSetKeyboardState(), NtUserSetObjectInformation(), NtUserSetWindowStationUser(), NtUserSystemParametersInfo(), NtUserToUnicodeEx(), NtVdmControl(), NtWaitForMultipleObjects(), NtWriteFile(), NtWriteFileGather(), ObpCaptureObjectCreateInformation(), ObpCaptureObjectName(), PspCaptureTokenFilter(), PspExitThread(), PspSetContext(), SeAccessCheckByType(), SeCaptureAcl(), SeCaptureLuidAndAttributesArray(), SeCaptureObjectTypeList(), SeCaptureSecurityDescriptor(), SeCaptureSecurityQos(), SeCaptureSid(), SeCaptureSidAndAttributesArray(), SepAccessCheckAndAuditAlarm(), SepProbeAndCaptureQosData(), SepProbeAndCaptureString_U(), SetAppCompatFlags(), VdmpDelayInterrupt(), VdmpInitialize(), VdmpPrinterDirectIoClose(), and VdmQueryDirectoryFile().

#define ProbeForWriteBoolean Address   ) 
 

Value:

{ \ if ((Address) >= (BOOLEAN * const)MM_USER_PROBE_ADDRESS) { \ *(volatile BOOLEAN * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile BOOLEAN *)(Address) = *(volatile BOOLEAN *)(Address); \ }

Definition at line 1447 of file ex.h.

Referenced by NtCancelTimer(), NtOpenObjectAuditAlarm(), NtPrivilegeCheck(), NtSetTimer(), NtUserQueryInformationThread(), NtVdmControl(), and SepAccessCheckAndAuditAlarm().

#define ProbeForWriteChar Address   ) 
 

Value:

{ \ if ((Address) >= (CHAR * const)MM_USER_PROBE_ADDRESS) { \ *(volatile CHAR * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile CHAR *)(Address) = *(volatile CHAR *)(Address); \ }

Definition at line 1464 of file ex.h.

Referenced by MmProbeAndLockPages().

#define ProbeForWriteHandle Address   ) 
 

Value:

{ \ if ((Address) >= (HANDLE * const)MM_USER_PROBE_ADDRESS) { \ *(volatile HANDLE * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile HANDLE *)(Address) = *(volatile HANDLE *)(Address); \ }

Definition at line 1564 of file ex.h.

Referenced by LpcpCreatePort(), NtAcceptConnectPort(), NtCreateDirectoryObject(), NtCreateEvent(), NtCreateEventPair(), NtCreateIoCompletion(), NtCreateJobObject(), NtCreateMutant(), NtCreateProcess(), NtCreateProfile(), NtCreateSection(), NtCreateSemaphore(), NtCreateSuperSection(), NtCreateSymbolicLinkObject(), NtCreateThread(), NtCreateTimer(), NtCreateToken(), NtDuplicateObject(), NtDuplicateToken(), NtFilterToken(), NtOpenDirectoryObject(), NtOpenEvent(), NtOpenEventPair(), NtOpenIoCompletion(), NtOpenJobObject(), NtOpenMutant(), NtOpenProcess(), NtOpenProcessToken(), NtOpenSection(), NtOpenSemaphore(), NtOpenSuperSection(), NtOpenSymbolicLinkObject(), NtOpenThread(), NtOpenThreadToken(), NtOpenTimer(), NtSecureConnectPort(), NtUserGetImeHotKey(), and VdmpInitialize().

#define ProbeForWriteIoStatus Address   ) 
 

Value:

{ \ if ((Address) >= (IO_STATUS_BLOCK * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile IO_STATUS_BLOCK *)(Address) = *(volatile IO_STATUS_BLOCK *)(Address); \ }

Definition at line 1498 of file ex.h.

Referenced by IoCreateFile(), IopSetEaOrQuotaInformationFile(), NtCancelIoFile(), NtFlushBuffersFile(), NtFlushVirtualMemory(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtRemoveIoCompletion(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), and NtUnlockFile().

#define ProbeForWriteIoStatusEx Address,
Cookie   )     ProbeForWriteIoStatus(Address)
 

Definition at line 1518 of file ex.h.

Referenced by BuildQueryDirectoryIrp(), IopXxxControlFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtReadFile(), NtReadFileScatter(), NtWriteFile(), and NtWriteFileGather().

#define ProbeForWriteLong Address   ) 
 

Value:

{ \ if ((Address) >= (LONG * const)MM_USER_PROBE_ADDRESS) { \ *(volatile LONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile LONG *)(Address) = *(volatile LONG *)(Address); \ }

Definition at line 1632 of file ex.h.

Referenced by NtPulseEvent(), NtReleaseMutant(), NtReleaseSemaphore(), NtResetEvent(), NtSetEvent(), and NtUserGetCursorFrameInfo().

#define ProbeForWritePointer Address   ) 
 

Value:

{ \ if ((PVOID *)(Address) >= (PVOID * const)MM_USER_PROBE_ADDRESS) { \ *(volatile PVOID * const)MM_USER_PROBE_ADDRESS = NULL; \ } \ \ *(volatile PVOID *)(Address) = *(volatile PVOID *)(Address); \ }

Definition at line 1598 of file ex.h.

Referenced by NtAllocateUserPhysicalPages(), NtAllocateVirtualMemory(), NtFlushVirtualMemory(), NtFreeUserPhysicalPages(), NtFreeVirtualMemory(), NtLockVirtualMemory(), NtMapViewOfSection(), NtProtectVirtualMemory(), and NtUnlockVirtualMemory().

#define ProbeForWriteQuad Address   ) 
 

Value:

{ \ if ((Address) >= (QUAD * const)MM_USER_PROBE_ADDRESS) { \ *(volatile LONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile QUAD *)(Address) = *(volatile QUAD *)(Address); \ }

Definition at line 1683 of file ex.h.

#define ProbeForWriteShort Address   ) 
 

Value:

{ \ if ((Address) >= (SHORT * const)MM_USER_PROBE_ADDRESS) { \ *(volatile SHORT * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile SHORT *)(Address) = *(volatile SHORT *)(Address); \ }

Definition at line 1530 of file ex.h.

#define ProbeForWriteUchar Address   ) 
 

Value:

{ \ if ((Address) >= (UCHAR * const)MM_USER_PROBE_ADDRESS) { \ *(volatile UCHAR * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile UCHAR *)(Address) = *(volatile UCHAR *)(Address); \ }

Definition at line 1481 of file ex.h.

#define ProbeForWriteUlong Address   ) 
 

Value:

{ \ if ((Address) >= (ULONG * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile ULONG *)(Address) = *(volatile ULONG *)(Address); \ }

Definition at line 1649 of file ex.h.

Referenced by LpcpCopyRequestData(), NtAdjustGroupsToken(), NtAdjustPrivilegesToken(), NtAlertResumeThread(), NtCreateKey(), NtCreateThread(), NtEnumerateKey(), NtEnumerateValueKey(), NtMapViewOfSuperSection(), NtProtectVirtualMemory(), NtQueryDefaultLocale(), NtQueryDirectoryObject(), NtQueryEvent(), NtQueryInformationAtom(), NtQueryInformationJobObject(), NtQueryInformationPort(), NtQueryInformationProcess(), NtQueryInformationThread(), NtQueryInformationToken(), NtQueryIntervalProfile(), NtQueryIoCompletion(), NtQueryKey(), NtQueryMultipleValueKey(), NtQueryMutant(), NtQueryObject(), NtQueryOpenSubKeys(), NtQuerySection(), NtQuerySecurityObject(), NtQuerySemaphore(), NtQuerySymbolicLinkObject(), NtQuerySystemInformation(), NtQueryTimer(), NtQueryValueKey(), NtQueryVirtualMemory(), NtRaiseHardError(), NtReadVirtualMemory(), NtReplyWaitReceivePort(), NtReplyWaitReceivePortEx(), NtResumeThread(), NtSecureConnectPort(), NtSetSystemInformation(), NtSuspendThread(), NtSystemDebugControl(), NtUserBuildHimcList(), NtUserBuildHwndList(), NtUserBuildNameList(), NtUserBuildPropList(), NtUserGetClassInfo(), NtUserGetCursorFrameInfo(), NtUserGetImeHotKey(), NtUserGetObjectInformation(), NtUserQueryInformationThread(), NtUserSystemParametersInfo(), NtUserUpdateInstance(), NtW32Call(), NtWriteVirtualMemory(), SeAccessCheckByType(), SepAccessCheckAndAuditAlarm(), VdmpDelayInterrupt(), and VdmpInitialize().

#define ProbeForWriteUlong_ptr Address   ) 
 

Value:

{ \ if ((Address) >= (ULONG_PTR * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG_PTR * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile ULONG_PTR *)(Address) = *(volatile ULONG_PTR *)(Address); \ }

Definition at line 1666 of file ex.h.

Referenced by NtAllocateVirtualMemory(), NtFlushVirtualMemory(), NtFreeVirtualMemory(), NtLockVirtualMemory(), NtMapViewOfSection(), NtProtectVirtualMemory(), NtRemoveIoCompletion(), and NtUnlockVirtualMemory().

#define ProbeForWriteUquad Address   ) 
 

Value:

{ \ if ((Address) >= (QUAD * const)MM_USER_PROBE_ADDRESS) { \ *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile UQUAD *)(Address) = *(volatile UQUAD *)(Address); \ }

Definition at line 1700 of file ex.h.

#define ProbeForWriteUshort Address   ) 
 

Value:

{ \ if ((Address) >= (USHORT * const)MM_USER_PROBE_ADDRESS) { \ *(volatile USHORT * const)MM_USER_PROBE_ADDRESS = 0; \ } \ \ *(volatile USHORT *)(Address) = *(volatile USHORT *)(Address); \ }

Definition at line 1547 of file ex.h.

Referenced by NtAddAtom(), NtFindAtom(), NtQueryDefaultUILanguage(), NtQueryInstallUILanguage(), NtQuerySymbolicLinkObject(), and NtQuerySystemEnvironmentValue().

#define PROTECTED_POOL   0x80000000
 

Definition at line 281 of file ex.h.

Referenced by CmpAddInfoAfterParseFailure(), CmpCleanUpKcbCacheWithLock(), CmpCleanUpSubKeyInfo(), CmpConstructName(), CmpCreateKeyControlBlock(), CmpDereferenceNameControlBlockWithLock(), CmpGetNameControlBlock(), CmpGetSymbolicLink(), CmpLoadHiveVolatile(), CmpQueryKeyName(), CmQueryKey(), CmRestoreKey(), ExFreePoolWithTag(), ExpCheckSingleFilter(), ExpInsertPoolTracker(), ExpRemovePoolTracker(), ObpAllocateObject(), and ObpFreeObject().

#define RECORD_CALL_DATA Table   ) 
 

Value:

{ \ PVOID CallersAddress; \ PVOID CallersCaller; \ RtlGetCallersAddress(&CallersAddress, &CallersCaller); \ ExRecordCallerInHashTable((Table), CallersAddress, CallersCaller); \ }

Definition at line 54 of file ex.h.

Referenced by KeFlushSingleTb(), KeSetEvent(), and KeWaitForSingleObject().

#define RESOURCE_HASH_TABLE_SIZE   64
 

Definition at line 2313 of file ex.h.

Referenced by ExDeleteResourceLite(), and ExpResourceInitialization().

#define ResourceNeverExclusive   0x10
 

Definition at line 2309 of file ex.h.

Referenced by CcAllocateInitializeBcb(), ExAcquireResourceExclusive(), ExAcquireResourceExclusiveLite(), and ExTryToAcquireResourceExclusiveLite().

#define ResourceOwnedExclusive   0x80
 

Definition at line 2311 of file ex.h.

Referenced by ExAcquireResourceExclusive(), ExAcquireResourceExclusiveLite(), ExConvertExclusiveToSharedLite(), ExReleaseResourceForThread(), ExReleaseResourceForThreadLite(), ExReleaseResourceLite(), and ExTryToAcquireResourceExclusiveLite().

#define ResourceReleaseByOtherThread   0x20
 

Definition at line 2310 of file ex.h.


Typedef Documentation

typedef struct _CALL_HASH_ENTRY CALL_HASH_ENTRY
 

Referenced by ExRecordCallerInHashTable().

typedef struct _CALL_PERFORMANCE_DATA CALL_PERFORMANCE_DATA
 

typedef struct _EEVENT_PAIR EEVENT_PAIR
 

Referenced by ExpEventPairInitialization().

typedef struct _ERESOURCE ERESOURCE
 

Referenced by InitCreateUserCrit(), and SmbTraceInitialize().

typedef ULONG_PTR ERESOURCE_THREAD
 

Definition at line 2274 of file ex.h.

Referenced by ExAcquireResourceExclusive(), ExAcquireResourceExclusiveLite(), ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), ExAcquireSharedWaitForExclusive(), ExConvertExclusiveToSharedLite(), ExIsResourceAcquiredExclusiveLite(), ExIsResourceAcquiredSharedLite(), ExpAcquireResourceExclusiveLite(), ExReleaseResourceLite(), ExSetResourceOwnerPointer(), ExTryToAcquireResourceExclusiveLite(), FsRtlNotifyInitializeSync(), IopDeviceRelationsComplete(), IopDeviceStartComplete(), LfsAllocateSpanningBuffer(), LfsFreeSpanningBuffer(), and LfsGetLbcb().

typedef struct _EX_DEBUG_LOG EX_DEBUG_LOG
 

typedef struct _EX_DEBUG_LOG_EVENT EX_DEBUG_LOG_EVENT
 

typedef struct _EX_DEBUG_LOG_TAG EX_DEBUG_LOG_TAG
 

typedef VOID(* EX_DESTROY_HANDLE_ROUTINE)(IN HANDLE Handle)
 

Definition at line 2849 of file ex.h.

typedef BOOLEAN(* EX_DUPLICATE_HANDLE_ROUTINE)(IN struct _EPROCESS *Process OPTIONAL, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
 

Definition at line 2884 of file ex.h.

typedef BOOLEAN(* EX_ENUMERATE_HANDLE_ROUTINE)(IN PHANDLE_TABLE_ENTRY HandleTableEntry, IN HANDLE Handle, IN PVOID EnumParameter)
 

Definition at line 2865 of file ex.h.

typedef enum _EX_POOL_PRIORITY EX_POOL_PRIORITY
 

Referenced by MmResourcesAvailable(), and VeAllocatePoolWithTagPriority().

typedef struct _EX_WORK_QUEUE EX_WORK_QUEUE
 

typedef struct _EXHANDLE EXHANDLE
 

Referenced by RtlpAtomMapAtomToHandleEntry().

typedef struct _FAST_MUTEX FAST_MUTEX
 

typedef struct _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
 

typedef struct _HANDLE_TABLE HANDLE_TABLE
 

Referenced by ExpAllocateHandleTable().

typedef struct _HANDLE_TABLE_ENTRY HANDLE_TABLE_ENTRY
 

Referenced by ExpAllocateHandleTable(), ExpAllocateHandleTableEntry(), and RtlpCreateHandleForAtom().

typedef struct _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
 

Referenced by IoInitSystem(), and ObInitSystem().

typedef struct _NTDDK_ERESOURCE NTDDK_ERESOURCE
 

typedef struct _OWNER_ENTRY OWNER_ENTRY
 

Referenced by ExpFindCurrentThread().

typedef struct _PAGED_LOOKASIDE_LIST PAGED_LOOKASIDE_LIST
 

Referenced by InitQEntryLookaside().

typedef PVOID(* PALLOCATE_FUNCTION)(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
 

Definition at line 711 of file ex.h.

typedef struct _CALL_HASH_ENTRY * PCALL_HASH_ENTRY
 

Referenced by ExRecordCallerInHashTable().

typedef struct _CALL_PERFORMANCE_DATA * PCALL_PERFORMANCE_DATA
 

Referenced by ExInitializeCallData().

typedef VOID(* PCALLBACK_FUNCTION)(IN PVOID CallbackContext, IN PVOID Argument1, IN PVOID Argument2)
 

Definition at line 3264 of file ex.h.

Referenced by ExRegisterCallback().

typedef struct _CALLBACK_OBJECT* PCALLBACK_OBJECT
 

Definition at line 3262 of file ex.h.

typedef struct _EEVENT_PAIR * PEEVENT_PAIR
 

Referenced by NtCreateEventPair(), and NtSetInformationThread().

typedef struct _ERESOURCE * PERESOURCE
 

typedef ERESOURCE_THREAD* PERESOURCE_THREAD
 

Definition at line 2275 of file ex.h.

typedef BOOLEAN(* PEX_CHANGE_HANDLE_ROUTINE)(IN OUT PHANDLE_TABLE_ENTRY HandleTableEntry, IN ULONG_PTR Parameter)
 

Definition at line 2942 of file ex.h.

typedef struct _EX_DEBUG_LOG * PEX_DEBUG_LOG
 

typedef struct _EX_DEBUG_LOG_EVENT * PEX_DEBUG_LOG_EVENT
 

typedef struct _EX_DEBUG_LOG_TAG * PEX_DEBUG_LOG_TAG
 

typedef NTSTATUS(* PEX_SNAPSHOT_HANDLE_ENTRY)(IN OUT PSYSTEM_HANDLE_TABLE_ENTRY_INFO *HandleEntryInfo, IN HANDLE UniqueProcessId, IN PHANDLE_TABLE_ENTRY HandleEntry, IN HANDLE Handle, IN ULONG Length, IN OUT PULONG RequiredLength)
 

Definition at line 2902 of file ex.h.

typedef struct _EX_WORK_QUEUE * PEX_WORK_QUEUE
 

Referenced by ExpNewThreadNecessary().

typedef struct _EXHANDLE * PEXHANDLE
 

Referenced by CheckHandleFlag().

typedef struct _FAST_MUTEX * PFAST_MUTEX
 

typedef VOID(* PFREE_FUNCTION)(IN PVOID Buffer)
 

Definition at line 719 of file ex.h.

typedef struct _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE
 

typedef struct _HANDLE_TABLE * PHANDLE_TABLE
 

typedef struct _HANDLE_TABLE_ENTRY * PHANDLE_TABLE_ENTRY
 

Referenced by RtlpAtomMapAtomToHandleEntry().

typedef PVOID(* PKWIN32_GLOBALATOMTABLE_CALLOUT)(void)
 

Definition at line 3334 of file ex.h.

typedef struct _NPAGED_LOOKASIDE_LIST * PNPAGED_LOOKASIDE_LIST
 

Referenced by ExAllocateFromPPNPagedLookasideList(), ExFreeToPPNPagedLookasideList(), and IoSetIoCompletion().

typedef NTDDK_ERESOURCE* PNTDDK_ERESOURCE
 

Definition at line 2555 of file ex.h.

Referenced by ExQuerySystemLockInformation().

typedef enum _POOL_TYPE POOL_TYPE
 

Referenced by DumpAllocatedPool(), ExAllocatePoolWithQuotaTag(), ExAllocatePoolWithTag(), ExFreePool(), ExFreePoolSanityChecks(), ExFreePoolWithTag(), ExReturnPoolQuota(), InitializePool(), IopXxxControlFile(), MiFreePoolPages(), MmFreeSpecialPool(), ObCreateObjectType(), and ObpAllocateObject().

typedef struct _OWNER_ENTRY * POWNER_ENTRY
 

typedef enum _PP_NPAGED_LOOKASIDE_NUMBER PP_NPAGED_LOOKASIDE_NUMBER
 

Referenced by IoMakeAssociatedIrp(), IopAllocateIrpPrivate(), and IopFreeIrp().

typedef struct _PAGED_LOOKASIDE_LIST * PPAGED_LOOKASIDE_LIST
 

typedef enum _PP_NPAGED_LOOKASIDE_NUMBER * PPP_NPAGED_LOOKASIDE_NUMBER
 

typedef struct _RESOURCE_HASH_ENTRY * PRESOURCE_HASH_ENTRY
 

Referenced by ExDeleteResourceLite().

typedef struct _RESOURCE_PERFORMANCE_DATA * PRESOURCE_PERFORMANCE_DATA
 

typedef struct _WORK_QUEUE_ITEM * PWORK_QUEUE_ITEM
 

Referenced by CmpClaimGlobalQuota().

typedef VOID(* PWORKER_THREAD_ROUTINE)(IN PVOID Parameter)
 

Definition at line 1950 of file ex.h.

Referenced by ExpWorkerThread(), KdpTrap(), SepInformFileSystemsOfDeletedLogon(), SepQueueWorkItem(), and UdfInitializeGlobalData().

typedef struct _ZONE_HEADER * PZONE_HEADER
 

Referenced by InitLookaside().

typedef struct _ZONE_SEGMENT_HEADER * PZONE_SEGMENT_HEADER
 

typedef struct _RESOURCE_HASH_ENTRY RESOURCE_HASH_ENTRY
 

Referenced by ExDeleteResourceLite().

typedef struct _RESOURCE_PERFORMANCE_DATA RESOURCE_PERFORMANCE_DATA
 

typedef GUID UUID
 

Definition at line 3344 of file ex.h.

Referenced by CmpCloneHwProfile(), and ExUuidCreate().

typedef struct _WORK_QUEUE_ITEM WORK_QUEUE_ITEM
 

typedef enum _WORK_QUEUE_TYPE WORK_QUEUE_TYPE
 

Referenced by ExpCheckDynamicThreadCount(), ExpCheckForWorker(), ExpWorkerInitialization(), ExpWorkerThread(), and NtNotifyChangeMultipleKeys().

typedef struct _ZONE_HEADER ZONE_HEADER
 

typedef struct _ZONE_SEGMENT_HEADER ZONE_SEGMENT_HEADER
 

Referenced by InitLookaside().


Enumeration Type Documentation

enum _EX_POOL_PRIORITY
 

Enumeration values:
LowPoolPriority 
LowPoolPrioritySpecialPoolOverrun 
LowPoolPrioritySpecialPoolUnderrun 
NormalPoolPriority 
NormalPoolPrioritySpecialPoolOverrun 
NormalPoolPrioritySpecialPoolUnderrun 
HighPoolPriority 
HighPoolPrioritySpecialPoolOverrun 
HighPoolPrioritySpecialPoolUnderrun 

Definition at line 227 of file ex.h.

enum _POOL_TYPE
 

Enumeration values:
NonPagedPool 
PagedPool 
NonPagedPoolMustSucceed 
DontUseThisType 
NonPagedPoolCacheAligned 
PagedPoolCacheAligned 
NonPagedPoolCacheAlignedMustS 
MaxPoolType 
NonPagedPoolSession 
PagedPoolSession 
NonPagedPoolMustSucceedSession 
DontUseThisTypeSession 
NonPagedPoolCacheAlignedSession 
PagedPoolCacheAlignedSession 
NonPagedPoolCacheAlignedMustSSession 

Definition at line 107 of file ex.h.

00107 { 00108 NonPagedPool, 00109 PagedPool, 00110 NonPagedPoolMustSucceed, 00111 DontUseThisType, 00112 NonPagedPoolCacheAligned, 00113 PagedPoolCacheAligned, 00114 NonPagedPoolCacheAlignedMustS, 00115 MaxPoolType 00116 00117 // end_wdm 00118 , 00119 // 00120 // Note these per session types are carefully chosen so that the appropriate 00121 // masking still applies as well as MaxPoolType above. 00122 // 00123 00124 NonPagedPoolSession = 32, 00125 PagedPoolSession = NonPagedPoolSession + 1, 00126 NonPagedPoolMustSucceedSession = PagedPoolSession + 1, 00127 DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1, 00128 NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1, 00129 PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1, 00130 NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1, 00131 00132 // begin_wdm 00133 00134 } POOL_TYPE;

enum _PP_NPAGED_LOOKASIDE_NUMBER
 

Enumeration values:
LookasideSmallIrpList 
LookasideLargeIrpList 
LookasideMdlList 
LookasideCreateInfoList 
LookasideNameBufferList 
LookasideTwilightList 
LookasideCompletionList 
LookasideMaximumList 

Definition at line 996 of file ex.h.

enum _WORK_QUEUE_TYPE
 

Enumeration values:
CriticalWorkQueue 
DelayedWorkQueue 
HyperCriticalWorkQueue 
MaximumWorkQueue 

Definition at line 1941 of file ex.h.


Function Documentation

NTKERNELAPI VOID FASTCALL ExAcquireFastMutexUnsafe IN PFAST_MUTEX  FastMutex  ) 
 

Referenced by EnterMediaCrit(), EnterPowerCrit(), ExUuidCreate(), FsRtlAcknowledgeOplockBreak(), FsRtlOpBatchBreakClosePending(), FsRtlOplockBreakNotify(), FsRtlOplockBreakToII(), FsRtlOplockBreakToNone(), FsRtlOplockCleanup(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlUninitializeOplock(), MiMapViewOfDataSection(), MiProtectVirtualMemory(), MiRemoveMappedView(), NtAllocateUuids(), NtAllocateVirtualMemory(), NtQueryInformationJobObject(), NtSetInformationJobObject(), PsChangeJobMemoryUsage(), PsLockProcess(), PspAddProcessToJob(), PspApplyJobLimitsToProcess(), PspJobClose(), PsReportProcessMemoryLimitViolation(), PsUnlockProcess(), and VerifierExAcquireFastMutexUnsafe().

NTKERNELAPI BOOLEAN ExAcquireResourceExclusiveLite IN PERESOURCE  Resource,
IN BOOLEAN  Wait
 

Definition at line 492 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, Event(), ExpAcquireResourceExclusiveLite(), ExpIncrementCounter, FALSE, _ERESOURCE::Flag, IsOwnedExclusive, _OWNER_ENTRY::OwnerCount, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, ResourceNeverExclusive, ResourceOwnedExclusive, _ERESOURCE::SpinLock, and TRUE.

Referenced by ChangeAcquireResourceType(), EnterCrit(), ExpAcquireResourceExclusiveLite(), LeaveMouseCrit(), and VerifierExAcquireResourceExclusive().

00499 : 00500 00501 The routine acquires the specified resource for exclusive access. 00502 00503 N.B. This routine uses fast locking. 00504 00505 Arguments: 00506 00507 Resource - Supplies a pointer to the resource that is acquired 00508 for exclusive access. 00509 00510 Wait - A boolean value that specifies whether to wait for the 00511 resource to become available if access cannot be granted 00512 immediately. 00513 00514 Return Value: 00515 00516 BOOLEAN - TRUE if the resource is acquired and FALSE otherwise. 00517 00518 --*/ 00519 00520 { 00521 00522 ERESOURCE_THREAD CurrentThread; 00523 PKEVENT Event; 00524 KIRQL OldIrql = 0; 00525 BOOLEAN Result; 00526 00527 ASSERT((Resource->Flag & ResourceNeverExclusive) == 0); 00528 00529 // 00530 // Acquire exclusive access to the specified resource. 00531 // 00532 00533 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 00534 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 00535 00536 ASSERT(KeIsExecutingDpc() == FALSE); 00537 ASSERT_RESOURCE(Resource); 00538 00539 // 00540 // If the active count of the resource is zero, then there is neither 00541 // an exclusive owner nor a shared owner and access to the resource can 00542 // be immediately granted. Otherwise, there is either a shared owner or 00543 // an exclusive owner. 00544 // 00545 00546 ExpIncrementCounter(ExclusiveAcquire); 00547 if (Resource->ActiveCount != 0) { 00548 00549 // 00550 // The resource is either owned exclusive or shared. 00551 // 00552 // If the resource is owned exclusive and the current thread is the 00553 // owner, then increment the recursion count. 00554 // 00555 00556 if (IsOwnedExclusive(Resource) && 00557 (Resource->OwnerThreads[0].OwnerThread == CurrentThread)) { 00558 Resource->OwnerThreads[0].OwnerCount += 1; 00559 Result = TRUE; 00560 00561 } else { 00562 00563 // 00564 // The resource is either owned exclusive by some other thread, 00565 // or owned shared. 00566 // 00567 // If wait is not specified, then return that the resource was 00568 // not acquired. Otherwise, wait for exclusive access to the 00569 // resource to be granted. 00570 // 00571 00572 if (Wait == FALSE) { 00573 Result = FALSE; 00574 00575 } else { 00576 return ExpAcquireResourceExclusiveLite(Resource, OldIrql); 00577 } 00578 } 00579 00580 } else { 00581 00582 // 00583 // The resource is not owned. 00584 // 00585 00586 Resource->Flag |= ResourceOwnedExclusive; 00587 Resource->OwnerThreads[0].OwnerThread = CurrentThread; 00588 Resource->OwnerThreads[0].OwnerCount = 1; 00589 Resource->ActiveCount = 1; 00590 Result = TRUE; 00591 } 00592 00593 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 00594 return Result; 00595 }

NTKERNELAPI BOOLEAN ExAcquireResourceSharedLite IN PERESOURCE  Resource,
IN BOOLEAN  Wait
 

Definition at line 762 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, ExAllocatePoolWithTag, ExpFindCurrentThread(), ExpIncrementCounter, ExpWaitForResource(), FALSE, IsExclusiveWaiting, IsOwnedExclusive, KeInitializeSemaphore(), NonPagedPoolMustSucceed, NULL, _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerCount, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, _ERESOURCE::SharedWaiters, _ERESOURCE::SpinLock, and TRUE.

Referenced by EnterSharedCrit().

00769 : 00770 00771 The routine acquires the specified resource for shared access. 00772 00773 Arguments: 00774 00775 Resource - Supplies a pointer to the resource that is acquired 00776 for shared access. 00777 00778 Wait - A boolean value that specifies whether to wait for the 00779 resource to become available if access cannot be granted 00780 immediately. 00781 00782 Return Value: 00783 00784 BOOLEAN - TRUE if the resource is acquired and FALSE otherwise 00785 00786 --*/ 00787 00788 { 00789 00790 ERESOURCE_THREAD CurrentThread; 00791 KIRQL OldIrql; 00792 POWNER_ENTRY OwnerEntry; 00793 PKSEMAPHORE Semaphore; 00794 00795 // 00796 // Acquire exclusive access to the specified resource. 00797 // 00798 00799 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 00800 ExAcquireSpinLock(&Resource->SpinLock, &OldIrql); 00801 00802 ASSERT(KeIsExecutingDpc() == FALSE); 00803 ASSERT_RESOURCE(Resource); 00804 00805 ExpIncrementCounter(SharedSecondLevel); 00806 00807 // 00808 // If the active count of the resource is zero, then there is neither 00809 // an exclusive owner nor a shared owner and access to the resource can 00810 // be immediately granted. 00811 // 00812 00813 if (Resource->ActiveCount == 0) { 00814 Resource->OwnerThreads[1].OwnerThread = CurrentThread; 00815 Resource->OwnerThreads[1].OwnerCount = 1; 00816 Resource->ActiveCount = 1; 00817 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 00818 return TRUE; 00819 } 00820 00821 // 00822 // The resource is either owned exclusive or shared. 00823 // 00824 // If the resource is owned exclusive and the current thread is the 00825 // owner, then treat the shared request as an exclusive request and 00826 // increment the recursion count. Otherwise, it is owned shared. 00827 // 00828 00829 if (IsOwnedExclusive(Resource)) { 00830 if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 00831 Resource->OwnerThreads[0].OwnerCount += 1; 00832 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 00833 return TRUE; 00834 } 00835 00836 // 00837 // Find an empty entry in the thread array. 00838 // 00839 00840 OwnerEntry = ExpFindCurrentThread(Resource, 0); 00841 00842 } else { 00843 00844 // 00845 // The resource is owned shared. 00846 // 00847 // If the current thread already has acquired the resource for 00848 // shared access, then increment the recursion count. Otherwise 00849 // grant shared access if there are no exclusive waiters. 00850 // 00851 00852 OwnerEntry = ExpFindCurrentThread(Resource, CurrentThread); 00853 if (OwnerEntry->OwnerThread == CurrentThread) { 00854 OwnerEntry->OwnerCount += 1; 00855 00856 ASSERT(OwnerEntry->OwnerCount != 0); 00857 00858 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 00859 return TRUE; 00860 } 00861 00862 // 00863 // If there are no exclusive waiters, then grant shared access 00864 // to the resource. Otherwise, wait for the resource to become 00865 // available. 00866 // 00867 00868 if (IsExclusiveWaiting(Resource) == FALSE) { 00869 OwnerEntry->OwnerThread = CurrentThread; 00870 OwnerEntry->OwnerCount = 1; 00871 Resource->ActiveCount += 1; 00872 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 00873 return TRUE; 00874 } 00875 } 00876 00877 // 00878 // The resource is either owned exclusive by some other thread, or 00879 // owned shared by some other threads, but there is an exclusive 00880 // waiter and the current thread does not already have shared access 00881 // to the resource. 00882 // 00883 // If wait is not specified, then return that the resource was 00884 // not acquired. 00885 // 00886 00887 if (Wait == FALSE) { 00888 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 00889 return FALSE; 00890 } 00891 00892 // 00893 // If the shared wait semaphore has not yet been allocated, then allocate 00894 // and initialize it. 00895 // 00896 00897 if (Resource->SharedWaiters == NULL) { 00898 Semaphore = ExAllocatePoolWithTag(NonPagedPoolMustSucceed, 00899 sizeof(KSEMAPHORE), 00900 'eSeR'); 00901 00902 KeInitializeSemaphore(Semaphore, 0, MAXLONG); 00903 Resource->SharedWaiters = Semaphore; 00904 } 00905 00906 // 00907 // Wait for shared access to the resource to be granted and increment 00908 // the recursion count. 00909 // 00910 00911 OwnerEntry->OwnerThread = CurrentThread; 00912 OwnerEntry->OwnerCount = 1; 00913 Resource->NumberOfSharedWaiters += 1; 00914 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 00915 ExpWaitForResource(Resource, Resource->SharedWaiters); 00916 return TRUE; 00917 }

NTKERNELAPI BOOLEAN ExAcquireSharedStarveExclusive IN PERESOURCE  Resource,
IN BOOLEAN  Wait
 

Definition at line 1014 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, ExAllocatePoolWithTag, ExpFindCurrentThread(), ExpIncrementCounter, ExpWaitForResource(), FALSE, IsOwnedExclusive, KeInitializeSemaphore(), NonPagedPoolMustSucceed, NULL, _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerCount, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, _ERESOURCE::SharedWaiters, _ERESOURCE::SpinLock, and TRUE.

Referenced by CcPinFileData(), CcPinMappedData(), and UdfAcquireResource().

01020 : 01021 01022 This routine acquires the specified resource for shared access and 01023 does not wait for any pending exclusive owners. 01024 01025 Arguments: 01026 01027 Resource - Supplies a pointer to the resource that is acquired 01028 for shared access. 01029 01030 Wait - A boolean value that specifies whether to wait for the 01031 resource to become available if access cannot be granted 01032 immediately. 01033 01034 Return Value: 01035 01036 BOOLEAN - TRUE if the resource is acquired and FALSE otherwise 01037 01038 --*/ 01039 01040 { 01041 01042 ERESOURCE_THREAD CurrentThread; 01043 KIRQL OldIrql; 01044 POWNER_ENTRY OwnerEntry; 01045 PKSEMAPHORE Semaphore; 01046 01047 // 01048 // Acquire exclusive access to the specified resource. 01049 // 01050 01051 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 01052 ExAcquireSpinLock(&Resource->SpinLock, &OldIrql); 01053 01054 ASSERT(KeIsExecutingDpc() == FALSE); 01055 ASSERT_RESOURCE(Resource); 01056 01057 ExpIncrementCounter(StarveSecondLevel); 01058 01059 // 01060 // If the active count of the resource is zero, then there is neither 01061 // an exclusive owner nor a shared owner and access to the resource can 01062 // be immediately granted. 01063 // 01064 01065 if (Resource->ActiveCount == 0) { 01066 Resource->OwnerThreads[1].OwnerThread = CurrentThread; 01067 Resource->OwnerThreads[1].OwnerCount = 1; 01068 Resource->ActiveCount = 1; 01069 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01070 return TRUE; 01071 } 01072 01073 // 01074 // The resource is either owned exclusive or shared. 01075 // 01076 // If the resource is owned exclusive and the current thread is the 01077 // owner, then treat the shared request as an exclusive request and 01078 // increment the recursion count. Otherwise, it is owned shared. 01079 // 01080 01081 if (IsOwnedExclusive(Resource)) { 01082 if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 01083 Resource->OwnerThreads[0].OwnerCount += 1; 01084 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01085 return TRUE; 01086 } 01087 01088 // 01089 // Find an empty entry in the thread array. 01090 // 01091 01092 OwnerEntry = ExpFindCurrentThread(Resource, 0); 01093 01094 } else { 01095 01096 // 01097 // The resource is owned shared. 01098 // 01099 // If the current thread already has acquired the resource for 01100 // shared access, then increment the recursion count. Otherwise 01101 // grant shared access to the current thread 01102 // 01103 01104 OwnerEntry = ExpFindCurrentThread(Resource, CurrentThread); 01105 if (OwnerEntry->OwnerThread == CurrentThread) { 01106 OwnerEntry->OwnerCount += 1; 01107 01108 ASSERT(OwnerEntry->OwnerCount != 0); 01109 01110 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01111 return TRUE; 01112 } 01113 01114 // 01115 // Grant the current thread shared access to the resource. 01116 // 01117 01118 OwnerEntry->OwnerThread = CurrentThread; 01119 OwnerEntry->OwnerCount = 1; 01120 Resource->ActiveCount += 1; 01121 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01122 return TRUE; 01123 } 01124 01125 // 01126 // The resource is owned exclusive by some other thread. 01127 // 01128 // If wait is not specified, then return that the resource was 01129 // not acquired. 01130 // 01131 01132 if (Wait == FALSE) { 01133 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01134 return FALSE; 01135 } 01136 01137 // 01138 // If the shared wait semaphore has not yet been allocated, then allocate 01139 // and initialize it. 01140 // 01141 01142 if (Resource->SharedWaiters == NULL) { 01143 Semaphore = ExAllocatePoolWithTag(NonPagedPoolMustSucceed, 01144 sizeof(KSEMAPHORE), 01145 'eSeR'); 01146 01147 KeInitializeSemaphore(Semaphore, 0, MAXLONG); 01148 Resource->SharedWaiters = Semaphore; 01149 } 01150 01151 // 01152 // Wait for shared access to the resource to be granted and increment 01153 // the recursion count. 01154 // 01155 01156 OwnerEntry->OwnerThread = CurrentThread; 01157 OwnerEntry->OwnerCount = 1; 01158 Resource->NumberOfSharedWaiters += 1; 01159 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01160 ExpWaitForResource(Resource, Resource->SharedWaiters); 01161 return TRUE; 01162 }

NTKERNELAPI BOOLEAN ExAcquireSharedWaitForExclusive IN PERESOURCE  Resource,
IN BOOLEAN  Wait
 

Definition at line 1165 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, ExAllocatePoolWithTag, ExpFindCurrentThread(), ExpIncrementCounter, ExpWaitForResource(), FALSE, IsExclusiveWaiting, IsOwnedExclusive, KeInitializeSemaphore(), NonPagedPoolMustSucceed, NULL, _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerCount, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, _ERESOURCE::SharedWaiters, _ERESOURCE::SpinLock, and TRUE.

Referenced by FsRtlAcquireFileForModWrite().

01171 : 01172 01173 This routine acquires the specified resource for shared access, but 01174 waits for any pending exclusive owners. 01175 01176 Arguments: 01177 01178 Resource - Supplies a pointer to the resource that is acquired 01179 for shared access. 01180 01181 Wait - A boolean value that specifies whether to wait for the 01182 resource to become available if access cannot be granted 01183 immediately. 01184 01185 Return Value: 01186 01187 BOOLEAN - TRUE if the resource is acquired and FALSE otherwise 01188 01189 --*/ 01190 01191 { 01192 01193 ERESOURCE_THREAD CurrentThread; 01194 KIRQL OldIrql; 01195 POWNER_ENTRY OwnerEntry; 01196 PKSEMAPHORE Semaphore; 01197 01198 // 01199 // Acquire exclusive access to the specified resource. 01200 // 01201 01202 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 01203 ExAcquireSpinLock(&Resource->SpinLock, &OldIrql); 01204 01205 ASSERT(KeIsExecutingDpc() == FALSE); 01206 ASSERT_RESOURCE(Resource); 01207 01208 ExpIncrementCounter(WaitForExclusive); 01209 01210 // 01211 // If the active count of the resource is zero, then there is neither 01212 // an exclusive owner nor a shared owner and access to the resource can 01213 // be immediately granted. 01214 // 01215 01216 if (Resource->ActiveCount == 0) { 01217 Resource->OwnerThreads[1].OwnerThread = CurrentThread; 01218 Resource->OwnerThreads[1].OwnerCount = 1; 01219 Resource->ActiveCount = 1; 01220 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01221 return TRUE; 01222 } 01223 01224 // 01225 // The resource is either owned exclusive or shared. 01226 // 01227 // If the resource is owned exclusive and the current thread is the 01228 // owner, then treat the shared request as an exclusive request and 01229 // increment the recursion count. Otherwise, it is owned shared. 01230 // 01231 01232 if (IsOwnedExclusive(Resource)) { 01233 if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 01234 Resource->OwnerThreads[0].OwnerCount += 1; 01235 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01236 return TRUE; 01237 } 01238 01239 // 01240 // Find an empty entry in the thread array. 01241 // 01242 01243 OwnerEntry = ExpFindCurrentThread(Resource, 0); 01244 01245 } else { 01246 01247 // 01248 // The resource is owned shared. 01249 // 01250 // If there is an exclusive waiter, then wait for the exclusive 01251 // waiter to gain access to the resource, then acquire the resource 01252 // shared without regard to exclusive waiters. Otherwise, if the 01253 // current thread already has acquired the resource for shared access, 01254 // then increment the recursion count. Otherwise grant shared access 01255 // to the current thread 01256 // 01257 01258 if (IsExclusiveWaiting(Resource)) { 01259 01260 // 01261 // The resource is shared, but there is an exclusive waiter. 01262 // 01263 // If wait is not specified, then return that the resource was 01264 // not acquired. 01265 // 01266 01267 if (Wait == FALSE) { 01268 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01269 return FALSE; 01270 } 01271 01272 // 01273 // If the shared wait semaphore has not yet been allocated, then 01274 // allocate and initialize it. 01275 // 01276 01277 if (Resource->SharedWaiters == NULL) { 01278 Semaphore = ExAllocatePoolWithTag(NonPagedPoolMustSucceed, 01279 sizeof(KSEMAPHORE), 01280 'eSeR'); 01281 01282 KeInitializeSemaphore(Semaphore, 0, MAXLONG); 01283 Resource->SharedWaiters = Semaphore; 01284 } 01285 01286 // 01287 // Increment the number of shared waiters and wait for shared 01288 // access to the resource to be granted to some other set of 01289 // threads, and then acquire the resource shared without regard 01290 // to exclusive access. 01291 // 01292 // N.B. The resource is left in a state such that the calling 01293 // thread does not have a reference in the owner table 01294 // for the requested access even though the active count 01295 // is incremented when control is returned. However, the 01296 // resource is owned shared at this point, so an owner 01297 // entry can simply be allocated and the owner count set 01298 // to one. 01299 // 01300 01301 Resource->NumberOfSharedWaiters += 1; 01302 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01303 ExpWaitForResource(Resource, Resource->SharedWaiters); 01304 01305 // 01306 // Reacquire the resource spin lock, allocate an owner entry, 01307 // and initialize the owner count to one. The active count 01308 // was already incremented when shared access was granted. 01309 // 01310 01311 ExAcquireSpinLock(&Resource->SpinLock, &OldIrql); 01312 01313 ASSERT(IsOwnedExclusive(Resource) == FALSE); 01314 ASSERT(Resource->ActiveCount > 0); 01315 01316 OwnerEntry = ExpFindCurrentThread(Resource, CurrentThread); 01317 01318 ASSERT(OwnerEntry->OwnerThread != CurrentThread); 01319 01320 OwnerEntry->OwnerThread = CurrentThread; 01321 OwnerEntry->OwnerCount = 1; 01322 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01323 return TRUE; 01324 01325 } else { 01326 OwnerEntry = ExpFindCurrentThread(Resource, CurrentThread); 01327 if (OwnerEntry->OwnerThread == CurrentThread) { 01328 OwnerEntry->OwnerCount += 1; 01329 01330 ASSERT(OwnerEntry->OwnerCount != 0); 01331 01332 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01333 return TRUE; 01334 } 01335 01336 // 01337 // Grant the current thread shared access to the resource. 01338 // 01339 01340 OwnerEntry->OwnerThread = CurrentThread; 01341 OwnerEntry->OwnerCount = 1; 01342 Resource->ActiveCount += 1; 01343 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01344 return TRUE; 01345 } 01346 } 01347 01348 // 01349 // The resource is owned exclusive by some other thread. 01350 // 01351 // If wait is not specified, then return that the resource was 01352 // not acquired. 01353 // 01354 01355 if (Wait == FALSE) { 01356 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01357 return FALSE; 01358 } 01359 01360 // 01361 // If the shared wait semaphore has not yet been allocated, then allocate 01362 // and initialize it. 01363 // 01364 01365 if (Resource->SharedWaiters == NULL) { 01366 Semaphore = ExAllocatePoolWithTag(NonPagedPoolMustSucceed, 01367 sizeof(KSEMAPHORE), 01368 'eSeR'); 01369 01370 KeInitializeSemaphore(Semaphore, 0, MAXLONG); 01371 Resource->SharedWaiters = Semaphore; 01372 } 01373 01374 // 01375 // Wait for shared access to the resource to be granted and increment 01376 // the recursion count. 01377 // 01378 01379 OwnerEntry->OwnerThread = CurrentThread; 01380 OwnerEntry->OwnerCount = 1; 01381 Resource->NumberOfSharedWaiters += 1; 01382 ExReleaseSpinLock(&Resource->SpinLock, OldIrql); 01383 ExpWaitForResource(Resource, Resource->SharedWaiters); 01384 return TRUE; 01385 }

VOID ExAcquireTimeRefreshLock VOID   ) 
 

Referenced by KdpTimeSlipWork().

VOID ExAdjustLookasideDepth VOID   ) 
 

Definition at line 89 of file ex/lookasid.c.

References ExNPagedLookasideListHead, ExNPagedLookasideLock, ExpAdjustScanPeriod, ExPagedLookasideListHead, ExPagedLookasideLock, ExpCurrentScanPeriod, ExPoolLookasideListHead, ExpScanGeneralLookasideList(), ExpScanPoolLookasideList(), FALSE, and MAXIMUM_SCAN_PERIOD.

Referenced by KeBalanceSetManager().

00095 : 00096 00097 This function is called periodically to adjust the maximum depth of 00098 all lookaside lists. 00099 00100 Arguments: 00101 00102 None. 00103 00104 Return Value: 00105 00106 None. 00107 00108 --*/ 00109 00110 { 00111 00112 LOGICAL Changes; 00113 00114 // 00115 // Decrement the scan period and check if it is time to dynamically 00116 // adjust the maximum depth of lookaside lists. 00117 // 00118 00119 ExpCurrentScanPeriod -= 1; 00120 if (ExpCurrentScanPeriod == 0) { 00121 Changes = FALSE; 00122 00123 // 00124 // Scan the general paged and nonpaged lookaside lists. 00125 // 00126 00127 Changes |= ExpScanGeneralLookasideList(&ExNPagedLookasideListHead, 00128 &ExNPagedLookasideLock); 00129 00130 Changes |= ExpScanGeneralLookasideList(&ExPagedLookasideListHead, 00131 &ExPagedLookasideLock); 00132 00133 // 00134 // Scan the pool paged and nonpaged lookaside lists; 00135 // 00136 00137 Changes |= ExpScanPoolLookasideList(&ExPoolLookasideListHead); 00138 00139 // 00140 // If any changes were made to the depth of any lookaside list during 00141 // this scan period, then lower the scan period to the minimum value. 00142 // Otherwise, attempt to raise the scan period. 00143 // 00144 00145 if (Changes != FALSE) { 00146 ExpAdjustScanPeriod = 1; 00147 00148 } else { 00149 if (ExpAdjustScanPeriod != MAXIMUM_SCAN_PERIOD) { 00150 ExpAdjustScanPeriod += 1; 00151 } 00152 } 00153 00154 ExpCurrentScanPeriod = ExpAdjustScanPeriod; 00155 } 00156 00157 return; 00158 }

__inline PVOID ExAllocateFromNPagedLookasideList IN PNPAGED_LOOKASIDE_LIST  Lookaside  ) 
 

Definition at line 780 of file ex.h.

References ExInterlockedPopEntrySList(), and NULL.

Referenced by ExAllocateFromPPNPagedLookasideList(), ExDeleteNPagedLookasideList(), FsRtlAllocateExclusiveLock(), FsRtlAllocateLockInfo(), FsRtlAllocateLockTreeNode(), FsRtlAllocateSharedLock(), FsRtlAllocateWaitingLock(), and UdfCreateIrpContext().

00786 : 00787 00788 This function removes (pops) the first entry from the specified 00789 nonpaged lookaside list. 00790 00791 Arguments: 00792 00793 Lookaside - Supplies a pointer to a nonpaged lookaside list structure. 00794 00795 Return Value: 00796 00797 If an entry is removed from the specified lookaside list, then the 00798 address of the entry is returned as the function value. Otherwise, 00799 NULL is returned. 00800 00801 --*/ 00802 00803 { 00804 00805 PVOID Entry; 00806 00807 Lookaside->L.TotalAllocates += 1; 00808 Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, &Lookaside->Lock); 00809 if (Entry == NULL) { 00810 Lookaside->L.AllocateMisses += 1; 00811 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, 00812 Lookaside->L.Size, 00813 Lookaside->L.Tag); 00814 } 00815 00816 return Entry; 00817 }

__inline PVOID ExAllocateFromPagedLookasideList IN PPAGED_LOOKASIDE_LIST  Lookaside  ) 
 

Definition at line 906 of file ex.h.

References ExInterlockedPopEntrySList(), and NULL.

Referenced by AllocQEntry(), AllocQueue(), AllocSMS(), ExDeletePagedLookasideList(), FsRtlAddToTunnelCache(), FsRtlAllocateFileLock(), and UdfInsertPrefix().

00912 : 00913 00914 This function removes (pops) the first entry from the specified 00915 paged lookaside list. 00916 00917 Arguments: 00918 00919 Lookaside - Supplies a pointer to a paged lookaside list structure. 00920 00921 Return Value: 00922 00923 If an entry is removed from the specified lookaside list, then the 00924 address of the entry is returned as the function value. Otherwise, 00925 NULL is returned. 00926 00927 --*/ 00928 00929 { 00930 00931 PVOID Entry; 00932 00933 Lookaside->L.TotalAllocates += 1; 00934 Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, NULL); 00935 if (Entry == NULL) { 00936 Lookaside->L.AllocateMisses += 1; 00937 Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, 00938 Lookaside->L.Size, 00939 Lookaside->L.Tag); 00940 } 00941 00942 return Entry; 00943 }

__inline PVOID ExAllocateFromPPNPagedLookasideList IN PP_NPAGED_LOOKASIDE_NUMBER  Number  ) 
 

Definition at line 1011 of file ex.h.

References _GENERAL_LOOKASIDE::AllocateMisses, ASSERT, ExAllocateFromNPagedLookasideList(), ExInterlockedPopEntrySList(), KeGetCurrentPrcb, _NPAGED_LOOKASIDE_LIST::L, _GENERAL_LOOKASIDE::ListHead, _NPAGED_LOOKASIDE_LIST::Lock, LookasideMaximumList, NULL, PNPAGED_LOOKASIDE_LIST, and _GENERAL_LOOKASIDE::TotalAllocates.

Referenced by IoAllocateMdl(), and ObpAllocateObjectNameBuffer().

01017 : 01018 01019 This function removes (pops) the first entry from the specified 01020 nonpaged per processor lookaside list. 01021 01022 Arguments: 01023 01024 Number - Supplies the per processor nonpaged lookaside list number. 01025 01026 Return Value: 01027 01028 If an entry is removed from the specified lookaside list, then the 01029 address of the entry is returned as the function value. Otherwise, 01030 NULL is returned. 01031 01032 --*/ 01033 01034 { 01035 01036 PVOID Entry; 01037 PNPAGED_LOOKASIDE_LIST Lookaside; 01038 PKPRCB Prcb; 01039 01040 // 01041 // Get address of current processor block. 01042 // 01043 // N.B. It is possible to context switch during the allocation from a 01044 // per processor nonpaged lookaside list, but this should happen 01045 // infrequently and should not aversely effect the benefits of 01046 // per processor lookaside lists. 01047 // 01048 01049 ASSERT((Number >= 0) && (Number < LookasideMaximumList)); 01050 01051 Prcb = KeGetCurrentPrcb(); 01052 01053 // 01054 // Attempt to allocate from the per processor lookaside list. 01055 // 01056 01057 Lookaside = Prcb->PPLookasideList[Number].P; 01058 Lookaside->L.TotalAllocates += 1; 01059 Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, &Lookaside->Lock); 01060 01061 // 01062 // If the per processor allocation attempt failed, then attempt to 01063 // allocate from the system lookaside list. 01064 // 01065 01066 if (Entry == NULL) { 01067 Lookaside->L.AllocateMisses += 1; 01068 Lookaside = Prcb->PPLookasideList[Number].L; 01069 Entry = ExAllocateFromNPagedLookasideList(Lookaside); 01070 } 01071 01072 return Entry; 01073 }

NTKERNELAPI PVOID ExAllocatePool IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes
 

Definition at line 910 of file ex/pool.c.

References ExAllocatePoolWithTag.

00917 : 00918 00919 This function allocates a block of pool of the specified type and 00920 returns a pointer to the allocated block. This function is used to 00921 access both the page-aligned pools, and the list head entries (less than 00922 a page) pools. 00923 00924 If the number of bytes specifies a size that is too large to be 00925 satisfied by the appropriate list, then the page-aligned 00926 pool allocator is used. The allocated block will be page-aligned 00927 and a page-sized multiple. 00928 00929 Otherwise, the appropriate pool list entry is used. The allocated 00930 block will be 64-bit aligned, but will not be page aligned. The 00931 pool allocator calculates the smallest number of POOL_BLOCK_SIZE 00932 that can be used to satisfy the request. If there are no blocks 00933 available of this size, then a block of the next larger block size 00934 is allocated and split. One piece is placed back into the pool, and 00935 the other piece is used to satisfy the request. If the allocator 00936 reaches the paged-sized block list, and nothing is there, the 00937 page-aligned pool allocator is called. The page is split and added 00938 to the pool... 00939 00940 Arguments: 00941 00942 PoolType - Supplies the type of pool to allocate. If the pool type 00943 is one of the "MustSucceed" pool types, then this call will 00944 always succeed and return a pointer to allocated pool. 00945 Otherwise, if the system cannot allocate the requested amount 00946 of memory a NULL is returned. 00947 00948 Valid pool types: 00949 00950 NonPagedPool 00951 PagedPool 00952 NonPagedPoolMustSucceed, 00953 NonPagedPoolCacheAligned 00954 PagedPoolCacheAligned 00955 NonPagedPoolCacheAlignedMustS 00956 00957 NumberOfBytes - Supplies the number of bytes to allocate. 00958 00959 Return Value: 00960 00961 NULL - The PoolType is not one of the "MustSucceed" pool types, and 00962 not enough pool exists to satisfy the request. 00963 00964 NON-NULL - Returns a pointer to the allocated pool. 00965 00966 --*/ 00967 00968 { 00969 return ExAllocatePoolWithTag (PoolType, 00970 NumberOfBytes, 00971 'enoN'); 00972 }

VOID ExAllocatePoolSanityChecks IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes
 

Definition at line 3828 of file ex/pool.c.

References APC_LEVEL, BASE_POOL_TYPE_MASK, DISPATCH_LEVEL, KeBugCheckEx(), MUST_SUCCEED_POOL_TYPE_MASK, PAGE_SIZE, and PagedPool.

Referenced by VeAllocatePoolWithTagPriority().

03835 : 03836 03837 This function performs sanity checks on the caller. 03838 03839 Return Value: 03840 03841 None. 03842 03843 Environment: 03844 03845 Only enabled as part of the driver verification package. 03846 03847 --*/ 03848 03849 { 03850 if (NumberOfBytes == 0) { 03851 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03852 0x0, 03853 KeGetCurrentIrql(), 03854 PoolType, 03855 NumberOfBytes); 03856 } 03857 03858 if ((PoolType & BASE_POOL_TYPE_MASK) == PagedPool) { 03859 03860 if (KeGetCurrentIrql() > APC_LEVEL) { 03861 03862 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03863 0x1, 03864 KeGetCurrentIrql(), 03865 PoolType, 03866 NumberOfBytes); 03867 } 03868 } 03869 else { 03870 if (KeGetCurrentIrql() > DISPATCH_LEVEL) { 03871 03872 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03873 0x2, 03874 KeGetCurrentIrql(), 03875 PoolType, 03876 NumberOfBytes); 03877 } 03878 } 03879 03880 if (PoolType & MUST_SUCCEED_POOL_TYPE_MASK) { 03881 if (NumberOfBytes > PAGE_SIZE) { 03882 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03883 0x3, 03884 KeGetCurrentIrql(), 03885 PoolType, 03886 NumberOfBytes); 03887 } 03888 } 03889 }

NTKERNELAPI PVOID ExAllocatePoolWithQuota IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes
 

Definition at line 2550 of file ex/pool.c.

References ExAllocatePoolWithQuotaTag.

02557 : 02558 02559 This function allocates a block of pool of the specified type, 02560 returns a pointer to the allocated block, and if the binary buddy 02561 allocator was used to satisfy the request, charges pool quota to the 02562 current process. This function is used to access both the 02563 page-aligned pools, and the binary buddy. 02564 02565 If the number of bytes specifies a size that is too large to be 02566 satisfied by the appropriate binary buddy pool, then the 02567 page-aligned pool allocator is used. The allocated block will be 02568 page-aligned and a page-sized multiple. No quota is charged to the 02569 current process if this is the case. 02570 02571 Otherwise, the appropriate binary buddy pool is used. The allocated 02572 block will be 64-bit aligned, but will not be page aligned. After 02573 the allocation completes, an attempt will be made to charge pool 02574 quota (of the appropriate type) to the current process object. If 02575 the quota charge succeeds, then the pool block's header is adjusted 02576 to point to the current process. The process object is not 02577 dereferenced until the pool is deallocated and the appropriate 02578 amount of quota is returned to the process. Otherwise, the pool is 02579 deallocated, a "quota exceeded" condition is raised. 02580 02581 Arguments: 02582 02583 PoolType - Supplies the type of pool to allocate. If the pool type 02584 is one of the "MustSucceed" pool types and sufficient quota 02585 exists, then this call will always succeed and return a pointer 02586 to allocated pool. Otherwise, if the system cannot allocate 02587 the requested amount of memory a STATUS_INSUFFICIENT_RESOURCES 02588 status is raised. 02589 02590 NumberOfBytes - Supplies the number of bytes to allocate. 02591 02592 Return Value: 02593 02594 NON-NULL - Returns a pointer to the allocated pool. 02595 02596 Unspecified - If insufficient quota exists to complete the pool 02597 allocation, the return value is unspecified. 02598 02599 --*/ 02600 02601 { 02602 return (ExAllocatePoolWithQuotaTag (PoolType, NumberOfBytes, 'enoN')); 02603 }

NTKERNELAPI PVOID ExAllocatePoolWithQuotaTag IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes,
IN ULONG  Tag
 

Definition at line 2607 of file ex/pool.c.

References BASE_POOL_TYPE_MASK, _POOL_HEADER::BlockSize, ExAllocatePoolWithTag, ExpAllocatePoolWithQuotaHandler(), ExRaiseStatus(), FALSE, KeBugCheck(), MmSpecialPoolEnd, MmSpecialPoolStart, NtGlobalFlag, NULL, ObReferenceObject, PAGE_ALIGNED, POOL_BLOCK_SHIFT, POOL_OVERHEAD, POOL_QUOTA_ENABLED, POOL_QUOTA_FAIL_INSTEAD_OF_RAISE, POOL_QUOTA_MASK, POOL_TYPE, _POOL_HEADER::ProcessBilled, PsChargePoolQuota(), PsGetCurrentProcess, PsInitialSystemProcess, and TRUE.

02615 : 02616 02617 This function allocates a block of pool of the specified type, 02618 returns a pointer to the allocated block, and if the binary buddy 02619 allocator was used to satisfy the request, charges pool quota to the 02620 current process. This function is used to access both the 02621 page-aligned pools, and the binary buddy. 02622 02623 If the number of bytes specifies a size that is too large to be 02624 satisfied by the appropriate binary buddy pool, then the 02625 page-aligned pool allocator is used. The allocated block will be 02626 page-aligned and a page-sized multiple. No quota is charged to the 02627 current process if this is the case. 02628 02629 Otherwise, the appropriate binary buddy pool is used. The allocated 02630 block will be 64-bit aligned, but will not be page aligned. After 02631 the allocation completes, an attempt will be made to charge pool 02632 quota (of the appropriate type) to the current process object. If 02633 the quota charge succeeds, then the pool block's header is adjusted 02634 to point to the current process. The process object is not 02635 dereferenced until the pool is deallocated and the appropriate 02636 amount of quota is returned to the process. Otherwise, the pool is 02637 deallocated, a "quota exceeded" condition is raised. 02638 02639 Arguments: 02640 02641 PoolType - Supplies the type of pool to allocate. If the pool type 02642 is one of the "MustSucceed" pool types and sufficient quota 02643 exists, then this call will always succeed and return a pointer 02644 to allocated pool. Otherwise, if the system cannot allocate 02645 the requested amount of memory a STATUS_INSUFFICIENT_RESOURCES 02646 status is raised. 02647 02648 NumberOfBytes - Supplies the number of bytes to allocate. 02649 02650 Return Value: 02651 02652 NON-NULL - Returns a pointer to the allocated pool. 02653 02654 Unspecified - If insufficient quota exists to complete the pool 02655 allocation, the return value is unspecified. 02656 02657 --*/ 02658 02659 { 02660 PVOID p; 02661 PEPROCESS Process; 02662 PPOOL_HEADER Entry; 02663 LOGICAL IgnoreQuota; 02664 LOGICAL RaiseOnQuotaFailure; 02665 02666 IgnoreQuota = FALSE; 02667 RaiseOnQuotaFailure = TRUE; 02668 02669 if ( PoolType & POOL_QUOTA_FAIL_INSTEAD_OF_RAISE ) { 02670 RaiseOnQuotaFailure = FALSE; 02671 PoolType &= ~POOL_QUOTA_FAIL_INSTEAD_OF_RAISE; 02672 } 02673 02674 if ((POOL_QUOTA_ENABLED == FALSE) 02675 #if i386 && !FPO 02676 || (NtGlobalFlag & FLG_KERNEL_STACK_TRACE_DB) 02677 #endif // i386 && !FPO 02678 ) { 02679 IgnoreQuota = TRUE; 02680 } else { 02681 PoolType = (POOL_TYPE)((UCHAR)PoolType + POOL_QUOTA_MASK); 02682 } 02683 02684 p = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag); 02685 02686 // 02687 // Note - NULL is page aligned. 02688 // 02689 02690 if (!PAGE_ALIGNED(p) && !IgnoreQuota) { 02691 02692 if ((p >= MmSpecialPoolStart) && (p < MmSpecialPoolEnd)) { 02693 return p; 02694 } 02695 02696 #if POOL_CACHE_SUPPORTED 02697 02698 // 02699 // Align entry on pool allocation boundary. 02700 // 02701 02702 if (((ULONG)p & POOL_CACHE_CHECK) == 0) { 02703 Entry = (PPOOL_HEADER)((ULONG)p - PoolCacheSize); 02704 } else { 02705 Entry = (PPOOL_HEADER)((PCH)p - POOL_OVERHEAD); 02706 } 02707 02708 #else 02709 Entry = (PPOOL_HEADER)((PCH)p - POOL_OVERHEAD); 02710 #endif //POOL_CACHE_SUPPORTED 02711 02712 Process = PsGetCurrentProcess(); 02713 02714 // 02715 // Catch exception and back out allocation if necessary 02716 // 02717 02718 try { 02719 02720 Entry->ProcessBilled = NULL; 02721 02722 if (Process != PsInitialSystemProcess) { 02723 02724 PsChargePoolQuota(Process, 02725 PoolType & BASE_POOL_TYPE_MASK, 02726 (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT)); 02727 02728 ObReferenceObject(Process); 02729 Entry->ProcessBilled = Process; 02730 } 02731 02732 } except ( ExpAllocatePoolWithQuotaHandler(GetExceptionCode(),p,RaiseOnQuotaFailure)) { 02733 if ( RaiseOnQuotaFailure ) { 02734 KeBugCheck(GetExceptionCode()); 02735 } 02736 else { 02737 p = NULL; 02738 } 02739 } 02740 02741 } else { 02742 if ( !p && RaiseOnQuotaFailure ) { 02743 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 02744 } 02745 } 02746 02747 return p; 02748 }

NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTag IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes,
IN ULONG  Tag
 

Definition at line 1104 of file ex/pool.c.

References _GENERAL_LOOKASIDE::AllocateHits, ASSERT, ASSERT_ALLOCATE_IRQL, BASE_POOL_TYPE_MASK, _POOL_HEADER::BlockSize, BYTES_TO_PAGES, CACHE_ALIGNED_POOL_TYPE_MASK, CacheOverhead, CHECK_LIST, CHECK_LOOKASIDE_LIST, CHECK_POOL_HEADER, DECODE_POOL_INDEX, ENCODE_POOL_INDEX, ExInterlockedPopEntrySList(), ExpAddTagForBigPages(), ExpCheckSingleFilter(), ExpInsertPoolTracker(), ExpNumberOfPagedPools, ExpPagedPoolDescriptor, ExpPoolIndex, ExpSessionPoolDescriptor, ExRaiseStatus(), FALSE, HighPoolPriority, Index, Isx86FeaturePresent, KeGetCurrentPrcb, KernelVerifier, KF_CMPXCHG8B, _NPAGED_LOOKASIDE_LIST::L, _GENERAL_LOOKASIDE::ListHead, _POOL_DESCRIPTOR::ListHeads, Lock, _NPAGED_LOOKASIDE_LIST::Lock, LOCK_IF_PAGED_POOL, LOCK_POOL, LOCK_POOL_GRANULAR, _POOL_DESCRIPTOR::LockAddress, MARK_POOL_HEADER_ALLOCATED, MiAllocatePoolPages(), MiSessionPoolAllocated(), MmAllocateSpecialPool(), MmSpecialPoolTag, MmSqueezeBadTags(), MUST_SUCCEED_POOL_TYPE_MASK, NonPagedPool, NonPagedPoolLock, NonPagedPoolMustSucceed, NULL, PAGE_END, PAGE_SIZE, PagedPool, PERFINFO_ADDPOOLPAGE, PERFINFO_BIGPOOLALLOC, PERFINFO_EXALLOCATEPOOLWITHTAG_DECL, PERFINFO_POOLALLOC, PERFINFO_POOLALLOC_ADDR, POOL_BLOCK_SHIFT, POOL_BUDDY_MAX, POOL_DRIVER_MASK, POOL_LIST_HEADS, POOL_OVERHEAD, POOL_QUOTA_MASK, POOL_RAISE_IF_ALLOCATION_FAILURE, POOL_SMALL_LISTS, POOL_SMALLEST_BLOCK, POOL_TYPE, POOL_VERIFIER_MASK, PoolBigPageTable, _POOL_DESCRIPTOR::PoolIndex, _POOL_HEADER::PoolTag, PoolTrackTable, _POOL_HEADER::PoolType, PoolVector, PPOOL_BLOCK, PPOOL_HEADER, _POOL_HEADER::PreviousSize, PrivateInsertHeadList, PrivateInsertTailList, PrivateIsListEmpty, PrivateRemoveHeadList, ROUND_TO_PAGES, RtlGetCallersAddress(), _POOL_DESCRIPTOR::RunningAllocs, SESSION_POOL_MASK, _GENERAL_LOOKASIDE::TotalAllocates, _POOL_DESCRIPTOR::TotalBigPages, _POOL_DESCRIPTOR::TotalPages, TRUE, UNLOCK_IF_PAGED_POOL, UNLOCK_POOL, UNLOCK_POOL_GRANULAR, and VeAllocatePoolWithTagPriority().

01112 : 01113 01114 This function allocates a block of pool of the specified type and 01115 returns a pointer to the allocated block. This function is used to 01116 access both the page-aligned pools and the list head entries (less 01117 than a page) pools. 01118 01119 If the number of bytes specifies a size that is too large to be 01120 satisfied by the appropriate list, then the page-aligned pool 01121 allocator is used. The allocated block will be page-aligned and a 01122 page-sized multiple. 01123 01124 Otherwise, the appropriate pool list entry is used. The allocated 01125 block will be 64-bit aligned, but will not be page aligned. The 01126 pool allocator calculates the smallest number of POOL_BLOCK_SIZE 01127 that can be used to satisfy the request. If there are no blocks 01128 available of this size, then a block of the next larger block size 01129 is allocated and split. One piece is placed back into the pool, and 01130 the other piece is used to satisfy the request. If the allocator 01131 reaches the paged-sized block list, and nothing is there, the 01132 page-aligned pool allocator is called. The page is split and added 01133 to the pool. 01134 01135 Arguments: 01136 01137 PoolType - Supplies the type of pool to allocate. If the pool type 01138 is one of the "MustSucceed" pool types, then this call will 01139 always succeed and return a pointer to allocated pool. Otherwise, 01140 if the system cannot allocate the requested amount of memory a 01141 NULL is returned. 01142 01143 Valid pool types: 01144 01145 NonPagedPool 01146 PagedPool 01147 NonPagedPoolMustSucceed, 01148 NonPagedPoolCacheAligned 01149 PagedPoolCacheAligned 01150 NonPagedPoolCacheAlignedMustS 01151 01152 Tag - Supplies the caller's identifying tag. 01153 01154 NumberOfBytes - Supplies the number of bytes to allocate. 01155 01156 Return Value: 01157 01158 NULL - The PoolType is not one of the "MustSucceed" pool types, and 01159 not enough pool exists to satisfy the request. 01160 01161 NON-NULL - Returns a pointer to the allocated pool. 01162 01163 --*/ 01164 01165 { 01166 PVOID Block; 01167 PPOOL_HEADER Entry; 01168 PNPAGED_LOOKASIDE_LIST LookasideList; 01169 PPOOL_HEADER NextEntry; 01170 PPOOL_HEADER SplitEntry; 01171 KIRQL LockHandle; 01172 PPOOL_DESCRIPTOR PoolDesc; 01173 ULONG Index; 01174 ULONG ListNumber; 01175 ULONG NeededSize; 01176 ULONG PoolIndex; 01177 POOL_TYPE CheckType; 01178 POOL_TYPE RequestType; 01179 PLIST_ENTRY ListHead; 01180 POOL_TYPE NewPoolType; 01181 LOGICAL GlobalSpace; 01182 ULONG IsLargeSessionAllocation; 01183 PKPRCB Prcb; 01184 ULONG NumberOfPages; 01185 PVOID CallingAddress; 01186 PVOID CallersCaller; 01187 01188 #if POOL_CACHE_SUPPORTED 01189 ULONG CacheOverhead; 01190 #else 01191 #define CacheOverhead POOL_OVERHEAD 01192 #endif 01193 01194 PERFINFO_EXALLOCATEPOOLWITHTAG_DECL(); 01195 01196 #ifdef _NTOSKRNL_VERIFIER_ 01197 01198 if (KernelVerifier == TRUE) { 01199 #if defined (_X86_) 01200 RtlGetCallersAddress(&CallingAddress, &CallersCaller); 01201 #else 01202 CallingAddress = (PVOID)_ReturnAddress(); 01203 #endif 01204 01205 ASSERT(NumberOfBytes != 0); 01206 ASSERT_ALLOCATE_IRQL(PoolType, NumberOfBytes); 01207 01208 if ((PoolType & POOL_DRIVER_MASK) == 0) { 01209 01210 // 01211 // Use the Driver Verifier pool framework. Note this will 01212 // result in a recursive callback to this routine. 01213 // 01214 01215 return VeAllocatePoolWithTagPriority (PoolType | POOL_DRIVER_MASK, 01216 NumberOfBytes, 01217 Tag, 01218 HighPoolPriority, 01219 CallingAddress); 01220 } 01221 PoolType &= ~POOL_DRIVER_MASK; 01222 } 01223 01224 #else 01225 01226 ASSERT(NumberOfBytes != 0); 01227 ASSERT_ALLOCATE_IRQL(PoolType, NumberOfBytes); 01228 01229 #endif 01230 01231 // 01232 // Isolate the base pool type and select a pool from which to allocate 01233 // the specified block size. 01234 // 01235 01236 CheckType = PoolType & BASE_POOL_TYPE_MASK; 01237 01238 // 01239 // Currently only Hydra paged pool allocations come from the per session 01240 // pools. Nonpaged Hydra pool allocations still come from global pool. 01241 // 01242 01243 if (PoolType & SESSION_POOL_MASK) { 01244 if (ExpSessionPoolDescriptor == NULL) { 01245 01246 // 01247 // Promote this down to support common binaries. 01248 // 01249 01250 PoolType &= ~SESSION_POOL_MASK; 01251 PoolDesc = PoolVector[CheckType]; 01252 GlobalSpace = TRUE; 01253 } 01254 else { 01255 GlobalSpace = FALSE; 01256 if (CheckType == NonPagedPool) { 01257 PoolDesc = PoolVector[CheckType]; 01258 } 01259 else { 01260 PoolDesc = ExpSessionPoolDescriptor; 01261 } 01262 } 01263 } 01264 else { 01265 PoolDesc = PoolVector[CheckType]; 01266 GlobalSpace = TRUE; 01267 } 01268 01269 // 01270 // Check to determine if the requested block can be allocated from one 01271 // of the pool lists or must be directly allocated from virtual memory. 01272 // 01273 01274 if (NumberOfBytes > POOL_BUDDY_MAX) { 01275 01276 // 01277 // The requested size is greater than the largest block maintained 01278 // by allocation lists. 01279 // 01280 01281 ASSERT ((NumberOfBytes <= PAGE_SIZE) || 01282 (ExpPagedPoolDescriptor == (PPOOL_DESCRIPTOR)0) || 01283 ((PoolType & MUST_SUCCEED_POOL_TYPE_MASK) == 0)); 01284 01285 LOCK_POOL(PoolDesc, LockHandle); 01286 01287 PoolDesc->RunningAllocs += 1; 01288 01289 IsLargeSessionAllocation = (PoolType & SESSION_POOL_MASK); 01290 01291 RequestType = (PoolType & (BASE_POOL_TYPE_MASK | SESSION_POOL_MASK | POOL_VERIFIER_MASK)); 01292 01293 RetryWithMustSucceed: 01294 Entry = (PPOOL_HEADER) MiAllocatePoolPages (RequestType, 01295 NumberOfBytes, 01296 IsLargeSessionAllocation); 01297 01298 // 01299 // Large session pool allocations are accounted for directly by 01300 // the memory manager so no need to call MiSessionPoolAllocated here. 01301 // 01302 01303 if (Entry != NULL) { 01304 01305 NumberOfPages = BYTES_TO_PAGES(NumberOfBytes); 01306 PoolDesc->TotalBigPages += NumberOfPages; 01307 01308 UNLOCK_POOL(PoolDesc, LockHandle); 01309 01310 if ((PoolBigPageTable) && (IsLargeSessionAllocation == 0)) { 01311 01312 if (ExpAddTagForBigPages((PVOID)Entry, 01313 Tag, 01314 NumberOfPages) == FALSE) { 01315 Tag = ' GIB'; 01316 } 01317 01318 ExpInsertPoolTracker (Tag, 01319 (ULONG) ROUND_TO_PAGES(NumberOfBytes), 01320 PoolType); 01321 } 01322 01323 } else { 01324 if (PoolType & MUST_SUCCEED_POOL_TYPE_MASK) { 01325 RequestType |= MUST_SUCCEED_POOL_TYPE_MASK; 01326 goto RetryWithMustSucceed; 01327 } 01328 01329 UNLOCK_POOL(PoolDesc, LockHandle); 01330 01331 KdPrint(("EX: ExAllocatePool (%p, 0x%x ) returning NULL\n", 01332 NumberOfBytes, 01333 PoolType)); 01334 01335 if ((PoolType & POOL_RAISE_IF_ALLOCATION_FAILURE) != 0) { 01336 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 01337 } 01338 } 01339 01340 PERFINFO_BIGPOOLALLOC(PoolType, Tag, NumberOfBytes, Entry); 01341 01342 return Entry; 01343 } 01344 01345 // 01346 // The requested size is less than or equal to the size of the 01347 // maximum block maintained by the allocation lists. 01348 // 01349 01350 PERFINFO_POOLALLOC(PoolType, Tag, NumberOfBytes); 01351 01352 // 01353 // Check for a special pool tag match by actual tag. 01354 // 01355 01356 if (MmSpecialPoolTag != 0 && NumberOfBytes != 0) { 01357 01358 #ifndef NO_POOL_CHECKS 01359 Entry = MmSqueezeBadTags (NumberOfBytes, Tag, CheckType, 2); 01360 if (Entry != NULL) { 01361 return (PVOID)Entry; 01362 } 01363 #endif 01364 01365 // 01366 // Check for a special pool tag match by tag string and size ranges. 01367 // 01368 01369 if ((ExpCheckSingleFilter(Tag, MmSpecialPoolTag)) || 01370 ((MmSpecialPoolTag >= (NumberOfBytes + POOL_OVERHEAD)) && 01371 (MmSpecialPoolTag < (NumberOfBytes + POOL_OVERHEAD + POOL_SMALLEST_BLOCK)))) { 01372 01373 Entry = MmAllocateSpecialPool (NumberOfBytes, 01374 Tag, 01375 PoolType & (BASE_POOL_TYPE_MASK | POOL_VERIFIER_MASK), 01376 2); 01377 if (Entry != NULL) { 01378 return (PVOID)Entry; 01379 } 01380 } 01381 } 01382 01383 // 01384 // If the request is for cache aligned memory adjust the number of 01385 // bytes. 01386 // 01387 01388 #if POOL_CACHE_SUPPORTED 01389 01390 CacheOverhead = POOL_OVERHEAD; 01391 if (PoolType & CACHE_ALIGNED_POOL_TYPE_MASK) { 01392 NumberOfBytes += PoolCacheOverhead; 01393 CacheOverhead = PoolCacheSize; 01394 } 01395 01396 #endif //POOL_CACHE_SUPPORTED 01397 01398 // 01399 // Compute the Index of the listhead for blocks of the requested 01400 // size. 01401 // 01402 01403 ListNumber = (ULONG)((NumberOfBytes + POOL_OVERHEAD + (POOL_SMALLEST_BLOCK - 1)) >> POOL_BLOCK_SHIFT); 01404 01405 NeededSize = ListNumber; 01406 01407 // 01408 // If the pool type is paged, then pick a starting pool number and 01409 // attempt to lock each paged pool in circular succession. Otherwise, 01410 // lock the nonpaged pool as the same lock is used for both nonpaged 01411 // and nonpaged must succeed. 01412 // 01413 // N.B. The paged pool is selected in a round robin fashion using a 01414 // simple counter. Note that the counter is incremented using a 01415 // a noninterlocked sequence, but the pool index is never allowed 01416 // to get out of range. 01417 // 01418 01419 if (CheckType == PagedPool) { 01420 01421 // 01422 // If the requested pool block is a small block, then attempt to 01423 // allocate the requested pool from the per processor lookaside 01424 // list. If the attempt fails, then attempt to allocate from the 01425 // system lookaside list. If the attempt fails, then select a 01426 // pool to allocate from and allocate the block normally. 01427 // 01428 // Session space allocations do not currently use lookaside lists. 01429 // 01430 01431 if ((GlobalSpace == TRUE) && 01432 (NeededSize <= POOL_SMALL_LISTS) && 01433 (Isx86FeaturePresent(KF_CMPXCHG8B))) { 01434 01435 Prcb = KeGetCurrentPrcb(); 01436 LookasideList = Prcb->PPPagedLookasideList[NeededSize - 1].P; 01437 LookasideList->L.TotalAllocates += 1; 01438 01439 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, Entry); 01440 01441 Entry = (PPOOL_HEADER) 01442 ExInterlockedPopEntrySList (&LookasideList->L.ListHead, 01443 &LookasideList->Lock); 01444 01445 if (Entry == NULL) { 01446 LookasideList = Prcb->PPPagedLookasideList[NeededSize - 1].L; 01447 LookasideList->L.TotalAllocates += 1; 01448 01449 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, Entry); 01450 01451 Entry = (PPOOL_HEADER) 01452 ExInterlockedPopEntrySList (&LookasideList->L.ListHead, 01453 &LookasideList->Lock); 01454 } 01455 01456 if (Entry != NULL) { 01457 01458 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, Entry); 01459 01460 Entry -= 1; 01461 LookasideList->L.AllocateHits += 1; 01462 NewPoolType = (PoolType & (BASE_POOL_TYPE_MASK | POOL_QUOTA_MASK | SESSION_POOL_MASK | POOL_VERIFIER_MASK)) + 1; 01463 01464 #if _POOL_LOCK_GRANULAR_ 01465 PoolDesc = &PoolDesc[DECODE_POOL_INDEX(Entry)]; 01466 #endif 01467 01468 LOCK_POOL_GRANULAR(PoolDesc, LockHandle); 01469 01470 Entry->PoolType = (UCHAR)NewPoolType; 01471 MARK_POOL_HEADER_ALLOCATED(Entry); 01472 01473 UNLOCK_POOL_GRANULAR(PoolDesc, LockHandle); 01474 01475 Entry->PoolTag = Tag; 01476 01477 if ((PoolTrackTable != NULL) && 01478 ((PoolType & SESSION_POOL_MASK) == 0)) { 01479 01480 ExpInsertPoolTracker (Tag, 01481 Entry->BlockSize << POOL_BLOCK_SHIFT, 01482 PoolType); 01483 } 01484 01485 // 01486 // Zero out any back pointer to our internal structures 01487 // to stop someone from corrupting us via an 01488 // uninitialized pointer. 01489 // 01490 01491 ((PULONG)((PCHAR)Entry + CacheOverhead))[0] = 0; 01492 01493 PERFINFO_POOLALLOC_ADDR((PUCHAR)Entry + CacheOverhead); 01494 01495 return (PUCHAR)Entry + CacheOverhead; 01496 } 01497 } 01498 01499 // 01500 // If there is more than one paged pool, then attempt to find 01501 // one that can be immediately locked. 01502 // 01503 01504 if (GlobalSpace == TRUE) { 01505 01506 PVOID Lock; 01507 01508 PoolIndex = 1; 01509 if (ExpNumberOfPagedPools != PoolIndex) { 01510 ExpPoolIndex += 1; 01511 PoolIndex = ExpPoolIndex; 01512 if (PoolIndex > ExpNumberOfPagedPools) { 01513 PoolIndex = 1; 01514 ExpPoolIndex = 1; 01515 } 01516 01517 Index = PoolIndex; 01518 do { 01519 Lock = PoolDesc[PoolIndex].LockAddress; 01520 if (ExTryToAcquireFastMutex((PFAST_MUTEX)Lock) == TRUE) { 01521 PoolDesc = &PoolDesc[PoolIndex]; 01522 goto PoolLocked; 01523 } 01524 01525 PoolIndex += 1; 01526 if (PoolIndex > ExpNumberOfPagedPools) { 01527 PoolIndex = 1; 01528 } 01529 01530 } while (PoolIndex != Index); 01531 } 01532 PoolDesc = &PoolDesc[PoolIndex]; 01533 } 01534 else { 01535 01536 // 01537 // Only one paged pool is currently available per session. 01538 // 01539 01540 PoolIndex = 0; 01541 ASSERT (PoolDesc == ExpSessionPoolDescriptor); 01542 } 01543 01544 // 01545 // None of the paged pools could be conditionally locked or there 01546 // is only one paged pool. The first pool considered is picked as 01547 // the victim to wait on. 01548 // 01549 01550 ExAcquireFastMutex((PFAST_MUTEX)PoolDesc->LockAddress); 01551 PoolLocked: 01552 01553 GlobalSpace = GlobalSpace; 01554 #if DBG 01555 if (GlobalSpace == TRUE) { 01556 ASSERT(PoolIndex == PoolDesc->PoolIndex); 01557 } 01558 else { 01559 ASSERT(PoolIndex == 0); 01560 ASSERT(PoolDesc->PoolIndex == 0); 01561 } 01562 #endif 01563 01564 } else { 01565 01566 // 01567 // If the requested pool block is a small block, then attempt to 01568 // allocate the requested pool from the per processor lookaside 01569 // list. If the attempt fails, then attempt to allocate from the 01570 // system lookaside list. If the attempt fails, then select a 01571 // pool to allocate from and allocate the block normally. 01572 // 01573 01574 if (GlobalSpace == TRUE && NeededSize <= POOL_SMALL_LISTS) { 01575 Prcb = KeGetCurrentPrcb(); 01576 LookasideList = Prcb->PPNPagedLookasideList[NeededSize - 1].P; 01577 LookasideList->L.TotalAllocates += 1; 01578 01579 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, 0); 01580 01581 Entry = (PPOOL_HEADER) 01582 ExInterlockedPopEntrySList (&LookasideList->L.ListHead, 01583 &LookasideList->Lock); 01584 01585 if (Entry == NULL) { 01586 LookasideList = Prcb->PPNPagedLookasideList[NeededSize - 1].L; 01587 LookasideList->L.TotalAllocates += 1; 01588 01589 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, 0); 01590 01591 Entry = (PPOOL_HEADER) 01592 ExInterlockedPopEntrySList (&LookasideList->L.ListHead, 01593 &LookasideList->Lock); 01594 } 01595 01596 if (Entry != NULL) { 01597 01598 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, Entry); 01599 01600 Entry -= 1; 01601 LookasideList->L.AllocateHits += 1; 01602 NewPoolType = (PoolType & (BASE_POOL_TYPE_MASK | POOL_QUOTA_MASK | SESSION_POOL_MASK | POOL_VERIFIER_MASK)) + 1; 01603 01604 LOCK_POOL_GRANULAR(PoolDesc, LockHandle); 01605 01606 Entry->PoolType = (UCHAR)NewPoolType; 01607 MARK_POOL_HEADER_ALLOCATED(Entry); 01608 01609 UNLOCK_POOL_GRANULAR(PoolDesc, LockHandle); 01610 01611 Entry->PoolTag = Tag; 01612 01613 if (PoolTrackTable != NULL) { 01614 01615 ExpInsertPoolTracker (Tag, 01616 Entry->BlockSize << POOL_BLOCK_SHIFT, 01617 PoolType); 01618 } 01619 01620 // 01621 // Zero out any back pointer to our internal structures 01622 // to stop someone from corrupting us via an 01623 // uninitialized pointer. 01624 // 01625 01626 ((PULONG)((PCHAR)Entry + CacheOverhead))[0] = 0; 01627 01628 PERFINFO_POOLALLOC_ADDR((PUCHAR)Entry + CacheOverhead); 01629 01630 return (PUCHAR)Entry + CacheOverhead; 01631 } 01632 } 01633 01634 PoolIndex = 0; 01635 ExAcquireSpinLock(&NonPagedPoolLock, &LockHandle); 01636 01637 ASSERT(PoolIndex == PoolDesc->PoolIndex); 01638 } 01639 01640 // 01641 // The following code has an outer loop and an inner loop. 01642 // 01643 // The outer loop is utilized to repeat a nonpaged must succeed 01644 // allocation if necessary. 01645 // 01646 // The inner loop is used to repeat an allocation attempt if there 01647 // are no entries in any of the pool lists. 01648 // 01649 01650 RequestType = PoolType & (BASE_POOL_TYPE_MASK | SESSION_POOL_MASK); 01651 01652 PoolDesc->RunningAllocs += 1; 01653 ListHead = &PoolDesc->ListHeads[ListNumber]; 01654 01655 do { 01656 01657 // 01658 // Attempt to allocate the requested block from the current free 01659 // blocks. 01660 // 01661 01662 do { 01663 01664 // 01665 // If the list is not empty, then allocate a block from the 01666 // selected list. 01667 // 01668 01669 if (PrivateIsListEmpty(ListHead) == FALSE) { 01670 01671 CHECK_LIST( __LINE__, ListHead, 0 ); 01672 Block = PrivateRemoveHeadList(ListHead); 01673 CHECK_LIST( __LINE__, ListHead, 0 ); 01674 Entry = (PPOOL_HEADER)((PCHAR)Block - POOL_OVERHEAD); 01675 01676 ASSERT(Entry->BlockSize >= NeededSize); 01677 01678 ASSERT(DECODE_POOL_INDEX(Entry) == PoolIndex); 01679 01680 ASSERT(Entry->PoolType == 0); 01681 01682 if (Entry->BlockSize != NeededSize) { 01683 01684 // 01685 // The selected block is larger than the allocation 01686 // request. Split the block and insert the remaining 01687 // fragment in the appropriate list. 01688 // 01689 // If the entry is at the start of a page, then take 01690 // the allocation from the front of the block so as 01691 // to minimize fragmentation. Otherwise, take the 01692 // allocation from the end of the block which may 01693 // also reduce fragmentation if the block is at the 01694 // end of a page. 01695 // 01696 01697 if (Entry->PreviousSize == 0) { 01698 01699 // 01700 // The entry is at the start of a page. 01701 // 01702 01703 SplitEntry = (PPOOL_HEADER)((PPOOL_BLOCK)Entry + NeededSize); 01704 SplitEntry->BlockSize = (UCHAR)(Entry->BlockSize - (UCHAR)NeededSize); 01705 SplitEntry->PreviousSize = (UCHAR)NeededSize; 01706 01707 // 01708 // If the allocated block is not at the end of a 01709 // page, then adjust the size of the next block. 01710 // 01711 01712 NextEntry = (PPOOL_HEADER)((PPOOL_BLOCK)SplitEntry + SplitEntry->BlockSize); 01713 if (PAGE_END(NextEntry) == FALSE) { 01714 NextEntry->PreviousSize = SplitEntry->BlockSize; 01715 } 01716 01717 } else { 01718 01719 // 01720 // The entry is not at the start of a page. 01721 // 01722 01723 SplitEntry = Entry; 01724 Entry->BlockSize -= (UCHAR)NeededSize; 01725 Entry = (PPOOL_HEADER)((PPOOL_BLOCK)Entry + Entry->BlockSize); 01726 Entry->PreviousSize = SplitEntry->BlockSize; 01727 01728 // 01729 // If the allocated block is not at the end of a 01730 // page, then adjust the size of the next block. 01731 // 01732 01733 NextEntry = (PPOOL_HEADER)((PPOOL_BLOCK)Entry + NeededSize); 01734 if (PAGE_END(NextEntry) == FALSE) { 01735 NextEntry->PreviousSize = (UCHAR)NeededSize; 01736 } 01737 } 01738 01739 // 01740 // Set the size of the allocated entry, clear the pool 01741 // type of the split entry, set the index of the split 01742 // entry, and insert the split entry in the appropriate 01743 // free list. 01744 // 01745 01746 Entry->BlockSize = (UCHAR)NeededSize; 01747 ENCODE_POOL_INDEX(Entry, PoolIndex); 01748 SplitEntry->PoolType = 0; 01749 ENCODE_POOL_INDEX(SplitEntry, PoolIndex); 01750 Index = SplitEntry->BlockSize; 01751 01752 CHECK_LIST(__LINE__, &PoolDesc->ListHeads[Index - 1], 0); 01753 PrivateInsertTailList(&PoolDesc->ListHeads[Index - 1], ((PLIST_ENTRY)((PCHAR)SplitEntry + POOL_OVERHEAD))); 01754 CHECK_LIST(__LINE__, &PoolDesc->ListHeads[Index - 1], 0); 01755 CHECK_LIST(__LINE__, ((PLIST_ENTRY)((PCHAR)SplitEntry + POOL_OVERHEAD)), 0); 01756 } 01757 01758 Entry->PoolType = (UCHAR)((PoolType & (BASE_POOL_TYPE_MASK | POOL_QUOTA_MASK | SESSION_POOL_MASK | POOL_VERIFIER_MASK)) + 1); 01759 01760 MARK_POOL_HEADER_ALLOCATED(Entry); 01761 01762 CHECK_POOL_HEADER(__LINE__, Entry); 01763 01764 // 01765 // Notify the memory manager of session pool allocations 01766 // so leaked allocations can be caught on session exit. 01767 // This call must be made with the relevant pool locked. 01768 // 01769 01770 if (PoolType & SESSION_POOL_MASK) { 01771 MiSessionPoolAllocated( 01772 (PVOID)((PCHAR)Entry + CacheOverhead), 01773 (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT), 01774 PoolType); 01775 } 01776 01777 UNLOCK_POOL(PoolDesc, LockHandle); 01778 01779 Entry->PoolTag = Tag; 01780 01781 if ((PoolTrackTable != NULL) && 01782 ((PoolType & SESSION_POOL_MASK) == 0)) { 01783 01784 ExpInsertPoolTracker (Tag, 01785 Entry->BlockSize << POOL_BLOCK_SHIFT, 01786 PoolType); 01787 } 01788 01789 // 01790 // Zero out any back pointer to our internal structures 01791 // to stop someone from corrupting us via an 01792 // uninitialized pointer. 01793 // 01794 01795 ((PULONGLONG)((PCHAR)Entry + CacheOverhead))[0] = 0; 01796 01797 PERFINFO_POOLALLOC_ADDR((PUCHAR)Entry + CacheOverhead); 01798 return (PCHAR)Entry + CacheOverhead; 01799 01800 } 01801 ListHead += 1; 01802 01803 } while (ListHead != &PoolDesc->ListHeads[POOL_LIST_HEADS]); 01804 01805 // 01806 // A block of the desired size does not exist and there are 01807 // no large blocks that can be split to satisfy the allocation. 01808 // Attempt to expand the pool by allocating another page to be 01809 // added to the pool. 01810 // 01811 // If the pool type is paged pool, then the paged pool page lock 01812 // must be held during the allocation of the pool pages. 01813 // 01814 01815 LOCK_IF_PAGED_POOL(CheckType, GlobalSpace); 01816 01817 Entry = (PPOOL_HEADER)MiAllocatePoolPages (RequestType, 01818 PAGE_SIZE, 01819 FALSE); 01820 01821 UNLOCK_IF_PAGED_POOL(CheckType, GlobalSpace); 01822 01823 if (Entry == NULL) { 01824 if ((PoolType & MUST_SUCCEED_POOL_TYPE_MASK) != 0) { 01825 01826 // 01827 // Must succeed pool was requested. Reset the type, 01828 // the pool descriptor address, and continue the search. 01829 // 01830 01831 CheckType = NonPagedPoolMustSucceed; 01832 RequestType = RequestType | MUST_SUCCEED_POOL_TYPE_MASK; 01833 PoolDesc = PoolVector[NonPagedPoolMustSucceed]; 01834 ListHead = &PoolDesc->ListHeads[ListNumber]; 01835 continue; 01836 01837 } else { 01838 01839 // 01840 // No more pool of the specified type is available. 01841 // 01842 01843 KdPrint(("EX: ExAllocatePool (%p, 0x%x ) returning NULL\n", 01844 NumberOfBytes, 01845 PoolType)); 01846 01847 UNLOCK_POOL(PoolDesc, LockHandle); 01848 01849 if ((PoolType & POOL_RAISE_IF_ALLOCATION_FAILURE) != 0) { 01850 ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES); 01851 } 01852 01853 return NULL; 01854 } 01855 } 01856 01857 // 01858 // Insert the allocated page in the last allocation list. 01859 // 01860 01861 PoolDesc->TotalPages += 1; 01862 Entry->PoolType = 0; 01863 ENCODE_POOL_INDEX(Entry, PoolIndex); 01864 01865 PERFINFO_ADDPOOLPAGE(CheckType, PoolIndex, Entry, PoolDesc); 01866 01867 // 01868 // N.B. A byte is used to store the block size in units of the 01869 // smallest block size. Therefore, if the number of small 01870 // blocks in the page is greater than 255, the block size 01871 // is set to 255. 01872 // 01873 01874 if ((PAGE_SIZE / POOL_SMALLEST_BLOCK) > 255) { 01875 Entry->BlockSize = 255; 01876 01877 } else { 01878 Entry->BlockSize = (UCHAR)(PAGE_SIZE / POOL_SMALLEST_BLOCK); 01879 } 01880 01881 Entry->PreviousSize = 0; 01882 ListHead = &PoolDesc->ListHeads[POOL_LIST_HEADS - 1]; 01883 01884 CHECK_LIST(__LINE__, ListHead, 0); 01885 PrivateInsertHeadList(ListHead, ((PLIST_ENTRY)((PCHAR)Entry + POOL_OVERHEAD))); 01886 CHECK_LIST(__LINE__, ListHead, 0); 01887 CHECK_LIST(__LINE__, ((PLIST_ENTRY)((PCHAR)Entry + POOL_OVERHEAD)), 0); 01888 01889 } while (TRUE); 01890 }

NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTagPriority IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes,
IN ULONG  Tag,
IN EX_POOL_PRIORITY  Priority
 

Definition at line 993 of file ex/pool.c.

References BASE_POOL_TYPE_MASK, ExAllocatePoolWithTag, ExpSessionPoolDescriptor, FALSE, HighPoolPriority, MmAllocateSpecialPool(), MmResourcesAvailable(), MUST_SUCCEED_POOL_TYPE_MASK, NULL, POOL_BUDDY_MAX, POOL_SPECIAL_POOL_BIT, POOL_SPECIAL_POOL_UNDERRUN_BIT, POOL_VERIFIER_MASK, and SESSION_POOL_MASK.

Referenced by IovAllocateIrp(), IovpProtectedIrpAllocate(), VeAllocatePoolWithTagPriority(), VerifierAllocatePoolWithTagPriority(), and ViReservePoolAllocation().

01002 : 01003 01004 This function allocates a block of pool of the specified type and 01005 returns a pointer to the allocated block. This function is used to 01006 access both the page-aligned pools, and the list head entries (less than 01007 a page) pools. 01008 01009 If the number of bytes specifies a size that is too large to be 01010 satisfied by the appropriate list, then the page-aligned 01011 pool allocator is used. The allocated block will be page-aligned 01012 and a page-sized multiple. 01013 01014 Otherwise, the appropriate pool list entry is used. The allocated 01015 block will be 64-bit aligned, but will not be page aligned. The 01016 pool allocator calculates the smallest number of POOL_BLOCK_SIZE 01017 that can be used to satisfy the request. If there are no blocks 01018 available of this size, then a block of the next larger block size 01019 is allocated and split. One piece is placed back into the pool, and 01020 the other piece is used to satisfy the request. If the allocator 01021 reaches the paged-sized block list, and nothing is there, the 01022 page-aligned pool allocator is called. The page is split and added 01023 to the pool... 01024 01025 Arguments: 01026 01027 PoolType - Supplies the type of pool to allocate. If the pool type 01028 is one of the "MustSucceed" pool types, then this call will 01029 always succeed and return a pointer to allocated pool. 01030 Otherwise, if the system cannot allocate the requested amount 01031 of memory a NULL is returned. 01032 01033 Valid pool types: 01034 01035 NonPagedPool 01036 PagedPool 01037 NonPagedPoolMustSucceed, 01038 NonPagedPoolCacheAligned 01039 PagedPoolCacheAligned 01040 NonPagedPoolCacheAlignedMustS 01041 01042 NumberOfBytes - Supplies the number of bytes to allocate. 01043 01044 Tag - Supplies the caller's identifying tag. 01045 01046 Priority - Supplies an indication as to how important it is that this 01047 request succeed under low available pool conditions. This 01048 can also be used to specify special pool. 01049 01050 Return Value: 01051 01052 NULL - The PoolType is not one of the "MustSucceed" pool types, and 01053 not enough pool exists to satisfy the request. 01054 01055 NON-NULL - Returns a pointer to the allocated pool. 01056 01057 --*/ 01058 01059 { 01060 PVOID Entry; 01061 01062 if ((Priority & POOL_SPECIAL_POOL_BIT) && (NumberOfBytes <= POOL_BUDDY_MAX)) { 01063 Entry = MmAllocateSpecialPool (NumberOfBytes, 01064 Tag, 01065 PoolType & (BASE_POOL_TYPE_MASK | POOL_VERIFIER_MASK), 01066 (Priority & POOL_SPECIAL_POOL_UNDERRUN_BIT) ? 1 : 0); 01067 01068 if (Entry != NULL) { 01069 return Entry; 01070 } 01071 Priority &= ~(POOL_SPECIAL_POOL_BIT | POOL_SPECIAL_POOL_UNDERRUN_BIT); 01072 } 01073 01074 // 01075 // Pool and other resources can be allocated directly through the Mm 01076 // without the pool code knowing - so always call the Mm for the 01077 // up-to-date counters. 01078 // 01079 01080 if ((Priority != HighPoolPriority) && ((PoolType & MUST_SUCCEED_POOL_TYPE_MASK) == 0)) { 01081 01082 if (ExpSessionPoolDescriptor == NULL) { 01083 PoolType &= ~SESSION_POOL_MASK; 01084 } 01085 01086 if (MmResourcesAvailable (PoolType, NumberOfBytes, Priority) == FALSE) { 01087 return NULL; 01088 } 01089 } 01090 01091 // 01092 // There is a window between determining whether to proceed and actually 01093 // doing the allocation. In this window the pool may deplete. This is not 01094 // worth closing at this time. 01095 // 01096 01097 return ExAllocatePoolWithTag (PoolType, 01098 NumberOfBytes, 01099 Tag); 01100 }

NTKERNELAPI BOOLEAN ExChangeHandle IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle,
IN PEX_CHANGE_HANDLE_ROUTINE  ChangeRoutine,
IN ULONG_PTR  Parameter
 

Definition at line 1315 of file ex/handle.c.

References ExLockHandleTableEntry(), ExpLookupHandleTableEntry(), ExUnlockHandleTableEntry(), FALSE, _EXHANDLE::GenericHandleOverlay, Handle, KeEnterCriticalRegion, KeLeaveCriticalRegion, NULL, and PAGED_CODE.

Referenced by NtSetInformationObject(), PspCreateThread(), and PspExitThread().

01324 : 01325 01326 This function provides the capability to change the contents of the 01327 handle entry corrsponding to the specified handle. 01328 01329 Arguments: 01330 01331 HandleTable - Supplies a pointer to a handle table. 01332 01333 Handle - Supplies the handle for the handle entry that is changed. 01334 01335 ChangeRoutine - Supplies a pointer to a function that is called to 01336 perform the change. 01337 01338 Parameter - Supplies an uninterpreted parameter that is passed to 01339 the change routine. 01340 01341 Return Value: 01342 01343 If the operation was successfully performed, then a value of TRUE 01344 is returned. Otherwise, a value of FALSE is returned. 01345 01346 --*/ 01347 01348 { 01349 EXHANDLE LocalHandle; 01350 01351 PHANDLE_TABLE_ENTRY HandleTableEntry; 01352 BOOLEAN ReturnValue; 01353 01354 PAGED_CODE(); 01355 01356 LocalHandle.GenericHandleOverlay = Handle; 01357 01358 // 01359 // Translate the input handle to a handle table entry and make 01360 // sure it is a valid handle. 01361 // 01362 01363 HandleTableEntry = ExpLookupHandleTableEntry( HandleTable, 01364 LocalHandle ); 01365 01366 if (HandleTableEntry == NULL) { 01367 01368 return FALSE; 01369 } 01370 01371 // 01372 // Try and lock the handle table entry, If this fails then that's 01373 // because someone freed the handle 01374 // 01375 01376 if (!ExLockHandleTableEntry( HandleTable, HandleTableEntry )) { 01377 01378 return FALSE; 01379 } 01380 01381 // 01382 // Make sure we can't get suspended and then invoke the callback 01383 // 01384 01385 KeEnterCriticalRegion(); 01386 01387 try { 01388 01389 ReturnValue = (*ChangeRoutine)( HandleTableEntry, Parameter ); 01390 01391 } finally { 01392 01393 ExUnlockHandleTableEntry( HandleTable, HandleTableEntry ); 01394 KeLeaveCriticalRegion(); 01395 } 01396 01397 return ReturnValue; 01398 }

ULONG ExComputeTickCountMultiplier IN ULONG  TimeIncrement  ) 
 

NTKERNELAPI VOID ExConvertExclusiveToSharedLite IN PERESOURCE  Resource  ) 
 

Definition at line 1942 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, FALSE, _ERESOURCE::Flag, IsOwnedExclusive, IsSharedWaiting, KeReleaseSemaphore(), _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, ResourceOwnedExclusive, _ERESOURCE::SharedWaiters, SHORT, and _ERESOURCE::SpinLock.

01948 : 01949 01950 This routine converts the specified resource from acquired for exclusive 01951 access to acquired for shared access. 01952 01953 N.B. This routine uses fast locking. 01954 01955 Arguments: 01956 01957 Resource - Supplies a pointer to the resource to acquire for shared access. it 01958 01959 Return Value: 01960 01961 None. 01962 01963 --*/ 01964 01965 { 01966 01967 ULONG Number; 01968 KIRQL OldIrql; 01969 01970 // 01971 // Acquire exclusive access to the specified resource. 01972 // 01973 01974 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 01975 01976 ASSERT(KeIsExecutingDpc() == FALSE); 01977 ASSERT_RESOURCE(Resource); 01978 ASSERT(IsOwnedExclusive(Resource)); 01979 ASSERT(Resource->OwnerThreads[0].OwnerThread == (ERESOURCE_THREAD)PsGetCurrentThread()); 01980 01981 // 01982 // Convert the granted access from exclusive to shared. 01983 // 01984 01985 Resource->Flag &= ~ResourceOwnedExclusive; 01986 01987 // 01988 // If there are any shared waiters, then grant them shared access. 01989 // 01990 01991 if (IsSharedWaiting(Resource)) { 01992 Number = Resource->NumberOfSharedWaiters; 01993 Resource->ActiveCount += (SHORT)Number; 01994 Resource->NumberOfSharedWaiters = 0; 01995 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01996 KeReleaseSemaphore(Resource->SharedWaiters, 0, Number, FALSE); 01997 return; 01998 } 01999 02000 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 02001 return; 02002 }

NTKERNELAPI NTSTATUS ExCreateCallback OUT PCALLBACK_OBJECT CallbackObject,
IN POBJECT_ATTRIBUTES  ObjectAttributes,
IN BOOLEAN  Create,
IN BOOLEAN  AllowMultipleCallbacks
 

Definition at line 222 of file ex/callback.c.

References Create(), ExCallbackObjectType, Handle, KeInitializeSpinLock(), KernelMode, NT_SUCCESS, NTSTATUS(), NULL, ObCreateObject(), ObInsertObject(), ObjectAttributes, ObOpenObjectByName(), ObReferenceObjectByHandle(), PAGED_CODE, PCALLBACK_OBJECT, and Status.

Referenced by ExpInitializeCallbacks().

00231 : 00232 00233 This function opens a callback object with the specified callback 00234 object. If the callback object does not exist or it is a NULL then 00235 a callback object will be created if create is TRUE. If a callbackobject 00236 is created it will only support mulitiple registered callbacks if 00237 AllowMulitipleCallbacks is TRUE. 00238 00239 Arguments: 00240 00241 CallbackObject - Supplies a pointer to a variable that will receive the 00242 Callback object. 00243 00244 CallbackName - Supplies a pointer to a object name that will receive the 00245 00246 Create - Supplies a flag which indicates whether a callback object will 00247 be created or not . 00248 00249 AllowMultipleCallbacks - Supplies a flag which indicates only support 00250 mulitiple registered callbacks. 00251 00252 Return Value: 00253 00254 Returns STATUS_SUCESS unless fali... 00255 00256 --*/ 00257 00258 { 00259 PCALLBACK_OBJECT cbObject; 00260 NTSTATUS Status; 00261 HANDLE Handle; 00262 00263 PAGED_CODE(); 00264 00265 // 00266 // If named callback, open handle to it 00267 // 00268 00269 if (ObjectAttributes->ObjectName) { 00270 Status = ObOpenObjectByName(ObjectAttributes, 00271 ExCallbackObjectType, 00272 KernelMode, 00273 NULL, 00274 0, // DesiredAccess, 00275 NULL, 00276 &Handle); 00277 } else { 00278 Status = STATUS_UNSUCCESSFUL; 00279 } 00280 00281 // 00282 // If not opened, check if callback should be created 00283 // 00284 00285 if(!NT_SUCCESS(Status) && Create ) { 00286 Status = ObCreateObject(KernelMode, 00287 ExCallbackObjectType, 00288 ObjectAttributes, 00289 KernelMode, 00290 NULL, 00291 sizeof(CALLBACK_OBJECT), 00292 0, 00293 0, 00294 (PVOID *)&cbObject ); 00295 00296 if(NT_SUCCESS(Status)){ 00297 00298 // 00299 // Fill in structure signature 00300 // 00301 00302 cbObject->Signature = 'llaC'; 00303 00304 // 00305 // It will support multiple registered callbacks if 00306 // AllowMultipleCallbacks is TRUE. 00307 // 00308 00309 cbObject->AllowMultipleCallbacks = AllowMultipleCallbacks; 00310 00311 // 00312 // Initialize CallbackObject queue. 00313 // 00314 00315 InitializeListHead( &cbObject->RegisteredCallbacks ); 00316 00317 // 00318 // Initialize spinlock 00319 // 00320 00321 KeInitializeSpinLock (&cbObject->Lock); 00322 00323 00324 // 00325 // Put the object in the root directory 00326 // 00327 00328 Status = ObInsertObject ( 00329 cbObject, 00330 NULL, 00331 FILE_READ_DATA, 00332 0, 00333 NULL, 00334 &Handle ); 00335 00336 } 00337 00338 } 00339 00340 if(NT_SUCCESS(Status)){ 00341 00342 // 00343 // Add one to callback object reference count 00344 // 00345 00346 Status = ObReferenceObjectByHandle ( 00347 Handle, 00348 0, // DesiredAccess 00349 ExCallbackObjectType, 00350 KernelMode, 00351 &cbObject, 00352 NULL 00353 ); 00354 00355 ZwClose (Handle); 00356 } 00357 00358 // 00359 // If SUCEESS , returns a referenced pointer to the CallbackObject. 00360 // 00361 00362 if (NT_SUCCESS(Status)) { 00363 *CallbackObject = cbObject; 00364 } 00365 00366 return Status; 00367 }

NTKERNELAPI PEX_DEBUG_LOG ExCreateDebugLog IN UCHAR  MaximumNumberOfTags,
IN ULONG  MaximumNumberOfEvents
 

Definition at line 30 of file logger.c.

References ExAllocatePoolWithTag, _EX_DEBUG_LOG::First, KeInitializeSpinLock(), _EX_DEBUG_LOG::Last, _EX_DEBUG_LOG::Lock, _EX_DEBUG_LOG::MaximumNumberOfTags, _EX_DEBUG_LOG::Next, NonPagedPool, NULL, Size, and _EX_DEBUG_LOG::Tags.

00034 { 00035 PEX_DEBUG_LOG Log; 00036 ULONG Size; 00037 00038 Size = sizeof( EX_DEBUG_LOG ) + 00039 (MaximumNumberOfTags * 00040 sizeof( EX_DEBUG_LOG_TAG ) 00041 ) + 00042 (MaximumNumberOfEvents * 00043 sizeof( EX_DEBUG_LOG_EVENT ) 00044 ); 00045 00046 00047 Log = ExAllocatePoolWithTag( NonPagedPool, Size, 'oLbD' ); 00048 if (Log != NULL) { 00049 RtlZeroMemory( Log, Size ); 00050 KeInitializeSpinLock( &Log->Lock ); 00051 Log->MaximumNumberOfTags = MaximumNumberOfTags; 00052 Log->Tags = (PEX_DEBUG_LOG_TAG)(Log + 1); 00053 Log->First = (PEX_DEBUG_LOG_EVENT)(Log->Tags + MaximumNumberOfTags); 00054 Log->Last = Log->First + MaximumNumberOfEvents; 00055 Log->Next = Log->First; 00056 } 00057 00058 return Log; 00059 }

NTKERNELAPI UCHAR ExCreateDebugLogTag IN PEX_DEBUG_LOG  Log,
IN PCHAR  Name,
IN UCHAR  Format1,
IN UCHAR  Format2,
IN UCHAR  Format3,
IN UCHAR  Format4
 

Definition at line 62 of file logger.c.

References ExAllocatePoolWithTag, ExFreePool(), _EX_DEBUG_LOG_TAG::Format, _EX_DEBUG_LOG_TAG::Name, Name, NonPagedPool, NULL, Size, and strlen().

00070 { 00071 KIRQL OldIrql; 00072 ULONG Size; 00073 PEX_DEBUG_LOG_TAG Tag; 00074 UCHAR TagIndex; 00075 PCHAR CapturedName; 00076 00077 Size = strlen( Name ); 00078 CapturedName = ExAllocatePoolWithTag( NonPagedPool, Size, 'oLbD' ); 00079 RtlMoveMemory( CapturedName, Name, Size + 1 ); 00080 00081 ExAcquireSpinLock( &Log->Lock, &OldIrql ); 00082 00083 if (Log->NumberOfTags < Log->MaximumNumberOfTags) { 00084 TagIndex = (UCHAR)(Log->NumberOfTags++); 00085 Tag = &Log->Tags[ TagIndex ]; 00086 Tag->Name = CapturedName; 00087 Tag->Format[ 0 ] = Format1; 00088 Tag->Format[ 1 ] = Format2; 00089 Tag->Format[ 2 ] = Format3; 00090 Tag->Format[ 3 ] = Format4; 00091 CapturedName = NULL; 00092 } 00093 else { 00094 TagIndex = (UCHAR)0xFF; 00095 } 00096 00097 ExReleaseSpinLock( &Log->Lock, OldIrql ); 00098 00099 if (CapturedName != NULL) { 00100 ExFreePool( CapturedName ); 00101 } 00102 return TagIndex; 00103 }

NTKERNELAPI HANDLE ExCreateHandle IN PHANDLE_TABLE  HandleTable,
IN PHANDLE_TABLE_ENTRY  HandleTableEntry
 

Definition at line 1144 of file ex/handle.c.

References ExLockHandleTableExclusive(), ExpAllocateHandleTableEntry(), ExUnlockHandleTableEntry(), ExUnlockHandleTableExclusive(), Handle, KeEnterCriticalRegion, KeLeaveCriticalRegion, NULL, and PAGED_CODE.

Referenced by DoHandleTest(), NtDuplicateObject(), ObpCreateHandle(), ObpCreateUnnamedHandle(), PspCreateThread(), and RtlpCreateHandleForAtom().

01151 : 01152 01153 This function creates a handle entry in the specified handle table and 01154 returns a handle for the entry. 01155 01156 Arguments: 01157 01158 HandleTable - Supplies a pointer to a handle table 01159 01160 HandleEntry - Supplies a poiner to the handle entry for which a 01161 handle entry is created. 01162 01163 Return Value: 01164 01165 If the handle entry is successfully created, then value of the created 01166 handle is returned as the function value. Otherwise, a value of zero is 01167 returned. 01168 01169 --*/ 01170 01171 { 01172 EXHANDLE Handle; 01173 PHANDLE_TABLE_ENTRY NewHandleTableEntry; 01174 01175 PAGED_CODE(); 01176 01177 // 01178 // Set out output variable to zero (i.e., null) before going on 01179 // 01180 01181 // 01182 // Clears Handle.Index and Handle.TagBits 01183 // 01184 01185 Handle.GenericHandleOverlay = NULL; 01186 01187 // 01188 // Lock the handle table for exclusive access 01189 // 01190 01191 KeEnterCriticalRegion(); 01192 ExLockHandleTableExclusive( HandleTable ); 01193 01194 try { 01195 01196 // 01197 // Allocate a new handle table entry, and get the handle value 01198 // 01199 01200 NewHandleTableEntry = ExpAllocateHandleTableEntry( HandleTable, 01201 &Handle ); 01202 01203 // 01204 // If we really got a handle then copy over the template and unlock 01205 // the entry 01206 // 01207 01208 if (NewHandleTableEntry != NULL) { 01209 01210 *NewHandleTableEntry = *HandleTableEntry; 01211 01212 ExUnlockHandleTableEntry( HandleTable, NewHandleTableEntry ); 01213 } 01214 01215 } finally { 01216 01217 ExUnlockHandleTableExclusive( HandleTable ); 01218 KeLeaveCriticalRegion(); 01219 } 01220 01221 return Handle.GenericHandleOverlay; 01222 }

NTKERNELAPI PHANDLE_TABLE ExCreateHandleTable IN struct _EPROCESS *Process  OPTIONAL  ) 
 

Definition at line 457 of file ex/handle.c.

References ExpAllocateHandleTable(), and PAGED_CODE.

Referenced by DoHandleTest(), ObInitProcess(), ObInitSystem(), PspInitPhase0(), and RtlpInitializeHandleTableForAtomTable().

00463 : 00464 00465 This function allocate and initialize a new new handle table 00466 00467 Arguments: 00468 00469 Process - Supplies an optional pointer to the process against which quota 00470 will be charged. 00471 00472 Return Value: 00473 00474 If a handle table is successfully created, then the address of the 00475 handle table is returned as the function value. Otherwize, a value 00476 NULL is returned. 00477 00478 --*/ 00479 00480 { 00481 PHANDLE_TABLE HandleTable; 00482 00483 PAGED_CODE(); 00484 00485 // 00486 // Allocate and initialize a handle table descriptor 00487 // 00488 00489 HandleTable = ExpAllocateHandleTable( Process ); 00490 00491 // 00492 // And return to our caller 00493 // 00494 00495 return HandleTable; 00496 }

NTKERNELAPI VOID ExDebugLogEvent IN PEX_DEBUG_LOG  Log,
IN UCHAR  Tag,
IN ULONG  Data1,
IN ULONG  Data2,
IN ULONG  Data3,
IN ULONG  Data4
 

Definition at line 106 of file logger.c.

References _ETHREAD::Cid, _EX_DEBUG_LOG_EVENT::Data, KeQuerySystemTime(), _EX_DEBUG_LOG_EVENT::ProcessId, PsGetCurrentThread, _EX_DEBUG_LOG_EVENT::Tag, _EX_DEBUG_LOG_EVENT::ThreadId, and _EX_DEBUG_LOG_EVENT::Time.

00114 { 00115 KIRQL OldIrql; 00116 PEX_DEBUG_LOG_EVENT p; 00117 PETHREAD Thread = PsGetCurrentThread(); 00118 LARGE_INTEGER CurrentTime; 00119 00120 KeQuerySystemTime( &CurrentTime ); 00121 00122 ExAcquireSpinLock( &Log->Lock, &OldIrql ); 00123 00124 p = Log->Next; 00125 if (p == Log->Last) { 00126 p = Log->First; 00127 } 00128 Log->Next = p + 1; 00129 00130 p->ThreadId = Thread->Cid.UniqueThread; 00131 p->ProcessId = Thread->Cid.UniqueProcess; 00132 p->Time = CurrentTime.LowPart; 00133 p->Tag = Tag; 00134 p->Data[ 0 ] = Data1; 00135 p->Data[ 1 ] = Data2; 00136 p->Data[ 2 ] = Data3; 00137 p->Data[ 3 ] = Data4; 00138 00139 ExReleaseSpinLock( &Log->Lock, OldIrql ); 00140 00141 return; 00142 }

NTKERNELAPI VOID ExDeleteNPagedLookasideList IN PNPAGED_LOOKASIDE_LIST  Lookaside  ) 
 

Definition at line 494 of file ex/lookasid.c.

References ExAllocateFromNPagedLookasideList(), ExNPagedLookasideLock, ExpDummyAllocate(), and NULL.

00500 : 00501 00502 This function removes a paged lookaside structure from the system paged 00503 lookaside list and frees any entries specified by the lookaside structure. 00504 00505 Arguments: 00506 00507 Lookaside - Supplies a pointer to a nonpaged lookaside list structure. 00508 00509 Return Value: 00510 00511 None. 00512 00513 --*/ 00514 00515 { 00516 00517 PVOID Entry; 00518 KIRQL OldIrql; 00519 00520 // 00521 // Acquire the nonpaged system lookaside list lock and remove the 00522 // specified lookaside list structure from the list. 00523 // 00524 00525 ExAcquireSpinLock(&ExNPagedLookasideLock, &OldIrql); 00526 RemoveEntryList(&Lookaside->L.ListEntry); 00527 ExReleaseSpinLock(&ExNPagedLookasideLock, OldIrql); 00528 00529 // 00530 // Remove all pool entries from the specified lookaside structure 00531 // and free them. 00532 // 00533 00534 Lookaside->L.Allocate = ExpDummyAllocate; 00535 while ((Entry = ExAllocateFromNPagedLookasideList(Lookaside)) != NULL) { 00536 (Lookaside->L.Free)(Entry); 00537 } 00538 00539 return; 00540 }

NTKERNELAPI VOID ExDeletePagedLookasideList IN PPAGED_LOOKASIDE_LIST  Lookaside  ) 
 

Definition at line 629 of file ex/lookasid.c.

References ExAllocateFromPagedLookasideList(), ExPagedLookasideLock, ExpDummyAllocate(), and NULL.

Referenced by FreeCachedQueues(), and Win32kNtUserCleanup().

00635 : 00636 00637 This function removes a paged lookaside structure from the system paged 00638 lookaside list and frees any entries specified by the lookaside structure. 00639 00640 Arguments: 00641 00642 Lookaside - Supplies a pointer to a paged lookaside list structure. 00643 00644 Return Value: 00645 00646 None. 00647 00648 --*/ 00649 00650 { 00651 00652 PVOID Entry; 00653 KIRQL OldIrql; 00654 00655 // 00656 // Acquire the paged system lookaside list lock and remove the 00657 // specified lookaside list structure from the list. 00658 // 00659 00660 ExAcquireSpinLock(&ExPagedLookasideLock, &OldIrql); 00661 RemoveEntryList(&Lookaside->L.ListEntry); 00662 ExReleaseSpinLock(&ExPagedLookasideLock, OldIrql); 00663 00664 // 00665 // Remove all pool entries from the specified lookaside structure 00666 // and free them. 00667 // 00668 00669 Lookaside->L.Allocate = ExpDummyAllocate; 00670 while ((Entry = ExAllocateFromPagedLookasideList(Lookaside)) != NULL) { 00671 (Lookaside->L.Free)(Entry); 00672 } 00673 00674 return; 00675 }

NTKERNELAPI NTSTATUS ExDeleteResourceLite IN PERESOURCE  Resource  ) 
 

Definition at line 2005 of file ex/resource.c.

References _RESOURCE_PERFORMANCE_DATA::ActiveResourceCount, _RESOURCE_HASH_ENTRY::Address, _ERESOURCE::Address, ASSERT, ASSERT_RESOURCE, _ERESOURCE::ContentionCount, _RESOURCE_HASH_ENTRY::ContentionCount, ExAllocatePoolWithTag, _ERESOURCE::ExclusiveWaiters, ExFreePool(), ExpResourceSpinLock, FALSE, _RESOURCE_PERFORMANCE_DATA::HashTable, IsExclusiveWaiting, IsSharedWaiting, _RESOURCE_HASH_ENTRY::ListEntry, NonPagedPool, NULL, _RESOURCE_HASH_ENTRY::Number, _ERESOURCE::OwnerTable, PRESOURCE_HASH_ENTRY, Resource, RESOURCE_HASH_ENTRY, RESOURCE_HASH_TABLE_SIZE, _ERESOURCE::SharedWaiters, and _ERESOURCE::SystemResourcesList.

02011 : 02012 02013 This routine deallocates any pool allocated to support the specified 02014 resource. 02015 02016 02017 Arguments: 02018 02019 Resource - Supplies a pointer to the resource whose allocated pool 02020 is freed. 02021 02022 Return Value: 02023 02024 STATUS_SUCCESS. 02025 02026 --*/ 02027 02028 { 02029 02030 PRESOURCE_HASH_ENTRY HashEntry; 02031 ULONG Hash; 02032 PRESOURCE_HASH_ENTRY MatchEntry; 02033 PLIST_ENTRY NextEntry; 02034 KIRQL OldIrql; 02035 02036 ASSERT(IsSharedWaiting(Resource) == FALSE); 02037 ASSERT(IsExclusiveWaiting(Resource) == FALSE); 02038 02039 // 02040 // Acquire the executive resource spinlock and remove the resource from 02041 // the system resource list. 02042 // 02043 02044 ExAcquireSpinLock(&ExpResourceSpinLock, &OldIrql); 02045 02046 ASSERT(KeIsExecutingDpc() == FALSE); 02047 ASSERT_RESOURCE(Resource); 02048 02049 RemoveEntryList(&Resource->SystemResourcesList); 02050 02051 #if defined(_COLLECT_RESOURCE_DATA_) 02052 02053 // 02054 // Lookup resource initialization address in resource hash table. If 02055 // the address does not exist in the table, then create a new entry. 02056 // 02057 02058 Hash = (ULONG)Resource->Address; 02059 Hash = ((Hash > 24) ^ (Hash > 16) ^ (Hash > 8) ^ (Hash)) & (RESOURCE_HASH_TABLE_SIZE - 1); 02060 MatchEntry = NULL; 02061 NextEntry = ExpResourcePerformanceData.HashTable[Hash].Flink; 02062 while (NextEntry != &ExpResourcePerformanceData.HashTable[Hash]) { 02063 HashEntry = CONTAINING_RECORD(NextEntry, 02064 RESOURCE_HASH_ENTRY, 02065 ListEntry); 02066 02067 if (HashEntry->Address == Resource->Address) { 02068 MatchEntry = HashEntry; 02069 break; 02070 } 02071 02072 NextEntry = NextEntry->Flink; 02073 } 02074 02075 // 02076 // If a matching initialization address was found, then update the call 02077 // site statistics. Otherwise, allocate a new hash entry and initialize 02078 // call site statistics. 02079 // 02080 02081 if (MatchEntry != NULL) { 02082 MatchEntry->ContentionCount += Resource->ContentionCount; 02083 MatchEntry->Number += 1; 02084 02085 } else { 02086 MatchEntry = ExAllocatePoolWithTag(NonPagedPool, 02087 sizeof(RESOURCE_HASH_ENTRY), 02088 'vEpR'); 02089 02090 if (MatchEntry != NULL) { 02091 MatchEntry->Address = Resource->Address; 02092 MatchEntry->ContentionCount = Resource->ContentionCount; 02093 MatchEntry->Number = 1; 02094 InsertTailList(&ExpResourcePerformanceData.HashTable[Hash], 02095 &MatchEntry->ListEntry); 02096 } 02097 } 02098 02099 ExpResourcePerformanceData.ActiveResourceCount -= 1; 02100 02101 #endif 02102 02103 ExReleaseSpinLock(&ExpResourceSpinLock, OldIrql); 02104 02105 // 02106 // If an owner table was allocated, then free it to pool. 02107 // 02108 02109 if (Resource->OwnerTable != NULL) { 02110 ExFreePool(Resource->OwnerTable); 02111 } 02112 02113 // 02114 // If a semaphore was allocated, then free it to pool. 02115 // 02116 02117 if (Resource->SharedWaiters) { 02118 ExFreePool(Resource->SharedWaiters); 02119 } 02120 02121 // 02122 // If an event was allocated, then free it to pool. 02123 // 02124 02125 if (Resource->ExclusiveWaiters) { 02126 ExFreePool(Resource->ExclusiveWaiters); 02127 } 02128 02129 return STATUS_SUCCESS; 02130 }

NTKERNELAPI BOOLEAN ExDestroyHandle IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle,
IN PHANDLE_TABLE_ENTRY HandleTableEntry  OPTIONAL
 

Definition at line 1227 of file ex/handle.c.

References ExLockHandleTableEntry(), ExLockHandleTableExclusive(), ExpFreeHandleTableEntry(), ExpLookupHandleTableEntry(), ExUnlockHandleTableExclusive(), FALSE, _EXHANDLE::GenericHandleOverlay, Handle, KeEnterCriticalRegion, KeLeaveCriticalRegion, NULL, PAGED_CODE, and TRUE.

Referenced by DoHandleTest(), NtClose(), PspProcessDelete(), PspThreadDelete(), and RtlpFreeHandleForAtom().

01235 : 01236 01237 This function removes a handle from a handle table. 01238 01239 Arguments: 01240 01241 HandleTable - Supplies a pointer to a handle table 01242 01243 Handle - Supplies the handle value of the entry to remove. 01244 01245 HandleTableEntry - Optionally supplies a pointer to the handle 01246 table entry being destroyed. If supplied the entry is 01247 assume to be locked. 01248 01249 Return Value: 01250 01251 If the specified handle is successfully removed, then a value of 01252 TRUE is returned. Otherwise, a value of FALSE is returned. 01253 01254 --*/ 01255 01256 { 01257 EXHANDLE LocalHandle; 01258 01259 PAGED_CODE(); 01260 01261 LocalHandle.GenericHandleOverlay = Handle; 01262 01263 // 01264 // If the caller did not supply the optional handle table entry then 01265 // locate the entry via the supplied handle, make sure it is real, and 01266 // then lock the entry. 01267 // 01268 01269 if (HandleTableEntry == NULL) { 01270 01271 HandleTableEntry = ExpLookupHandleTableEntry( HandleTable, 01272 LocalHandle ); 01273 01274 if (HandleTableEntry == NULL) { 01275 01276 return FALSE; 01277 } 01278 01279 if (!ExLockHandleTableEntry( HandleTable, HandleTableEntry )) { 01280 01281 return FALSE; 01282 } 01283 } 01284 01285 // 01286 // At this point we have a locked handle table entry. Now mark it free 01287 // which does the implicit unlock. The system will not allocate it 01288 // again until we add it to the free list which we will do right after 01289 // we take out the lock 01290 // 01291 01292 HandleTableEntry->Object = NULL; 01293 01294 KeEnterCriticalRegion(); 01295 ExLockHandleTableExclusive( HandleTable ); 01296 01297 try { 01298 01299 ExpFreeHandleTableEntry( HandleTable, 01300 LocalHandle, 01301 HandleTableEntry ); 01302 01303 } finally { 01304 01305 ExUnlockHandleTableExclusive( HandleTable ); 01306 KeLeaveCriticalRegion(); 01307 } 01308 01309 return TRUE; 01310 }

NTKERNELAPI VOID ExDestroyHandleTable IN PHANDLE_TABLE  HandleTable,
IN EX_DESTROY_HANDLE_ROUTINE  DestroyHandleProcedure
 

Definition at line 560 of file ex/handle.c.

References ExpFreeHandleTable(), ExpLookupHandleTableEntry(), ExRemoveHandleTable(), Handle, NULL, _HANDLE_TABLE_ENTRY::Object, and PAGED_CODE.

Referenced by DoHandleTest(), ObKillProcess(), and RtlpDestroyHandleTableForAtomTable().

00567 : 00568 00569 This function destroys the specified handle table. 00570 00571 Arguments: 00572 00573 HandleTable - Supplies a pointer to a handle table 00574 00575 DestroyHandleProcedure - Supplies a pointer to a function to call for each 00576 valid handle entry in the handle table. 00577 00578 Return Value: 00579 00580 None. 00581 00582 --*/ 00583 00584 { 00585 EXHANDLE Handle; 00586 PHANDLE_TABLE_ENTRY HandleTableEntry; 00587 00588 PAGED_CODE(); 00589 00590 // 00591 // Remove the handle table from the handle table list 00592 // 00593 00594 ExRemoveHandleTable( HandleTable ); 00595 00596 // 00597 // Iterate through the handle table and for each handle that is allocated 00598 // we'll invoke the call back. Note that this loop exits when we get a 00599 // null handle table entry. We know there will be no more possible 00600 // entries after the first null one is encountered because we allocate 00601 // memory of the handles in a dense fashion. But first test that we have 00602 // call back to use 00603 // 00604 00605 if (ARGUMENT_PRESENT(DestroyHandleProcedure)) { 00606 00607 for (Handle.GenericHandleOverlay = NULL; // does essentially the following "Handle.Index = 0, Handle.TagBits = 0;" 00608 (HandleTableEntry = ExpLookupHandleTableEntry( HandleTable, Handle )) != NULL; 00609 Handle.Index += 1) { 00610 00611 // 00612 // Only do the callback if the entry is not free 00613 // 00614 00615 if (HandleTableEntry->Object != NULL) { 00616 00617 (*DestroyHandleProcedure)( Handle.GenericHandleOverlay ); 00618 } 00619 } 00620 } 00621 00622 // 00623 // Now free up the handle table memory and return to our caller 00624 // 00625 00626 ExpFreeHandleTable( HandleTable ); 00627 00628 return; 00629 }

NTKERNELAPI VOID ExDisableResourceBoostLite IN PERESOURCE  Resource  ) 
 

Definition at line 370 of file ex/resource.c.

References ASSERT_RESOURCE, DisablePriorityBoost, _ERESOURCE::Flag, Resource, and _ERESOURCE::SpinLock.

00376 : 00377 00378 This routine disables priority inversion boosting for the specified 00379 resource. 00380 00381 Arguments: 00382 00383 Resource - Supplies a pointer to the resource for which priority 00384 boosting is disabled. 00385 00386 Return Value: 00387 00388 None. 00389 00390 --*/ 00391 00392 { 00393 00394 KIRQL OldIrql; 00395 00396 // 00397 // Disable priority boosts for the specified resource. 00398 // 00399 00400 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 00401 00402 ASSERT_RESOURCE(Resource); 00403 00404 Resource->Flag |= DisablePriorityBoost; 00405 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 00406 }

NTKERNELAPI PHANDLE_TABLE ExDupHandleTable IN struct _EPROCESS *Process  OPTIONAL,
IN PHANDLE_TABLE  OldHandleTable,
IN EX_DUPLICATE_HANDLE_ROUTINE DupHandleProcedure  OPTIONAL
 

Definition at line 765 of file ex/handle.c.

References ExLockHandleTableEntry(), ExLockHandleTableShared(), ExpAllocateHandleTable(), ExpAllocateHandleTableEntry(), ExpFreeHandleTable(), ExpFreeHandleTableEntry(), ExpLookupHandleTableEntry(), ExUnlockHandleTableEntry(), ExUnlockHandleTableShared(), _HANDLE_TABLE::FirstFreeTableEntry, Handle, _HANDLE_TABLE::HandleCount, KeEnterCriticalRegion, KeLeaveCriticalRegion, _HANDLE_TABLE_ENTRY::NextFreeTableEntry, _HANDLE_TABLE::NextIndexNeedingPool, NULL, _HANDLE_TABLE_ENTRY::Object, and PAGED_CODE.

Referenced by DoHandleTest(), and ObInitProcess().

00773 : 00774 00775 This function creates a duplicate copy of the specified handle table. 00776 00777 Arguments: 00778 00779 Process - Supplies an optional to the process to charge quota to. 00780 00781 OldHandleTable - Supplies a pointer to a handle table. 00782 00783 DupHandleProcedure - Supplies an optional pointer to a function to call 00784 for each valid handle in the duplicated handle table. 00785 00786 Return Value: 00787 00788 If the specified handle table is successfully duplicated, then the 00789 address of the new handle table is returned as the function value. 00790 Otherwize, a value NULL is returned. 00791 00792 --*/ 00793 00794 { 00795 PHANDLE_TABLE NewHandleTable; 00796 00797 PHANDLE_TABLE_ENTRY AdditionalFreeEntries; 00798 00799 EXHANDLE Handle; 00800 00801 PHANDLE_TABLE_ENTRY OldHandleTableEntry; 00802 PHANDLE_TABLE_ENTRY NewHandleTableEntry; 00803 00804 PAGED_CODE(); 00805 00806 // 00807 // First allocate a new handle table. If this fails then 00808 // return immediately to our caller 00809 // 00810 00811 NewHandleTable = ExpAllocateHandleTable( Process ); 00812 00813 if (NewHandleTable == NULL) { 00814 00815 return NULL; 00816 } 00817 00818 // 00819 // Now lock down the old handle table. We will release it 00820 // right after enumerating through the table 00821 // 00822 00823 KeEnterCriticalRegion(); 00824 ExLockHandleTableShared( OldHandleTable ); 00825 00826 AdditionalFreeEntries = NULL; 00827 00828 try { 00829 00830 // 00831 // Now we'll build up the new handle table. We do this by calling 00832 // allocating new handle table entries, and "fooling" the worker 00833 // routine to allocate keep on allocating until the next free 00834 // index needing pool are equal 00835 // 00836 00837 while (NewHandleTable->NextIndexNeedingPool < OldHandleTable->NextIndexNeedingPool) { 00838 00839 // 00840 // If we set the first free table entry to -1 then the worker 00841 // routine will allocate another buffer 00842 // 00843 00844 NewHandleTable->FirstFreeTableEntry = -1; 00845 00846 // 00847 // Call the worker routine to grow the new handle table. If 00848 // not successful then free the new table as far as we got, 00849 // set out output variable and exit out here 00850 // 00851 00852 if (ExpAllocateHandleTableEntry( NewHandleTable, &Handle ) == NULL) { 00853 00854 ExpFreeHandleTable( NewHandleTable ); 00855 00856 NewHandleTable = NULL; 00857 00858 leave; 00859 } 00860 } 00861 00862 // 00863 // Now modify the new handle table to think it has zero handles 00864 // and set its free list to start on the same index as the old 00865 // free list 00866 // 00867 00868 NewHandleTable->HandleCount = 0; 00869 NewHandleTable->FirstFreeTableEntry = OldHandleTable->FirstFreeTableEntry; 00870 00871 // 00872 // Now for every valid index value we'll copy over the old entry into 00873 // the new entry 00874 // 00875 00876 for (Handle.GenericHandleOverlay = NULL; // does essentially the following "Handle.Index = 0, Handle.TagBits = 0;" 00877 (OldHandleTableEntry = ExpLookupHandleTableEntry( OldHandleTable, Handle )) != NULL; 00878 Handle.Index += 1) { 00879 00880 // 00881 // The conditinal in the loop gives up the old handle table 00882 // entry, by definition there must exist a corresponding new 00883 // handle table entry, so now look it up 00884 // 00885 00886 NewHandleTableEntry = ExpLookupHandleTableEntry( NewHandleTable, 00887 Handle ); 00888 00889 // 00890 // If the old entry is free then simply copy over the entire 00891 // old entry to the new entry. The lock command will tell us 00892 // it entry is free. 00893 // 00894 00895 if (!ExLockHandleTableEntry( OldHandleTable, OldHandleTableEntry )) { 00896 00897 *NewHandleTableEntry = *OldHandleTableEntry; 00898 00899 } else { 00900 00901 // 00902 // Otherwise we have a non empty entry. So now copy it 00903 // over, and unlock the old entry. In both cases we bump 00904 // the handle count because either the entry is going into 00905 // the new table or we're going to remove it with Exp Free 00906 // Handle Table Entry which will decrement the handle count 00907 // 00908 00909 *NewHandleTableEntry = *OldHandleTableEntry; 00910 NewHandleTable->HandleCount += 1; 00911 00912 ExUnlockHandleTableEntry( OldHandleTable, OldHandleTableEntry ); 00913 00914 // 00915 // Invoke the callback and if it returns true then we 00916 // unlock the new entry 00917 // 00918 00919 if ((*DupHandleProcedure)( Process, NewHandleTableEntry )) { 00920 00921 ExUnlockHandleTableEntry( NewHandleTable, NewHandleTableEntry ); 00922 00923 } else { 00924 00925 // 00926 // Otherwise this entry is going to be freed in the 00927 // new handle table. So add it to the stack list of 00928 // additional freed entries 00929 // 00930 00931 NewHandleTableEntry->Object = AdditionalFreeEntries; 00932 NewHandleTableEntry->NextFreeTableEntry = Handle.Index; 00933 00934 AdditionalFreeEntries = NewHandleTableEntry; 00935 } 00936 } 00937 } 00938 00939 } finally { 00940 00941 ExUnlockHandleTableShared( OldHandleTable ); 00942 KeLeaveCriticalRegion(); 00943 } 00944 00945 // 00946 // At this point we are through with the old handle table, 00947 // and if present the new handle table is done with except 00948 // for adding back the newly freed entrires. The only time 00949 // the additionalFreeEntries variable will not be null is if 00950 // we successfully built the new table and the dup routine 00951 // came back false. 00952 // 00953 // While there are additional entries to add to the free list 00954 // pop the entry off the stack and add it to the table 00955 // 00956 00957 Handle.GenericHandleOverlay = NULL; 00958 while (AdditionalFreeEntries != NULL) { 00959 00960 PVOID Next; 00961 00962 Next = AdditionalFreeEntries->Object; 00963 Handle.Index = AdditionalFreeEntries->NextFreeTableEntry; 00964 00965 AdditionalFreeEntries->Object = NULL; 00966 00967 ExpFreeHandleTableEntry( NewHandleTable, 00968 Handle, 00969 AdditionalFreeEntries ); 00970 00971 AdditionalFreeEntries = Next; 00972 } 00973 00974 // 00975 // lastly return the new handle table to our caller 00976 // 00977 00978 return NewHandleTable; 00979 }

NTKERNELAPI BOOLEAN ExEnumHandleTable IN PHANDLE_TABLE  HandleTable,
IN EX_ENUMERATE_HANDLE_ROUTINE  EnumHandleProcedure,
IN PVOID  EnumParameter,
OUT PHANDLE Handle  OPTIONAL
 

Definition at line 634 of file ex/handle.c.

References ExLockHandleTableEntry(), ExLockHandleTableShared(), ExpLookupHandleTableEntry(), ExUnlockHandleTableEntry(), ExUnlockHandleTableShared(), FALSE, _EXHANDLE::GenericHandleOverlay, Handle, _EXHANDLE::Index, KeEnterCriticalRegion, KeLeaveCriticalRegion, NULL, _HANDLE_TABLE_ENTRY::Object, PAGED_CODE, and TRUE.

Referenced by DoHandleTest(), ObFindHandleForObject(), and ObInitProcess().

00643 : 00644 00645 This function enumerates all the valid handles in a handle table. 00646 For each valid handle in the handle table, the specified eumeration 00647 function is called. If the enumeration function returns TRUE, then 00648 the enumeration is stopped, the current handle is returned to the 00649 caller via the optional Handle parameter, and this function returns 00650 TRUE to indicated that the enumeration stopped at a specific handle. 00651 00652 Arguments: 00653 00654 HandleTable - Supplies a pointer to a handle table. 00655 00656 EnumHandleProcedure - Supplies a pointer to a fucntion to call for 00657 each valid handle in the enumerated handle table. 00658 00659 EnumParameter - Supplies an uninterpreted 32-bit value that is passed 00660 to the EnumHandleProcedure each time it is called. 00661 00662 Handle - Supplies an optional pointer a variable that receives the 00663 Handle value that the enumeration stopped at. Contents of the 00664 variable only valid if this function returns TRUE. 00665 00666 Return Value: 00667 00668 If the enumeration stopped at a specific handle, then a value of TRUE 00669 is returned. Otherwise, a value of FALSE is returned. 00670 00671 --*/ 00672 00673 { 00674 BOOLEAN ResultValue; 00675 EXHANDLE LocalHandle; 00676 PHANDLE_TABLE_ENTRY HandleTableEntry; 00677 00678 PAGED_CODE(); 00679 00680 // 00681 // First lock the handle table shared to stop anyone from creating or 00682 // destroying new handles. We need to do this because out iteration 00683 // function doesn't want the handles to be closed while we're doing 00684 // our work 00685 // 00686 00687 KeEnterCriticalRegion(); 00688 ExLockHandleTableShared( HandleTable ); 00689 00690 try { 00691 00692 // 00693 // Our initial return value is false until the enumeration callback 00694 // function tells us otherwise 00695 // 00696 00697 ResultValue = FALSE; 00698 00699 // 00700 // Iterate through the handle table and for each handle that is 00701 // allocated we'll invoke the call back. Note that this loop exits 00702 // when we get a null handle table entry. We know there will be no 00703 // more possible entries after the first null one is encountered 00704 // because we allocate memory of the handles in a dense fashion 00705 // 00706 00707 for (LocalHandle.GenericHandleOverlay = NULL; // does essentially the following "LocalHandle.Index = 0, LocalHandle.TagBits = 0;" 00708 (HandleTableEntry = ExpLookupHandleTableEntry( HandleTable, LocalHandle )) != NULL; 00709 LocalHandle.Index += 1) { 00710 00711 // 00712 // Only do the callback if the entry is not free 00713 // 00714 00715 if (HandleTableEntry->Object != NULL) { 00716 00717 // 00718 // Lock the handle table entry because we're about to give 00719 // it to the callback function, then release the entry 00720 // right after the call back. 00721 // 00722 00723 if (ExLockHandleTableEntry( HandleTable, HandleTableEntry )) { 00724 00725 try { 00726 00727 // 00728 // Invoke the callback, and if it returns true then set 00729 // the proper output values and break out of the loop. 00730 // 00731 00732 if ((*EnumHandleProcedure)( HandleTableEntry, 00733 LocalHandle.GenericHandleOverlay, 00734 EnumParameter )) { 00735 00736 if (ARGUMENT_PRESENT( Handle )) { 00737 00738 *Handle = LocalHandle.GenericHandleOverlay; 00739 } 00740 00741 ResultValue = TRUE; 00742 break; 00743 } 00744 00745 } finally { 00746 00747 ExUnlockHandleTableEntry( HandleTable, HandleTableEntry ); 00748 } 00749 } 00750 } 00751 } 00752 00753 } finally { 00754 00755 ExUnlockHandleTableShared( HandleTable ); 00756 KeLeaveCriticalRegion(); 00757 } 00758 00759 return ResultValue; 00760 }

NTKERNELAPI NTSTATUS ExExtendZone IN PZONE_HEADER  Zone,
IN PVOID  Segment,
IN ULONG  SegmentSize
 

Definition at line 138 of file zone.c.

References DbgPrint.

Referenced by CcAllocateInitializeBcb(), DoZoneTest(), ExInterlockedExtendZone(), and LpcpExtendPortZone().

00146 : 00147 00148 This function extends a zone by adding another segment's worth of 00149 blocks to the zone. 00150 00151 Arguments: 00152 00153 Zone - Supplies the address of a zone header to be extended. 00154 00155 Segment - Supplies the address of a segment of storage. The first 00156 ZONE_SEGMENT_HEADER-sized portion of the segment is used by the 00157 zone allocator. The remainder of the segment is carved up 00158 into fixed-size (BlockSize) blocks and is added to the 00159 zone. The address of the segment must be aligned on a 64- 00160 bit boundary. 00161 00162 SegmentSize - Supplies the size in bytes of Segment. 00163 00164 Return Value: 00165 00166 STATUS_UNSUCCESSFUL - BlockSize or Segment was not aligned on 00167 64-bit boundaries, or BlockSize was larger than 00168 the segment size. 00169 00170 STATUS_SUCCESS - The zone was successfully extended. 00171 00172 --*/ 00173 00174 { 00175 ULONG i; 00176 PCH p; 00177 00178 if ( ((ULONG_PTR)Segment & 7) || 00179 (SegmentSize & 7) || 00180 (Zone->BlockSize > SegmentSize) ) { 00181 return STATUS_UNSUCCESSFUL; 00182 } 00183 00184 ((PZONE_SEGMENT_HEADER) Segment)->SegmentList.Next = Zone->SegmentList.Next; 00185 Zone->SegmentList.Next = &((PZONE_SEGMENT_HEADER) Segment)->SegmentList; 00186 00187 p = (PCH)Segment + sizeof(ZONE_SEGMENT_HEADER); 00188 00189 for (i = sizeof(ZONE_SEGMENT_HEADER); 00190 i <= SegmentSize - Zone->BlockSize; 00191 i += Zone->BlockSize 00192 ) { 00193 00194 ((PSINGLE_LIST_ENTRY)p)->Next = Zone->FreeList.Next; 00195 Zone->FreeList.Next = (PSINGLE_LIST_ENTRY)p; 00196 p += Zone->BlockSize; 00197 } 00198 Zone->TotalSegmentSize += i; 00199 00200 #if 0 00201 DbgPrint( "EX: ExExtendZone( %lx, %lx, %lu, %lu, %lx )\n", 00202 Zone, Segment, SegmentSize, Zone->BlockSize, p 00203 ); 00204 #endif 00205 00206 return STATUS_SUCCESS; 00207 }

NTKERNELAPI VOID NTAPI ExFreePool IN PVOID  P  ) 
 

Definition at line 304 of file cmwraper.c.

References APC_LEVEL, BasePoolTypeTable, DbgPrint, DeallocatePoolInternal(), FALSE, HBLOCK_SIZE, KeAcquireSpinLock, KeBugCheck(), KeLowerIrql(), KeRaiseIrql(), KeReleaseSemaphore(), KeReleaseSpinLock(), KernelMode, KeSweepDcache(), KeWaitForSingleObject(), KiFlushSingleTb(), L, Lock, LOCK_POOL, _POOL_DESCRIPTOR::LockAddress, _POOL_HEADER::LogAllocationSize, MaxPoolType, MI_PFN_ELEMENT, MiDecrementShareCountOnly, MiFreePoolPages(), MiGetPteAddress, MiReleaseSystemPtes(), MM_EMPTY_LIST, MmDeterminePoolType(), MmPfnLock, NtFreeVirtualMemory(), NULL, ObDereferenceObject, PAGE_ALIGNED, POOL_OVERHEAD, POOL_TYPE, PoolAllocation, _POOL_HEADER::PoolType, PoolVector, PPOOL_DESCRIPTOR, PPOOL_HEADER, _POOL_HEADER::ProcessBilled, PsGetCurrentThread, PsReturnPoolQuota(), _MMPFN::PteAddress, SystemPteSpace, TRUE, _MMPTE::u, UNLOCK_POOL, VOID(), and ZeroPte.

Referenced by ArbAddOrdering(), ArbBuildAssignmentOrdering(), ArbDeleteArbiterInstance(), ArbFreeOrderingList(), ArbInitializeArbiterInstance(), ArbpBuildAllocationStack(), ArbpGetRegistryValue(), ArbPruneOrdering(), ArbQueryConflict(), BuildQueryDirectoryIrp(), CcDeallocateBcb(), CcDeleteMbcb(), CcDeleteSharedCacheMap(), CcDrainVacbLevelZone(), CcExtendVacbArray(), CcInitializeCacheMap(), CcPostDeferredWrites(), CcUninitializeCacheMap(), CcUnpinData(), CcUnpinDataForThread(), CcWriteBehind(), CcZeroData(), CmDeleteKeyRecursive(), CmInitSystem1(), CmpAddToHiveFileList(), CmpAllocatePostBlock(), CmpAppendStringToMultiSz(), CmpCleanUpKcbValueCache(), CmpCloneControlSet(), CmpCloneHwProfile(), CmpCloseInfFile(), CmpCopySyncTree(), CmpCopySyncTree2(), CmpCreateRegistryRoot(), CmpDelayedDerefKeys(), CmpDestroyTemporaryHive(), CmpDiskFullWarningWorker(), CmpFindACPITable(), CmpFindRSDTTable(), CmpFlushNotify(), CmpFree(), CmpFreeLineList(), CmpFreePostBlock(), CmpFreeSectionList(), CmpFreeValueList(), CmpGetAcpiProfileInformation(), CmpGetRegistryValue(), CmpGetSymbolicLink(), CmpGetValueDataFromCache(), CmpHiveRootSecurityDescriptor(), CmpInitializeHardwareConfiguration(), CmpInitializeHive(), CmpInitializeHiveList(), CmpInitializeMachineDependentConfiguration(), CmpInitializeRegistryNode(), CmpInitializeSystemHive(), CmpLoadHiveVolatile(), CmpMergeKeyValues(), CmpNameFromAttributes(), CmpNotifyChangeKey(), CmpOpenHiveFiles(), CmpOpenRegKey(), CmpParseInfBuffer(), CmpPostNotify(), CmpProcessBitRegLine(), CmpQuotaWarningWorker(), CmpRemoveFromHiveFileList(), CmpSaveBootControlSet(), CmpSaveKeyByFileCopy(), CmpSetSecurityDescriptorInfo(), CmpSetValueKeyExisting(), CmpSetVersionData(), CmpValidateAlternate(), CmpWorker(), CmReplaceKey(), CmSetAcpiHwProfile(), CmUnloadKey(), ComPortDBAdd(), DbgkCreateThread(), DbgkpSectionHandleToFileHandle(), DoPoolTest(), DriverEntry(), EisaBuildEisaDeviceNode(), EisaGetEisaDevicesResources(), ExCreateDebugLogTag(), ExDeleteResourceLite(), ExLockUserBuffer(), ExpAllocateHandleTable(), ExpAllocateHandleTableEntry(), ExpAllocatePoolWithQuotaHandler(), ExpFindCurrentThread(), ExpFreeHandleTable(), ExpGetPoolTagInfo(), ExpProfileDelete(), ExpQueryLegacyDriverInformation(), ExpSystemErrorHandler(), ExRegisterCallback(), ExUnlockUserBuffer(), ExUnregisterCallback(), FatRecFsControl(), FindPathForDevice(), FsgWriteToFrameBuffer(), FsRecUnload(), FsRtlAddLargeEntry(), FsRtlAllocateOplock(), FsRtlCancelNotify(), FsRtlDeregisterUncProvider(), FsRtlFreeTunnelNode(), FsRtlGetCompatibilityModeValue(), FsRtlGetTunnelParameterValue(), FsRtlIsDbcsInExpression(), FsRtlIsNameInExpressionPrivate(), FsRtlNotifyCleanup(), FsRtlNotifyCompleteIrp(), FsRtlNotifyFullChangeDirectory(), FsRtlNotifyFullReportChange(), FsRtlNotifyUninitializeSync(), FsRtlpRegisterProviderWithMUP(), FsRtlRegisterUncProvider(), FsRtlRemoveAndCompleteWaitIrp(), FsRtlStackOverflowRead(), FsRtlTruncateLargeMcb(), FsRtlUninitializeLargeMcb(), FsRtlUninitializeOplock(), FsVgaServiceParameters(), FsVgaWriteToFrameBuffer(), GetNextReparseVolumePath(), HalpGetFullGeometry(), HalpNextMountLetter(), HalpSetMountLetter(), HvpDiscardBins(), HvpDoWriteHive(), HvpReadFileImageAndBuildMap(), HvpRecoverData(), HvpWriteLog(), InitCreateUserCrit(), IoAllocateDriverObjectExtension(), IoBuildDeviceIoControlRequest(), IoConnectInterrupt(), IoCreateDevice(), IoCreateFile(), IoDeleteDevice(), IoDisconnectInterrupt(), IoepFreeErrStack(), IoepGetErrCaseDB(), IoepInitErrLog(), IoepLogErr(), IoErrFreeSavedData(), IoErrGetErrData(), IoErrPropagateErrLog(), IoErrTerminateErrLog(), IoFreeDumpStack(), IoFreeMdl(), IoFreePoDeviceNotifyList(), IoFreeWorkItem(), IoGetBootDiskInformation(), IoGetDeviceInterfaceAlias(), IoGetDeviceProperty(), IoGetLegacyVetoList(), IoInitSystem(), IoIsValidNameGraftingBuffer(), IoOpenDeviceRegistryKey(), IopAllocateResources(), IopApcHardError(), IopAppendLegacyVeto(), IopAppendStringToValueKey(), IopApplyFunctionToServiceInstances(), IopApplyFunctionToSubKeys(), IopApplySystemPartitionProt(), IopArbitrateDeviceResources(), IopBuildCmResourceList(), IopCallDriverAddDevice(), IopCallDriverAddDeviceQueryRoutine(), IopChangeDeviceObjectFromRegistryProperties(), IopCheckDependencies(), IopChildToRootTranslation(), IopCompleteRequest(), IopCompleteUnloadOrDelete(), IopCompressRelationList(), IopCopyBootLogRegistryToFile(), IopCreateArcNames(), IopCreateCmResourceList(), IopCreateMadeupNode(), IopDeallocateApc(), IopDelayedRemoveWorker(), IopDeleteDevice(), IopDeleteDriver(), IopDeleteFile(), IopDeleteLegacyKey(), IopDeleteLockedDeviceNode(), IopDeleteSessionSymLinks(), IopDereferenceNotify(), IopDereferenceVpbAndFree(), IopDestroyDeviceNode(), IopDeviceActionWorker(), IopDeviceObjectFromDeviceInstance(), IopDeviceRelationsComplete(), IopDeviceStartComplete(), IopDoDeferredSetInterfaceState(), IopDoNameTransmogrify(), IopDriverLoadingFailed(), IopDropIrp(), IopDuplicateDetection(), IopEnumerateDevice(), IopErrorLogDpc(), IopErrorLogThread(), IopExceptionCleanup(), IopExecuteHardwareProfileChange(), IopFilterResourceRequirementsList(), IopFreeAllocatedUnicodeString(), IopFreeBuffer(), IopFreeDCB(), IopFreeGroupTree(), IopFreeIrp(), IopFreeMiniPacket(), IopFreePoDeviceNotifyListHead(), IopFreeRelationList(), IopFreeReqAlternative(), IopFreeReqList(), IopFreeResourceRequirementsForAssignTable(), IopFreeUnicodeStringList(), IopGetBusTypeGuidIndex(), IopGetDeviceInstanceCsConfigFlags(), IopGetDeviceInterfaces(), IopGetDeviceResourcesFromRegistry(), IopGetDriverDeviceList(), IopGetDriverNameFromKeyNode(), IopGetDriverTagPriority(), IopGetDumpStack(), IopGetGroupOrderIndex(), IopGetLegacyVetoListDrivers(), IopGetRegistryDwordWithFallback(), IopGetRegistryKeyInformation(), IopGetRegistrySecurityWithFallback(), IopGetRegistryValue(), IopGetRelatedTargetDevice(), IopGetResourceRequirementsForAssignTable(), IopGetRootDevices(), IopGetServiceInstanceCsConfigFlags(), IopGetServiceType(), IopHardErrorThread(), IopHardwareProfileCommitRemovedDock(), IopHardwareProfileMarkDock(), IopInitializeBootDrivers(), IopInitializeDCB(), IopInitializeDeviceInstanceKey(), IopInitializePlugPlayServices(), IopInitializeResourceMap(), IopInitializeSystemDrivers(), IopInvalidateDeviceStateWorker(), IopIsAnyDeviceInstanceEnabled(), IopIsDeviceInstanceEnabled(), IopIsFirmwareMapperDevicePresent(), IopIsReportedAlready(), IopLegacyResourceAllocation(), IopLoadBootFilterDriver(), IopLoadDriver(), IopLoadDumpDriver(), IopLoadUnloadDriver(), IopMakeGloballyUniqueId(), IoPnPDeliverServicePowerNotification(), IopOpenDeviceParametersSubkey(), IopParseDevice(), IopPrepareDriverLoading(), IopProcessAssignResources(), IopProcessCompletedEject(), IopProcessCriticalDeviceRoutine(), IopProcessDeferredRegistrations(), IopProcessNewDeviceNode(), IopProcessNewProfileWorker(), IopProcessRelation(), IopProcessSetInterfaceState(), IopQueryConflictListInternal(), IopQueryDeviceResources(), IopQueryDockRemovalInterface(), IopQueryLegacyBusInformation(), IopQueryName(), IopQueryPnpBusInformation(), IopQueryRebalance(), IopQueryResourceHandlerInterface(), IopRaiseHardError(), IopRaiseInformationalHardError(), IopReadDeviceConfiguration(), IopReadDumpRegistry(), IopRealloc(), IopReallocateResources(), IopRebalance(), IopReleaseFilteredBootResources(), IopReleaseResources(), IopRemoveDeviceInterfaces(), IopRemoveIndirectRelationsFromList(), IopRemoveRelationFromList(), IopRemoveStringFromValueKey(), IopReportTargetDeviceChangeAsyncWorker(), IopRequestDeviceEjectWorker(), IopReserveBootResources(), IopReserveBootResourcesInternal(), IopReserveLegacyBootResources(), IopResizeBuffer(), IopRestartDeviceNode(), IopRestoreResourcesInternal(), IopSafebootDriverLoad(), IopServiceInstanceToDeviceInstance(), IopSetDefaultGateway(), IopSetDeviceSecurityDescriptors(), IopSetEaOrQuotaInformationFile(), IopSetSecurityObjectFromRegistry(), IopStartAndEnumerateDevice(), IopStartApcHardError(), IopStartDriverDevices(), IopStartNetworkForRemoteBoot(), IopSynchronousApiServiceTail(), IopTCPSetInformationEx(), IopTrackLink(), IopTranslateAndAdjustReqDesc(), IopUncacheInterfaceInformation(), IopUnloadAttachedDriver(), IopUnregisterDeviceInterface(), IopUpdateHardwareProfile(), IoQueryDeviceDescription(), IoRaiseInformationalHardError(), IoRegisterPlugPlayNotification(), IoReleaseRemoveLockAndWaitEx(), IoReleaseRemoveLockEx(), IoReportDetectedDevice(), IoReportResourceUsageInternal(), IoShutdownSystem(), IoUnregisterFsRegistrationChange(), IoUnregisterPlugPlayNotification(), IoUnregisterShutdownNotification(), IovpInternalCompleteAfterWait(), IovpInternalDeferredCompletion(), IovpProtectedIrpMakeUntouchable(), IovpSessionDataDereference(), IovpThrowChaffAtStartedPdoStack(), IovpTrackingDataFree(), IoWriteErrorLogEntry(), IsUdfsVolume(), Ke386CallBios(), KeRestoreFloatingPointState(), KeSetAutoAlignmentThread(), KeStartAllProcessors(), KeStartProfile(), KeStopProfile(), KiAddRange(), KiCompleteEffectiveRangeChange(), KiInitializeMTRR(), LfsDeallocateLbcb(), LfsDeallocateLcb(), LfsDeallocateLfcb(), LfsDeleteLogHandle(), LfsWriteLfsRestart(), LpcpDestroyPortQueue(), LpcpExtendPortZone(), LpcpInitializePortZone(), MapperAdjustResourceList(), MapperCallback(), MapperConstructRootEnumTree(), MapperFreeList(), MapperMarkKey(), MapperPeripheralCallback(), MapperPhantomizeDetectedComPorts(), MapperSeedKey(), MiAllocateContiguousMemory(), MiBuildImportsForBootDrivers(), MiCleanPhysicalProcessPages(), MiClearImports(), MiCloneProcessAddressSpace(), MiCreateDataFileMap(), MiCreateImageFileMap(), MiCreatePagingFileMap(), MiCreatePebOrTeb(), MiDecrementCloneBlockReference(), MiDereferenceImports(), MiDereferenceSegmentThread(), MiDoPoolCopy(), MiFindContiguousMemory(), MiFlushEventCounter(), MiFlushInPageSupportBlock(), MiFreeMdlTracker(), MiFreeSessionPoolBitMaps(), MiFreeSessionSpaceMap(), MiGetInPageSupportBlock(), MiGetWorkingSetInfo(), MiInitializeLoadedModuleList(), MiInsertInSystemSpace(), MiLoadSystemImage(), MiMapLockedPagesInUserSpace(), MiMapViewOfDataSection(), MiMapViewOfImageSection(), MiMapViewOfPhysicalSection(), MiPhysicalViewRemover(), MiReleaseDeadPteTrackers(), MiRemoveMappedView(), MiRemoveVad(), MiResolveImageReferences(), MiSectionInitialization(), MiSegmentDelete(), MiSessionRemoveImage(), MiSessionWideDereferenceImage(), MiSessionWideInsertImageAddress(), MiSnapThunk(), MiUnmapLockedPagesInUserSpace(), MiVerifierCheckThunks(), MiVerifyingDriverUnloading(), MmAddPhysicalMemory(), MmAddVerifierThunks(), MmAllocatePagesForMdl(), MmCallDllInitialize(), MmCleanProcessAddressSpace(), MmCreateSection(), MmDeleteTeb(), MmExtendSection(), MmFreeContiguousMemory(), MmFreeContiguousMemorySpecifyCache(), MmGetFileNameForSection(), MmInitializeProcessAddressSpace(), MmMapLockedPagesSpecifyCache(), MmMapVideoDisplay(), MmRemovePhysicalMemory(), MmSecureVirtualMemory(), MmUnloadSystemImage(), MmUnmapVideoDisplay(), MmUnmapViewOfSection(), MmUnsecureVirtualMemory(), NtAddAtom(), NtAllocateUserPhysicalPages(), NtAllocateVirtualMemory(), NtCloseObjectAuditAlarm(), NtCreatePagingFile(), NtDeleteObjectAuditAlarm(), NtFindAtom(), NtFlushBuffersFile(), NtFreeUserPhysicalPages(), NtFreeVirtualMemory(), NtfsRecFsControl(), NtLoadDriver(), NtLoadKey2(), NtMapUserPhysicalPages(), NtMapUserPhysicalPagesScatter(), NtOpenObjectAuditAlarm(), NtOpenThreadToken(), NtPrivilegedServiceAuditAlarm(), NtPrivilegeObjectAuditAlarm(), NtQueryDirectoryObject(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQuerySystemEnvironmentValue(), NtQueryVolumeInformationFile(), NtQueueApcThread(), NtRaiseHardError(), NtReadFileScatter(), NtReplaceKey(), NtSecureConnectPort(), NtSetEaFile(), NtSetInformationFile(), NtSetInformationJobObject(), NtSetInformationProcess(), NtSetLdtEntries(), NtSetSystemEnvironmentValue(), NtSetSystemInformation(), NtSetValueKey(), NtSetVolumeInformationFile(), NtStartProfile(), NtStopProfile(), NtUnloadDriver(), NtUnlockFile(), NtWaitForMultipleObjects(), NtWriteFileGather(), ObCreateObjectType(), ObDereferenceDeviceMap(), ObGetObjectSecurity(), ObpCaptureObjectName(), ObpDeleteDirectoryEntry(), ObpDeleteNameCheck(), ObpDeleteSymbolicLink(), ObpDestroySecurityDescriptorHeader(), ObpFreeDosDevicesProtection(), ObpFreeObject(), ObpFreeObjectNameBuffer(), ObpInitSecurityDescriptorCache(), ObpInsertHandleCount(), ObpLogSecurityDescriptor(), ObpLookupObjectName(), ObpParseSymbolicLink(), ObpProcessDosDeviceSymbolicLink(), ObpRemoveObjectRoutine(), ObReleaseObjectSecurity(), ObSetSecurityDescriptorInfo(), OpenDeviceReparseIndex(), pIoQueryBusDescription(), pIoQueryDeviceDescription(), PnPBiosCopyDeviceParamKey(), PnPBiosCopyIoDecode(), PnPBiosEliminateDupes(), PnPBiosFreeDevNodeInfo(), PnPBiosGetBiosInfo(), PnPBiosMapper(), PnPBiosTranslateInfo(), PnPBiosWriteInfo(), PnPCheckFixedIoOverrideDecodes(), PsExitSpecialApc(), Psp386CreateVdmIoListHead(), Psp386InstallIoHandler(), PspApplyJobLimitsToProcessSet(), PspCaptureTokenFilter(), PspDeleteLdt(), PspDeleteThreadSecurity(), PspDeleteVdmObjects(), PspDereferenceQuota(), PspExitNormalApc(), PspExitThread(), PspJobDelete(), PspNullSpecialApc(), PspProcessDelete(), PspQueueApcSpecialApc(), PspSetLdtInformation(), PspSetLdtSize(), PspSetQuotaLimits(), PspTerminateThreadByPointer(), PspUserThreadStartup(), PsReturnSharedPoolQuota(), QueryDeviceNameForPath(), QuerySymbolicLink(), RtlpAllocDeallocQueryBuffer(), RtlpComputeMergedAcl(), RtlpConvertAclToAutoInherit(), RtlpConvertToAutoInheritSecurityObject(), RtlpFreeAtom(), RtlpInheritAcl(), RtlpNewSecurityObject(), RtlpSetSecurityObject(), RtlReleaseRemoveLock(), RtlReleaseRemoveLockAndWait(), RtlVolumeDeviceToDosName(), SeAccessCheckByType(), SeAppendPrivileges(), SeCaptureAcl(), SeCaptureLuidAndAttributesArray(), SeCaptureObjectTypeList(), SeCaptureSecurityDescriptor(), SeCaptureSecurityQos(), SeCaptureSid(), SeCaptureSidAndAttributesArray(), SeCreateObjectAuditAlarm(), SeDeassignSecurity(), SeDeleteAccessState(), SeFreeCapturedObjectTypeList(), SeFreeCapturedSecurityQos(), SeFreePrivileges(), SeMakeAnonymousLogonToken(), SeMakeSystemToken(), SeOpenObjectAuditAlarm(), SeOpenObjectForDeleteAuditAlarm(), SepAccessCheckAndAuditAlarm(), SepAdtInitializeBounds(), SepAdtLogAuditRecord(), SepAdtObjectReferenceAuditAlarm(), SepAdtOpenObjectAuditAlarm(), SepCopyProxyData(), SepCreateLogonSessionTrack(), SepDeleteLogonSessionTrack(), SepDequeueWorkItem(), SepDeReferenceLogonSession(), SepDuplicateToken(), SepFilterToken(), SepFreeCapturedString(), SepFreeProxyData(), SepInformLsaOfDeletedLogon(), SepInitializationPhase1(), SepNotifyFileSystems(), SepProbeAndCaptureQosData(), SepProbeAndCaptureString_U(), SepQueryNameString(), SepRmCallLsa(), SepTokenDeleteMethod(), SeReleaseAcl(), SeReleaseLuidAndAttributesArray(), SeReleaseSecurityDescriptor(), SeReleaseSid(), SeReleaseSidAndAttributesArray(), SeRmInitPhase1(), SeUnregisterLogonSessionTerminatedRoutine(), SmbTraceCompleteRdr(), SmbTraceCompleteSrv(), SmbTraceDeferredDereferenceHeap(), SmbTraceEmptyQueue(), SmbTraceInitialize(), SmbTraceTerminate(), SmbTraceThreadEntry(), TestCaptureSecurityDescriptor(), TestDefaultObjectMethod(), TestMakeSystemToken(), TestTokenCopy(), TestTokenSize(), UdfDeallocateTable(), UdfDeletePcb(), UdfFreePool(), UdfNormalizeFileNames(), UdfRemovePrefix(), UdfUpdateVcbPhase0(), VdmpDelayInterrupt(), VdmpInitialize(), VdmQueryDirectoryFile(), VerifierFreePool(), ViReservePoolAllocation(), Win32KDriverUnload(), Win32kNtUserCleanup(), xHalExamineMBR(), xHalGetPartialGeometry(), xHalIoAssignDriveLetters(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

00307 { 00308 ULONG size; 00309 size = HBLOCK_SIZE; 00310 00311 // if it was really more than 1 page, well, too bad 00312 NtFreeVirtualMemory( 00313 NtCurrentProcess(), 00314 &P, 00315 &size, 00316 MEM_DECOMMIT 00317 ); 00318 return; 00319 }

VOID ExFreePoolSanityChecks IN PVOID  P  ) 
 

Definition at line 3892 of file ex/pool.c.

References APC_LEVEL, BASE_POOL_TYPE_MASK, _POOL_HEADER::BlockSize, BYTE_OFFSET, DISPATCH_LEVEL, ExpCheckForResource(), ExpCheckForWorker(), IS_POOL_HEADER_MARKED_ALLOCATED, KeBugCheckEx(), KeCheckForTimer(), MmDeterminePoolType(), MmSpecialPoolEnd, MmSpecialPoolStart, NULL, PAGE_ALIGNED, PAGE_SIZE, PagedPool, POOL_BLOCK_SHIFT, POOL_OVERHEAD, POOL_TYPE, POOL_TYPE_MASK, _POOL_HEADER::PoolType, and _POOL_HEADER::Ulong1.

Referenced by VerifierFreePoolWithTag().

03898 : 03899 03900 This function performs sanity checks on the caller. 03901 03902 Return Value: 03903 03904 None. 03905 03906 Environment: 03907 03908 Only enabled as part of the driver verification package. 03909 03910 --*/ 03911 03912 { 03913 PPOOL_HEADER Entry; 03914 POOL_TYPE PoolType; 03915 PVOID StillQueued; 03916 03917 if (P <= (PVOID)(MM_HIGHEST_USER_ADDRESS)) { 03918 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03919 0x10, 03920 (ULONG_PTR)P, 03921 0, 03922 0); 03923 } 03924 03925 if ((P >= MmSpecialPoolStart) && (P < MmSpecialPoolEnd)) { 03926 StillQueued = KeCheckForTimer(P, PAGE_SIZE - BYTE_OFFSET (P)); 03927 if (StillQueued != NULL) { 03928 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03929 0x15, 03930 (ULONG_PTR)StillQueued, 03931 (ULONG_PTR)-1, 03932 (ULONG_PTR)P); 03933 } 03934 03935 // 03936 // Check if an ERESOURCE is currently active in this memory block. 03937 // 03938 03939 StillQueued = ExpCheckForResource(P, PAGE_SIZE - BYTE_OFFSET (P)); 03940 if (StillQueued != NULL) { 03941 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03942 0x17, 03943 (ULONG_PTR)StillQueued, 03944 (ULONG_PTR)-1, 03945 (ULONG_PTR)P); 03946 } 03947 03948 ExpCheckForWorker (P, PAGE_SIZE - BYTE_OFFSET (P)); // bugchecks inside 03949 return; 03950 } 03951 03952 if (PAGE_ALIGNED(P)) { 03953 PoolType = MmDeterminePoolType(P); 03954 03955 if ((PoolType & BASE_POOL_TYPE_MASK) == PagedPool) { 03956 if (KeGetCurrentIrql() > APC_LEVEL) { 03957 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03958 0x11, 03959 KeGetCurrentIrql(), 03960 PoolType, 03961 (ULONG_PTR)P); 03962 } 03963 } 03964 else { 03965 if (KeGetCurrentIrql() > DISPATCH_LEVEL) { 03966 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03967 0x12, 03968 KeGetCurrentIrql(), 03969 PoolType, 03970 (ULONG_PTR)P); 03971 } 03972 } 03973 03974 // 03975 // Just check the first page. 03976 // 03977 03978 StillQueued = KeCheckForTimer(P, PAGE_SIZE); 03979 if (StillQueued != NULL) { 03980 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03981 0x15, 03982 (ULONG_PTR)StillQueued, 03983 PoolType, 03984 (ULONG_PTR)P); 03985 } 03986 03987 // 03988 // Check if an ERESOURCE is currently active in this memory block. 03989 // 03990 03991 StillQueued = ExpCheckForResource(P, PAGE_SIZE); 03992 03993 if (StillQueued != NULL) { 03994 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 03995 0x17, 03996 (ULONG_PTR)StillQueued, 03997 PoolType, 03998 (ULONG_PTR)P); 03999 } 04000 } 04001 else { 04002 04003 #if !defined (_WIN64) 04004 if (((ULONG_PTR)P & 0x17) != 0) { 04005 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04006 0x16, 04007 __LINE__, 04008 (ULONG_PTR)P, 04009 0); 04010 } 04011 #endif 04012 04013 Entry = (PPOOL_HEADER)((PCHAR)P - POOL_OVERHEAD); 04014 04015 if ((Entry->PoolType & POOL_TYPE_MASK) == 0) { 04016 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04017 0x13, 04018 __LINE__, 04019 (ULONG_PTR)Entry, 04020 Entry->Ulong1); 04021 } 04022 04023 PoolType = (Entry->PoolType & POOL_TYPE_MASK) - 1; 04024 04025 if ((PoolType & BASE_POOL_TYPE_MASK) == PagedPool) { 04026 if (KeGetCurrentIrql() > APC_LEVEL) { 04027 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04028 0x11, 04029 KeGetCurrentIrql(), 04030 PoolType, 04031 (ULONG_PTR)P); 04032 } 04033 } 04034 else { 04035 if (KeGetCurrentIrql() > DISPATCH_LEVEL) { 04036 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04037 0x12, 04038 KeGetCurrentIrql(), 04039 PoolType, 04040 (ULONG_PTR)P); 04041 } 04042 } 04043 04044 if (!IS_POOL_HEADER_MARKED_ALLOCATED(Entry)) { 04045 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04046 0x14, 04047 __LINE__, 04048 (ULONG_PTR)Entry, 04049 0); 04050 } 04051 StillQueued = KeCheckForTimer(Entry, (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT)); 04052 if (StillQueued != NULL) { 04053 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04054 0x15, 04055 (ULONG_PTR)StillQueued, 04056 PoolType, 04057 (ULONG_PTR)P); 04058 } 04059 04060 // 04061 // Check if an ERESOURCE is currently active in this memory block. 04062 // 04063 04064 StillQueued = ExpCheckForResource(Entry, (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT)); 04065 04066 if (StillQueued != NULL) { 04067 KeBugCheckEx (DRIVER_VERIFIER_DETECTED_VIOLATION, 04068 0x17, 04069 (ULONG_PTR)StillQueued, 04070 PoolType, 04071 (ULONG_PTR)P); 04072 } 04073 } 04074 } }

NTKERNELAPI VOID ExFreePoolWithTag IN PVOID  P,
IN ULONG  Tag
 

Definition at line 2760 of file ex/pool.c.

References ASSERT, ASSERT_FREE_IRQL, ASSERT_POOL_NOT_FREE, ASSERT_POOL_TYPE_NOT_ZERO, BASE_POOL_TYPE_MASK, _POOL_HEADER::BlockSize, CHECK_LIST, CHECK_LOOKASIDE_LIST, CHECK_POOL_HEADER, DbgPrint, DECODE_POOL_INDEX, DecodeLink, _GENERAL_LOOKASIDE::Depth, ENCODE_POOL_INDEX, ExInterlockedPushEntrySList(), ExpFindAndRemoveTagBigPages(), ExpRemovePoolTracker(), ExpSessionPoolDescriptor, ExQueryDepthSList, FALSE, FREE_CHECK_ERESOURCE, FREE_CHECK_KTIMER, FREE_CHECK_WORKER, _GENERAL_LOOKASIDE::FreeHits, Index, IS_POOL_HEADER_MARKED_ALLOCATED, Isx86FeaturePresent, KeBugCheckEx(), KeGetCurrentPrcb, KF_CMPXCHG8B, _NPAGED_LOOKASIDE_LIST::L, _GENERAL_LOOKASIDE::ListHead, _POOL_DESCRIPTOR::ListHeads, _NPAGED_LOOKASIDE_LIST::Lock, LOCK_IF_PAGED_POOL, LOCK_POOL, MARK_POOL_HEADER_FREED, MiFreePoolPages(), MiSessionPoolFreed(), MmDeterminePoolType(), MmFreeSpecialPool(), MmSpecialPoolEnd, MmSpecialPoolStart, NonPagedPool, NonPagedPoolMustSucceed, NULL, ObDereferenceObject, PAGE_ALIGNED, PAGE_END, PAGE_SHIFT, PAGE_SIZE, PagedPool, PagedPoolSession, PERFINFO_EXFREEPOOLWITHTAG_DECL, PERFINFO_FREEPOOL, PERFINFO_FREEPOOLPAGE, POOL_BLOCK_SHIFT, POOL_OVERHEAD, POOL_QUOTA_MASK, POOL_SMALL_LISTS, POOL_TYPE, POOL_TYPE_MASK, POOL_VERIFIER_MASK, _POOL_DESCRIPTOR::PoolIndex, _POOL_HEADER::PoolTag, PoolTrackTable, _POOL_HEADER::PoolType, PoolVector, _POOL_HEADER::PreviousSize, PrivateInsertHeadList, PrivateInsertTailList, PrivateRemoveEntryList, _POOL_HEADER::ProcessBilled, PROTECTED_POOL, PsReturnPoolQuota(), _POOL_DESCRIPTOR::RunningDeAllocs, SESSION_POOL_MASK, _POOL_DESCRIPTOR::TotalBigPages, _GENERAL_LOOKASIDE::TotalFrees, _POOL_DESCRIPTOR::TotalPages, TRUE, UNLOCK_IF_PAGED_POOL, UNLOCK_POOL, and VerifierFreeTrackedPool().

02764 { 02765 02766 /*++ 02767 02768 Routine Description: 02769 02770 This function deallocates a block of pool. This function is used to 02771 deallocate to both the page aligned pools and the buddy (less than 02772 a page) pools. 02773 02774 If the address of the block being deallocated is page-aligned, then 02775 the page-aligned pool deallocator is used. 02776 02777 Otherwise, the binary buddy pool deallocator is used. Deallocation 02778 looks at the allocated block's pool header to determine the pool 02779 type and block size being deallocated. If the pool was allocated 02780 using ExAllocatePoolWithQuota, then after the deallocation is 02781 complete, the appropriate process's pool quota is adjusted to reflect 02782 the deallocation, and the process object is dereferenced. 02783 02784 Arguments: 02785 02786 P - Supplies the address of the block of pool being deallocated. 02787 02788 Return Value: 02789 02790 None. 02791 02792 --*/ 02793 02794 POOL_TYPE CheckType; 02795 PPOOL_HEADER Entry; 02796 ULONG Index; 02797 KIRQL LockHandle; 02798 PNPAGED_LOOKASIDE_LIST LookasideList; 02799 PPOOL_HEADER NextEntry; 02800 ULONG PoolIndex; 02801 POOL_TYPE PoolType; 02802 PPOOL_DESCRIPTOR PoolDesc; 02803 PEPROCESS ProcessBilled; 02804 LOGICAL Combined; 02805 ULONG BigPages; 02806 ULONG Tag; 02807 LOGICAL GlobalSpace; 02808 PKPRCB Prcb; 02809 PERFINFO_EXFREEPOOLWITHTAG_DECL(); 02810 02811 PERFINFO_FREEPOOL(P); 02812 02813 if ((P >= MmSpecialPoolStart) && (P < MmSpecialPoolEnd)) { 02814 MmFreeSpecialPool (P); 02815 return; 02816 } 02817 02818 ProcessBilled = NULL; 02819 02820 // 02821 // If entry is page aligned, then call free block to the page aligned 02822 // pool. Otherwise, free the block to the allocation lists. 02823 // 02824 02825 if (PAGE_ALIGNED(P)) { 02826 02827 PoolType = MmDeterminePoolType(P); 02828 02829 ASSERT_FREE_IRQL(PoolType, P); 02830 02831 CheckType = PoolType & BASE_POOL_TYPE_MASK; 02832 02833 if (PoolType == PagedPoolSession) { 02834 PoolDesc = ExpSessionPoolDescriptor; 02835 } 02836 else { 02837 PoolDesc = PoolVector[PoolType]; 02838 } 02839 02840 if ((PoolTrackTable != NULL) && (PoolType != PagedPoolSession)) { 02841 Tag = ExpFindAndRemoveTagBigPages(P); 02842 } 02843 02844 LOCK_POOL(PoolDesc, LockHandle); 02845 02846 PoolDesc->RunningDeAllocs += 1; 02847 02848 // 02849 // Large session pool allocations are accounted for directly by 02850 // the memory manager so no need to call MiSessionPoolFreed here. 02851 // 02852 02853 BigPages = MiFreePoolPages(P); 02854 02855 if ((PoolTrackTable != NULL) && (PoolType != PagedPoolSession)) { 02856 if (Tag & PROTECTED_POOL) { 02857 Tag &= ~PROTECTED_POOL; 02858 TagToFree &= ~PROTECTED_POOL; 02859 if (Tag != TagToFree) { 02860 DbgPrint( "EX: Invalid attempt to free protected pool block %x (%c%c%c%c)\n", 02861 P, 02862 Tag, 02863 Tag >> 8, 02864 Tag >> 16, 02865 Tag >> 24 02866 ); 02867 DbgBreakPoint(); 02868 } 02869 } 02870 02871 ExpRemovePoolTracker(Tag, 02872 BigPages * PAGE_SIZE, 02873 PoolType); 02874 } 02875 02876 // 02877 // Check if an ERESOURCE is currently active in this memory block. 02878 // 02879 02880 FREE_CHECK_ERESOURCE (P, BigPages << PAGE_SHIFT); 02881 02882 // 02883 // Check if a KTIMER is currently active in this memory block 02884 // 02885 02886 FREE_CHECK_KTIMER(P, BigPages << PAGE_SHIFT); 02887 02888 // 02889 // Search worker queues for work items still queued 02890 // 02891 FREE_CHECK_WORKER(P, BigPages << PAGE_SHIFT); 02892 02893 PoolDesc->TotalBigPages -= BigPages; 02894 02895 UNLOCK_POOL(PoolDesc, LockHandle); 02896 02897 return; 02898 } 02899 02900 // 02901 // Align the entry address to a pool allocation boundary. 02902 // 02903 02904 #if POOL_CACHE_SUPPORTED 02905 02906 if (((ULONG)P & POOL_CACHE_CHECK) == 0) { 02907 Entry = (PPOOL_HEADER)((ULONG)P - PoolCacheSize); 02908 02909 } else { 02910 Entry = (PPOOL_HEADER)((PCHAR)P - POOL_OVERHEAD); 02911 } 02912 02913 #else 02914 02915 Entry = (PPOOL_HEADER)((PCHAR)P - POOL_OVERHEAD); 02916 02917 #endif //POOL_CACHE_SUPPORTED 02918 02919 ASSERT_POOL_NOT_FREE(Entry); 02920 02921 PoolType = (Entry->PoolType & POOL_TYPE_MASK) - 1; 02922 02923 CheckType = PoolType & BASE_POOL_TYPE_MASK; 02924 02925 ASSERT_FREE_IRQL(PoolType, P); 02926 02927 if (Entry->PoolType & POOL_VERIFIER_MASK) { 02928 VerifierFreeTrackedPool (P, 02929 Entry->BlockSize << POOL_BLOCK_SHIFT, 02930 CheckType, 02931 FALSE); 02932 } 02933 02934 PoolDesc = PoolVector[PoolType]; 02935 GlobalSpace = TRUE; 02936 02937 if (Entry->PoolType & SESSION_POOL_MASK) { 02938 if (CheckType == PagedPool) { 02939 PoolDesc = ExpSessionPoolDescriptor; 02940 } 02941 GlobalSpace = FALSE; 02942 } 02943 else if (CheckType == PagedPool) { 02944 PoolDesc = &PoolDesc[DECODE_POOL_INDEX(Entry)]; 02945 } 02946 02947 LOCK_POOL(PoolDesc, LockHandle); 02948 02949 if (!IS_POOL_HEADER_MARKED_ALLOCATED(Entry)) { 02950 KeBugCheckEx (BAD_POOL_CALLER, 7, __LINE__, (ULONG_PTR)Entry, (ULONG_PTR)P); 02951 } 02952 02953 MARK_POOL_HEADER_FREED(Entry); 02954 02955 // 02956 // If this allocation was in session space, let the memory 02957 // manager know to delete it so it won't be considered in use on 02958 // session exit. Note this call must be made with the 02959 // relevant pool still locked. 02960 // 02961 02962 if (GlobalSpace == FALSE) { 02963 MiSessionPoolFreed(P, Entry->BlockSize << POOL_BLOCK_SHIFT, CheckType); 02964 } 02965 02966 UNLOCK_POOL(PoolDesc, LockHandle); 02967 02968 ASSERT_POOL_TYPE_NOT_ZERO(Entry); 02969 02970 // 02971 // Check if an ERESOURCE is currently active in this memory block. 02972 // 02973 02974 FREE_CHECK_ERESOURCE (Entry, (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT)); 02975 02976 // 02977 // Check if a KTIMER is currently active in this memory block. 02978 // 02979 02980 FREE_CHECK_KTIMER(Entry, (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT)); 02981 02982 // 02983 // Look for work items still queued 02984 // 02985 02986 FREE_CHECK_WORKER(Entry, (ULONG)(Entry->BlockSize << POOL_BLOCK_SHIFT)); 02987 02988 02989 #if DBG 02990 02991 // 02992 // Check if the pool index field is defined correctly. 02993 // 02994 02995 if (CheckType == NonPagedPool) { 02996 if (DECODE_POOL_INDEX(Entry) != 0) { 02997 KeBugCheckEx(BAD_POOL_CALLER, 2, (ULONG_PTR)Entry, (ULONG_PTR)(*(PULONG)Entry), 0); 02998 } 02999 } 03000 else { 03001 if (GlobalSpace == FALSE) { 03002 // 03003 // All session space allocations have an index of 0. 03004 // 03005 ASSERT (DECODE_POOL_INDEX(Entry) == 0); 03006 } 03007 else if (DECODE_POOL_INDEX(Entry) == 0) { 03008 KeBugCheckEx(BAD_POOL_CALLER, 4, (ULONG_PTR)Entry, *(PULONG)Entry, 0); 03009 } 03010 } 03011 03012 #endif // DBG 03013 03014 // 03015 // If pool tagging is enabled, then update the pool tracking database. 03016 // Otherwise, check to determine if quota was charged when the pool 03017 // block was allocated. 03018 // 03019 03020 #if defined (_WIN64) 03021 if (Entry->PoolType & POOL_QUOTA_MASK) { 03022 ProcessBilled = Entry->ProcessBilled; 03023 } 03024 03025 Tag = Entry->PoolTag; 03026 if (Tag & PROTECTED_POOL) { 03027 Tag &= ~PROTECTED_POOL; 03028 TagToFree &= ~PROTECTED_POOL; 03029 if (Tag != TagToFree) { 03030 DbgPrint( "EX: Invalid attempt to free protected pool block %x (%c%c%c%c)\n", 03031 P, 03032 Tag, 03033 Tag >> 8, 03034 Tag >> 16, 03035 Tag >> 24 03036 ); 03037 DbgBreakPoint(); 03038 } 03039 } 03040 if (PoolTrackTable != NULL) { 03041 if (GlobalSpace == TRUE) { 03042 ExpRemovePoolTracker(Tag, 03043 Entry->BlockSize << POOL_BLOCK_SHIFT, 03044 PoolType); 03045 03046 } 03047 } 03048 if (ProcessBilled != NULL) { 03049 PsReturnPoolQuota(ProcessBilled, 03050 PoolType & BASE_POOL_TYPE_MASK, 03051 (ULONG)Entry->BlockSize << POOL_BLOCK_SHIFT); 03052 ObDereferenceObject(ProcessBilled); 03053 } 03054 #else 03055 if (Entry->PoolType & POOL_QUOTA_MASK) { 03056 if (PoolTrackTable == NULL) { 03057 ProcessBilled = Entry->ProcessBilled; 03058 Entry->PoolTag = 'atoQ'; 03059 } 03060 } 03061 03062 if (PoolTrackTable != NULL) { 03063 Tag = Entry->PoolTag; 03064 if (Tag & PROTECTED_POOL) { 03065 Tag &= ~PROTECTED_POOL; 03066 TagToFree &= ~PROTECTED_POOL; 03067 if (Tag != TagToFree) { 03068 DbgPrint( "EX: Invalid attempt to free protected pool block %x (%c%c%c%c)\n", 03069 P, 03070 Tag, 03071 Tag >> 8, 03072 Tag >> 16, 03073 Tag >> 24 03074 ); 03075 DbgBreakPoint(); 03076 } 03077 } 03078 if (GlobalSpace == TRUE) { 03079 ExpRemovePoolTracker(Tag, 03080 Entry->BlockSize << POOL_BLOCK_SHIFT , 03081 PoolType); 03082 } 03083 } else if (ProcessBilled != NULL) { 03084 PsReturnPoolQuota(ProcessBilled, 03085 PoolType & BASE_POOL_TYPE_MASK, 03086 (ULONG)Entry->BlockSize << POOL_BLOCK_SHIFT); 03087 ObDereferenceObject(ProcessBilled); 03088 } 03089 #endif 03090 03091 // 03092 // If the pool block is a small block, then attempt to free the block 03093 // to the single entry lookaside list. If the free attempt fails, then 03094 // free the block by merging it back into the pool data structures. 03095 // 03096 03097 PoolIndex = DECODE_POOL_INDEX(Entry); 03098 03099 Index = Entry->BlockSize; 03100 03101 if (Index <= POOL_SMALL_LISTS && GlobalSpace == TRUE) { 03102 03103 // 03104 // Attempt to free the small block to a per processor lookaside 03105 // list. 03106 // 03107 03108 if (CheckType == PagedPool) { 03109 if (Isx86FeaturePresent(KF_CMPXCHG8B)) { 03110 Prcb = KeGetCurrentPrcb(); 03111 LookasideList = Prcb->PPPagedLookasideList[Index - 1].P; 03112 LookasideList->L.TotalFrees += 1; 03113 03114 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03115 03116 if (ExQueryDepthSList(&LookasideList->L.ListHead) < LookasideList->L.Depth) { 03117 LookasideList->L.FreeHits += 1; 03118 Entry += 1; 03119 ExInterlockedPushEntrySList(&LookasideList->L.ListHead, 03120 (PSINGLE_LIST_ENTRY)Entry, 03121 &LookasideList->Lock); 03122 03123 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03124 03125 return; 03126 03127 } else { 03128 LookasideList = Prcb->PPPagedLookasideList[Index - 1].L; 03129 LookasideList->L.TotalFrees += 1; 03130 03131 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03132 03133 if (ExQueryDepthSList(&LookasideList->L.ListHead) < LookasideList->L.Depth) { 03134 LookasideList->L.FreeHits += 1; 03135 Entry += 1; 03136 ExInterlockedPushEntrySList(&LookasideList->L.ListHead, 03137 (PSINGLE_LIST_ENTRY)Entry, 03138 &LookasideList->Lock); 03139 03140 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03141 03142 return; 03143 } 03144 } 03145 } 03146 03147 } else { 03148 03149 // 03150 // Make sure we don't put a must succeed buffer into the 03151 // regular nonpaged pool list. 03152 // 03153 03154 if (PoolType != NonPagedPoolMustSucceed) { 03155 Prcb = KeGetCurrentPrcb(); 03156 LookasideList = Prcb->PPNPagedLookasideList[Index - 1].P; 03157 LookasideList->L.TotalFrees += 1; 03158 03159 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03160 03161 if (ExQueryDepthSList(&LookasideList->L.ListHead) < LookasideList->L.Depth) { 03162 LookasideList->L.FreeHits += 1; 03163 Entry += 1; 03164 ExInterlockedPushEntrySList(&LookasideList->L.ListHead, 03165 (PSINGLE_LIST_ENTRY)Entry, 03166 &LookasideList->Lock); 03167 03168 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03169 03170 return; 03171 03172 } else { 03173 LookasideList = Prcb->PPNPagedLookasideList[Index - 1].L; 03174 LookasideList->L.TotalFrees += 1; 03175 03176 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03177 03178 if (ExQueryDepthSList(&LookasideList->L.ListHead) < LookasideList->L.Depth) { 03179 LookasideList->L.FreeHits += 1; 03180 Entry += 1; 03181 ExInterlockedPushEntrySList(&LookasideList->L.ListHead, 03182 (PSINGLE_LIST_ENTRY)Entry, 03183 &LookasideList->Lock); 03184 03185 CHECK_LOOKASIDE_LIST(__LINE__, LookasideList, P); 03186 03187 return; 03188 } 03189 } 03190 } 03191 } 03192 } 03193 03194 ASSERT(PoolIndex == PoolDesc->PoolIndex); 03195 03196 LOCK_POOL(PoolDesc, LockHandle); 03197 03198 CHECK_POOL_HEADER(__LINE__, Entry); 03199 03200 PoolDesc->RunningDeAllocs += 1; 03201 03202 // 03203 // Free the specified pool block. 03204 // 03205 // Check to see if the next entry is free. 03206 // 03207 03208 Combined = FALSE; 03209 NextEntry = (PPOOL_HEADER)((PPOOL_BLOCK)Entry + Entry->BlockSize); 03210 if (PAGE_END(NextEntry) == FALSE) { 03211 03212 if (NextEntry->PoolType == 0) { 03213 03214 // 03215 // This block is free, combine with the released block. 03216 // 03217 03218 Combined = TRUE; 03219 03220 CHECK_LIST(__LINE__, ((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD)), P); 03221 PrivateRemoveEntryList(((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD))); 03222 CHECK_LIST(__LINE__, DecodeLink(((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD))->Flink), P); 03223 CHECK_LIST(__LINE__, DecodeLink(((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD))->Blink), P); 03224 03225 Entry->BlockSize += NextEntry->BlockSize; 03226 } 03227 } 03228 03229 // 03230 // Check to see if the previous entry is free. 03231 // 03232 03233 if (Entry->PreviousSize != 0) { 03234 NextEntry = (PPOOL_HEADER)((PPOOL_BLOCK)Entry - Entry->PreviousSize); 03235 if (NextEntry->PoolType == 0) { 03236 03237 // 03238 // This block is free, combine with the released block. 03239 // 03240 03241 Combined = TRUE; 03242 03243 CHECK_LIST(__LINE__, ((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD)), P); 03244 PrivateRemoveEntryList(((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD))); 03245 CHECK_LIST(__LINE__, DecodeLink(((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD))->Flink), P); 03246 CHECK_LIST(__LINE__, DecodeLink(((PLIST_ENTRY)((PCHAR)NextEntry + POOL_OVERHEAD))->Blink), P); 03247 03248 NextEntry->BlockSize += Entry->BlockSize; 03249 Entry = NextEntry; 03250 } 03251 } 03252 03253 // 03254 // If the block being freed has been combined into a full page, 03255 // then return the free page to memory management. 03256 // 03257 03258 if (PAGE_ALIGNED(Entry) && 03259 (PAGE_END((PPOOL_BLOCK)Entry + Entry->BlockSize) != FALSE)) { 03260 03261 // 03262 // If the pool type is paged pool, then the paged pool page lock 03263 // must be held during the free of the pool pages. 03264 // 03265 03266 LOCK_IF_PAGED_POOL(CheckType, GlobalSpace); 03267 03268 PERFINFO_FREEPOOLPAGE(CheckType, PoolIndex, Entry, PoolDesc); 03269 03270 MiFreePoolPages(Entry); 03271 03272 UNLOCK_IF_PAGED_POOL(CheckType, GlobalSpace); 03273 03274 PoolDesc->TotalPages -= 1; 03275 03276 } else { 03277 03278 // 03279 // Insert this element into the list. 03280 // 03281 03282 Entry->PoolType = 0; 03283 ENCODE_POOL_INDEX(Entry, PoolIndex); 03284 Index = Entry->BlockSize; 03285 03286 // 03287 // If the freed block was combined with any other block, then 03288 // adjust the size of the next block if necessary. 03289 // 03290 03291 if (Combined != FALSE) { 03292 03293 // 03294 // The size of this entry has changed, if this entry is 03295 // not the last one in the page, update the pool block 03296 // after this block to have a new previous allocation size. 03297 // 03298 03299 NextEntry = (PPOOL_HEADER)((PPOOL_BLOCK)Entry + Entry->BlockSize); 03300 if (PAGE_END(NextEntry) == FALSE) { 03301 NextEntry->PreviousSize = Entry->BlockSize; 03302 } 03303 03304 // 03305 // Reduce fragmentation and insert at the tail in hopes 03306 // neighbors for this will be freed before this is reallocated. 03307 // 03308 03309 CHECK_LIST(__LINE__, &PoolDesc->ListHeads[Index - 1], P); 03310 PrivateInsertTailList(&PoolDesc->ListHeads[Index - 1], ((PLIST_ENTRY)((PCHAR)Entry + POOL_OVERHEAD))); 03311 CHECK_LIST(__LINE__, &PoolDesc->ListHeads[Index - 1], P); 03312 CHECK_LIST(__LINE__, ((PLIST_ENTRY)((PCHAR)Entry + POOL_OVERHEAD)), P); 03313 03314 } else { 03315 03316 CHECK_LIST(__LINE__, &PoolDesc->ListHeads[Index - 1], P); 03317 PrivateInsertHeadList(&PoolDesc->ListHeads[Index - 1], ((PLIST_ENTRY)((PCHAR)Entry + POOL_OVERHEAD))); 03318 CHECK_LIST(__LINE__, &PoolDesc->ListHeads[Index - 1], P); 03319 CHECK_LIST(__LINE__, ((PLIST_ENTRY)((PCHAR)Entry + POOL_OVERHEAD)), P); 03320 } 03321 } 03322 03323 UNLOCK_POOL(PoolDesc, LockHandle); 03324 }

__inline VOID ExFreeToNPagedLookasideList IN PNPAGED_LOOKASIDE_LIST  Lookaside,
IN PVOID  Entry
 

Definition at line 821 of file ex.h.

References ExInterlockedPushEntrySList(), and ExQueryDepthSList.

Referenced by ExFreeToPPNPagedLookasideList(), FsRtlFreeExclusiveLock(), FsRtlFreeLockInfo(), FsRtlFreeLockTreeNode(), FsRtlFreeSharedLock(), FsRtlFreeWaitingLock(), and UdfCleanupIrpContext().

00828 : 00829 00830 This function inserts (pushes) the specified entry into the specified 00831 nonpaged lookaside list. 00832 00833 Arguments: 00834 00835 Lookaside - Supplies a pointer to a nonpaged lookaside list structure. 00836 00837 Entry - Supples a pointer to the entry that is inserted in the 00838 lookaside list. 00839 00840 Return Value: 00841 00842 None. 00843 00844 --*/ 00845 00846 { 00847 00848 Lookaside->L.TotalFrees += 1; 00849 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { 00850 Lookaside->L.FreeMisses += 1; 00851 (Lookaside->L.Free)(Entry); 00852 00853 } else { 00854 ExInterlockedPushEntrySList(&Lookaside->L.ListHead, 00855 (PSINGLE_LIST_ENTRY)Entry, 00856 &Lookaside->Lock); 00857 } 00858 00859 return; 00860 }

__inline VOID ExFreeToPagedLookasideList IN PPAGED_LOOKASIDE_LIST  Lookaside,
IN PVOID  Entry
 

Definition at line 947 of file ex.h.

References ExInterlockedPushEntrySList(), ExQueryDepthSList, and NULL.

Referenced by DelQEntry(), FreeQueue(), FreeSMS(), FsRtlFreeFileLock(), FsRtlFreeTunnelNode(), and UdfRemovePrefix().

00954 : 00955 00956 This function inserts (pushes) the specified entry into the specified 00957 paged lookaside list. 00958 00959 Arguments: 00960 00961 Lookaside - Supplies a pointer to a nonpaged lookaside list structure. 00962 00963 Entry - Supples a pointer to the entry that is inserted in the 00964 lookaside list. 00965 00966 Return Value: 00967 00968 None. 00969 00970 --*/ 00971 00972 { 00973 00974 Lookaside->L.TotalFrees += 1; 00975 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { 00976 Lookaside->L.FreeMisses += 1; 00977 (Lookaside->L.Free)(Entry); 00978 00979 } else { 00980 ExInterlockedPushEntrySList(&Lookaside->L.ListHead, 00981 (PSINGLE_LIST_ENTRY)Entry, 00982 NULL); 00983 } 00984 00985 return; 00986 }

__inline VOID ExFreeToPPNPagedLookasideList IN PP_NPAGED_LOOKASIDE_NUMBER  Number,
IN PVOID  Entry
 

Definition at line 1077 of file ex.h.

References ASSERT, _GENERAL_LOOKASIDE::Depth, ExFreeToNPagedLookasideList(), ExInterlockedPushEntrySList(), ExQueryDepthSList, _GENERAL_LOOKASIDE::FreeMisses, KeGetCurrentPrcb, _NPAGED_LOOKASIDE_LIST::L, _GENERAL_LOOKASIDE::ListHead, _NPAGED_LOOKASIDE_LIST::Lock, LookasideMaximumList, PNPAGED_LOOKASIDE_LIST, and _GENERAL_LOOKASIDE::TotalFrees.

Referenced by IoFreeMdl(), and ObpFreeObjectNameBuffer().

01084 : 01085 01086 This function inserts (pushes) the specified entry into the specified 01087 nonpaged per processor lookaside list. 01088 01089 Arguments: 01090 01091 Number - Supplies the per processor nonpaged lookaside list number. 01092 01093 Entry - Supples a pointer to the entry that is inserted in the nonpaged 01094 per processor lookaside list. 01095 01096 Return Value: 01097 01098 None. 01099 01100 --*/ 01101 01102 { 01103 01104 PNPAGED_LOOKASIDE_LIST Lookaside; 01105 PKPRCB Prcb; 01106 01107 // 01108 // Get address of current processor block. 01109 // 01110 // N.B. It is possible to context switch during the free to a per 01111 // processor nonpaged lookaside list, but this should happen 01112 // infrequently and should not aversely effect the benefits of 01113 // per processor lookaside lists. 01114 // 01115 01116 ASSERT((Number >= 0) && (Number < LookasideMaximumList)); 01117 01118 Prcb = KeGetCurrentPrcb(); 01119 01120 // 01121 // If the current depth is less than of equal to the maximum depth, then 01122 // free the specified entry to the per processor lookaside list. Otherwise, 01123 // free the entry to the system lookaside list; 01124 // 01125 // 01126 01127 Lookaside = Prcb->PPLookasideList[Number].P; 01128 Lookaside->L.TotalFrees += 1; 01129 if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { 01130 Lookaside->L.FreeMisses += 1; 01131 Lookaside = Prcb->PPLookasideList[Number].L; 01132 ExFreeToNPagedLookasideList(Lookaside, Entry); 01133 01134 } else { 01135 ExInterlockedPushEntrySList(&Lookaside->L.ListHead, 01136 (PSINGLE_LIST_ENTRY)Entry, 01137 &Lookaside->Lock); 01138 } 01139 01140 return; 01141 }

NTKERNELAPI ULONG ExGetExclusiveWaiterCount IN PERESOURCE  Resource  ) 
 

Definition at line 2133 of file ex/resource.c.

References _ERESOURCE::NumberOfExclusiveWaiters, and Resource.

Referenced by MNAnimate().

02139 : 02140 02141 This routine returns the exclusive waiter count. 02142 02143 02144 Arguments: 02145 02146 Resource - Supplies a pointer to and executive resource. 02147 02148 Return Value: 02149 02150 The current number of exclusive waiters is returned as the function 02151 value. 02152 02153 --*/ 02154 02155 { 02156 return Resource->NumberOfExclusiveWaiters; 02157 }

VOID ExGetNextWakeTime OUT PULONGLONG  DueTime,
OUT PTIME_FIELDS  TimeFields,
OUT PVOID *  TimerObject
 

Definition at line 1212 of file timer.c.

References ExpWakeTimerList, ExpWakeTimerListLock, ExSystemTimeToLocalTime(), KeQueryInterruptTime(), KeQuerySystemTime(), KeQueryTimerDueTime(), _ETIMER::KeTimer, NULL, PETIMER, RtlTimeToTimeFields(), TimeFields, _ETIMER::WakeTimer, and _ETIMER::WakeTimerListEntry.

01217 { 01218 PLIST_ENTRY Link; 01219 PETIMER ExTimer; 01220 PETIMER BestTimer; 01221 KIRQL OldIrql; 01222 ULONGLONG TimerDueTime; 01223 ULONGLONG BestDueTime; 01224 ULONGLONG InterruptTime; 01225 LARGE_INTEGER SystemTime; 01226 LARGE_INTEGER CmosTime; 01227 01228 ExAcquireSpinLock(&ExpWakeTimerListLock, &OldIrql); 01229 BestDueTime = 0; 01230 BestTimer = NULL; 01231 Link = ExpWakeTimerList.Flink; 01232 while (Link != &ExpWakeTimerList) { 01233 ExTimer = CONTAINING_RECORD(Link, ETIMER, WakeTimerListEntry); 01234 Link = Link->Flink; 01235 01236 if (ExTimer->WakeTimer) { 01237 01238 TimerDueTime = KeQueryTimerDueTime(&ExTimer->KeTimer); 01239 TimerDueTime = 0 - TimerDueTime; 01240 01241 // 01242 // Is this timers due time closer? 01243 // 01244 01245 if (TimerDueTime > BestDueTime) { 01246 BestDueTime = TimerDueTime; 01247 BestTimer = ExTimer; 01248 } 01249 01250 } else { 01251 01252 // 01253 // Timer is not an active wake timer, remove it 01254 // 01255 01256 RemoveEntryList(&ExTimer->WakeTimerListEntry); 01257 ExTimer->WakeTimerListEntry.Flink = NULL; 01258 } 01259 } 01260 01261 ExReleaseSpinLock(&ExpWakeTimerListLock, OldIrql); 01262 01263 if (BestDueTime) { 01264 // 01265 // Convert time to timefields 01266 // 01267 01268 KeQuerySystemTime (&SystemTime); 01269 InterruptTime = KeQueryInterruptTime (); 01270 BestDueTime = 0 - BestDueTime; 01271 01272 SystemTime.QuadPart += BestDueTime - InterruptTime; 01273 01274 // 01275 // Many system alarms are only good to 1 second resolution. 01276 // Add one sceond to the target time so that the timer is really 01277 // elasped if this is the wake event. 01278 // 01279 01280 SystemTime.QuadPart += 10000000; 01281 01282 ExSystemTimeToLocalTime(&SystemTime,&CmosTime); 01283 RtlTimeToTimeFields(&CmosTime, TimeFields); 01284 } 01285 01286 *DueTime = BestDueTime; 01287 *TimerObject = BestTimer; 01288 }

NTKERNELAPI KPROCESSOR_MODE ExGetPreviousMode VOID   ) 
 

NTKERNELAPI ULONG ExGetSharedWaiterCount IN PERESOURCE  Resource  ) 
 

Definition at line 2160 of file ex/resource.c.

References _ERESOURCE::NumberOfSharedWaiters, and Resource.

Referenced by MNAnimate().

02166 : 02167 02168 This routine returns the shared waiter count. 02169 02170 02171 Arguments: 02172 02173 Resource - Supplies a pointer to and executive resource. 02174 02175 Return Value: 02176 02177 The current number of shared waiters is returned as the function 02178 value. 02179 02180 --*/ 02181 02182 { 02183 return Resource->NumberOfSharedWaiters; 02184 }

VOID ExInitializeCallData IN PCALL_PERFORMANCE_DATA  CallData  ) 
 

Definition at line 28 of file callperf.c.

References CALL_HASH_TABLE_SIZE, Index, KeInitializeSpinLock(), and PCALL_PERFORMANCE_DATA.

Referenced by KiInitSystem().

00034 : 00035 00036 This function initializes a call performance data structure. 00037 00038 Arguments: 00039 00040 CallData - Supplies a pointer to the call performance data structure 00041 that is initialized. 00042 00043 Return Value: 00044 00045 None. 00046 00047 --*/ 00048 00049 { 00050 00051 ULONG Index; 00052 00053 // 00054 // Initialize the spinlock and listheads for the call performance 00055 // data structure. 00056 // 00057 00058 KeInitializeSpinLock(&CallData->SpinLock); 00059 for (Index = 0; Index < CALL_HASH_TABLE_SIZE; Index += 1) { 00060 InitializeListHead(&CallData->HashTable[Index]); 00061 } 00062 }

NTKERNELAPI VOID ExInitializeHandleTablePackage VOID   ) 
 

Definition at line 422 of file ex/handle.c.

References ExInitializeResource, HandleTableListHead, and HandleTableListLock.

00428 : 00429 00430 This routine is called once at system initialization to setup the ex handle 00431 table package 00432 00433 Arguments: 00434 00435 None. 00436 00437 Return Value: 00438 00439 None. 00440 00441 --*/ 00442 00443 { 00444 // 00445 // Initialize the handle table synchronization resource and list head 00446 // 00447 00448 InitializeListHead( &HandleTableListHead ); 00449 ExInitializeResource( &HandleTableListLock ); 00450 00451 return; 00452 }

NTKERNELAPI VOID ExInitializeNPagedLookasideList IN PNPAGED_LOOKASIDE_LIST  Lookaside,
IN PALLOCATE_FUNCTION  Allocate,
IN PFREE_FUNCTION  Free,
IN ULONG  Flags,
IN SIZE_T  Size,
IN ULONG  Tag,
IN USHORT  Depth
 

Definition at line 408 of file ex/lookasid.c.

References ExAllocatePoolWithTag, ExFreePool(), ExInitializeSListHead, ExInterlockedInsertTailList(), ExNPagedLookasideListHead, ExNPagedLookasideLock, KeInitializeSpinLock(), MINIMUM_LOOKASIDE_DEPTH, NonPagedPool, NULL, and Size.

Referenced by CcInitializeCacheManager(), FsRtlInitializeFileLocks(), FsRtlInitializeLargeMcbs(), IoInitSystem(), and ObInitSystem().

00420 : 00421 00422 This function initializes a nonpaged lookaside list structure and inserts 00423 the structure in the system nonpaged lookaside list. 00424 00425 Arguments: 00426 00427 Lookaside - Supplies a pointer to a nonpaged lookaside list structure. 00428 00429 Allocate - Supplies an optional pointer to an allocate function. 00430 00431 Free - Supplies an optional pointer to a free function. 00432 00433 Flags - Supplies the pool allocation flags which are merged with the 00434 pool allocation type (NonPagedPool) to control pool allocation. 00435 00436 Size - Supplies the size for the lookaside list entries. 00437 00438 Tag - Supplies the pool tag for the lookaside list entries. 00439 00440 Depth - Supplies the maximum depth of the lookaside list. 00441 00442 Return Value: 00443 00444 None. 00445 00446 --*/ 00447 00448 { 00449 00450 // 00451 // Initialize the lookaside list structure. 00452 // 00453 00454 ExInitializeSListHead(&Lookaside->L.ListHead); 00455 Lookaside->L.Depth = MINIMUM_LOOKASIDE_DEPTH; 00456 Lookaside->L.MaximumDepth = 256; //Depth; 00457 Lookaside->L.TotalAllocates = 0; 00458 Lookaside->L.AllocateMisses = 0; 00459 Lookaside->L.TotalFrees = 0; 00460 Lookaside->L.FreeMisses = 0; 00461 Lookaside->L.Type = NonPagedPool | Flags; 00462 Lookaside->L.Tag = Tag; 00463 Lookaside->L.Size = (ULONG)Size; 00464 if (Allocate == NULL) { 00465 Lookaside->L.Allocate = ExAllocatePoolWithTag; 00466 00467 } else { 00468 Lookaside->L.Allocate = Allocate; 00469 } 00470 00471 if (Free == NULL) { 00472 Lookaside->L.Free = ExFreePool; 00473 00474 } else { 00475 Lookaside->L.Free = Free; 00476 } 00477 00478 Lookaside->L.LastTotalAllocates = 0; 00479 Lookaside->L.LastAllocateMisses = 0; 00480 KeInitializeSpinLock(&Lookaside->Lock); 00481 00482 // 00483 // Insert the lookaside list structure is the system nonpaged lookaside 00484 // list. 00485 // 00486 00487 ExInterlockedInsertTailList(&ExNPagedLookasideListHead, 00488 &Lookaside->L.ListEntry, 00489 &ExNPagedLookasideLock); 00490 return; 00491 }

NTKERNELAPI VOID ExInitializePagedLookasideList IN PPAGED_LOOKASIDE_LIST  Lookaside,
IN PALLOCATE_FUNCTION  Allocate,
IN PFREE_FUNCTION  Free,
IN ULONG  Flags,
IN SIZE_T  Size,
IN ULONG  Tag,
IN USHORT  Depth
 

Definition at line 543 of file ex/lookasid.c.

References ExAllocatePoolWithTag, ExFreePool(), ExInitializeFastMutex, ExInitializeSListHead, ExInterlockedInsertTailList(), ExPagedLookasideListHead, ExPagedLookasideLock, MINIMUM_LOOKASIDE_DEPTH, NULL, PagedPool, and Size.

Referenced by FsRtlInitializeFileLocks(), FsRtlInitializeLargeMcbs(), FsRtlInitializeTunnels(), InitQEntryLookaside(), and InitSMSLookaside().

00555 : 00556 00557 This function initializes a paged lookaside list structure and inserts 00558 the structure in the system paged lookaside list. 00559 00560 Arguments: 00561 00562 Lookaside - Supplies a pointer to a paged lookaside list structure. 00563 00564 Allocate - Supplies an optional pointer to an allocate function. 00565 00566 Free - Supplies an optional pointer to a free function. 00567 00568 Flags - Supplies the pool allocation flags which are merged with the 00569 pool allocation type (NonPagedPool) to control pool allocation. 00570 00571 Size - Supplies the size for the lookaside list entries. 00572 00573 Tag - Supplies the pool tag for the lookaside list entries. 00574 00575 Depth - Supplies the maximum depth of the lookaside list. 00576 00577 Return Value: 00578 00579 None. 00580 00581 --*/ 00582 00583 { 00584 00585 // 00586 // Initialize the lookaside list structure. 00587 // 00588 00589 ExInitializeSListHead(&Lookaside->L.ListHead); 00590 Lookaside->L.Depth = MINIMUM_LOOKASIDE_DEPTH; 00591 Lookaside->L.MaximumDepth = 256; //Depth; 00592 Lookaside->L.TotalAllocates = 0; 00593 Lookaside->L.AllocateMisses = 0; 00594 Lookaside->L.TotalFrees = 0; 00595 Lookaside->L.FreeMisses = 0; 00596 Lookaside->L.Type = PagedPool | Flags; 00597 Lookaside->L.Tag = Tag; 00598 Lookaside->L.Size = (ULONG)Size; 00599 if (Allocate == NULL) { 00600 Lookaside->L.Allocate = ExAllocatePoolWithTag; 00601 00602 } else { 00603 Lookaside->L.Allocate = Allocate; 00604 } 00605 00606 if (Free == NULL) { 00607 Lookaside->L.Free = ExFreePool; 00608 00609 } else { 00610 Lookaside->L.Free = Free; 00611 } 00612 00613 Lookaside->L.LastTotalAllocates = 0; 00614 Lookaside->L.LastAllocateMisses = 0; 00615 ExInitializeFastMutex(&Lookaside->Lock); 00616 00617 // 00618 // Insert the lookaside list structure in the system paged lookaside 00619 // list. 00620 // 00621 00622 ExInterlockedInsertTailList(&ExPagedLookasideListHead, 00623 &Lookaside->L.ListEntry, 00624 &ExPagedLookasideLock); 00625 return; 00626 }

NTKERNELAPI NTSTATUS ExInitializeResourceLite IN PERESOURCE  Resource  ) 
 

Definition at line 209 of file ex/resource.c.

References _RESOURCE_PERFORMANCE_DATA::ActiveResourceCount, _ERESOURCE::Address, ASSERT, _ERESOURCE::CreatorBackTraceIndex, ExInterlockedInsertTailList(), ExpResourceSpinLock, ExpSystemResourcesList, KeInitializeSpinLock(), MmDeterminePoolType(), NonPagedPool, NtGlobalFlag, Resource, RtlGetCallersAddress(), _ERESOURCE::SpinLock, _ERESOURCE::SystemResourcesList, and _RESOURCE_PERFORMANCE_DATA::TotalResourceCount.

Referenced by InitCreateUserCrit(), ObCreateObjectType(), and ObInitSystem().

00215 : 00216 00217 This routine initializes the specified resource. 00218 00219 Arguments: 00220 00221 Resource - Supplies a pointer to the resource to initialize. 00222 00223 Return Value: 00224 00225 STATUS_SUCCESS. 00226 00227 --*/ 00228 00229 { 00230 00231 PVOID CallersCaller; 00232 00233 ASSERT(MmDeterminePoolType(Resource) == NonPagedPool); 00234 00235 // 00236 // Initialize the specified resource. 00237 // 00238 // N.B. All fields are initialized to zero (NULL pointers) except 00239 // the list entry and spinlock. 00240 // 00241 00242 RtlZeroMemory(Resource, sizeof(ERESOURCE)); 00243 KeInitializeSpinLock(&Resource->SpinLock); 00244 00245 #if i386 && !FPO 00246 if (NtGlobalFlag & FLG_KERNEL_STACK_TRACE_DB) { 00247 Resource->CreatorBackTraceIndex = RtlLogStackBackTrace(); 00248 } 00249 else { 00250 Resource->CreatorBackTraceIndex = 0; 00251 } 00252 #endif // i386 && !FPO 00253 ExInterlockedInsertTailList(&ExpSystemResourcesList, 00254 &Resource->SystemResourcesList, 00255 &ExpResourceSpinLock); 00256 00257 // 00258 // Initialize performance data entry for the resource. 00259 // 00260 00261 #if defined(_COLLECT_RESOURCE_DATA_) 00262 00263 RtlGetCallersAddress(&Resource->Address, &CallersCaller); 00264 ExpResourcePerformanceData.TotalResourceCount += 1; 00265 ExpResourcePerformanceData.ActiveResourceCount += 1; 00266 00267 #endif 00268 00269 return STATUS_SUCCESS; 00270 }

NTKERNELAPI VOID ExInitializeTimeRefresh VOID   ) 
 

NTKERNELAPI NTSTATUS ExInitializeZone IN PZONE_HEADER  Zone,
IN ULONG  BlockSize,
IN PVOID  InitialSegment,
IN ULONG  InitialSegmentSize
 

Definition at line 48 of file zone.c.

References BlockSize, DbgPrint, and NULL.

Referenced by CcInitializeCacheManager(), DoZoneTest(), and LpcpInitializePortZone().

00057 : 00058 00059 This function initializes a zone header. Once successfully 00060 initialized, blocks can be allocated and freed from the zone, and 00061 the zone can be extended. 00062 00063 Arguments: 00064 00065 Zone - Supplies the address of a zone header to be initialized. 00066 00067 BlockSize - Supplies the block size of the allocatable unit within 00068 the zone. The size must be larger that the size of the 00069 initial segment, and must be 64-bit aligned. 00070 00071 InitialSegment - Supplies the address of a segment of storage. The 00072 first ZONE_SEGMENT_HEADER-sized portion of the segment 00073 is used by the zone allocator. The remainder of 00074 the segment is carved up into fixed size 00075 (BlockSize) blocks and is made available for 00076 allocation and deallocation from the zone. The 00077 address of the segment must be aligned on a 64-bit 00078 boundary. 00079 00080 InitialSegmentSize - Supplies the size in bytes of the InitialSegment. 00081 00082 Return Value: 00083 00084 STATUS_UNSUCCESSFUL - BlockSize or InitialSegment was not aligned on 00085 64-bit boundaries, or BlockSize was larger than 00086 the initial segment size. 00087 00088 STATUS_SUCCESS - The zone was successfully initialized. 00089 00090 --*/ 00091 00092 { 00093 ULONG i; 00094 PCH p; 00095 00096 if ( (BlockSize & 7) || ((ULONG_PTR)InitialSegment & 7) || 00097 (BlockSize > InitialSegmentSize) ) { 00098 #if DBG 00099 DbgPrint( "EX: ExInitializeZone( %x, %x, %x, %x ) - Invalid parameters.\n", 00100 Zone, BlockSize, InitialSegment, InitialSegmentSize 00101 ); 00102 DbgBreakPoint(); 00103 #endif 00104 return STATUS_INVALID_PARAMETER; 00105 } 00106 00107 Zone->BlockSize = BlockSize; 00108 00109 Zone->SegmentList.Next = &((PZONE_SEGMENT_HEADER) InitialSegment)->SegmentList; 00110 ((PZONE_SEGMENT_HEADER) InitialSegment)->SegmentList.Next = NULL; 00111 ((PZONE_SEGMENT_HEADER) InitialSegment)->Reserved = NULL; 00112 00113 Zone->FreeList.Next = NULL; 00114 00115 p = (PCH)InitialSegment + sizeof(ZONE_SEGMENT_HEADER); 00116 00117 for (i = sizeof(ZONE_SEGMENT_HEADER); 00118 i <= InitialSegmentSize - BlockSize; 00119 i += BlockSize 00120 ) { 00121 ((PSINGLE_LIST_ENTRY)p)->Next = Zone->FreeList.Next; 00122 Zone->FreeList.Next = (PSINGLE_LIST_ENTRY)p; 00123 p += BlockSize; 00124 } 00125 Zone->TotalSegmentSize = i; 00126 00127 #if 0 00128 DbgPrint( "EX: ExInitializeZone( %lx, %lx, %lu, %lu, %lx )\n", 00129 Zone, InitialSegment, InitialSegmentSize, 00130 BlockSize, p 00131 ); 00132 #endif 00133 00134 return STATUS_SUCCESS; 00135 }

VOID ExInitPoolLookasidePointers VOID   ) 
 

NTKERNELAPI BOOLEAN ExInitSystem VOID   ) 
 

NTKERNELAPI VOID ExInitSystemPhase2 VOID   ) 
 

VOID ExInsertPoolTag ULONG  Tag,
PVOID  Va,
SIZE_T  NumberOfBytes,
POOL_TYPE  PoolType
 

Definition at line 1893 of file ex/pool.c.

References ASSERT, BYTES_TO_PAGES, ExpAddTagForBigPages(), ExpInsertPoolTracker(), FALSE, NonPagedPool, NULL, PAGE_SIZE, PoolBigPageTable, PoolTrackTable, and SESSION_POOL_MASK.

Referenced by MiFindContiguousMemory().

01902 : 01903 01904 This function inserts a pool tag in the tag table and increments the 01905 number of allocates and updates the total allocation size. 01906 01907 This function also inserts the pool tag in the big page tag table. 01908 01909 N.B. This function is for use by memory management ONLY. 01910 01911 Arguments: 01912 01913 Tag - Supplies the tag used to insert an entry in the tag table. 01914 01915 Va - Supplies the allocated virtual address. 01916 01917 NumberOfBytes - Supplies the allocation size in bytes. 01918 01919 PoolType - Supplies the pool type. 01920 01921 Return Value: 01922 01923 None. 01924 01925 Environment: 01926 01927 No pool locks held so pool may be freely allocated here as needed. 01928 01929 --*/ 01930 01931 { 01932 ULONG NumberOfPages; 01933 01934 ASSERT ((PoolType & SESSION_POOL_MASK) == 0); 01935 01936 if ((PoolBigPageTable) && (NumberOfBytes >= PAGE_SIZE)) { 01937 01938 NumberOfPages = BYTES_TO_PAGES(NumberOfBytes); 01939 01940 if (ExpAddTagForBigPages((PVOID)Va, Tag, NumberOfPages) == FALSE) { 01941 Tag = ' GIB'; 01942 } 01943 } 01944 01945 if (PoolTrackTable != NULL) { 01946 ExpInsertPoolTracker (Tag, NumberOfBytes, NonPagedPool); 01947 } 01948 }

NTKERNELAPI LARGE_INTEGER ExInterlockedAddLargeInteger IN PLARGE_INTEGER  Addend,
IN LARGE_INTEGER  Increment,
IN PKSPIN_LOCK  Lock
 

NTKERNELAPI VOID FASTCALL ExInterlockedAddLargeStatistic IN PLARGE_INTEGER  Addend,
IN ULONG  Increment
 

Referenced by IopUpdateOtherOperationCount(), IopUpdateOtherTransferCount(), IopUpdateReadOperationCount(), IopUpdateReadTransferCount(), IopUpdateWriteOperationCount(), and IopUpdateWriteTransferCount().

NTKERNELAPI ULONG FASTCALL ExInterlockedAddUlong IN PULONG  Addend,
IN ULONG  Increment,
IN PKSPIN_LOCK  Lock
 

Referenced by ExInterlockedDecrementLong(), ExInterlockedIncrementLong(), IoCancelFileOpen(), IoCreateStreamFileObject(), IoCreateStreamFileObjectLite(), IopDeleteFile(), IopErrorLogThread(), IopMountVolume(), IopParseDevice(), IoRegisterFileSystem(), and IoUnregisterFileSystem().

NTKERNELAPI ULONG FASTCALL ExInterlockedClearBits IN OUT PULONG  Flags,
IN ULONG  Flag
 

NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64 IN PLONGLONG  Destination,
IN PLONGLONG  Exchange,
IN PLONGLONG  Comperand,
IN PKSPIN_LOCK  Lock
 

NTKERNELAPI NTSTATUS ExInterlockedExtendZone IN PZONE_HEADER  Zone,
IN PVOID  Segment,
IN ULONG  SegmentSize,
IN PKSPIN_LOCK  Lock
 

Definition at line 212 of file zone.c.

References ExExtendZone(), Lock, NTSTATUS(), and Status.

00221 : 00222 00223 This function extends a zone by adding another segment's worth of 00224 blocks to the zone. 00225 00226 Arguments: 00227 00228 Zone - Supplies the address of a zone header to be extended. 00229 00230 Segment - Supplies the address of a segment of storage. The first 00231 ZONE_SEGMENT_HEADER-sized portion of the segment is used by the 00232 zone allocator. The remainder of the segment is carved up 00233 into fixed-size (BlockSize) blocks and is added to the 00234 zone. The address of the segment must be aligned on a 64- 00235 bit boundary. 00236 00237 SegmentSize - Supplies the size in bytes of Segment. 00238 00239 Lock - pointer to spinlock to use 00240 00241 Return Value: 00242 00243 STATUS_UNSUCCESSFUL - BlockSize or Segment was not aligned on 00244 64-bit boundaries, or BlockSize was larger than 00245 the segment size. 00246 00247 STATUS_SUCCESS - The zone was successfully extended. 00248 00249 --*/ 00250 00251 { 00252 NTSTATUS Status; 00253 KIRQL OldIrql; 00254 00255 ExAcquireSpinLock( Lock, &OldIrql ); 00256 00257 Status = ExExtendZone( Zone, Segment, SegmentSize ); 00258 00259 ExReleaseSpinLock( Lock, OldIrql ); 00260 00261 return Status; 00262 } }

NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList IN PSLIST_HEADER  ListHead  ) 
 

NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList IN PLIST_ENTRY  ListHead,
IN PLIST_ENTRY  ListEntry,
IN PKSPIN_LOCK  Lock
 

Referenced by CcCanIWrite(), CcDeferWrite(), IoepInitErrLog(), IoepNewErrThread(), IoErrSaveErrData(), IoRegisterLastChanceShutdownNotification(), and IoRegisterShutdownNotification().

NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList IN PLIST_ENTRY  ListHead,
IN PLIST_ENTRY  ListEntry,
IN PKSPIN_LOCK  Lock
 

Referenced by CcCanIWrite(), CcDeferWrite(), ExInitializeNPagedLookasideList(), ExInitializePagedLookasideList(), ExInitializeResource(), ExInitializeResourceLite(), IoErrRegisterErrHandlers(), IoInitializeTimer(), IoRegisterBootDriverReinitialization(), IoRegisterDriverReinitialization(), SmbTraceCompleteRdr(), and SmbTraceCompleteSrv().

NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList IN PSINGLE_LIST_ENTRY  ListHead,
IN PKSPIN_LOCK  Lock
 

NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntrySList IN PSLIST_HEADER  ListHead,
IN PKSPIN_LOCK  Lock
 

Referenced by ExAllocateFromNPagedLookasideList(), ExAllocateFromPagedLookasideList(), ExAllocateFromPPNPagedLookasideList(), ExAllocatePoolWithTag(), IoMakeAssociatedIrp(), IopAllocateIrpPrivate(), and IoSetIoCompletion().

NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList IN PSINGLE_LIST_ENTRY  ListHead,
IN PSINGLE_LIST_ENTRY  ListEntry,
IN PKSPIN_LOCK  Lock
 

NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntrySList IN PSLIST_HEADER  ListHead,
IN PSINGLE_LIST_ENTRY  ListEntry,
IN PKSPIN_LOCK  Lock
 

Referenced by ExFreePoolWithTag(), ExFreeToNPagedLookasideList(), ExFreeToPagedLookasideList(), ExFreeToPPNPagedLookasideList(), IopFreeIrp(), and IopFreeMiniPacket().

NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList IN PLIST_ENTRY  ListHead,
IN PKSPIN_LOCK  Lock
 

Referenced by IoInitSystem(), IopCallDriverAddDeviceQueryRoutine(), IopInitializeBootDrivers(), IopLoadUnloadDriver(), IoShutdownSystem(), SmbTraceEmptyQueue(), and SmbTraceThreadEntry().

NTKERNELAPI ULONG FASTCALL ExInterlockedSetBits IN OUT PULONG  Flags,
IN ULONG  Flag
 

NTKERNELAPI ULONG FASTCALL ExInterlockedSetClearBits IN OUT PULONG  Flags,
IN ULONG  sFlag,
IN ULONG  cFlag
 

NTKERNELAPI BOOLEAN ExIsProcessorFeaturePresent ULONG  ProcessorFeature  ) 
 

Definition at line 4311 of file sysinfo.c.

References FALSE.

04314 { 04315 BOOLEAN rv; 04316 04317 if ( ProcessorFeature < PROCESSOR_FEATURE_MAX ) { 04318 rv = SharedUserData->ProcessorFeatures[ProcessorFeature]; 04319 } 04320 else { 04321 rv = FALSE; 04322 } 04323 return rv; 04324 }

NTKERNELAPI BOOLEAN ExIsResourceAcquiredExclusiveLite IN PERESOURCE  Resource  ) 
 

Definition at line 2187 of file ex/resource.c.

References ASSERT_RESOURCE, ERESOURCE_THREAD, FALSE, IsOwnedExclusive, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, _ERESOURCE::SpinLock, and TRUE.

Referenced by RequestDeviceChange(), StartDeviceRead(), UpdateJob(), UserIsUserCritSecIn(), UserJobCallout(), and xxxUserFindHandleForObject().

02193 : 02194 02195 This routine determines if a resource is acquired exclusive by the 02196 calling thread. 02197 02198 Arguments: 02199 02200 Resource - Supplies a pointer the resource to query. 02201 02202 Return Value: 02203 02204 If the current thread has acquired the resource exclusive, a value of 02205 TRUE is returned. Otherwise, a value of FALSE is returned. 02206 02207 --*/ 02208 02209 { 02210 02211 ERESOURCE_THREAD CurrentThread; 02212 KIRQL OldIrql; 02213 BOOLEAN Result; 02214 02215 // 02216 // Acquire exclusive access to the specified resource. 02217 // 02218 02219 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 02220 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 02221 02222 ASSERT_RESOURCE(Resource); 02223 02224 // 02225 // If the resource is owned exclusive and the current thread is the 02226 // owner, then set the return value of TRUE. Otherwise, set the return 02227 // value to FALSE. 02228 // 02229 02230 Result = FALSE; 02231 if ((IsOwnedExclusive(Resource)) && 02232 (Resource->OwnerThreads[0].OwnerThread == CurrentThread)) { 02233 Result = TRUE; 02234 } 02235 02236 // 02237 // Release exclusive access to the specified resource. 02238 // 02239 02240 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 02241 return Result; 02242 }

NTKERNELAPI ULONG ExIsResourceAcquiredSharedLite IN PERESOURCE  Resource  ) 
 

Definition at line 2245 of file ex/resource.c.

References ASSERT_RESOURCE, ERESOURCE_THREAD, Index, NULL, _OWNER_ENTRY::OwnerCount, _ERESOURCE::OwnerTable, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, _ERESOURCE::SpinLock, and _OWNER_ENTRY::TableSize.

Referenced by UserIsUserCritSecIn(), and xxxUserFindHandleForObject().

02251 : 02252 02253 This routine determines if a resource is acquired either shared or 02254 exclusive by the calling thread. 02255 02256 Arguments: 02257 02258 Resource - Supplies a pointer to the resource to query. 02259 02260 Return Value: 02261 02262 If the current thread has not acquired the resource a value of zero 02263 is returned. Otherwise, the thread's acquire count is returned. 02264 02265 --*/ 02266 02267 { 02268 02269 ERESOURCE_THREAD CurrentThread; 02270 ULONG Index; 02271 ULONG Number; 02272 KIRQL OldIrql; 02273 POWNER_ENTRY OwnerEntry; 02274 ULONG Result; 02275 02276 // 02277 // Acquire exclusive access to the specified resource. 02278 // 02279 02280 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 02281 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 02282 02283 ASSERT_RESOURCE(Resource); 02284 02285 // 02286 // Find the current thread in the thread array and return the count. 02287 // 02288 // N.B. If the thread is not found a value of zero will be returned. 02289 // 02290 02291 if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 02292 Result = Resource->OwnerThreads[0].OwnerCount; 02293 02294 } else if (Resource->OwnerThreads[1].OwnerThread == CurrentThread) { 02295 Result = Resource->OwnerThreads[1].OwnerCount; 02296 02297 } else { 02298 02299 // 02300 // If the resource hint is not within range or the resource table 02301 // entry does not match the current thread, then search the owner 02302 // table for a match. 02303 // 02304 02305 OwnerEntry = Resource->OwnerTable; 02306 Result = 0; 02307 if (OwnerEntry != NULL) { 02308 Index = ((PKTHREAD)(CurrentThread))->ResourceIndex; 02309 Number = OwnerEntry->TableSize; 02310 if ((Index >= Number) || 02311 (OwnerEntry[Index].OwnerThread != CurrentThread)) { 02312 for (Index = 1; Index < Number; Index += 1) { 02313 OwnerEntry += 1; 02314 if (OwnerEntry->OwnerThread == CurrentThread) { 02315 Result = OwnerEntry->OwnerCount; 02316 break; 02317 } 02318 } 02319 02320 } else { 02321 Result = OwnerEntry[Index].OwnerCount; 02322 } 02323 } 02324 } 02325 02326 // 02327 // Release exclusive access to the specified resource. 02328 // 02329 02330 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 02331 return Result; 02332 }

NTKERNELAPI VOID ExLocalTimeToSystemTime IN PLARGE_INTEGER  LocalTime,
OUT PLARGE_INTEGER  SystemTime
 

NTKERNELAPI BOOLEAN ExLockHandleTableEntry PHANDLE_TABLE  HandleTable,
PHANDLE_TABLE_ENTRY  HandleTableEntry
 

Definition at line 240 of file ex/handle.c.

References Ex10Milliseconds, Executive, EXHANDLE_TABLE_ENTRY_LOCK_BIT, FALSE, _HANDLE_TABLE::HandleContentionEvent, KernelMode, KeStallExecutionProcessor(), KeWaitForSingleObject(), _HANDLE_TABLE_ENTRY::Object, PAGED_CODE, and TRUE.

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

00247 : 00248 00249 This routine locks the specified handle table entry. After the entry is 00250 locked the sign bit will be set. 00251 00252 Arguments: 00253 00254 HandleTable - Supplies the handle table containing the entry being locked. 00255 00256 HandleTableEntry - Supplies the handle table entry being locked. 00257 00258 Return Value: 00259 00260 TRUE if the entry is valid and locked, and FALSE if the entry is 00261 marked free. 00262 00263 --*/ 00264 00265 { 00266 LONG_PTR NewValue; 00267 LONG_PTR CurrentValue; 00268 ULONG LoopCount = 0; 00269 00270 PAGED_CODE(); 00271 00272 // 00273 // We'll keep on looping reading in the value, making sure it is not null, 00274 // and if it is not currently locked we'll try for the lock and return 00275 // true if we get it. Otherwise we'll pause a bit and then try again. 00276 // 00277 00278 while (TRUE) { 00279 00280 NewValue = 00281 CurrentValue = *((volatile LONG_PTR *)&HandleTableEntry->Object); 00282 00283 // 00284 // Make sure the handle table entry is not freed 00285 // 00286 00287 if (CurrentValue == 0) { 00288 00289 return FALSE; 00290 } 00291 00292 // 00293 // If the handle value is greater than zero then it is not currently 00294 // locked and we should try for the lock, but setting the lock bit and 00295 // doing an interlocked exchange. 00296 // 00297 00298 if (CurrentValue > 0) { 00299 00300 NewValue |= EXHANDLE_TABLE_ENTRY_LOCK_BIT; 00301 00302 if ((LONG_PTR)(InterlockedCompareExchangePointer( &HandleTableEntry->Object, 00303 (PVOID)NewValue, 00304 (PVOID)CurrentValue )) == CurrentValue) { 00305 00306 return TRUE; 00307 } 00308 } 00309 00310 // 00311 // Either someone already has the entry locked or the value changed 00312 // somehow, either way we'll wait a bit and try again. The first 00313 // time we'll wait by spinning for 10us and if that doesn't work 00314 // then we'll wait for the handle contention event to go off or 00315 // for 10ms, whichever comes first. 00316 // 00317 00318 if (LoopCount++ < 1) { 00319 00320 KeStallExecutionProcessor( 10 ); 00321 00322 } else { 00323 00324 KeWaitForSingleObject( &HandleTable->HandleContentionEvent, 00325 Executive, 00326 KernelMode, 00327 FALSE, 00328 &Ex10Milliseconds ); 00329 } 00330 } 00331 }

NTKERNELAPI VOID ExLockHandleTableExclusive PHANDLE_TABLE  HandleTable  ) 
 

Definition at line 146 of file ex/handle.c.

References ExAcquireResourceExclusive, _HANDLE_TABLE::HandleTableLock, PAGED_CODE, TRUE, and VOID().

Referenced by ExCreateHandle(), ExDestroyHandle(), and ExSnapShotHandleTables().

00152 : 00153 00154 This routine locks the specified handle table for exclusive access. Once 00155 locked the onwer can add or delete entries from the handle table. 00156 00157 Arguments: 00158 00159 HandleTable - Supplies the handle table being locked. 00160 00161 Return Value: 00162 00163 None. 00164 00165 --*/ 00166 00167 { 00168 PAGED_CODE(); 00169 00170 (VOID)ExAcquireResourceExclusive( &HandleTable->HandleTableLock, TRUE ); 00171 00172 return; 00173 }

NTKERNELAPI VOID ExLockHandleTableShared PHANDLE_TABLE  HandleTable  ) 
 

Definition at line 114 of file ex/handle.c.

References ExAcquireResourceShared, _HANDLE_TABLE::HandleTableLock, PAGED_CODE, TRUE, and VOID().

Referenced by ExDupHandleTable(), and ExEnumHandleTable().

00120 : 00121 00122 This routine locks the specified handle table for shared access. Once 00123 locked new entries cannot be added to deleted from the handle table. 00124 00125 Arguments: 00126 00127 HandleTable - Supplies the handle table being locked. 00128 00129 Return Value: 00130 00131 None. 00132 00133 --*/ 00134 00135 { 00136 PAGED_CODE(); 00137 00138 (VOID)ExAcquireResourceShared( &HandleTable->HandleTableLock, TRUE ); 00139 00140 return; 00141 }

NTKERNELAPI KIRQL ExLockPool IN POOL_TYPE  PoolType  ) 
 

Definition at line 506 of file ex/pool.c.

References APC_LEVEL, BASE_POOL_TYPE_MASK, FALSE, KeAcquireSpinLock, KeRaiseIrql(), KernelMode, KeWaitForSingleObject(), _POOL_DESCRIPTOR::LockAddress, NonPagedPool, NonPagedPoolDescriptor, NonPagedPoolMustSucceed, NULL, PagedPool, PoolAllocation, and PoolVector.

Referenced by MiFindContiguousMemory().

00512 : 00513 00514 This function locks the pool specified by pool type. 00515 00516 Arguments: 00517 00518 PoolType - Specifies the pool that should be locked. 00519 00520 Return Value: 00521 00522 The previous IRQL is returned as the function value. 00523 00524 --*/ 00525 00526 { 00527 00528 KIRQL OldIrql; 00529 00530 // 00531 // If the pool type is nonpaged, then use a spinlock to lock the 00532 // pool. Otherwise, use a fast mutex to lock the pool. 00533 // 00534 00535 if ((PoolType & BASE_POOL_TYPE_MASK) == NonPagedPool) { 00536 ExAcquireSpinLock(NonPagedPoolDescriptor.LockAddress, &OldIrql); 00537 00538 } else { 00539 ExAcquireFastMutex((PFAST_MUTEX)PoolVector[PagedPool]->LockAddress); 00540 OldIrql = (KIRQL)((PFAST_MUTEX)(PoolVector[PagedPool]->LockAddress))->OldIrql; 00541 } 00542 00543 return OldIrql; 00544 }

NTKERNELAPI PVOID ExLockUserBuffer IN PVOID  Buffer,
IN ULONG  Length,
OUT PVOID *  LockVariable
 

Definition at line 2995 of file sysinfo.c.

References Buffer, ExAllocatePoolWithQuotaTag, EXCEPTION_EXECUTE_HANDLER, ExFreePool(), ExUnlockUserBuffer(), IoWriteAccess, MDL_MAPPING_CAN_FAIL, _MDL::MdlFlags, MmGetSystemAddressForMdl, MmInitializeMdl, MmProbeAndLockPages(), MmSizeOfMdl(), NonPagedPool, and NULL.

Referenced by ExpGetHandleInformation(), ExpGetLockInformation(), ExpGetLookasideInformation(), ExpGetObjectInformation(), ExpGetPoolInformation(), and ExpGetProcessInformation().

03001 { 03002 PMDL Mdl; 03003 PVOID Address; 03004 SIZE_T MdlSize; 03005 03006 // 03007 // Allocate an MDL to map the request. 03008 // 03009 03010 MdlSize = MmSizeOfMdl( Buffer, Length ); 03011 Mdl = ExAllocatePoolWithQuotaTag (NonPagedPool, 03012 MdlSize, 03013 'ofnI'); 03014 if (Mdl == NULL) { 03015 return NULL; 03016 } 03017 03018 // 03019 // Initialize MDL for request. 03020 // 03021 03022 MmInitializeMdl(Mdl, Buffer, Length); 03023 03024 try { 03025 03026 MmProbeAndLockPages (Mdl, KeGetPreviousMode(), IoWriteAccess); 03027 03028 } except (EXCEPTION_EXECUTE_HANDLER) { 03029 03030 ExFreePool (Mdl); 03031 03032 return( NULL ); 03033 } 03034 03035 Mdl->MdlFlags |= MDL_MAPPING_CAN_FAIL; 03036 Address = MmGetSystemAddressForMdl (Mdl); 03037 *LockVariable = Mdl; 03038 if (Address == NULL) { 03039 ExUnlockUserBuffer (Mdl); 03040 *LockVariable = NULL; 03041 } 03042 03043 return Address; 03044 }

NTKERNELAPI BOOLEAN ExLuidInitialization VOID   ) 
 

Definition at line 37 of file luid.c.

References ExpLuid, ExpLuidIncrement, ExpLuidLock, KeInitializeSpinLock(), and TRUE.

Referenced by SepInitializationPhase0().

00043 : 00044 00045 This function initializes the locally unique identifier allocation. 00046 00047 NOTE: THE LUID ALLOCATION SERVICES ARE NEEDED BY SECURITY IN PHASE 0 00048 SYSTEM INITIALIZATION. FOR THIS REASON, LUID INITIALIZATION IS 00049 PERFORMED AS PART OF PHASE 0 SECURITY INITIALIZATION. 00050 00051 Arguments: 00052 00053 None. 00054 00055 Return Value: 00056 00057 A value of TRUE is returned if the initialization is successfully 00058 completed. Otherwise, a value of FALSE is returned. 00059 00060 --*/ 00061 00062 { 00063 00064 // 00065 // Initialize the LUID source value. 00066 // 00067 // The first 1000 values are reserved for static definition. This 00068 // value can be increased with later releases with no adverse impact. 00069 // 00070 // N.B. The LUID source always refers to the "next" allocatable LUID. 00071 // 00072 00073 ExpLuid.LowPart = 1001; 00074 ExpLuid.HighPart = 0; 00075 KeInitializeSpinLock(&ExpLuidLock); 00076 ExpLuidIncrement.QuadPart = 1; 00077 return TRUE; 00078 }

NTKERNELAPI PHANDLE_TABLE_ENTRY ExMapHandleToPointer IN PHANDLE_TABLE  HandleTable,
IN HANDLE  Handle
 

Definition at line 1403 of file ex/handle.c.

References ExLockHandleTableEntry(), ExpLookupHandleTableEntry(), _EXHANDLE::GenericHandleOverlay, Handle, NULL, and PAGED_CODE.

Referenced by DoHandleTest(), NtClose(), NtWaitForMultipleObjects(), ObQueryObjectAuditingByHandle(), ObReferenceObjectByHandle(), PsLookupProcessByProcessId(), PsLookupProcessThreadByCid(), PsLookupThreadByThreadId(), and RtlpAtomMapAtomToHandleEntry().

01410 : 01411 01412 This function maps a handle to a pointer to a handle table entry. If the 01413 map operation is successful then the handle table entry is locked when 01414 we return. 01415 01416 Arguments: 01417 01418 HandleTable - Supplies a pointer to a handle table. 01419 01420 Handle - Supplies the handle to be mapped to a handle entry. 01421 01422 Return Value: 01423 01424 If the handle was successfully mapped to a pointer to a handle entry, 01425 then the address of the handle table entry is returned as the function 01426 value with the entry locked. Otherwise, a value of NULL is returned. 01427 01428 --*/ 01429 01430 { 01431 EXHANDLE LocalHandle; 01432 01433 PHANDLE_TABLE_ENTRY HandleTableEntry; 01434 01435 PAGED_CODE(); 01436 01437 LocalHandle.GenericHandleOverlay = Handle; 01438 01439 // 01440 // Translate the input handle to a handle table entry and make 01441 // sure it is a valid handle. 01442 // 01443 01444 HandleTableEntry = ExpLookupHandleTableEntry( HandleTable, 01445 LocalHandle ); 01446 01447 if (HandleTableEntry == NULL) { 01448 01449 return NULL; 01450 } 01451 01452 // 01453 // Try and lock the handle table entry, If this fails then that's 01454 // because someone freed the handle 01455 // 01456 01457 if (!ExLockHandleTableEntry( HandleTable, HandleTableEntry )) { 01458 01459 return NULL; 01460 } 01461 01462 // 01463 // Return the locked valid handle table entry 01464 // 01465 01466 return HandleTableEntry; 01467 }

NTKERNELAPI VOID ExNotifyCallback IN PVOID  CallbackObject,
IN PVOID  Argument1,
IN PVOID  Argument2
 

NTKERNELAPI ULONG ExQueryPoolBlockSize IN PVOID  PoolBlock,
OUT PBOOLEAN  QuotaCharged
 

Definition at line 3328 of file ex/pool.c.

References _POOL_HEADER::BlockSize, FALSE, MmQuerySpecialPoolBlockSize(), MmSpecialPoolEnd, MmSpecialPoolStart, NULL, PAGE_ALIGNED, PAGE_SIZE, POOL_BLOCK_SHIFT, POOL_OVERHEAD, PoolTrackTable, and _POOL_HEADER::ProcessBilled.

Referenced by HMAllocObject(), and HMFreeObject().

03335 : 03336 03337 This function returns the size of the pool block. 03338 03339 Arguments: 03340 03341 PoolBlock - Supplies the address of the block of pool. 03342 03343 QuotaCharged - Supplies a BOOLEAN variable to receive whether or not the 03344 pool block had quota charged. 03345 03346 NOTE: If the entry is bigger than a page, the value PAGE_SIZE is returned 03347 rather than the correct number of bytes. 03348 03349 Return Value: 03350 03351 Size of pool block. 03352 03353 --*/ 03354 03355 { 03356 PPOOL_HEADER Entry; 03357 ULONG size; 03358 03359 if ((PoolBlock >= MmSpecialPoolStart) && (PoolBlock < MmSpecialPoolEnd)) { 03360 *QuotaCharged = FALSE; 03361 return (ULONG)MmQuerySpecialPoolBlockSize (PoolBlock); 03362 } 03363 03364 if (PAGE_ALIGNED(PoolBlock)) { 03365 *QuotaCharged = FALSE; 03366 return PAGE_SIZE; 03367 } 03368 03369 #if POOL_CACHE_SUPPORTED 03370 03371 // 03372 // Align entry on pool allocation boundary. 03373 // 03374 03375 if (((ULONG)PoolBlock & POOL_CACHE_CHECK) == 0) { 03376 Entry = (PPOOL_HEADER)((ULONG)PoolBlock - PoolCacheSize); 03377 size = (Entry->BlockSize << POOL_BLOCK_SHIFT) - PoolCacheSize; 03378 03379 } else { 03380 Entry = (PPOOL_HEADER)((PCHAR)PoolBlock - POOL_OVERHEAD); 03381 size = (Entry->BlockSize << POOL_BLOCK_SHIFT) - POOL_OVERHEAD; 03382 } 03383 03384 #else 03385 03386 Entry = (PPOOL_HEADER)((PCHAR)PoolBlock - POOL_OVERHEAD); 03387 size = (ULONG)((Entry->BlockSize << POOL_BLOCK_SHIFT) - POOL_OVERHEAD); 03388 03389 #endif //POOL_CACHE_SUPPORTED 03390 03391 #ifdef _WIN64 03392 *QuotaCharged = (BOOLEAN) (Entry->ProcessBilled != NULL); 03393 #else 03394 if ( PoolTrackTable ) { 03395 *QuotaCharged = FALSE; 03396 } 03397 else { 03398 *QuotaCharged = (BOOLEAN) (Entry->ProcessBilled != NULL); 03399 } 03400 #endif 03401 return size; 03402 }

NTKERNELAPI VOID ExQueryPoolUsage OUT PULONG  PagedPoolPages,
OUT PULONG  NonPagedPoolPages,
OUT PULONG  PagedPoolAllocs,
OUT PULONG  PagedPoolFrees,
OUT PULONG  PagedPoolLookasideHits,
OUT PULONG  NonPagedPoolAllocs,
OUT PULONG  NonPagedPoolFrees,
OUT PULONG  NonPagedPoolLookasideHits
 

Definition at line 3405 of file ex/pool.c.

References _GENERAL_LOOKASIDE::AllocateHits, ExpNumberOfPagedPools, ExPoolLookasideListHead, Index, _NPAGED_LOOKASIDE_LIST::L, L, NonPagedPool, NonPagedPoolMustSucceed, PagedPool, pd, PoolVector, and _GENERAL_LOOKASIDE::Type.

Referenced by NtQuerySystemInformation().

03416 { 03417 ULONG Index; 03418 PNPAGED_LOOKASIDE_LIST Lookaside; 03419 PLIST_ENTRY NextEntry; 03420 PPOOL_DESCRIPTOR pd; 03421 03422 // 03423 // Sum all the paged pool usage. 03424 // 03425 03426 pd = PoolVector[PagedPool]; 03427 *PagedPoolPages = 0; 03428 *PagedPoolAllocs = 0; 03429 *PagedPoolFrees = 0; 03430 03431 for (Index = 0; Index < ExpNumberOfPagedPools + 1; Index += 1) { 03432 *PagedPoolPages += pd[Index].TotalPages + pd[Index].TotalBigPages; 03433 *PagedPoolAllocs += pd[Index].RunningAllocs; 03434 *PagedPoolFrees += pd[Index].RunningDeAllocs; 03435 } 03436 03437 // 03438 // Sum all the nonpaged pool usage. 03439 // 03440 03441 pd = PoolVector[NonPagedPool]; 03442 *NonPagedPoolPages = pd->TotalPages + pd->TotalBigPages; 03443 *NonPagedPoolAllocs = pd->RunningAllocs; 03444 *NonPagedPoolFrees = pd->RunningDeAllocs; 03445 03446 // 03447 // Sum all the nonpaged must succeed usage. 03448 // 03449 03450 pd = PoolVector[NonPagedPoolMustSucceed]; 03451 *NonPagedPoolPages += pd->TotalPages + pd->TotalBigPages; 03452 *NonPagedPoolAllocs += pd->RunningAllocs; 03453 *NonPagedPoolFrees += pd->RunningDeAllocs; 03454 03455 // 03456 // Sum all the lookaside hits for paged and nonpaged pool. 03457 // 03458 03459 NextEntry = ExPoolLookasideListHead.Flink; 03460 while (NextEntry != &ExPoolLookasideListHead) { 03461 Lookaside = CONTAINING_RECORD(NextEntry, 03462 NPAGED_LOOKASIDE_LIST, 03463 L.ListEntry); 03464 03465 if (Lookaside->L.Type == NonPagedPool) { 03466 *NonPagedPoolLookasideHits += Lookaside->L.AllocateHits; 03467 03468 } else { 03469 *PagedPoolLookasideHits += Lookaside->L.AllocateHits; 03470 } 03471 03472 NextEntry = NextEntry->Flink; 03473 } 03474 03475 return; 03476 }

NTKERNELAPI VOID ExQueueWorkItem IN PWORK_QUEUE_ITEM  WorkItem,
IN WORK_QUEUE_TYPE  QueueType
 

Definition at line 375 of file worker.c.

References ASSERT, ExpNewThreadNecessary(), ExThreadSetManagerEvent, ExWorkerQueue, FALSE, KeInsertQueue(), KeSetEvent(), MaximumWorkQueue, and NULL.

Referenced by CcPostWorkQueue(), CmpClaimGlobalQuota(), CmpDiskFullWarning(), CmpLazyFlushDpcRoutine(), CmpPostNotify(), IopChainDereferenceComplete(), IopCompleteUnloadOrDelete(), IopDeviceEjectComplete(), IopEjectDevice(), IopErrorLogDpc(), IopProcessNewProfile(), IopQueueDeviceWorkItem(), IopRequestDeviceAction(), IopSendMessageToTrackService(), IoQueueWorkItem(), IoRaiseHardError(), IoRaiseInformationalHardError(), IoReportTargetDeviceChangeAsynchronous(), IovpInternalDeferredCompletion(), IoWriteErrorLogEntry(), KdpTimeSlipDpcRoutine(), KdpTrap(), MiCheckForCrashDump(), NtLoadDriver(), NtUnloadDriver(), ObfDereferenceObject(), SepInformFileSystemsOfDeletedLogon(), SepQueueWorkItem(), SmbTraceDereferenceHeap(), UdfAddToWorkque(), and UdfQueueClose().

00382 : 00383 00384 This function inserts a work item into a work queue that is processed 00385 by a worker thread of the corresponding type. 00386 00387 Arguments: 00388 00389 WorkItem - Supplies a pointer to the work item to add the the queue. 00390 This structure must be located in NonPagedPool. The work item 00391 structure contains a doubly linked list entry, the address of a 00392 routine to call and a parameter to pass to that routine. 00393 00394 QueueType - Specifies the type of work queue that the work item 00395 should be placed in. 00396 00397 Return Value: 00398 00399 None 00400 00401 --*/ 00402 00403 { 00404 00405 ASSERT(QueueType < MaximumWorkQueue); 00406 ASSERT(WorkItem->List.Flink == NULL); 00407 00408 // 00409 // Insert the work item in the appropriate queue object. 00410 // 00411 00412 KeInsertQueue(&ExWorkerQueue[QueueType].WorkerQueue, &WorkItem->List); 00413 00414 // 00415 // Determine whether another thread should be created, and signal the 00416 // thread set balance manager if so. 00417 // 00418 00419 if (ExpNewThreadNecessary(QueueType) != FALSE) { 00420 00421 KeSetEvent( &ExThreadSetManagerEvent, 00422 0, 00423 FALSE ); 00424 } 00425 00426 return; 00427 }

NTKERNELAPI VOID ExRaiseAccessViolation VOID   ) 
 

Definition at line 44 of file raise.c.

References ExRaiseStatus().

Referenced by ProbeForRead(), and ProbeForWrite().

00050 : 00051 00052 This function raises an access violation exception. 00053 00054 Arguments: 00055 00056 None. 00057 00058 Return Value: 00059 00060 None. 00061 00062 --*/ 00063 00064 { 00065 00066 ExRaiseStatus(STATUS_ACCESS_VIOLATION); 00067 return; 00068 }

NTKERNELAPI VOID ExRaiseDatatypeMisalignment VOID   ) 
 

Definition at line 71 of file raise.c.

References ExRaiseStatus().

Referenced by MESSAGECALL(), ProbeForRead(), ProbeForWrite(), and SeCaptureSecurityDescriptor().

00077 : 00078 00079 This function raises a datatype misalignment exception. 00080 00081 Arguments: 00082 00083 None. 00084 00085 Return Value: 00086 00087 None. 00088 00089 --*/ 00090 00091 { 00092 00093 ExRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); 00094 return; 00095 } }

NTKERNELAPI VOID NTAPI ExRaiseException PEXCEPTION_RECORD  ExceptionRecord  ) 
 

Referenced by Ki386VdmDispatchIo(), Ki386VdmDispatchStringIo(), KiDispatchException(), VdmCallStringIoHandler(), and VdmDispatchIRQ13().

NTKERNELAPI NTSTATUS ExRaiseHardError IN NTSTATUS  ErrorStatus,
IN ULONG  NumberOfParameters,
IN ULONG  UnicodeStringParameterMask,
IN PULONG_PTR  Parameters,
IN ULONG  ValidResponseOptions,
OUT PULONG  Response
 

Definition at line 700 of file ex/harderr.c.

References Buffer, ExpRaiseHardError(), ExpTooLateForErrors, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, and Status.

Referenced by CmpDiskFullWarningWorker(), CmpInitializeHiveList(), CmpQuotaWarningWorker(), IopHardErrorThread(), IopRaiseHardError(), IopRaiseInformationalHardError(), NtRaiseHardError(), and xxxCreateThreadInfo().

00708 { 00709 NTSTATUS Status; 00710 PULONG_PTR ParameterBlock; 00711 PULONG_PTR UserModeParameterBase; 00712 PUNICODE_STRING UserModeStringsBase; 00713 PUCHAR UserModeStringDataBase; 00714 UNICODE_STRING CapturedStrings[MAXIMUM_HARDERROR_PARAMETERS]; 00715 ULONG LocalResponse; 00716 ULONG Counter; 00717 SIZE_T UserModeSize; 00718 00719 PAGED_CODE(); 00720 00721 // 00722 // If we are in the process of shuting down the system, do not allow 00723 // hard errors. 00724 // 00725 00726 if ( ExpTooLateForErrors ) { 00727 00728 *Response = ResponseNotHandled; 00729 00730 return STATUS_SUCCESS; 00731 } 00732 00733 // 00734 // If the parameters contain strings, we need to capture 00735 // the strings and the string descriptors and push them into 00736 // user-mode. 00737 // 00738 00739 if ( ARGUMENT_PRESENT(Parameters) ) { 00740 if ( UnicodeStringParameterMask ) { 00741 00742 // 00743 // We have strings. The parameter block and all strings 00744 // must be pushed into usermode. 00745 // 00746 00747 UserModeSize = (sizeof(ULONG_PTR)+sizeof(UNICODE_STRING))*MAXIMUM_HARDERROR_PARAMETERS; 00748 UserModeSize += sizeof(UNICODE_STRING); 00749 00750 for(Counter=0;Counter < NumberOfParameters;Counter++){ 00751 00752 // 00753 // if there is a string in this position, 00754 // then probe and capture the string 00755 // 00756 00757 if ( UnicodeStringParameterMask & 1<<Counter ) { 00758 00759 RtlMoveMemory( 00760 &CapturedStrings[Counter], 00761 (PVOID)Parameters[Counter], 00762 sizeof(UNICODE_STRING) 00763 ); 00764 00765 UserModeSize += CapturedStrings[Counter].MaximumLength; 00766 00767 } 00768 } 00769 00770 // 00771 // Now we have the user-mode size all figured out. 00772 // Allocate some memory and point to it with the 00773 // parameter block. Then go through and copy all 00774 // of the parameters, string descriptors, and 00775 // string data into the memory 00776 // 00777 00778 ParameterBlock = NULL; 00779 Status = ZwAllocateVirtualMemory( 00780 NtCurrentProcess(), 00781 (PVOID *)&ParameterBlock, 00782 0, 00783 &UserModeSize, 00784 MEM_COMMIT, 00785 PAGE_READWRITE 00786 ); 00787 00788 if (!NT_SUCCESS( Status )) { 00789 return( Status ); 00790 } 00791 00792 UserModeParameterBase = ParameterBlock; 00793 UserModeStringsBase = (PUNICODE_STRING)((PUCHAR)ParameterBlock + sizeof(ULONG)*MAXIMUM_HARDERROR_PARAMETERS); 00794 UserModeStringDataBase = (PUCHAR)UserModeStringsBase + sizeof(UNICODE_STRING)*MAXIMUM_HARDERROR_PARAMETERS; 00795 00796 for(Counter=0;Counter < NumberOfParameters;Counter++){ 00797 00798 // 00799 // move parameters to user-mode portion of the 00800 // address space. 00801 // 00802 00803 if ( UnicodeStringParameterMask & 1<<Counter ) { 00804 00805 // 00806 // fix the parameter to point at the string descriptor slot 00807 // in the user-mode buffer. 00808 // 00809 00810 UserModeParameterBase[Counter] = (ULONG_PTR)&UserModeStringsBase[Counter]; 00811 00812 // 00813 // Copy the string data to user-mode 00814 // 00815 00816 RtlMoveMemory( 00817 UserModeStringDataBase, 00818 CapturedStrings[Counter].Buffer, 00819 CapturedStrings[Counter].MaximumLength 00820 ); 00821 00822 CapturedStrings[Counter].Buffer = (PWSTR)UserModeStringDataBase; 00823 00824 // 00825 // copy the string descriptor 00826 // 00827 00828 RtlMoveMemory( 00829 &UserModeStringsBase[Counter], 00830 &CapturedStrings[Counter], 00831 sizeof(UNICODE_STRING) 00832 ); 00833 00834 // 00835 // Adjust the string data base 00836 // 00837 00838 UserModeStringDataBase += CapturedStrings[Counter].MaximumLength; 00839 00840 } 00841 else { 00842 UserModeParameterBase[Counter] = Parameters[Counter]; 00843 } 00844 } 00845 } 00846 else { 00847 ParameterBlock = Parameters; 00848 } 00849 } 00850 else { 00851 ParameterBlock = NULL; 00852 } 00853 00854 // 00855 // Call the hard error sender. 00856 // 00857 00858 Status = ExpRaiseHardError( 00859 ErrorStatus, 00860 NumberOfParameters, 00861 UnicodeStringParameterMask, 00862 ParameterBlock, 00863 ValidResponseOptions, 00864 &LocalResponse 00865 ); 00866 // 00867 // If the parameter block was allocated, it needs to be 00868 // freed 00869 // 00870 00871 if ( ParameterBlock && ParameterBlock != Parameters ) { 00872 UserModeSize = 0; 00873 ZwFreeVirtualMemory( 00874 NtCurrentProcess(), 00875 (PVOID *)&ParameterBlock, 00876 &UserModeSize, 00877 MEM_RELEASE 00878 ); 00879 } 00880 *Response = LocalResponse; 00881 00882 return Status; 00883 }

NTKERNELAPI VOID NTAPI ExRaiseStatus IN NTSTATUS  Status  ) 
 

Definition at line 157 of file ex/alpha/raisests.c.

References DbgPrint, and ExpRaiseStatus().

Referenced by _purecall(), BuildQueryDirectoryIrp(), CcCopyRead(), CcCopyWrite(), CcCreateVacbArray(), CcExtendVacbArray(), CcFastCopyRead(), CcFastCopyWrite(), CcGetVacbMiss(), CcInitializeCacheMap(), CcMapAndCopy(), CcMdlRead(), CcPinFileData(), CcPrepareMdlWrite(), CcReferenceFileOffset(), CcSetFileSizes(), CcZeroData(), ExAllocatePoolWithQuota(), ExAllocatePoolWithQuotaTag(), ExAllocatePoolWithTag(), ExpRaiseException(), ExpRaiseStatus(), ExRaiseAccessViolation(), ExRaiseDatatypeMisalignment(), FsRtlAllocatePool(), FsRtlAllocatePoolWithQuota(), FsRtlAllocatePoolWithQuotaTag(), FsRtlAllocatePoolWithTag(), FsRtlAreNamesEqual(), FsRtlIsNameInExpression(), FsRtlPrivateInitializeFileLock(), FsRtlPrivateLock(), IoCreateFile(), IoCreateStreamFileObject(), IoCreateStreamFileObjectLite(), IopCreateEntry(), IopSetEaOrQuotaInformationFile(), IopXxxControlFile(), KeReleaseMutant(), KeReleaseSemaphore(), KeSuspendThread(), KeWaitForMultipleObjects(), KeWaitForSingleObject(), LfsAllocateLbcb(), LfsAllocateLcb(), LfsAllocateSpanningBuffer(), LfsCopyReadLogRecord(), LfsFindLastLsn(), LfsFindLogRecord(), LfsFlushLfcb(), LfsFlushToLsn(), LfsFlushToLsnPriv(), LfsForceWrite(), LfsInitializeLogFile(), LfsNormalizeBasicLogFile(), LfsOpenLogFile(), LfsPinOrMapData(), LfsQueryLastLsn(), LfsReadLogRecord(), LfsReadNextLogRecord(), LfsReadRestartArea(), LfsResetUndoTotal(), LfsRestartLogFile(), LfsSetBaseLsn(), LfsVerifyLogSpaceAvail(), LfsWrite(), LfsWriteRestartArea(), MapDesktop(), MESSAGECALL(), MiChargePageFileQuota(), MiCreatePebOrTeb(), MiDoMappedCopy(), MiFindEmptyAddressRangeDownTree(), MiFindEmptyAddressRangeInTree(), MiInsertVad(), MiMakeProtectionMask(), MiMapLockedPagesInUserSpace(), MiMapViewOfDataSection(), MiMapViewOfImageSection(), MiMapViewOfPhysicalSection(), MiSetProtectionOnSection(), MmCreatePeb(), MmGetVerifierInformation(), MmProbeAndLockPages(), MmProbeAndLockProcessPages(), MmProbeForWrite(), MmSetVerifierInformation(), NtAllocateVirtualMemory(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryMultipleValueKey(), NtQueryQuotaInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtSetInformationFile(), NtSetUuidSeed(), NtUserDrawCaptionTemp(), NtUserQueryUserCounters(), NtUserResolveDesktop(), NtUserResolveDesktopForWOW(), NtUserSendInput(), NtUserSetSysColors(), NtUserSystemParametersInfo(), NtUserToUnicodeEx(), NtWriteFile(), NtWriteFileGather(), ProbeAndCaptureSoftKbdData(), PsChargePoolQuota(), UdfCreateIrpContext(), UdfNormalizeAndRaiseStatus(), UdfRaiseStatus(), UserRtlRaiseStatus(), VdmDispatchInterrupts(), VdmQueryDirectoryFile(), VeAllocatePoolWithTagPriority(), VerifierAllocatePoolWithQuota(), VerifierAllocatePoolWithQuotaTag(), VerifierProbeAndLockPages(), VerifierProbeAndLockProcessPages(), and VerifierProbeAndLockSelectedPages().

00163 : 00164 00165 This function raises an exception with the specified status value by 00166 building an exception record, building a context record, and calling the 00167 exception dispatcher directly. The exception is marked as noncontinuable 00168 with no parameters. There is no return from this function. 00169 00170 N.B. This routine is a shell routine that simply calls another routine 00171 to do the real work. The reason this is done is to avoid a problem 00172 in try/finally scopes where the last statement in the scope is a 00173 call to raise an exception. 00174 00175 Arguments: 00176 00177 ExceptionCode - Supplies the status value to be used as the exception 00178 code for the exception that is to be raised. 00179 00180 Return Value: 00181 00182 None. 00183 00184 --*/ 00185 00186 { 00187 00188 #ifdef DBGxx 00189 DbgPrint("ExRaiseStatus(ExceptionCode = %lx)\n", ExceptionCode); 00190 #endif 00191 ExpRaiseStatus(ExceptionCode); 00192 return; 00193 }

VOID ExRecordCallerInHashTable IN PCALL_PERFORMANCE_DATA  CallData,
IN PVOID  CallersAddress,
IN PVOID  CallersCaller
 

Definition at line 65 of file callperf.c.

References CALL_HASH_ENTRY, CALL_HASH_TABLE_SIZE, _CALL_HASH_ENTRY::CallCount, _CALL_HASH_ENTRY::CallersAddress, _CALL_HASH_ENTRY::CallersCaller, ExAllocatePoolWithTag, InitializationPhase, _CALL_HASH_ENTRY::ListEntry, NonPagedPool, NULL, and PCALL_HASH_ENTRY.

00073 : 00074 00075 This function records call data in the specified call performance 00076 data structure. 00077 00078 Arguments: 00079 00080 CallData - Supplies a pointer to the call performance data structure 00081 in which the call data is recorded. 00082 00083 CallersAddress - Supplies the address of the caller of a fucntion. 00084 00085 CallersCaller - Supplies the address of the caller of a caller of 00086 a function. 00087 00088 Return Value: 00089 00090 None. 00091 00092 --*/ 00093 00094 { 00095 00096 PCALL_HASH_ENTRY HashEntry; 00097 ULONG Hash; 00098 PCALL_HASH_ENTRY MatchEntry; 00099 PLIST_ENTRY NextEntry; 00100 KIRQL OldIrql; 00101 00102 // 00103 // If the initialization phase is not zero, then collect call performance 00104 // data. 00105 // 00106 00107 if (InitializationPhase != 0) { 00108 00109 // 00110 // Acquire the call performance data structure spinlock. 00111 // 00112 00113 ExAcquireSpinLock(&CallData->SpinLock, &OldIrql); 00114 00115 // 00116 // Lookup the callers address in call performance data hash table. If 00117 // the address does not exist in the table, then create a new entry. 00118 // 00119 00120 Hash = (ULONG)((ULONG_PTR)CallersAddress ^ (ULONG_PTR)CallersCaller); 00121 Hash = ((Hash > 24) ^ (Hash > 16) ^ (Hash > 8) ^ (Hash)) & (CALL_HASH_TABLE_SIZE - 1); 00122 MatchEntry = NULL; 00123 NextEntry = CallData->HashTable[Hash].Flink; 00124 while (NextEntry != &CallData->HashTable[Hash]) { 00125 HashEntry = CONTAINING_RECORD(NextEntry, 00126 CALL_HASH_ENTRY, 00127 ListEntry); 00128 00129 if ((HashEntry->CallersAddress == CallersAddress) && 00130 (HashEntry->CallersCaller == CallersCaller)) { 00131 MatchEntry = HashEntry; 00132 break; 00133 } 00134 00135 NextEntry = NextEntry->Flink; 00136 } 00137 00138 // 00139 // If a matching caller address was found, then update the call site 00140 // statistics. Otherwise, allocate a new hash entry and initialize 00141 // call site statistics. 00142 // 00143 00144 if (MatchEntry != NULL) { 00145 MatchEntry->CallCount += 1; 00146 00147 } else { 00148 MatchEntry = ExAllocatePoolWithTag(NonPagedPool, 00149 sizeof(CALL_HASH_ENTRY), 00150 'CdHe'); 00151 00152 if (MatchEntry != NULL) { 00153 MatchEntry->CallersAddress = CallersAddress; 00154 MatchEntry->CallersCaller = CallersCaller; 00155 MatchEntry->CallCount = 1; 00156 InsertTailList(&CallData->HashTable[Hash], 00157 &MatchEntry->ListEntry); 00158 } 00159 } 00160 00161 // 00162 // Release the call performance data structure spinlock. 00163 // 00164 00165 ExReleaseSpinLock(&CallData->SpinLock, OldIrql); 00166 } 00167 00168 return; 00169 } }

NTKERNELAPI PVOID ExRegisterCallback IN PCALLBACK_OBJECT  CallbackObject,
IN PCALLBACK_FUNCTION  CallbackFunction,
IN PVOID  CallbackContext
 

Definition at line 378 of file ex/callback.c.

References ASSERT, _CALLBACK_REGISTRATION::Busy, _CALLBACK_REGISTRATION::CallbackContext, _CALLBACK_REGISTRATION::CallbackFunction, _CALLBACK_REGISTRATION::CallbackObject, DISPATCH_LEVEL, ExAllocatePoolWithTag, ExFreePool(), FALSE, KeAcquireSpinLock, KeReleaseSpinLock(), _CALLBACK_REGISTRATION::Link, NonPagedPool, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObject, PCALLBACK_FUNCTION, PCALLBACK_REGISTRATION, Status, TRUE, and _CALLBACK_REGISTRATION::UnregisterWaiting.

00386 : 00387 00388 This routine allows a caller to register that it would like to have its 00389 callback Function invoked when the callback notification call occurs. 00390 00391 Arguments: 00392 00393 CallbackObject - Supplies a pointer to a CallbackObject. 00394 00395 CallbackFunction - Supplies a pointer to a function which is to 00396 be executed when the Callback notification occures. 00397 00398 CallbackContext - Supplies a pointer to an arbitrary data structure 00399 that will be passed to the function specified by the CallbackFunction 00400 parameter. 00401 00402 Return Value: 00403 00404 Returns handle to callback registration. 00405 00406 --*/ 00407 { 00408 PCALLBACK_REGISTRATION CallbackRegistration; 00409 BOOLEAN Inserted; 00410 KIRQL OldIrql; 00411 NTSTATUS Status; 00412 00413 ASSERT (CallbackFunction); 00414 ASSERT (KeGetCurrentIrql() < DISPATCH_LEVEL); 00415 00416 // 00417 // Add reference to object 00418 // 00419 00420 ObReferenceObject (CallbackObject); 00421 00422 // 00423 // Begin by attempting to allocate storage for the CallbackRegistration. 00424 // one cannot be allocated, return the error status. 00425 // 00426 00427 CallbackRegistration = ExAllocatePoolWithTag( 00428 NonPagedPool, 00429 sizeof( CALLBACK_REGISTRATION ), 00430 'eRBC' 00431 ); 00432 00433 00434 if( !CallbackRegistration ) { 00435 ObDereferenceObject (CallbackObject); 00436 return NULL; 00437 } 00438 00439 00440 // 00441 // Initialize the callback packet 00442 // 00443 00444 CallbackRegistration->CallbackObject = CallbackObject; 00445 CallbackRegistration->CallbackFunction = CallbackFunction; 00446 CallbackRegistration->CallbackContext = CallbackContext; 00447 CallbackRegistration->Busy = 0; 00448 CallbackRegistration->UnregisterWaiting = FALSE; 00449 00450 00451 Inserted = FALSE; 00452 KeAcquireSpinLock (&CallbackObject->Lock, &OldIrql); 00453 00454 if( CallbackObject->AllowMultipleCallbacks || 00455 IsListEmpty( &CallbackObject->RegisteredCallbacks ) ) { 00456 00457 // 00458 // add CallbackRegistration to tail 00459 // 00460 00461 00462 Inserted = TRUE; 00463 InsertTailList( &CallbackObject->RegisteredCallbacks, 00464 &CallbackRegistration->Link ) 00465 } 00466 00467 KeReleaseSpinLock (&CallbackObject->Lock, OldIrql); 00468 00469 if (!Inserted) { 00470 ExFreePool (CallbackRegistration); 00471 CallbackRegistration = NULL; 00472 } 00473 00474 return (PVOID) CallbackRegistration; 00475 }

NTKERNELAPI NTSTATUS ExReinitializeResourceLite IN PERESOURCE  Resource  ) 
 

Definition at line 273 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, _ERESOURCE::ContentionCount, Event(), _ERESOURCE::ExclusiveWaiters, FALSE, _ERESOURCE::Flag, Index, KeInitializeEvent, KeInitializeSemaphore(), KeInitializeSpinLock(), MmDeterminePoolType(), NonPagedPool, NULL, _ERESOURCE::NumberOfExclusiveWaiters, _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerCount, _ERESOURCE::OwnerTable, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, Resource, _ERESOURCE::SharedWaiters, _ERESOURCE::SpinLock, and _OWNER_ENTRY::TableSize.

00279 : 00280 00281 This routine reinitializes the specified resource. 00282 00283 Arguments: 00284 00285 Resource - Supplies a pointer to the resource to initialize. 00286 00287 Return Value: 00288 00289 STATUS_SUCCESS. 00290 00291 --*/ 00292 00293 { 00294 00295 PKEVENT Event; 00296 ULONG Index; 00297 POWNER_ENTRY OwnerTable; 00298 PKSEMAPHORE Semaphore; 00299 ULONG TableSize; 00300 00301 ASSERT(MmDeterminePoolType(Resource) == NonPagedPool); 00302 00303 // 00304 // If the resource has an owner table, then zero the owner table. 00305 // 00306 00307 OwnerTable = Resource->OwnerTable; 00308 if (OwnerTable != NULL) { 00309 TableSize = OwnerTable->TableSize; 00310 for (Index = 1; Index < TableSize; Index += 1) { 00311 OwnerTable[Index].OwnerThread = 0; 00312 OwnerTable[Index].OwnerCount = 0; 00313 } 00314 } 00315 00316 // 00317 // Set the active count and flags to zero. 00318 // 00319 00320 Resource->ActiveCount = 0; 00321 Resource->Flag = 0; 00322 00323 // 00324 // If the resource has a shared waiter semaphore, then reinitialize 00325 // it. 00326 // 00327 00328 Semaphore = Resource->SharedWaiters; 00329 if (Semaphore != NULL) { 00330 KeInitializeSemaphore(Semaphore, 0, MAXLONG); 00331 } 00332 00333 // 00334 // If the resource has a exclusive waiter event, then reinitialize 00335 // it. 00336 // 00337 00338 Event = Resource->ExclusiveWaiters; 00339 if (Event != NULL) { 00340 KeInitializeEvent(Event, SynchronizationEvent, FALSE); 00341 } 00342 00343 // 00344 // Initialize the builtin owner table. 00345 // 00346 00347 Resource->OwnerThreads[0].OwnerThread = 0; 00348 Resource->OwnerThreads[0].OwnerCount = 0; 00349 Resource->OwnerThreads[1].OwnerThread = 0; 00350 Resource->OwnerThreads[1].OwnerCount = 0; 00351 00352 // 00353 // Set the contention count, number of shared waiters, and number 00354 // of exclusive waiters to zero. 00355 // 00356 00357 Resource->ContentionCount = 0; 00358 Resource->NumberOfSharedWaiters = 0; 00359 Resource->NumberOfExclusiveWaiters = 0; 00360 00361 // 00362 // Reinitialize the resource spinlock. 00363 // 00364 00365 KeInitializeSpinLock(&Resource->SpinLock); 00366 return STATUS_SUCCESS; 00367 }

NTKERNELAPI VOID FASTCALL ExReleaseFastMutexUnsafe IN PFAST_MUTEX  FastMutex  ) 
 

Referenced by ExUuidCreate(), FsRtlAcknowledgeOplockBreak(), FsRtlOpBatchBreakClosePending(), FsRtlOplockBreakNotify(), FsRtlOplockBreakToII(), FsRtlOplockBreakToNone(), FsRtlOplockCleanup(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlUninitializeOplock(), FsRtlWaitOnIrp(), LeaveMediaCrit(), LeavePowerCrit(), MiMapViewOfDataSection(), MiProtectVirtualMemory(), MiRemoveMappedView(), NtAllocateUuids(), NtAllocateVirtualMemory(), NtQueryInformationJobObject(), NtSetInformationJobObject(), PsChangeJobMemoryUsage(), PsLockProcess(), PspAddProcessToJob(), PspApplyJobLimitsToProcess(), PspJobClose(), PsReportProcessMemoryLimitViolation(), PsUnlockProcess(), and VerifierExReleaseFastMutexUnsafe().

NTKERNELAPI VOID ExReleaseResourceForThreadLite IN PERESOURCE  Resource,
IN ERESOURCE_THREAD  ResourceThreadId
 

Definition at line 1607 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, _ERESOURCE::ExclusiveWaiters, FALSE, _ERESOURCE::Flag, Index, IsExclusiveWaiting, IsOwnedExclusive, IsSharedWaiting, KeReleaseSemaphore(), KeSetEventBoostPriority(), NULL, _ERESOURCE::NumberOfExclusiveWaiters, _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerCount, _ERESOURCE::OwnerTable, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, Resource, ResourceOwnedExclusive, _ERESOURCE::SharedWaiters, SHORT, _ERESOURCE::SpinLock, _OWNER_ENTRY::TableSize, and TRUE.

01614 : 01615 01616 This routine release the specified resource for the specified thread 01617 and decrements the recursion count. If the count reaches zero, then 01618 the resource may also be released. 01619 01620 N.B. This routine uses fast locking. 01621 01622 Arguments: 01623 01624 Resource - Supplies a pointer to the resource to release. 01625 01626 Thread - Supplies the thread that originally acquired the resource. 01627 01628 Return Value: 01629 01630 None. 01631 01632 --*/ 01633 01634 { 01635 01636 ULONG Index; 01637 ULONG Number; 01638 KIRQL OldIrql; 01639 POWNER_ENTRY OwnerEntry; 01640 01641 ASSERT(CurrentThread != 0); 01642 01643 // 01644 // Acquire exclusive access to the specified resource. 01645 // 01646 01647 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 01648 01649 ASSERT_RESOURCE(Resource); 01650 01651 // 01652 // If the resource is exclusively owned, then release exclusive 01653 // ownership. Otherwise, release shared ownership. 01654 // 01655 // N.B. The two release paths are split since this is such a high 01656 // frequency function. 01657 // 01658 01659 if (IsOwnedExclusive(Resource)) { 01660 01661 ASSERT(Resource->OwnerThreads[0].OwnerThread == CurrentThread); 01662 01663 // 01664 // Decrement the recursion count and check if ownership can be 01665 // released. 01666 // 01667 01668 ASSERT(Resource->OwnerThreads[0].OwnerCount > 0); 01669 01670 if (--Resource->OwnerThreads[0].OwnerCount != 0) { 01671 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01672 return; 01673 } 01674 01675 // 01676 // Clear the owner thread. 01677 // 01678 01679 Resource->OwnerThreads[0].OwnerThread = 0; 01680 01681 // 01682 // The thread recursion count reached zero so decrement the resource 01683 // active count. If the active count reaches zero, then the resource 01684 // is no longer owned and an attempt should be made to grant access to 01685 // another thread. 01686 // 01687 01688 ASSERT(Resource->ActiveCount > 0); 01689 01690 if (--Resource->ActiveCount == 0) { 01691 01692 // 01693 // If there are shared waiters, then grant shared access to the 01694 // resource. Otherwise, grant exclusive ownership if there are 01695 // exclusive waiters. 01696 // 01697 01698 if (IsSharedWaiting(Resource)) { 01699 Resource->Flag &= ~ResourceOwnedExclusive; 01700 Number = Resource->NumberOfSharedWaiters; 01701 Resource->ActiveCount = (SHORT)Number; 01702 Resource->NumberOfSharedWaiters = 0; 01703 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01704 KeReleaseSemaphore(Resource->SharedWaiters, 0, Number, FALSE); 01705 return; 01706 01707 } else if (IsExclusiveWaiting(Resource)) { 01708 Resource->OwnerThreads[0].OwnerThread = 1; 01709 Resource->OwnerThreads[0].OwnerCount = 1; 01710 Resource->ActiveCount = 1; 01711 Resource->NumberOfExclusiveWaiters -= 1; 01712 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01713 KeSetEventBoostPriority(Resource->ExclusiveWaiters, 01714 (PRKTHREAD *)&Resource->OwnerThreads[0].OwnerThread); 01715 return; 01716 } 01717 01718 Resource->Flag &= ~ResourceOwnedExclusive; 01719 } 01720 01721 } else { 01722 if (Resource->OwnerThreads[1].OwnerThread == CurrentThread) { 01723 OwnerEntry = &Resource->OwnerThreads[1]; 01724 01725 } else if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 01726 OwnerEntry = &Resource->OwnerThreads[0]; 01727 01728 } else { 01729 01730 // 01731 // If the specified current thread is an owner address (low 01732 // bits are nonzero), then set the hint index to the first 01733 // entry. Otherwise, set the hint index from the owner thread. 01734 // 01735 01736 Index = 1; 01737 if (((ULONG)CurrentThread & 3) == 0) { 01738 Index = ((PKTHREAD)(CurrentThread))->ResourceIndex; 01739 } 01740 01741 OwnerEntry = Resource->OwnerTable; 01742 01743 ASSERT(OwnerEntry != NULL); 01744 01745 // 01746 // If the resource hint is not within range or the resource 01747 // table entry does match the current thread, then search 01748 // the owner table for a match. 01749 // 01750 01751 if ((Index >= OwnerEntry->TableSize) || 01752 (OwnerEntry[Index].OwnerThread != CurrentThread)) { 01753 do { 01754 OwnerEntry += 1; 01755 if (OwnerEntry->OwnerThread == CurrentThread) { 01756 break; 01757 } 01758 01759 } while (TRUE); 01760 01761 } else { 01762 OwnerEntry = &OwnerEntry[Index]; 01763 } 01764 } 01765 01766 // 01767 // Decrement the recursion count and check if ownership can be 01768 // released. 01769 // 01770 01771 ASSERT(OwnerEntry->OwnerThread == CurrentThread); 01772 ASSERT(OwnerEntry->OwnerCount > 0); 01773 01774 if (--OwnerEntry->OwnerCount != 0) { 01775 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01776 return; 01777 } 01778 01779 // 01780 // Clear the owner thread. 01781 // 01782 01783 OwnerEntry->OwnerThread = 0; 01784 01785 // 01786 // The thread recursion count reached zero so decrement the resource 01787 // active count. If the active count reaches zero, then the resource 01788 // is no longer owned and an attempt should be made to grant access to 01789 // another thread. 01790 // 01791 01792 ASSERT(Resource->ActiveCount > 0); 01793 01794 if (--Resource->ActiveCount == 0) { 01795 01796 // 01797 // If there are exclusive waiters, then grant exclusive access 01798 // to the resource. 01799 // 01800 01801 if (IsExclusiveWaiting(Resource)) { 01802 Resource->Flag |= ResourceOwnedExclusive; 01803 Resource->OwnerThreads[0].OwnerThread = 1; 01804 Resource->OwnerThreads[0].OwnerCount = 1; 01805 Resource->ActiveCount = 1; 01806 Resource->NumberOfExclusiveWaiters -= 1; 01807 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01808 KeSetEventBoostPriority(Resource->ExclusiveWaiters, 01809 (PRKTHREAD *)&Resource->OwnerThreads[0].OwnerThread); 01810 return; 01811 } 01812 } 01813 } 01814 01815 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01816 return; 01817 }

NTKERNELAPI VOID FASTCALL ExReleaseResourceLite IN PERESOURCE  Resource  ) 
 

Definition at line 1389 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, _ERESOURCE::ExclusiveWaiters, FALSE, _ERESOURCE::Flag, Index, IsExclusiveWaiting, IsOwnedExclusive, IsSharedWaiting, KeBugCheckEx(), KeReleaseSemaphore(), KeSetEventBoostPriority(), NULL, _ERESOURCE::NumberOfExclusiveWaiters, _ERESOURCE::NumberOfSharedWaiters, _OWNER_ENTRY::OwnerCount, _ERESOURCE::OwnerTable, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, ResourceOwnedExclusive, _ERESOURCE::SharedWaiters, SHORT, _ERESOURCE::SpinLock, and _OWNER_ENTRY::TableSize.

Referenced by MmTrimAllSystemPagableMemory(), and VerifierExReleaseResource().

01395 : 01396 01397 This routine releases the specified resource for the current thread 01398 and decrements the recursion count. If the count reaches zero, then 01399 the resource may also be released. 01400 01401 N.B. This routine uses fast locking. 01402 01403 Arguments: 01404 01405 Resource - Supplies a pointer to the resource to release. 01406 01407 Return Value: 01408 01409 None. 01410 01411 --*/ 01412 01413 { 01414 01415 ERESOURCE_THREAD CurrentThread; 01416 ULONG Index; 01417 ULONG Number; 01418 KIRQL OldIrql; 01419 POWNER_ENTRY OwnerEntry, OwnerEnd; 01420 01421 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 01422 01423 // 01424 // Acquire exclusive access to the specified resource. 01425 // 01426 01427 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 01428 01429 ASSERT_RESOURCE(Resource); 01430 01431 // 01432 // If the resource is exclusively owned, then release exclusive 01433 // ownership. Otherwise, release shared ownership. 01434 // 01435 // N.B. The two release paths are split since this is such a high 01436 // frequency function. 01437 // 01438 01439 if (IsOwnedExclusive(Resource)) { 01440 01441 // if (Resource->OwnerThreads[0].OwnerThread != CurrentThread) { 01442 // KeBugCheckEx(RESOURCE_NOT_OWNED, 01443 // (ULONG_PTR)Resource, 01444 // (ULONG_PTR)CurrentThread, 01445 // (ULONG_PTR)Resource->OwnerTable, 01446 // 0x1); 01447 // } 01448 01449 // 01450 // Decrement the recursion count and check if ownership can be 01451 // released. 01452 // 01453 01454 ASSERT(Resource->OwnerThreads[0].OwnerCount > 0); 01455 01456 if (--Resource->OwnerThreads[0].OwnerCount != 0) { 01457 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01458 return; 01459 } 01460 01461 // 01462 // Clear the owner thread. 01463 // 01464 01465 Resource->OwnerThreads[0].OwnerThread = 0; 01466 01467 // 01468 // The thread recursion count reached zero so decrement the resource 01469 // active count. If the active count reaches zero, then the resource 01470 // is no longer owned and an attempt should be made to grant access to 01471 // another thread. 01472 // 01473 01474 ASSERT(Resource->ActiveCount > 0); 01475 01476 if (--Resource->ActiveCount == 0) { 01477 01478 // 01479 // If there are shared waiters, then grant shared access to the 01480 // resource. Otherwise, grant exclusive ownership if there are 01481 // exclusive waiters. 01482 // 01483 01484 if (IsSharedWaiting(Resource)) { 01485 Resource->Flag &= ~ResourceOwnedExclusive; 01486 Number = Resource->NumberOfSharedWaiters; 01487 Resource->ActiveCount = (SHORT)Number; 01488 Resource->NumberOfSharedWaiters = 0; 01489 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01490 KeReleaseSemaphore(Resource->SharedWaiters, 0, Number, FALSE); 01491 return; 01492 01493 } else if (IsExclusiveWaiting(Resource)) { 01494 Resource->OwnerThreads[0].OwnerThread = 1; 01495 Resource->OwnerThreads[0].OwnerCount = 1; 01496 Resource->ActiveCount = 1; 01497 Resource->NumberOfExclusiveWaiters -= 1; 01498 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01499 KeSetEventBoostPriority(Resource->ExclusiveWaiters, 01500 (PRKTHREAD *)&Resource->OwnerThreads[0].OwnerThread); 01501 return; 01502 } 01503 01504 Resource->Flag &= ~ResourceOwnedExclusive; 01505 } 01506 01507 } else { 01508 if (Resource->OwnerThreads[1].OwnerThread == CurrentThread) { 01509 OwnerEntry = &Resource->OwnerThreads[1]; 01510 01511 } else if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 01512 OwnerEntry = &Resource->OwnerThreads[0]; 01513 01514 } else { 01515 Index = ((PKTHREAD)(CurrentThread))->ResourceIndex; 01516 OwnerEntry = Resource->OwnerTable; 01517 01518 if (OwnerEntry == NULL) { 01519 KeBugCheckEx(RESOURCE_NOT_OWNED, 01520 (ULONG_PTR)Resource, 01521 (ULONG_PTR)CurrentThread, 01522 (ULONG_PTR)Resource->OwnerTable, 01523 0x2); 01524 } 01525 01526 // 01527 // If the resource hint is not within range or the resource 01528 // table entry does match the current thread, then search 01529 // the owner table for a match. 01530 // 01531 01532 if ((Index >= OwnerEntry->TableSize) || 01533 (OwnerEntry[Index].OwnerThread != CurrentThread)) { 01534 OwnerEnd = &OwnerEntry[OwnerEntry->TableSize]; 01535 while (1) { 01536 OwnerEntry += 1; 01537 if (OwnerEntry >= OwnerEnd) { 01538 KeBugCheckEx(RESOURCE_NOT_OWNED, 01539 (ULONG_PTR)Resource, 01540 (ULONG_PTR)CurrentThread, 01541 (ULONG_PTR)Resource->OwnerTable, 01542 0x3); 01543 } 01544 if (OwnerEntry->OwnerThread == CurrentThread) { 01545 break; 01546 } 01547 }; 01548 } else { 01549 OwnerEntry = &OwnerEntry[Index]; 01550 } 01551 } 01552 01553 // 01554 // Decrement the recursion count and check if ownership can be 01555 // released. 01556 // 01557 01558 ASSERT(OwnerEntry->OwnerThread == CurrentThread); 01559 ASSERT(OwnerEntry->OwnerCount > 0); 01560 01561 if (--OwnerEntry->OwnerCount != 0) { 01562 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01563 return; 01564 } 01565 01566 // 01567 // Clear the owner thread. 01568 // 01569 01570 OwnerEntry->OwnerThread = 0; 01571 01572 // 01573 // The thread recursion count reached zero so decrement the resource 01574 // active count. If the active count reaches zero, then the resource 01575 // is no longer owned and an attempt should be made to grant access to 01576 // another thread. 01577 // 01578 01579 ASSERT(Resource->ActiveCount > 0); 01580 01581 if (--Resource->ActiveCount == 0) { 01582 01583 // 01584 // If there are exclusive waiters, then grant exclusive access 01585 // to the resource. 01586 // 01587 01588 if (IsExclusiveWaiting(Resource)) { 01589 Resource->Flag |= ResourceOwnedExclusive; 01590 Resource->OwnerThreads[0].OwnerThread = 1; 01591 Resource->OwnerThreads[0].OwnerCount = 1; 01592 Resource->ActiveCount = 1; 01593 Resource->NumberOfExclusiveWaiters -= 1; 01594 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01595 KeSetEventBoostPriority(Resource->ExclusiveWaiters, 01596 (PRKTHREAD *)&Resource->OwnerThreads[0].OwnerThread); 01597 return; 01598 } 01599 } 01600 } 01601 01602 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01603 return; 01604 }

VOID ExReleaseTimeRefreshLock VOID   ) 
 

Referenced by KdpTimeSlipWork().

NTKERNELAPI VOID ExRemoveHandleTable IN PHANDLE_TABLE  HandleTable  ) 
 

Definition at line 501 of file ex/handle.c.

References ExAcquireResourceExclusive, ExReleaseResource, HandleTableListLock, KeEnterCriticalRegion, KeLeaveCriticalRegion, PAGED_CODE, and TRUE.

Referenced by ExDestroyHandleTable(), PspInitPhase0(), and RtlpInitializeHandleTableForAtomTable().

00507 : 00508 00509 This function removes the specified exhandle table from the list of 00510 exhandle tables. Used by PS and ATOM packages to make sure their handle 00511 tables are not in the list enumerated by the ExSnapShotHandleTables 00512 routine and the !handle debugger extension. 00513 00514 Arguments: 00515 00516 HandleTable - Supplies a pointer to a handle table 00517 00518 Return Value: 00519 00520 None. 00521 00522 --*/ 00523 00524 { 00525 PAGED_CODE(); 00526 00527 // 00528 // First, acquire the global handle table lock 00529 // 00530 00531 KeEnterCriticalRegion(); 00532 ExAcquireResourceExclusive( &HandleTableListLock, TRUE ); 00533 00534 // 00535 // Remove the handle table from the handle table list. This routine is 00536 // written so that multiple calls to remove a handle table will not 00537 // corrupt the system. 00538 // 00539 00540 if (!IsListEmpty( &HandleTable->HandleTableList )) { 00541 00542 RemoveEntryList( &HandleTable->HandleTableList ); 00543 00544 InitializeListHead( &HandleTable->HandleTableList ); 00545 } 00546 00547 // 00548 // Now release the global lock and return to our caller 00549 // 00550 00551 ExReleaseResource( &HandleTableListLock ); 00552 KeLeaveCriticalRegion(); 00553 00554 return; 00555 }

VOID ExReturnPoolQuota IN PVOID  P  ) 
 

Definition at line 3480 of file ex/pool.c.

References BASE_POOL_TYPE_MASK, _POOL_HEADER::BlockSize, DECODE_POOL_INDEX, LOCK_POOL_GRANULAR, MmSpecialPoolEnd, MmSpecialPoolStart, NULL, ObDereferenceObject, PagedPool, POOL_BLOCK_SHIFT, POOL_OVERHEAD, POOL_QUOTA_ENABLED, POOL_QUOTA_MASK, POOL_TYPE, POOL_TYPE_MASK, _POOL_HEADER::PoolTag, _POOL_HEADER::PoolType, PoolVector, _POOL_HEADER::ProcessBilled, PsReturnPoolQuota(), and UNLOCK_POOL_GRANULAR.

Referenced by IopFreeIrp(), and IopFreeMiniPacket().

03486 : 03487 03488 This function returns quota charged to a subject process when the 03489 specified pool block was allocated. 03490 03491 Arguments: 03492 03493 P - Supplies the address of the block of pool being deallocated. 03494 03495 Return Value: 03496 03497 None. 03498 03499 --*/ 03500 03501 { 03502 03503 PPOOL_HEADER Entry; 03504 POOL_TYPE PoolType; 03505 PEPROCESS Process; 03506 #if defined(_ALPHA_) && !defined(_AXP64_) 03507 PPOOL_DESCRIPTOR PoolDesc; 03508 KIRQL LockHandle; 03509 #endif 03510 03511 // 03512 // Do nothing for special pool. No quota was charged. 03513 // 03514 03515 if ((P >= MmSpecialPoolStart) && (P < MmSpecialPoolEnd)) { 03516 03517 return; 03518 } 03519 03520 // 03521 // Align the entry address to a pool allocation boundary. 03522 // 03523 03524 #if POOL_CACHE_SUPPORTED 03525 03526 if (((ULONG)P & POOL_CACHE_CHECK) == 0) { 03527 Entry = (PPOOL_HEADER)((ULONG)P - PoolCacheSize); 03528 03529 } else { 03530 Entry = (PPOOL_HEADER)((PCHAR)P - POOL_OVERHEAD); 03531 } 03532 03533 #else 03534 03535 Entry = (PPOOL_HEADER)((PCHAR)P - POOL_OVERHEAD); 03536 03537 #endif //POOL_CACHE_SUPPORTED 03538 03539 // 03540 // If quota was charged, then return the appropriate quota to the 03541 // subject process. 03542 // 03543 03544 if ((Entry->PoolType & POOL_QUOTA_MASK) && POOL_QUOTA_ENABLED) { 03545 03546 PoolType = (Entry->PoolType & POOL_TYPE_MASK) - 1; 03547 03548 #if _POOL_LOCK_GRANULAR_ 03549 PoolDesc = PoolVector[PoolType]; 03550 if (PoolType == PagedPool) { 03551 PoolDesc = &PoolDesc[DECODE_POOL_INDEX(Entry)]; 03552 } 03553 #endif 03554 03555 LOCK_POOL_GRANULAR(PoolDesc, LockHandle); 03556 03557 Entry->PoolType &= ~POOL_QUOTA_MASK; 03558 03559 UNLOCK_POOL_GRANULAR(PoolDesc, LockHandle); 03560 03561 Process = Entry->ProcessBilled; 03562 03563 #if !defined (_WIN64) 03564 Entry->PoolTag = 'atoQ'; 03565 #endif 03566 03567 if (Process != NULL) { 03568 PsReturnPoolQuota(Process, 03569 PoolType & BASE_POOL_TYPE_MASK, 03570 (ULONG)Entry->BlockSize << POOL_BLOCK_SHIFT); 03571 03572 ObDereferenceObject(Process); 03573 } 03574 03575 } 03576 03577 return; 03578 }

NTKERNELAPI VOID ExSetResourceOwnerPointer IN PERESOURCE  Resource,
IN PVOID  OwnerPointer
 

Definition at line 1820 of file ex/resource.c.

References ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, Index, IsOwnedExclusive, NULL, _OWNER_ENTRY::OwnerCount, _ERESOURCE::OwnerTable, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, _ERESOURCE::SpinLock, _OWNER_ENTRY::TableSize, and TRUE.

Referenced by CcSetBcbOwnerPointer().

01827 : 01828 01829 This routine locates the owner entry for the current thread and stores 01830 the specified owner address as the owner thread. Subsequent to calling 01831 this routine, the only routine which may be called for this resource is 01832 ExReleaseResourceForThread, supplying the owner address as the "thread". 01833 01834 Owner addresses must obey the following rules: 01835 01836 They must be a unique pointer to a structure allocated in system space, 01837 and they must point to a structure which remains allocated until after 01838 the call to ExReleaseResourceForThread. This is to eliminate aliasing 01839 with a thread or other owner address. 01840 01841 The low order two bits of the owner address must be set by the caller, 01842 so that other routines in the resource package can distinguish owner 01843 address from thread addresses. 01844 01845 N.B. This routine uses fast locking. 01846 01847 Arguments: 01848 01849 Resource - Supplies a pointer to the resource to release. 01850 01851 OwnerPointer - Supplies a pointer to an allocated structure with the low 01852 order two bits set. 01853 01854 Return Value: 01855 01856 None. 01857 01858 --*/ 01859 01860 { 01861 01862 ERESOURCE_THREAD CurrentThread; 01863 ULONG Index; 01864 KIRQL OldIrql; 01865 POWNER_ENTRY OwnerEntry; 01866 01867 ASSERT((OwnerPointer != 0) && (((ULONG_PTR)OwnerPointer & 3) == 3)); 01868 01869 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 01870 01871 // 01872 // Acquire exclusive access to the specified resource. 01873 // 01874 01875 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 01876 01877 ASSERT_RESOURCE(Resource); 01878 01879 // 01880 // If the resource is exclusively owned, then it is the first owner entry. 01881 // 01882 01883 if (IsOwnedExclusive(Resource)) { 01884 01885 ASSERT(Resource->OwnerThreads[0].OwnerThread == CurrentThread); 01886 01887 // 01888 // Set the owner address. 01889 // 01890 01891 ASSERT(Resource->OwnerThreads[0].OwnerCount > 0); 01892 01893 Resource->OwnerThreads[0].OwnerThread = (ULONG_PTR)OwnerPointer; 01894 01895 // 01896 // For shared access we have to search for the current thread to set 01897 // the owner address. 01898 // 01899 01900 } else { 01901 if (Resource->OwnerThreads[1].OwnerThread == CurrentThread) { 01902 Resource->OwnerThreads[1].OwnerThread = (ULONG_PTR)OwnerPointer; 01903 01904 } else if (Resource->OwnerThreads[0].OwnerThread == CurrentThread) { 01905 Resource->OwnerThreads[0].OwnerThread = (ULONG_PTR)OwnerPointer; 01906 01907 } else { 01908 Index = ((PKTHREAD)(CurrentThread))->ResourceIndex; 01909 OwnerEntry = Resource->OwnerTable; 01910 01911 ASSERT(OwnerEntry != NULL); 01912 01913 // 01914 // If the resource hint is not within range or the resource 01915 // table entry does match the current thread, then search 01916 // the owner table for a match. 01917 // 01918 01919 if ((Index >= OwnerEntry->TableSize) || 01920 (OwnerEntry[Index].OwnerThread != CurrentThread)) { 01921 do { 01922 OwnerEntry += 1; 01923 if (OwnerEntry->OwnerThread == CurrentThread) { 01924 break; 01925 } 01926 01927 } while (TRUE); 01928 01929 } else { 01930 OwnerEntry = &OwnerEntry[Index]; 01931 } 01932 01933 OwnerEntry->OwnerThread = (ULONG_PTR)OwnerPointer; 01934 } 01935 } 01936 01937 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 01938 return; 01939 }

NTKERNELAPI ULONG ExSetTimerResolution IN ULONG  DesiredTime,
IN BOOLEAN  SetResolution
 

VOID ExShutdownSystem VOID   ) 
 

NTKERNELAPI NTSTATUS ExSnapShotHandleTables IN PEX_SNAPSHOT_HANDLE_ENTRY  SnapShotHandleEntry,
IN OUT PSYSTEM_HANDLE_INFORMATION  HandleInformation,
IN ULONG  Length,
IN OUT PULONG  RequiredLength
 

Definition at line 984 of file ex/handle.c.

References ExAcquireResourceExclusive, ExLockHandleTableEntry(), ExLockHandleTableExclusive(), ExpLookupHandleTableEntry(), ExReleaseResource, ExUnlockHandleTableEntry(), ExUnlockHandleTableExclusive(), Handle, HandleTableListHead, HandleTableListLock, KeEnterCriticalRegion, KeLeaveCriticalRegion, NTSTATUS(), NULL, _HANDLE_TABLE_ENTRY::Object, PAGED_CODE, Status, TRUE, and _HANDLE_TABLE::UniqueProcessId.

Referenced by ObGetHandleInformation().

00993 : 00994 00995 This function visits and invokes the specified callback for every valid 00996 handle that it can find off of the handle table. 00997 00998 Arguments: 00999 01000 SnapShotHandleEntry - Supplies a pointer to a function to call for 01001 each valid handle we encounter. 01002 01003 HandleInformation - Supplies a handle information structure to 01004 be filled in for each handle table we encounter. This routine 01005 fills in the handle count, but relies on a callback to fill in 01006 entry info fields. 01007 01008 Length - Supplies a parameter for the callback. In reality this is 01009 the total size, in bytes, of the Handle Information buffer. 01010 01011 RequiredLength - Supplies a parameter for the callback. In reality 01012 this is a final size in bytes used to store the requested 01013 information. 01014 01015 Return Value: 01016 01017 The last return status of the callback 01018 01019 --*/ 01020 01021 { 01022 NTSTATUS Status; 01023 PSYSTEM_HANDLE_TABLE_ENTRY_INFO HandleEntryInfo; 01024 PLIST_ENTRY NextEntry; 01025 PHANDLE_TABLE HandleTable; 01026 EXHANDLE Handle; 01027 PHANDLE_TABLE_ENTRY HandleTableEntry; 01028 01029 PAGED_CODE(); 01030 01031 // 01032 // Lock the handle table list exclusive and traverse the list of handle 01033 // tables. 01034 // 01035 01036 Status = STATUS_SUCCESS; 01037 01038 KeEnterCriticalRegion(); 01039 ExAcquireResourceExclusive( &HandleTableListLock, TRUE ); 01040 01041 try { 01042 01043 // 01044 // Setup the output buffer pointer that the callback will maintain 01045 // 01046 01047 HandleEntryInfo = &HandleInformation->Handles[0]; 01048 01049 // 01050 // Zero out the handle count 01051 // 01052 01053 HandleInformation->NumberOfHandles = 0; 01054 01055 // 01056 // Iterate through all the handle tables in the system. 01057 // 01058 01059 for (NextEntry = HandleTableListHead.Flink; 01060 NextEntry != &HandleTableListHead; 01061 NextEntry = NextEntry->Flink) { 01062 01063 // 01064 // Get the address of the next handle table, lock the handle 01065 // table exclusive, and scan the list of handle entries. 01066 // 01067 01068 HandleTable = CONTAINING_RECORD( NextEntry, 01069 HANDLE_TABLE, 01070 HandleTableList ); 01071 01072 ExLockHandleTableExclusive( HandleTable ); 01073 01074 try { 01075 01076 // Iterate through the handle table and for each handle that 01077 // is allocated we'll invoke the call back. Note that this 01078 // loop exits when we get a null handle table entry. We know 01079 // there will be no more possible entries after the first null 01080 // one is encountered because we allocate memory of the 01081 // handles in a dense fashion 01082 // 01083 01084 for (Handle.Index = 0, Handle.TagBits = 0; 01085 (HandleTableEntry = ExpLookupHandleTableEntry( HandleTable, Handle )) != NULL; 01086 Handle.Index += 1) { 01087 01088 // 01089 // Only do the callback if the entry is not free 01090 // 01091 01092 if (HandleTableEntry->Object != NULL) { 01093 01094 // 01095 // Increment the handle count information in the 01096 // information buffer 01097 // 01098 01099 HandleInformation->NumberOfHandles += 1; 01100 01101 // 01102 // Lock the handle table entry because we're about to 01103 // give it to the callback function, then release the 01104 // entry right after the call back. 01105 // 01106 01107 if (ExLockHandleTableEntry( HandleTable, HandleTableEntry )) { 01108 01109 try { 01110 01111 Status = (*SnapShotHandleEntry)( &HandleEntryInfo, 01112 HandleTable->UniqueProcessId, 01113 HandleTableEntry, 01114 Handle.GenericHandleOverlay, 01115 Length, 01116 RequiredLength ); 01117 01118 } finally { 01119 01120 ExUnlockHandleTableEntry( HandleTable, HandleTableEntry ); 01121 } 01122 } 01123 } 01124 } 01125 01126 } finally { 01127 01128 ExUnlockHandleTableExclusive( HandleTable ); 01129 } 01130 } 01131 01132 } finally { 01133 01134 ExReleaseResource( &HandleTableListLock ); 01135 KeLeaveCriticalRegion(); 01136 } 01137 01138 return Status; 01139 }

int ExSystemExceptionFilter VOID   ) 
 

Referenced by NtAllocateLocallyUniqueId(), NtAllocateUserPhysicalPages(), NtAllocateUuids(), NtAllocateVirtualMemory(), NtCancelTimer(), NtCreateChannel(), NtCreateEvent(), NtCreateEventPair(), NtCreateIoCompletion(), NtCreateJobObject(), NtCreateMutant(), NtCreatePagingFile(), NtCreateSemaphore(), NtCreateSuperSection(), NtCreateTimer(), NTFastDOSIO(), NtFreeUserPhysicalPages(), NtFreeVirtualMemory(), NtListenChannel(), NtLockVirtualMemory(), NtMapViewOfSection(), NtMapViewOfSuperSection(), NtOpenChannel(), NtOpenEvent(), NtOpenEventPair(), NtOpenIoCompletion(), NtOpenJobObject(), NtOpenMutant(), NtOpenSemaphore(), NtOpenTimer(), NtPulseEvent(), NtQueryEvent(), NtQueryInformationJobObject(), NtQueryIoCompletion(), NtQueryMutant(), NtQuerySemaphore(), NtQueryTimer(), NtReleaseMutant(), NtReleaseSemaphore(), NtRemoveIoCompletion(), NtReplyWaitSendChannel(), NtResetEvent(), NtSendWaitReplyChannel(), NtSetEvent(), NtSetInformationObject(), NtSetTimer(), NtUnlockVirtualMemory(), ObpCaptureObjectCreateInformation(), ObpCaptureObjectName(), SepProbeAndCaptureString_U(), VdmpInitialize(), and VdmpPrinterDirectIoClose().

NTKERNELAPI VOID ExSystemTimeToLocalTime IN PLARGE_INTEGER  SystemTime,
OUT PLARGE_INTEGER  LocalTime
 

Referenced by ExGetNextWakeTime(), and IopCopyBootLogRegistryToFile().

NTKERNELAPI VOID ExTimerRundown VOID   ) 
 

NTKERNELAPI BOOLEAN ExTryToAcquireResourceExclusiveLite IN PERESOURCE  Resource  ) 
 

Definition at line 598 of file ex/resource.c.

References _ERESOURCE::ActiveCount, ASSERT, ASSERT_RESOURCE, ERESOURCE_THREAD, ExpIncrementCounter, FALSE, _ERESOURCE::Flag, IsOwnedExclusive, _OWNER_ENTRY::OwnerCount, _OWNER_ENTRY::OwnerThread, _ERESOURCE::OwnerThreads, PsGetCurrentThread, Resource, ResourceNeverExclusive, ResourceOwnedExclusive, _ERESOURCE::SpinLock, and TRUE.

Referenced by MiEmptyWorkingSet(), MmTrimAllSystemPagableMemory(), and MmWorkingSetManager().

00604 : 00605 00606 The routine attempts to acquire the specified resource for exclusive 00607 access. 00608 00609 N.B. This routine uses fast locking. 00610 00611 Arguments: 00612 00613 Resource - Supplies a pointer to the resource that is acquired 00614 for exclusive access. 00615 00616 Return Value: 00617 00618 BOOLEAN - TRUE if the resource is acquired and FALSE otherwise. 00619 00620 --*/ 00621 00622 { 00623 00624 ERESOURCE_THREAD CurrentThread; 00625 KIRQL OldIrql; 00626 BOOLEAN Result; 00627 00628 ASSERT((Resource->Flag & ResourceNeverExclusive) == 0); 00629 00630 // 00631 // Attempt to acquire exclusive access to the specified resource. 00632 // 00633 00634 CurrentThread = (ERESOURCE_THREAD)PsGetCurrentThread(); 00635 ExAcquireFastLock(&Resource->SpinLock, &OldIrql); 00636 00637 ASSERT(KeIsExecutingDpc() == FALSE); 00638 ASSERT_RESOURCE(Resource); 00639 00640 // 00641 // If the active count of the resource is zero, then there is neither 00642 // an exclusive owner nor a shared owner and access to the resource can 00643 // be immediately granted. Otherwise, if the resource is owned exclusive 00644 // and the current thread is the owner, then access to the resource can 00645 // be immediately granted. Otherwise, access cannot be granted. 00646 // 00647 00648 Result = FALSE; 00649 if (Resource->ActiveCount == 0) { 00650 ExpIncrementCounter(ExclusiveAcquire); 00651 Resource->Flag |= ResourceOwnedExclusive; 00652 Resource->OwnerThreads[0].OwnerThread = CurrentThread; 00653 Resource->OwnerThreads[0].OwnerCount = 1; 00654 Resource->ActiveCount = 1; 00655 Result = TRUE; 00656 00657 } else if (IsOwnedExclusive(Resource) && 00658 (Resource->OwnerThreads[0].OwnerThread == CurrentThread)) { 00659 ExpIncrementCounter(ExclusiveAcquire); 00660 Resource->OwnerThreads[0].OwnerCount += 1; 00661 Result = TRUE; 00662 } 00663 00664 ExReleaseFastLock(&Resource->SpinLock, OldIrql); 00665 return Result; 00666 }

NTKERNELAPI VOID ExUnlockHandleTableEntry PHANDLE_TABLE  HandleTable,
PHANDLE_TABLE_ENTRY  HandleTableEntry
 

Definition at line 336 of file ex/handle.c.

References EVENT_INCREMENT, EXHANDLE_TABLE_ENTRY_LOCK_BIT, FALSE, _HANDLE_TABLE::HandleContentionEvent, _KEVENT::Header, KeBugCheckEx(), KePulseEvent(), _HANDLE_TABLE_ENTRY::Object, PAGED_CODE, and _DISPATCHER_HEADER::WaitListHead.

Referenced by ExChangeHandle(), ExCreateHandle(), ExDupHandleTable(), ExEnumHandleTable(), ExSnapShotHandleTables(), NtClose(), NtWaitForMultipleObjects(), ObQueryObjectAuditingByHandle(), ObReferenceObjectByHandle(), PsLookupProcessByProcessId(), PsLookupProcessThreadByCid(), PsLookupThreadByThreadId(), and RtlpAtomMapAtomToHandleEntry().

00343 : 00344 00345 This routine unlocks the specified handle table entry. After the entry is 00346 unlocked the sign bit will be clear. 00347 00348 Arguments: 00349 00350 HandleTable - Supplies the handle table containing the entry being unlocked. 00351 00352 HandleTableEntry - Supplies the handle table entry being unlocked. 00353 00354 Return Value: 00355 00356 None. 00357 00358 --*/ 00359 00360 { 00361 LONG_PTR NewValue; 00362 LONG_PTR CurrentValue; 00363 00364 PAGED_CODE(); 00365 00366 // 00367 // This routine does not need to loop and attempt the unlock opeation more 00368 // than once because by defintion the caller has the entry already locked 00369 // and no one can be changing the value without the lock. 00370 // 00371 // So we'll read in the current value, check that the entry is really 00372 // locked, clear the lock bit and make sure the compare exchange worked. 00373 // 00374 00375 NewValue = CurrentValue = *((volatile LONG_PTR *)&HandleTableEntry->Object); 00376 00377 if (CurrentValue >= 0) { 00378 00379 KeBugCheckEx( BAD_EXHANDLE, __LINE__, (LONG_PTR)HandleTableEntry, NewValue, CurrentValue ); 00380 } 00381 00382 NewValue &= ~EXHANDLE_TABLE_ENTRY_LOCK_BIT; 00383 00384 if ((LONG_PTR)(InterlockedCompareExchangePointer( &HandleTableEntry->Object, 00385 (PVOID)NewValue, 00386 (PVOID)CurrentValue )) != CurrentValue) { 00387 00388 KeBugCheckEx( BAD_EXHANDLE, __LINE__, (LONG_PTR)HandleTableEntry, NewValue, CurrentValue ); 00389 } 00390 00391 // 00392 // Now that we've unlocked the event we'll see if there are any waiters 00393 // for handle table entries in this table. If there are any waiters 00394 // we'll wake them up and let them try for their lock again. 00395 // 00396 // Note that this will wake up all the waiters for all locks in a given 00397 // handle table. Each waiter also has a short time out so the worse 00398 // that can happen is that we might wake someone too early. It can also 00399 // be that no one is waiting for this exact lock, or the one waiting for 00400 // it has already gone off, but these are all benign. 00401 // 00402 // **** Note that we're testing for a non empty event header wait list 00403 // head. This is sort of behind the back and a better design 00404 // would get a macro from ke.h to do the test, but this will 00405 // suffice for now. This is actually an unsafe test in that it 00406 // might return the wrong answer, but even then we are willing to 00407 // live with it because any waiters will wake up in 10ms anyway and 00408 // any extra call to pulse the event without waiters is benign. 00409 // 00410 00411 if (!IsListEmpty( &HandleTable->HandleContentionEvent.Header.WaitListHead )) { 00412 00413 KePulseEvent( &HandleTable->HandleContentionEvent, EVENT_INCREMENT, FALSE ); 00414 } 00415 00416 return; 00417 }

NTKERNELAPI VOID ExUnlockHandleTableExclusive PHANDLE_TABLE  HandleTable  ) 
 

Definition at line 209 of file ex/handle.c.

References ExReleaseResource, _HANDLE_TABLE::HandleTableLock, PAGED_CODE, and VOID().

Referenced by ExCreateHandle(), ExDestroyHandle(), and ExSnapShotHandleTables().

00215 : 00216 00217 This routine unlocks the specified handle table from exclusive access. 00218 00219 Arguments: 00220 00221 HandleTable - Supplies the handle table being unlocked. 00222 00223 Return Value: 00224 00225 None. 00226 00227 --*/ 00228 00229 { 00230 PAGED_CODE(); 00231 00232 (VOID)ExReleaseResource( &HandleTable->HandleTableLock ); 00233 00234 return; 00235 }

NTKERNELAPI VOID ExUnlockHandleTableShared PHANDLE_TABLE  HandleTable  ) 
 

Definition at line 178 of file ex/handle.c.

References ExReleaseResource, _HANDLE_TABLE::HandleTableLock, PAGED_CODE, and VOID().

Referenced by ExDupHandleTable(), and ExEnumHandleTable().

00184 : 00185 00186 This routine unlocks the specified handle table from shared access. 00187 00188 Arguments: 00189 00190 HandleTable - Supplies the handle table being unlocked. 00191 00192 Return Value: 00193 00194 None. 00195 00196 --*/ 00197 00198 { 00199 PAGED_CODE(); 00200 00201 (VOID)ExReleaseResource( &HandleTable->HandleTableLock ); 00202 00203 return; 00204 }

NTKERNELAPI VOID ExUnlockPool IN POOL_TYPE  PoolType,
IN KIRQL  LockHandle
 

Definition at line 565 of file ex/pool.c.

References BASE_POOL_TYPE_MASK, NonPagedPool, NonPagedPoolLock, PagedPool, and PoolVector.

Referenced by MiFindContiguousMemory().

00572 : 00573 00574 This function unlocks the pool specified by pool type. 00575 00576 00577 Arguments: 00578 00579 PoolType - Specifies the pool that should be unlocked. 00580 00581 LockHandle - Specifies the lock handle from a previous call to 00582 ExLockPool. 00583 00584 Return Value: 00585 00586 None. 00587 00588 --*/ 00589 00590 { 00591 00592 // 00593 // If the pool type is nonpaged, then use a spinlock to unlock the 00594 // pool. Otherwise, use a fast mutex to unlock the pool. 00595 // 00596 00597 if ((PoolType & BASE_POOL_TYPE_MASK) == NonPagedPool) { 00598 ExReleaseSpinLock(&NonPagedPoolLock, LockHandle); 00599 00600 } else { 00601 ExReleaseFastMutex((PFAST_MUTEX)PoolVector[PagedPool]->LockAddress); 00602 } 00603 00604 return; 00605 }

NTKERNELAPI VOID ExUnlockUserBuffer IN PVOID  LockVariable  ) 
 

Definition at line 3048 of file sysinfo.c.

References ExFreePool(), and MmUnlockPages().

Referenced by ExLockUserBuffer(), ExpGetHandleInformation(), ExpGetLockInformation(), ExpGetLookasideInformation(), ExpGetObjectInformation(), ExpGetPoolInformation(), and ExpGetProcessInformation().

03052 { 03053 MmUnlockPages ((PMDL)LockVariable); 03054 ExFreePool ((PMDL)LockVariable); 03055 return; 03056 }

NTKERNELAPI VOID ExUnregisterCallback IN PVOID  CallbackRegistration  ) 
 

Definition at line 479 of file ex/callback.c.

References ASSERT, _CALLBACK_REGISTRATION::Busy, _CALLBACK_REGISTRATION::CallbackObject, DISPATCH_LEVEL, Executive, ExFreePool(), ExpCallbackEvent, FALSE, KeAcquireSpinLock, KeClearEvent, KeReleaseSpinLock(), KernelMode, KeWaitForSingleObject(), _CALLBACK_REGISTRATION::Link, _CALLBACK_OBJECT::Lock, NULL, ObDereferenceObject, PCALLBACK_OBJECT, PCALLBACK_REGISTRATION, TRUE, and _CALLBACK_REGISTRATION::UnregisterWaiting.

00485 : 00486 00487 This function removes the callback registration for the callbacks 00488 from the list of callback object . 00489 00490 Arguments: 00491 00492 CallbackRegistration - Pointer to device object for the file system. 00493 00494 Return Value: 00495 00496 None. 00497 00498 --*/ 00499 00500 { 00501 PCALLBACK_REGISTRATION CallbackRegistration; 00502 PCALLBACK_OBJECT CallbackObject; 00503 KIRQL OldIrql; 00504 00505 ASSERT (KeGetCurrentIrql() < DISPATCH_LEVEL); 00506 00507 CallbackRegistration = (PCALLBACK_REGISTRATION) CbRegistration; 00508 CallbackObject = CallbackRegistration->CallbackObject; 00509 00510 KeAcquireSpinLock (&CallbackObject->Lock, &OldIrql); 00511 00512 // 00513 // Wait for registration 00514 // 00515 00516 while (CallbackRegistration->Busy) { 00517 00518 // 00519 // Set waiting flag, then wait. (not performance critical - use 00520 // single global event to wait for any and all unregister waits) 00521 // 00522 00523 CallbackRegistration->UnregisterWaiting = TRUE; 00524 KeClearEvent (&ExpCallbackEvent); 00525 KeReleaseSpinLock (&CallbackObject->Lock, OldIrql); 00526 00527 KeWaitForSingleObject ( 00528 &ExpCallbackEvent, 00529 Executive, 00530 KernelMode, 00531 FALSE, 00532 NULL 00533 ); 00534 00535 // 00536 // Synchronize with callback object and recheck registration busy 00537 // 00538 00539 KeAcquireSpinLock (&CallbackObject->Lock, &OldIrql); 00540 } 00541 00542 // 00543 // Registration not busy, remove it from the callback object 00544 // 00545 00546 RemoveEntryList (&CallbackRegistration->Link); 00547 KeReleaseSpinLock (&CallbackObject->Lock, OldIrql); 00548 00549 // 00550 // Free memory used for CallbackRegistration 00551 // 00552 00553 ExFreePool (CallbackRegistration); 00554 00555 // 00556 // Remove reference count on CallbackObject 00557 // 00558 00559 ObDereferenceObject (CallbackObject); 00560 }

VOID ExUpdateSystemTimeFromCmos IN BOOLEAN  UpdateInterruptTime,
IN ULONG  MaxSepInSeconds
 

Referenced by KdpTimeSlipWork().

NTKERNELAPI NTSTATUS ExUuidCreate OUT UUID Uuid  ) 
 

Definition at line 841 of file uuid.c.

References _UUID_CACHED_VALUES_STRUCT::AllocatedCount, ASSERT, CACHE_LOCAL_ONLY, _UUID_CACHED_VALUES_STRUCT::ClockSeqHiAndReserved, _UUID_GENERATE::ClockSeqHiAndReserved, ExAcquireFastMutexUnsafe(), ExpUuidCachedValues, ExpUuidCacheValid, ExpUuidGetValues(), ExpUuidLock, ExpUuidSaveSequenceNumberIf(), ExReleaseFastMutexUnsafe(), KeEnterCriticalRegion, KeLeaveCriticalRegion, _UUID_CACHED_VALUES_STRUCT::NodeId, _UUID_GENERATE::NodeId, NTSTATUS(), PAGED_CODE, Status, _UUID_CACHED_VALUES_STRUCT::Time, Time, _UUID_GENERATE::TimeHiAndVersion, _UUID_GENERATE::TimeLow, _UUID_GENERATE::TimeMid, USHORT, UUID, UUID_TIME_HIGH_MASK, and UUID_VERSION.

Referenced by CmpCloneHwProfile().

00847 : 00848 00849 This routine creates a DCE UUID and returns it in the caller's 00850 buffer. 00851 00852 Arguments: 00853 00854 Uuid - will receive the UUID. 00855 00856 Return Value: 00857 00858 STATUS_SUCCESS is returned if the service is successfully executed. 00859 00860 STATUS_RETRY is returned if we're unable to reserve a range of 00861 UUIDs. This will occur if system clock hasn't advanced 00862 and the allocator is out of cached values. 00863 00864 --*/ 00865 00866 { 00867 NTSTATUS Status = STATUS_SUCCESS; 00868 00869 UUID_GENERATE *UuidGen = (UUID_GENERATE *) Uuid; 00870 ULONGLONG Time; 00871 LONG Delta; 00872 00873 PAGED_CODE(); 00874 00875 // 00876 // Get a value from the cache. If the cache is empty, we'll fill 00877 // it and retry. The first time cache will be empty. 00878 // 00879 00880 for(;;) { 00881 00882 // Get the highest value in the cache (though it may not 00883 // be available). 00884 Time = ExpUuidCachedValues.Time; 00885 00886 // Copy the static info into the UUID. We can't do this later 00887 // because the clock sequence could be updated by another thread. 00888 00889 *(PULONG)&UuidGen->ClockSeqHiAndReserved = 00890 *(PULONG)&ExpUuidCachedValues.ClockSeqHiAndReserved; 00891 *(PULONG)&UuidGen->NodeId[2] = 00892 *(PULONG)&ExpUuidCachedValues.NodeId[2]; 00893 00894 // See what we need to subtract from Time to get a valid GUID. 00895 Delta = InterlockedDecrement(&ExpUuidCachedValues.AllocatedCount); 00896 00897 if (Time != ExpUuidCachedValues.Time) { 00898 00899 // If our captured time doesn't match the cache then another 00900 // thread already took the lock and updated the cache. We'll 00901 // just loop and try again. 00902 continue; 00903 } 00904 00905 // If the cache hadn't already run dry, we can break out of this retry 00906 // loop. 00907 if (Delta >= 0) { 00908 break; 00909 } 00910 00911 // 00912 // Allocate a new block of Uuids. 00913 // 00914 00915 // Take the cache lock 00916 KeEnterCriticalRegion(); 00917 ExAcquireFastMutexUnsafe(&ExpUuidLock); 00918 00919 // If the cache has already been updated, try again. 00920 if (Time != ExpUuidCachedValues.Time) { 00921 // Release the lock 00922 ExReleaseFastMutexUnsafe(&ExpUuidLock); 00923 KeLeaveCriticalRegion(); 00924 continue; 00925 } 00926 00927 // Update the cache. 00928 Status = ExpUuidGetValues( &ExpUuidCachedValues ); 00929 00930 if (Status != STATUS_SUCCESS) { 00931 // Release the lock 00932 ExReleaseFastMutexUnsafe(&ExpUuidLock); 00933 KeLeaveCriticalRegion(); 00934 return(Status); 00935 } 00936 00937 // The sequence number may have been dirtied, see if it needs 00938 // to be saved. If there's an error, we'll ignore it and 00939 // retry on a future call. 00940 00941 ExpUuidSaveSequenceNumberIf(); 00942 00943 // Release the lock 00944 ExReleaseFastMutexUnsafe(&ExpUuidLock); 00945 KeLeaveCriticalRegion(); 00946 00947 // Loop 00948 } 00949 00950 // Adjust the time to that of the next available UUID. 00951 Time -= Delta; 00952 00953 // Finish filling in the UUID. 00954 00955 UuidGen->TimeLow = (ULONG) Time; 00956 UuidGen->TimeMid = (USHORT) (Time >> 32); 00957 UuidGen->TimeHiAndVersion = (USHORT) 00958 (( (USHORT)(Time >> (32+16)) 00959 & UUID_TIME_HIGH_MASK) | UUID_VERSION); 00960 00961 ASSERT(Status == STATUS_SUCCESS); 00962 00963 if (ExpUuidCacheValid == CACHE_LOCAL_ONLY) { 00964 Status = RPC_NT_UUID_LOCAL_ONLY; 00965 } 00966 00967 return(Status); 00968 } }

NTKERNELAPI BOOLEAN ExVerifySuite SUITE_TYPE  SuiteType  ) 
 

Referenced by IoDeleteSymbolicLink(), MiInitMachineDependent(), MmInitializeProcessAddressSpace(), and MmInitSystem().

VOID InitializePool IN POOL_TYPE  PoolType,
IN ULONG  Threshold
 

DBG

DBG

Definition at line 677 of file ex/pool.c.

References ASSERT, _POOL_LIST_HEAD::CurrentFreeLength, ExAllocatePoolWithTag, ExInitializeFastMutex, ExpInitializePoolDescriptor(), ExpInsertPoolTracker(), ExpNumberOfPagedPools, ExpPagedPoolDescriptor, ExpTaggedPoolLock, FALSE, Index, KeBugCheck(), KeBugCheckEx(), KeInitializeMutex(), KeInitializeSemaphore(), KeInitializeSpinLock(), L, _POOL_DESCRIPTOR::ListHeads, _POOL_DESCRIPTOR::LockAddress, MAX_BIGPAGE_TABLE, MiAllocatePoolPages(), MUST_SUCCEED_POOL_TYPE_MASK, MustSucceedPoolTable, NonPagedPool, NonPagedPoolDescriptor, NonPagedPoolDescriptorMS, NonPagedPoolLock, NonPagedPoolMustSucceed, NtGlobalFlag, NULL, PagedPool, PagedPoolDescriptor, PagedPoolDescriptorMS, PagedPoolLock, POOL_HEADER, POOL_LIST_HEADS, POOL_OVERHEAD, POOL_PAGE_SIZE, POOL_SMALLEST_BLOCK, POOL_TRACKER_BIG_PAGES, POOL_TRACKER_TABLE, POOL_TYPE, PoolBigPageTable, PoolBigPageTableHash, PoolBigPageTableSize, PoolTrackTable, PoolTrackTableMask, PoolTrackTableSize, _POOL_DESCRIPTOR::PoolType, PoolVector, PsGetCurrentProcess, ROUND_TO_PAGES, Size, _POOL_DESCRIPTOR::Threshold, and _POOL_DESCRIPTOR::TotalPages.

Referenced by MiBuildPagedPool(), and MiInitMachineDependent().

00684 : 00685 00686 This procedure initializes a pool descriptor for the specified pool 00687 type. Once initialized, the pool may be used for allocation and 00688 deallocation. 00689 00690 This function should be called once for each base pool type during 00691 system initialization. 00692 00693 Each pool descriptor contains an array of list heads for free 00694 blocks. Each list head holds blocks which are a multiple of 00695 the POOL_BLOCK_SIZE. The first element on the list [0] links 00696 together free entries of size POOL_BLOCK_SIZE, the second element 00697 [1] links together entries of POOL_BLOCK_SIZE * 2, the third 00698 POOL_BLOCK_SIZE * 3, etc, up to the number of blocks which fit 00699 into a page. 00700 00701 Arguments: 00702 00703 PoolType - Supplies the type of pool being initialized (e.g. 00704 nonpaged pool, paged pool...). 00705 00706 Threshold - Supplies the threshold value for the specified pool. 00707 00708 Return Value: 00709 00710 None. 00711 00712 --*/ 00713 00714 { 00715 00716 PPOOL_DESCRIPTOR Descriptor; 00717 ULONG Index; 00718 PFAST_MUTEX FastMutex; 00719 SIZE_T Size; 00720 00721 ASSERT((PoolType & MUST_SUCCEED_POOL_TYPE_MASK) == 0); 00722 00723 if (PoolType == NonPagedPool) { 00724 00725 // 00726 // Initialize nonpaged pools. 00727 // 00728 00729 #if !DBG 00730 if (NtGlobalFlag & FLG_POOL_ENABLE_TAGGING) { 00731 #endif 00732 PoolTrackTableSize = MAX_TRACKER_TABLE; 00733 PoolTrackTableMask = PoolTrackTableSize - 2; 00734 PoolTrackTable = MiAllocatePoolPages(NonPagedPool, 00735 PoolTrackTableSize * 00736 sizeof(POOL_TRACKER_TABLE), 00737 FALSE); 00738 00739 RtlZeroMemory(PoolTrackTable, PoolTrackTableSize * sizeof(POOL_TRACKER_TABLE)); 00740 00741 PoolBigPageTableSize = MAX_BIGPAGE_TABLE; 00742 PoolBigPageTableHash = PoolBigPageTableSize - 1; 00743 PoolBigPageTable = MiAllocatePoolPages(NonPagedPool, 00744 PoolBigPageTableSize * 00745 sizeof(POOL_TRACKER_BIG_PAGES), 00746 FALSE); 00747 00748 RtlZeroMemory(PoolBigPageTable, PoolBigPageTableSize * sizeof(POOL_TRACKER_BIG_PAGES)); 00749 #if !DBG 00750 } 00751 #endif 00752 00753 // 00754 // Initialize the spinlocks for nonpaged pool. 00755 // 00756 00757 KeInitializeSpinLock (&ExpTaggedPoolLock); 00758 KeInitializeSpinLock(&NonPagedPoolLock); 00759 00760 // 00761 // Initialize the nonpaged pool descriptor. 00762 // 00763 00764 PoolVector[NonPagedPool] = &NonPagedPoolDescriptor; 00765 ExpInitializePoolDescriptor(&NonPagedPoolDescriptor, 00766 NonPagedPool, 00767 0, 00768 Threshold, 00769 (PVOID)&NonPagedPoolLock); 00770 00771 // 00772 // Initialize the nonpaged must succeed pool descriptor. 00773 // 00774 00775 PoolVector[NonPagedPoolMustSucceed] = &NonPagedPoolDescriptorMS; 00776 ExpInitializePoolDescriptor(&NonPagedPoolDescriptorMS, 00777 NonPagedPoolMustSucceed, 00778 0, 00779 0, 00780 (PVOID)&NonPagedPoolLock); 00781 00782 } else { 00783 00784 // 00785 // Allocate memory for the paged pool descriptors and fast mutexes. 00786 // 00787 00788 Size = (ExpNumberOfPagedPools + 1) * (sizeof(FAST_MUTEX) + sizeof(POOL_DESCRIPTOR)); 00789 Descriptor = (PPOOL_DESCRIPTOR)ExAllocatePoolWithTag (NonPagedPool, 00790 Size, 00791 'looP'); 00792 if (Descriptor == NULL) { 00793 KeBugCheckEx (MUST_SUCCEED_POOL_EMPTY, 00794 Size, 00795 (ULONG_PTR)-1, 00796 (ULONG_PTR)-1, 00797 (ULONG_PTR)-1); 00798 } 00799 00800 if (PoolTrackTable) { 00801 ExpInsertPoolTracker('looP', 00802 (ULONG) ROUND_TO_PAGES(PoolTrackTableSize * sizeof(POOL_TRACKER_TABLE)), 00803 NonPagedPool); 00804 00805 ExpInsertPoolTracker('looP', 00806 (ULONG) ROUND_TO_PAGES(PoolBigPageTableSize * sizeof(POOL_TRACKER_BIG_PAGES)), 00807 NonPagedPool); 00808 } 00809 00810 FastMutex = (PFAST_MUTEX)(Descriptor + ExpNumberOfPagedPools + 1); 00811 PoolVector[PagedPool] = Descriptor; 00812 ExpPagedPoolDescriptor = Descriptor; 00813 for (Index = 0; Index < (ExpNumberOfPagedPools + 1); Index += 1) { 00814 ExInitializeFastMutex(FastMutex); 00815 ExpInitializePoolDescriptor(Descriptor, 00816 PagedPool, 00817 Index, 00818 Threshold, 00819 (PVOID)FastMutex); 00820 00821 Descriptor += 1; 00822 FastMutex += 1; 00823 } 00824 } 00825 00826 // 00827 // The maximum cache alignment must be less than the size of the 00828 // smallest pool block because the lower bits are being cleared 00829 // in ExFreePool to find the entry's address. 00830 // 00831 00832 #if POOL_CACHE_SUPPORTED 00833 00834 // 00835 // Compute pool cache information. 00836 // 00837 00838 PoolCacheSize = HalGetDmaAlignmentRequirement(); 00839 00840 ASSERT(PoolCacheSize >= POOL_OVERHEAD); 00841 00842 PoolCacheOverhead = PoolCacheSize + PoolCacheSize - (sizeof(POOL_HEADER) + 1); 00843 00844 PoolBuddyMax = 00845 (POOL_PAGE_SIZE - (POOL_OVERHEAD + (3*POOL_SMALLEST_BLOCK) + 2*PoolCacheSize)); 00846 00847 #endif //POOL_CACHE_SUPPORTED 00848 00849 }

NTKERNELAPI VOID NTAPI ProbeForRead IN CONST VOID *  Address,
IN ULONG  Length,
IN ULONG  Alignment
 

Definition at line 148 of file probe.c.

References ASSERT, ExRaiseAccessViolation(), ExRaiseDatatypeMisalignment(), and PAGED_CODE.

00156 : 00157 00158 This function probes a structure for read accessibility and ensures 00159 correct alignment of the structure. If the structure is not accessible 00160 or has incorrect alignment, then an exception is raised. 00161 00162 Arguments: 00163 00164 Address - Supplies a pointer to the structure to be probed. 00165 00166 Length - Supplies the length of the structure. 00167 00168 Alignment - Supplies the required alignment of the structure expressed 00169 as the number of bytes in the primitive datatype (e.g., 1 for char, 00170 2 for short, 4 for long, and 8 for quad). 00171 00172 Return Value: 00173 00174 None. 00175 00176 --*/ 00177 { 00178 PAGED_CODE(); 00179 00180 ASSERT(((Alignment) == 1) || ((Alignment) == 2) || 00181 ((Alignment) == 4) || ((Alignment) == 8) || 00182 ((Alignment) == 16)); 00183 00184 if ((Length) != 0) { 00185 if (((ULONG_PTR)(Address) & ((Alignment) - 1)) != 0) { 00186 ExRaiseDatatypeMisalignment(); 00187 00188 } else if ((((ULONG_PTR)(Address) + (Length)) < (ULONG_PTR)(Address)) || 00189 (((ULONG_PTR)(Address) + (Length)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { 00190 ExRaiseAccessViolation(); 00191 } 00192 } 00193 }

NTKERNELAPI VOID NTAPI ProbeForWrite IN PVOID  Address,
IN ULONG  Length,
IN ULONG  Alignment
 

Definition at line 34 of file probe.c.

References ASSERT, CHAR, ExRaiseAccessViolation(), ExRaiseDatatypeMisalignment(), and PAGE_SIZE.

Referenced by _GetWinStationInfo(), BuildQueryDirectoryIrp(), GetHDevName(), IopXxxControlFile(), KdpTrap(), KeRaiseUserException(), KeUserModeCallback(), KiDispatchException(), KiEmulateByteWord(), KiEmulateReference(), KiInitializeUserApc(), LpcpCopyRequestData(), MESSAGECALL(), MiDoMappedCopy(), MiDoPoolCopy(), MmSecureVirtualMemory(), NtAcceptConnectPort(), NtAdjustGroupsToken(), NtAdjustPrivilegesToken(), NtAllocateLocallyUniqueId(), NtAllocateUserPhysicalPages(), NtAllocateUuids(), NtCreateProfile(), NtCreateThread(), NtEnumerateKey(), NtEnumerateValueKey(), NtExtendSection(), NtGetContextThread(), NtMapViewOfSection(), NtMapViewOfSuperSection(), NtNotifyChangeDirectoryFile(), NtNotifyChangeMultipleKeys(), NtPrivilegeCheck(), NtQueryAttributesFile(), NtQueryDirectoryObject(), NtQueryEaFile(), NtQueryEvent(), NtQueryFullAttributesFile(), NtQueryInformationAtom(), NtQueryInformationFile(), NtQueryInformationJobObject(), NtQueryInformationPort(), NtQueryInformationProcess(), NtQueryInformationThread(), NtQueryInformationToken(), NtQueryIoCompletion(), NtQueryKey(), NtQueryMultipleValueKey(), NtQueryMutant(), NtQueryObject(), NtQueryPerformanceCounter(), NtQueryQuotaInformationFile(), NtQuerySection(), NtQuerySecurityObject(), NtQuerySemaphore(), NtQuerySymbolicLinkObject(), NtQuerySystemEnvironmentValue(), NtQuerySystemInformation(), NtQueryTimer(), NtQueryVirtualMemory(), NtQueryVolumeInformationFile(), NtReadFile(), NtReplyWaitReceivePort(), NtReplyWaitReceivePortEx(), NtReplyWaitReplyPort(), NtRequestWaitReplyPort(), NtSecureConnectPort(), NtSystemDebugControl(), NtUserBuildNameList(), NtUserConsoleControl(), NtUserCreateLocalMemHandle(), NtUserDdeGetQualityOfService(), NtUserDdeSetQualityOfService(), NtUserDrawIconEx(), NtUserGetAltTabInfo(), NtUserGetClassInfo(), NtUserGetClassName(), NtUserGetComboBoxInfo(), NtUserGetCursorInfo(), NtUserGetGUIThreadInfo(), NtUserGetIconInfo(), NtUserGetImeInfoEx(), NtUserGetKeyboardLayoutName(), NtUserGetKeyboardState(), NtUserGetMenuBarInfo(), NtUserGetObjectInformation(), NtUserGetScrollBarInfo(), NtUserGetTitleBarInfo(), NtUserHardErrorControl(), NtUserOpenWindowStation(), NtUserProcessConnect(), NtUserQueryInformationThread(), NtUserQueryUserCounters(), NtUserSetInformationThread(), NtUserSystemParametersInfo(), NtUserWin32PoolAllocationStats(), SeAccessCheckByType(), SepAccessCheckAndAuditAlarm(), VdmDispatchInterrupts(), VdmpInitialize(), VdmpPrinterDirectIoClose(), VdmpPrinterInitialize(), VdmQueryDirectoryFile(), xxxCreateDefaultImeWindow(), and xxxSendMessageEx().

00042 : 00043 00044 This function probes a structure for write accessibility and ensures 00045 correct alignment of the structure. If the structure is not accessible 00046 or has incorrect alignment, then an exception is raised. 00047 00048 Arguments: 00049 00050 Address - Supplies a pointer to the structure to be probed. 00051 00052 Length - Supplies the length of the structure. 00053 00054 Alignment - Supplies the required alignment of the structure expressed 00055 as the number of bytes in the primitive datatype (e.g., 1 for char, 00056 2 for short, 4 for long, and 8 for quad). 00057 00058 Return Value: 00059 00060 None. 00061 00062 --*/ 00063 00064 { 00065 00066 ULONG_PTR EndAddress; 00067 ULONG_PTR StartAddress; 00068 00069 // 00070 // If the structure has zero length, then do not probe the structure for 00071 // write accessibility or alignment. 00072 // 00073 00074 if (Length != 0) { 00075 00076 // 00077 // If the structure is not properly aligned, then raise a data 00078 // misalignment exception. 00079 // 00080 00081 ASSERT((Alignment == 1) || (Alignment == 2) || 00082 (Alignment == 4) || (Alignment == 8) || 00083 (Alignment == 16)); 00084 00085 StartAddress = (ULONG_PTR)Address; 00086 if ((StartAddress & (Alignment - 1)) == 0) { 00087 00088 // 00089 // Compute the ending address of the structure and probe for 00090 // write accessibility. 00091 // 00092 00093 EndAddress = StartAddress + Length - 1; 00094 if ((StartAddress <= EndAddress) && 00095 (EndAddress < MM_USER_PROBE_ADDRESS)) { 00096 00097 // 00098 // N.B. Only the contents of the buffer may be probed. 00099 // Therefore the starting byte is probed for the 00100 // first page, and then the first byte in the page 00101 // for each succeeding page. 00102 // 00103 00104 EndAddress = (EndAddress & ~(PAGE_SIZE - 1)) + PAGE_SIZE; 00105 00106 #if defined(_ALPHA_) 00107 00108 // 00109 // N.B. The address is truncated to a longword aligned 00110 // address since Alpha has no load or store byte 00111 // instructions. 00112 // 00113 00114 StartAddress &= ~((ULONG_PTR)sizeof(LONG) - 1); 00115 00116 do { 00117 *(volatile LONG *)StartAddress = *(volatile LONG *)StartAddress; 00118 StartAddress = (StartAddress & ~(PAGE_SIZE - 1)) + PAGE_SIZE; 00119 } while (StartAddress != EndAddress); 00120 00121 #else 00122 00123 do { 00124 *(volatile CHAR *)StartAddress = *(volatile CHAR *)StartAddress; 00125 00126 StartAddress = (StartAddress & ~(PAGE_SIZE - 1)) + PAGE_SIZE; 00127 } while (StartAddress != EndAddress); 00128 #endif 00129 00130 return; 00131 00132 } else { 00133 ExRaiseAccessViolation(); 00134 } 00135 00136 } else { 00137 ExRaiseDatatypeMisalignment(); 00138 } 00139 } 00140 00141 return; 00142 }


Variable Documentation

ULONG EvPrSetHigh
 

Definition at line 3110 of file ex.h.

Referenced by NtSetHighEventPair(), and NtSetHighWaitLowEventPair().

ULONG EvPrSetLow
 

Definition at line 3111 of file ex.h.

Referenced by NtSetLowEventPair(), and NtSetLowWaitHighEventPair().

PCALLBACK_OBJECT ExCbPowerState
 

Definition at line 3329 of file ex.h.

PCALLBACK_OBJECT ExCbSetSystemState
 

Definition at line 3328 of file ex.h.

PCALLBACK_OBJECT ExCbSetSystemTime
 

Definition at line 3327 of file ex.h.

ULONG ExCriticalWorkerThreads
 

Definition at line 3313 of file ex.h.

Referenced by CcInitializeCacheManager(), and ExpWorkerInitialization().

ULONG ExDelayedWorkerThreads
 

Definition at line 3314 of file ex.h.

Referenced by ExpWorkerInitialization().

PKWIN32_GLOBALATOMTABLE_CALLOUT ExGlobalAtomTableCallout
 

Definition at line 3336 of file ex.h.

Referenced by ExpGetGlobalAtomTable(), and PsEstablishWin32Callouts().

PVOID ExPageLockHandle
 

Definition at line 3321 of file ex.h.

Referenced by ExpGetLockInformation(), ExpGetLookasideInformation(), ExpGetPoolInformation(), ExpGetProcessInformation(), KeSetPhysicalCacheTypeRange(), KiAmdK6MtrrSetMemoryType(), MiEmptyAllWorkingSets(), MiFindContiguousMemory(), MiLoadSystemImage(), MiMapViewInSystemSpace(), MiSetPagingOfDriver(), MiShareSessionImage(), MiUnmapLockedPagesInUserSpace(), MiUnmapViewInSystemSpace(), MmAdjustWorkingSetSize(), MmAllocateNonCachedMemory(), MmAllocatePagesForMdl(), MmFreeDriverInitialization(), MmFreeNonCachedMemory(), MmFreePagesFromMdl(), MmLockPagedPool(), MmMapViewOfSection(), MmResetDriverPaging(), MmShutdownSystem(), MmUnloadSystemImage(), MmUnlockPagedPool(), NtQueryVirtualMemory(), PspQueryPooledQuotaLimits(), PspQueryQuotaLimits(), PspQueryWorkingSetWatch(), and PspSetQuotaLimits().

LONG ExpAltTimeZoneBias
 

Definition at line 3310 of file ex.h.

ULONG ExpCurrentTimeZoneId
 

Definition at line 3311 of file ex.h.

Referenced by NtQuerySystemInformation().

LONG ExpLastTimeZoneBias
 

Definition at line 3309 of file ex.h.

LARGE_INTEGER ExpLuid
 

Definition at line 3019 of file ex.h.

Referenced by ExLuidInitialization().

LARGE_INTEGER ExpLuidIncrement
 

Definition at line 3020 of file ex.h.

Referenced by ExLuidInitialization().

KSPIN_LOCK ExpLuidLock
 

Definition at line 3021 of file ex.h.

ULONG ExpRealTimeIsUniversal
 

Definition at line 3312 of file ex.h.

ULONG ExpTickCountMultiplier
 

Definition at line 3315 of file ex.h.

Referenced by NtGetTickCount().

LARGE_INTEGER ExpTimeZoneBias
 

Definition at line 3308 of file ex.h.

Referenced by NtQuerySystemInformation().

BOOLEAN ExReadyForErrors
 

Definition at line 3087 of file ex.h.

Referenced by CmpClaimGlobalQuota(), CmpDiskFullWarning(), ExpRaiseHardError(), IopHardErrorThread(), IopRaiseHardError(), IopRaiseInformationalHardError(), and NtSetDefaultHardErrorPort().

EX_WORK_QUEUE ExWorkerQueue[]
 

Definition at line 2031 of file ex.h.

Referenced by ExpCheckForWorker(), ExpCreateWorkerThread(), ExpDetectWorkerThreadDeadlock(), ExpNewThreadNecessary(), ExpWorkerInitialization(), ExpWorkerThread(), ExQueueWorkItem(), KeRemoveQueue(), and KeTerminateThread().


Generated on Sat May 15 19:43:34 2004 for test by doxygen 1.3.7