summaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorDavid Spruill <[email protected]>2026-07-20 18:02:42 -0400
committerGitHub <[email protected]>2026-07-20 18:02:42 -0400
commit511c6abeb6fa009a3f9c39cd099d512e2915ca42 (patch)
tree7d8b5a04e58d567fb0d3a28f320e305391f9628a /video
parent15640356a5a6eeafefff403f6d287821213635cd (diff)
parent47e616d951b7a5aa379d7727d394d9ddc08ebd3b (diff)
Merge pull request #1343 from Spruill-1/user/daspr/kmodsamplefixdevelop
Correct the buggy KMOD sample
Diffstat (limited to 'video')
-rw-r--r--video/KMDOD/bdd.hxx18
-rw-r--r--video/KMDOD/bdd_ddi.cxx2
-rw-r--r--video/KMDOD/blthw.cxx2
-rw-r--r--video/KMDOD/memory.cxx34
4 files changed, 36 insertions, 20 deletions
diff --git a/video/KMDOD/bdd.hxx b/video/KMDOD/bdd.hxx
index 61c40e03..8fd3cdbb 100644
--- a/video/KMDOD/bdd.hxx
+++ b/video/KMDOD/bdd.hxx
@@ -626,18 +626,20 @@ IsEdidChecksumValid(_In_reads_bytes_(EDID_V1_BLOCK_SIZE) const BYTE* pEdid);
// Memory handling
//
+enum class BDD_POOL_TYPE
+{
+ Paged,
+ NonPaged
+};
+
// Defaulting the value of PoolType 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, BDD_POOL_TYPE PoolType = BDD_POOL_TYPE::Paged);
+void* __cdecl operator new[](size_t Size, BDD_POOL_TYPE PoolType = BDD_POOL_TYPE::Paged);
+void __cdecl operator delete(void* pObject, BDD_POOL_TYPE PoolType);
+void __cdecl operator delete[](void* pObject, BDD_POOL_TYPE PoolType);
void __cdecl operator delete(void* pObject);
void __cdecl operator delete(void* pObject, size_t s);
void __cdecl operator delete[](void* pObject);
diff --git a/video/KMDOD/bdd_ddi.cxx b/video/KMDOD/bdd_ddi.cxx
index 5a53a3be..f5f51cf8 100644
--- a/video/KMDOD/bdd_ddi.cxx
+++ b/video/KMDOD/bdd_ddi.cxx
@@ -103,7 +103,7 @@ BddDdiAddDevice(
}
*ppDeviceContext = NULL;
- BASIC_DISPLAY_DRIVER* pBDD = new(NonPagedPoolNx) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
+ BASIC_DISPLAY_DRIVER* pBDD = new(BDD_POOL_TYPE::NonPaged) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
if (pBDD == NULL)
{
BDD_LOG_LOW_RESOURCE0("pBDD failed to be allocated");
diff --git a/video/KMDOD/blthw.cxx b/video/KMDOD/blthw.cxx
index 2e6d2e5d..f9e8a51b 100644
--- a/video/KMDOD/blthw.cxx
+++ b/video/KMDOD/blthw.cxx
@@ -282,7 +282,7 @@ BDD_HWBLT::ExecutePresentDisplayOnly(
SIZE_T size = sizeof(DoPresentMemory) + sizeMoves + sizeRects;
DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>
- (new (PagedPool) BYTE[size]);
+ (new (BDD_POOL_TYPE::Paged) BYTE[size]);
if (!ctx)
{
diff --git a/video/KMDOD/memory.cxx b/video/KMDOD/memory.cxx
index 5b68c297..54f6a6dc 100644
--- a/video/KMDOD/memory.cxx
+++ b/video/KMDOD/memory.cxx
@@ -14,19 +14,17 @@
//
// 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, BDD_POOL_TYPE PoolType)
{
PAGED_CODE();
Size = (Size != 0) ? Size : 1;
+ POOL_FLAGS Flags = PoolType == BDD_POOL_TYPE::NonPaged ? POOL_FLAG_NON_PAGED : POOL_FLAG_PAGED;
// 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)
@@ -38,16 +36,14 @@ 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, BDD_POOL_TYPE PoolType)
{
PAGED_CODE();
Size = (Size != 0) ? Size : 1;
+ POOL_FLAGS Flags = PoolType == BDD_POOL_TYPE::NonPaged ? POOL_FLAG_NON_PAGED : POOL_FLAG_PAGED;
- void* pObject = ExAllocatePool2(PoolType, Size, BDDTAG);
+ void* pObject = ExAllocatePool2(Flags, Size, BDDTAG);
#if DBG
if (pObject != NULL)
@@ -59,6 +55,24 @@ void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType)
return pObject;
}
+void __cdecl operator delete(void* pObject, BDD_POOL_TYPE PoolType)
+{
+ PAGED_CODE();
+
+ UNREFERENCED_PARAMETER(PoolType);
+
+ ::operator delete(pObject);
+}
+
+void __cdecl operator delete[](void* pObject, BDD_POOL_TYPE PoolType)
+{
+ PAGED_CODE();
+
+ UNREFERENCED_PARAMETER(PoolType);
+
+ ::operator delete[](pObject);
+}
+
void __cdecl operator delete(void* pObject)
{
PAGED_CODE();