Driver: Prepare Windows 7 & 10 separating.

ExFreePoolWithTag() is deprecated since Windows 10 v2004.
This commit is contained in:
Nodir Temirkhodjaev 2021-09-01 12:59:11 +03:00
parent 27d55effba
commit a20b96f26c
5 changed files with 29 additions and 9 deletions

View File

@ -15,9 +15,10 @@ Fort is a simple firewall for Windows 7+.
## Supported OS versions ## Supported OS versions
OS | Version | Architectures Asset | OS | Version | Architectures
----------------|-------------------------------|-------------- -------------------------|----------|------------------|--------------
Windows | 7 SP1+, 8.1, 10 | x86, x64 \*-windows.\* | Windows | 7 SP1+, 8.1, 10 | x86, x64
\*-windows10-x86_64.\* | Windows | 10 v2004+ | x64
----- -----

View File

@ -5,14 +5,19 @@
/* WDM for Development in User Mode */ /* WDM for Development in User Mode */
#if !defined(FORT_DRIVER) #if !defined(FORT_DRIVER)
# include "wdm/um_wdm.h"
# include "wdm/um_ndis.h"
# include "wdm/um_fwpsk.h"
# include "wdm/um_fwpmk.h" # include "wdm/um_fwpmk.h"
# include "wdm/um_fwpsk.h"
# include "wdm/um_ndis.h"
# include "wdm/um_wdm.h"
#endif #endif
#define fort_mem_alloc(size, tag) ExAllocatePoolWithTag(NonPagedPool, (size), (tag)) #if defined(FORT_WIN7_COMPAT)
#define fort_mem_free(p, tag) ExFreePoolWithTag((p), (tag)) # define fort_mem_alloc(size, tag) ExAllocatePoolWithTag(NonPagedPool, (size), (tag))
#else
# define fort_mem_alloc(size, tag) \
ExAllocatePool2(POOL_FLAG_UNINITIALIZED | POOL_FLAG_NON_PAGED, (size), (tag))
#endif
#define fort_mem_free(p, tag) ExFreePoolWithTag((p), (tag))
#define fort_request_complete_info(irp, status, info) \ #define fort_request_complete_info(irp, status, info) \
do { \ do { \

View File

@ -27,7 +27,8 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration-Common"> <PropertyGroup Label="Configuration-Common">
<TargetVersion>WindowsV6.3</TargetVersion> <TargetVersion Condition="'$(Config)'=='win7'">WindowsV6.3</TargetVersion>
<TargetVersion Condition="'$(Config)'!='win7'">Windows10</TargetVersion>
<KernelBufferOverflowLib Condition="'$(Config)'=='win7'">$(DDK_LIB_PATH)\BufferOverflowK.lib</KernelBufferOverflowLib> <KernelBufferOverflowLib Condition="'$(Config)'=='win7'">$(DDK_LIB_PATH)\BufferOverflowK.lib</KernelBufferOverflowLib>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType> <ConfigurationType>Driver</ConfigurationType>

View File

@ -21,6 +21,13 @@ void ExFreePoolWithTag(PVOID p, ULONG tag)
HeapFree(GetProcessHeap(), 0, p); HeapFree(GetProcessHeap(), 0, p);
} }
PVOID ExAllocatePool2(POOL_FLAGS flags, SIZE_T size, ULONG tag)
{
UNUSED(flags);
UNUSED(tag);
return HeapAlloc(GetProcessHeap(), 0, size);
}
PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP irp) PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP irp)
{ {
UNUSED(irp); UNUSED(irp);

View File

@ -176,6 +176,12 @@ FORT_API ULONG DbgPrintEx(ULONG componentId, ULONG level, PCSTR format, ...);
FORT_API PVOID ExAllocatePoolWithTag(PVOID type, SIZE_T size, ULONG tag); FORT_API PVOID ExAllocatePoolWithTag(PVOID type, SIZE_T size, ULONG tag);
FORT_API void ExFreePoolWithTag(PVOID p, ULONG tag); FORT_API void ExFreePoolWithTag(PVOID p, ULONG tag);
typedef ULONG64 POOL_FLAGS;
#define POOL_FLAG_UNINITIALIZED 0x0000000000000002UI64 // Don't zero-initialize allocation
#define POOL_FLAG_NON_PAGED 0x0000000000000040UI64 // Non paged pool NX
#define POOL_FLAG_PAGED 0x0000000000000100UI64 // Paged pool
FORT_API PVOID ExAllocatePool2(POOL_FLAGS flags, SIZE_T size, ULONG tag);
FORT_API PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP irp); FORT_API PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP irp);
FORT_API void IoMarkIrpPending(PIRP irp); FORT_API void IoMarkIrpPending(PIRP irp);
FORT_API PDRIVER_CANCEL IoSetCancelRoutine(PIRP irp, PDRIVER_CANCEL routine); FORT_API PDRIVER_CANCEL IoSetCancelRoutine(PIRP irp, PDRIVER_CANCEL routine);