From 3e29cb6342f0e54daed31754060e7edb5f1d1b74 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 5 Oct 2022 07:05:06 -0700 Subject: [PATCH] Fix windows 7 support --- pm_kext/pm_kext.vcxproj | 6 ++++-- pm_kext/src/pm_callouts.c | 1 + pm_kext/src/pm_utils.c | 10 ++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pm_kext/pm_kext.vcxproj b/pm_kext/pm_kext.vcxproj index 3fbde71..87e9e12 100644 --- a/pm_kext/pm_kext.vcxproj +++ b/pm_kext/pm_kext.vcxproj @@ -36,9 +36,10 @@ WindowsKernelModeDriver10.0 Driver KMDF - Universal + Desktop false 1 + <_NT_TARGET_VERSION>0x0601 Windows10 @@ -46,9 +47,10 @@ WindowsKernelModeDriver10.0 Driver KMDF - Universal + Desktop false 0 + <_NT_TARGET_VERSION>0x0601 Windows10 diff --git a/pm_kext/src/pm_callouts.c b/pm_kext/src/pm_callouts.c index 438d582..6f0c8be 100644 --- a/pm_kext/src/pm_callouts.c +++ b/pm_kext/src/pm_callouts.c @@ -962,6 +962,7 @@ void classifyOutboundIPv6( // Used for freeing the packet info memory when clearing the packet cache static void freePacketInfo(PortmasterPacketInfo *info, verdict_t verdict) { + UNREFERENCED_PARAMETER(verdict); if(info != NULL) { portmasterFree(info); } diff --git a/pm_kext/src/pm_utils.c b/pm_kext/src/pm_utils.c index aa2b5d3..ac4aa82 100644 --- a/pm_kext/src/pm_utils.c +++ b/pm_kext/src/pm_utils.c @@ -16,11 +16,17 @@ */ void *portmasterMalloc(size_t size, bool paged) { - POOL_TYPE poolFlag = (paged ? POOL_FLAG_PAGED : POOL_FLAG_NON_PAGED); + POOL_TYPE poolFlag = (paged ? PagedPool : NonPagedPool); if (size == 0) { return NULL; } - void *pv = ExAllocatePool2(poolFlag, size, PORTMASTER_TAG); // Memory is zero initialized unless POOL_FLAG_UNINITIALIZED is specified. + // ExAllocatePoolWithTag is depercated but there is no working (tests) alternative for it in the old Windows versions + // ExAllocatePoolZero -> complies but crashes the kernel + // ExAllocatePool2 -> avaliable with Windows 10, version 2004 and after (release around 2020) + void *pv = ExAllocatePoolWithTag(poolFlag, size, PORTMASTER_TAG); + if (pv != 0) { + RtlZeroMemory(pv, size); + } return pv; }