Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions video/KMDOD/bdd.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,12 @@ IsEdidChecksumValid(_In_reads_bytes_(EDID_V1_BLOCK_SIZE) const BYTE* pEdid);
// Memory handling
//

// Defaulting the value of PoolType means that any call to new Foo()
// Defaulting the value of Flags means that any call to new Foo()
// will raise a compiler error for being ambiguous. This is to help keep
// any calls to allocate memory from accidentally NOT going through
// these functions.
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
void* __cdecl operator new(size_t Size, POOL_TYPE PoolType = PagedPool);
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType = PagedPool);
void* __cdecl operator new(size_t Size, POOL_FLAGS Flags = POOL_FLAG_PAGED);
void* __cdecl operator new[](size_t Size, POOL_FLAGS Flags = POOL_FLAG_PAGED);
void __cdecl operator delete(void* pObject);
void __cdecl operator delete(void* pObject, size_t s);
void __cdecl operator delete[](void* pObject);
Expand Down
2 changes: 1 addition & 1 deletion video/KMDOD/bdd_ddi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ BddDdiAddDevice(
}
*ppDeviceContext = NULL;

BASIC_DISPLAY_DRIVER* pBDD = new(NonPagedPoolNx) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
BASIC_DISPLAY_DRIVER* pBDD = new(POOL_FLAG_NON_PAGED) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
if (pBDD == NULL)
{
BDD_LOG_LOW_RESOURCE0("pBDD failed to be allocated");
Expand Down
2 changes: 1 addition & 1 deletion video/KMDOD/blthw.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ BDD_HWBLT::ExecutePresentDisplayOnly(
SIZE_T size = sizeof(DoPresentMemory) + sizeMoves + sizeRects;

DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>
(new (PagedPool) BYTE[size]);
(new (POOL_FLAG_PAGED) BYTE[size]);

if (!ctx)
{
Expand Down
14 changes: 4 additions & 10 deletions video/KMDOD/memory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
//
// New and delete operators
//
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
void* __cdecl operator new(size_t Size, POOL_TYPE PoolType)
void* __cdecl operator new(size_t Size, POOL_FLAGS Flags)
{
PAGED_CODE();

Expand All @@ -26,7 +23,7 @@ void* __cdecl operator new(size_t Size, POOL_TYPE PoolType)
// Note that ExAllocatePool2 replaces ExAllocatePool* APIs in OS's starting
// with Windows 10, version 2004. If your driver targets previous versions it
// should use ExAllocatePoolZero instead.
void* pObject = ExAllocatePool2(PoolType, Size, BDDTAG);
void* pObject = ExAllocatePool2(Flags, Size, BDDTAG);

#if DBG
if (pObject != NULL)
Expand All @@ -38,16 +35,13 @@ void* __cdecl operator new(size_t Size, POOL_TYPE PoolType)
return pObject;
}

_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType)
void* __cdecl operator new[](size_t Size, POOL_FLAGS Flags)
{
PAGED_CODE();

Size = (Size != 0) ? Size : 1;

void* pObject = ExAllocatePool2(PoolType, Size, BDDTAG);
void* pObject = ExAllocatePool2(Flags, Size, BDDTAG);

#if DBG
if (pObject != NULL)
Expand Down
Loading