36#if defined(EVENT_TRACING)
145 "Invalid Allocation Size of 0 requested");
150 if (FxDriverGlobals->IsPoolTrackingOn()) {
152 if (FxDriverGlobals->FxVerifierOn &&
153 (FxDriverGlobals->WdfVerifierAllocateFailCount != -1L)) {
162 if (FxDriverGlobals->WdfVerifierAllocateFailCount == 0) {
164 "Allocation Fail Count exceeded");
217 "overflow: allocation tracker (%d) + header (%d) + pool "
218 "request (%I64d)",
sizeof(FX_POOL_TRACKER),
230 if (pTrueBase ==
NULL) {
236 sizeof(FX_POOL_TRACKER),
239 pHeader->FxDriverGlobals = FxDriverGlobals;
306 "overflow: header + pool request (%I64d)",
Size);
316 allocationSize =
Size;
337 if (pTrueBase !=
NULL) {
341 pHeader->FxDriverGlobals = FxDriverGlobals;
431 if (
pHeader->FxDriverGlobals->IsPoolTrackingOn()) {
452 RtlZeroMemory(pTracker, pTracker->Size +
sizeof(FX_POOL_TRACKER));
490 "NonPagedBytes %I64d, PagedBytes %I64d, "
491 "NonPagedAllocations %d, PagedAllocations %d,"
492 "PeakNonPagedBytes %I64d, PeakPagedBytes %I64d,"
493 "FxPoolDump: PeakNonPagedAllocations %d, PeakPagedAllocations %d",
494 Pool->NonPagedBytes,
Pool->PagedBytes,
495 Pool->NonPagedAllocations,
Pool->PagedAllocations,
496 Pool->PeakNonPagedBytes,
Pool->PeakPagedBytes,
497 Pool->PeakNonPagedAllocations,
Pool->PeakPagedAllocations
505 Pool->PagedLock.Acquire();
515 "FX_POOL 0x%p leaked paged memory alloc 0x%p (tracking block %p)",
516 Pool, pTracker + 1, pTracker);
519 Pool->PagedLock.Release();
525 Pool->NonPagedLock.Acquire(&oldIrql);
527 for (
ple =
Pool->NonPagedHead.Flink;
537 "FX_POOL 0x%p leaked non-paged memory alloc 0x%p (tracking block %p)",
538 Pool, pTracker+1, pTracker);
541 Pool->NonPagedLock.Release(oldIrql);
574 "Initializing Pool 0x%p, Tracking %d",
575 Pool, FxDriverGlobals->IsPoolTrackingOn());
577 Pool->NonPagedLock.Initialize();
584 "Initializing paged lock failed for Pool 0x%p, "
593 Pool->NonPagedBytes = 0;
594 Pool->PagedBytes = 0;
596 Pool->NonPagedAllocations = 0;
597 Pool->PagedAllocations = 0;
599 Pool->PeakNonPagedBytes = 0;
600 Pool->PeakPagedBytes = 0;
602 Pool->PeakNonPagedAllocations = 0;
603 Pool->PeakPagedAllocations = 0;
613 FxDriverGlobals->FxPoolTrackingOn =
FALSE;
645 "Destroying Pool 0x%p",
Pool);
647 if (FxDriverGlobals->IsPoolTrackingOn()) {
650#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
659 Pool->PagedLock.Uninitialize();
660 Pool->NonPagedLock.Uninitialize();
685 return FxPoolInitialize(FxDriverGlobals, &FxDriverGlobals->FxPoolFrameworks);
707 FxPoolDestroy(FxDriverGlobals, &FxDriverGlobals->FxPoolFrameworks);
#define InterlockedDecrement
static __inline VOID MxFreePool(__in PVOID Ptr)
static __inline PVOID MxAllocatePoolWithTag(__in POOL_TYPE PoolType, __in SIZE_T NumberOfBytes, __in ULONG Tag)
static __inline BOOLEAN IsKM()
static __inline BOOLEAN IsUM()
static DECLSPEC_NORETURN VOID MxBugCheckEx(__in ULONG BugCheckCode, __in ULONG_PTR BugCheckParameter1, __in ULONG_PTR BugCheckParameter2, __in ULONG_PTR BugCheckParameter3, __in ULONG_PTR BugCheckParameter4)
#define NT_SUCCESS(StatCode)
#define InitializeListHead(ListHead)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
VOID FxMdlDump(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
#define FX_POOL_HEADER_SIZE
FX_POOL_TRACKER * PFX_POOL_TRACKER
FX_POOL_HEADER * PFX_POOL_HEADER
VOID __inline FxPoolRemoveNonPagedAllocateTracker(__in PFX_POOL_TRACKER Tracker)
VOID __inline FxPoolInsertNonPagedAllocateTracker(__in PFX_POOL Pool, __in PFX_POOL_TRACKER Tracker, __in SIZE_T Size, __in ULONG Tag, __in PVOID Caller)
VOID __inline FxPoolRemovePagedAllocateTracker(__in PFX_POOL_TRACKER Tracker)
VOID __inline FxPoolInsertPagedAllocateTracker(__in PFX_POOL Pool, __in PFX_POOL_TRACKER Tracker, __in SIZE_T Size, __in ULONG Tag, __in PVOID Caller)
FxContextHeader * pHeader
#define _Must_inspect_result_
#define ASSERTMSG(msg, exp)
#define MEMORY_ALLOCATION_ALIGNMENT
#define __in_xcount(size)
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_MORE_ENTRIES
static int Link(const char **args)
@ WDF_REQUIRED_PARAMETER_IS_NULL
#define WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, _type)
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
NTSTATUS FxPoolDump(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
BOOLEAN FxIsPagedPoolType(__in POOL_TYPE Type)
VOID FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
_Must_inspect_result_ NTSTATUS FxPoolPackageInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
VOID FxPoolDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
_Must_inspect_result_ NTSTATUS FxPoolInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
VOID FxPoolPackageDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
PVOID FxPoolAllocator(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool, __in POOL_TYPE Type, __in SIZE_T Size, __in ULONG Tag, __in PVOID Caller)
#define POOL_COLD_ALLOCATION