From c394368e889329268c463219dd2cc7d793c7a272 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 21 Jun 2019 10:58:37 +0200 Subject: [PATCH] Declare NDIS 6.70 compliant After confirming with Microsoft Documentation that Wintun is already NDIS 6.70 compliant, we declare it so. Furthermore, determine NDIS version bounds from NDISxxx_MINIPORT automatically. https://docs.microsoft.com/en-us/windows-hardware/drivers/network/introduction-to-ndis-6-40 https://docs.microsoft.com/en-us/windows-hardware/drivers/network/introduction-to-ndis-6-50 https://docs.microsoft.com/en-us/windows-hardware/drivers/network/introduction-to-ndis-6-60 https://docs.microsoft.com/en-us/windows-hardware/drivers/network/introduction-to-ndis-6-70 Signed-off-by: Simon Rozman --- wintun.c | 9 ++++++--- wintun.vcxproj | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/wintun.c b/wintun.c index aba7f2c..6df4a76 100644 --- a/wintun.c +++ b/wintun.c @@ -18,6 +18,9 @@ #pragma warning(disable : 4204) // nonstandard extension used: non-constant aggregate initializer #pragma warning(disable : 4221) // nonstandard extension used: : cannot be initialized using address of automatic variable +#define NDIS_MINIPORT_VERSION_MIN ((NDIS_MINIPORT_MINIMUM_MAJOR_VERSION << 16) | NDIS_MINIPORT_MINIMUM_MINOR_VERSION) +#define NDIS_MINIPORT_VERSION_MAX ((NDIS_MINIPORT_MAJOR_VERSION << 16) | NDIS_MINIPORT_MINOR_VERSION ) + #define TUN_DEVICE_NAME L"WINTUN%u" #define TUN_VENDOR_NAME "Wintun Tunnel" @@ -1536,10 +1539,10 @@ NTSTATUS DriverEntry(DRIVER_OBJECT *DriverObject, UNICODE_STRING *RegistryPath) NTSTATUS status; NdisVersion = NdisGetVersion(); - if (NdisVersion < NDIS_RUNTIME_VERSION_620) + if (NdisVersion < NDIS_MINIPORT_VERSION_MIN) return NDIS_STATUS_UNSUPPORTED_REVISION; - if (NdisVersion > NDIS_RUNTIME_VERSION_630) - NdisVersion = NDIS_RUNTIME_VERSION_630; + if (NdisVersion > NDIS_MINIPORT_VERSION_MAX) + NdisVersion = NDIS_MINIPORT_VERSION_MAX; NDIS_MINIPORT_DRIVER_CHARACTERISTICS miniport = { .Header = { diff --git a/wintun.vcxproj b/wintun.vcxproj index ad386d5..be3d03f 100644 --- a/wintun.vcxproj +++ b/wintun.vcxproj @@ -124,12 +124,12 @@ - WINTUN_VERSION_MAJ=$(WintunVersionMaj);WINTUN_VERSION_MIN=$(WintunVersionMin);WINTUN_VERSION_STR="$(WintunVersionStr)";NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS630_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions) + WINTUN_VERSION_MAJ=$(WintunVersionMaj);WINTUN_VERSION_MIN=$(WintunVersionMin);WINTUN_VERSION_STR="$(WintunVersionStr)";NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS670_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions) Level4 true - WINTUN_VERSION_MAJ=$(WintunVersionMaj);WINTUN_VERSION_MIN=$(WintunVersionMin);WINTUN_VERSION_STR="$(WintunVersionStr)";NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS630_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions) + WINTUN_VERSION_MAJ=$(WintunVersionMaj);WINTUN_VERSION_MIN=$(WintunVersionMin);WINTUN_VERSION_STR="$(WintunVersionStr)";NDIS_MINIPORT_DRIVER=1;NDIS620_MINIPORT=1;NDIS670_MINIPORT=1;NDIS_WDM=1;%(PreprocessorDefinitions) ndis.lib;wdmsec.lib;%(AdditionalDependencies)