diff options
author | Simon Rozman <simon@rozman.si> | 2019-04-03 03:01:28 +0200 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-04-03 03:37:24 +0200 |
commit | 58900a48418f73ff26b996ae12fdb9f9072095c1 (patch) | |
tree | da675be84350e4f0c0ba9e213720edbba50edaaf | |
parent | Change TunOidSet/TunOidQuery() parameters (diff) | |
download | wintun-58900a48418f73ff26b996ae12fdb9f9072095c1.tar.xz wintun-58900a48418f73ff26b996ae12fdb9f9072095c1.zip |
Implement dynamic NDIS 6.30 detection
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | wintun.c | 16 | ||||
-rw-r--r-- | wintun.vcxproj | 8 |
2 files changed, 15 insertions, 9 deletions
@@ -3,9 +3,8 @@ * Copyright (C) 2018-2019 WireGuard LLC. All Rights Reserved. */ -#define NDIS_MINIPORT_DRIVER -#define NDIS620_MINIPORT -#define NDIS_SUPPORT_NDIS620 1 +#define NDIS_MINIPORT_DRIVER 1 +#define NDIS630_MINIPORT 1 #define NDIS_WDM 1 #include <stdio.h> @@ -85,6 +84,7 @@ typedef struct _TUN_CTX { NDIS_HANDLE NBLPool; } TUN_CTX; +static UINT NdisVersion; static NDIS_HANDLE NdisMiniportDriverHandle = NULL; #if REG_DWORD == REG_DWORD_BIG_ENDIAN @@ -988,8 +988,8 @@ static NDIS_STATUS TunInitializeEx(NDIS_HANDLE MiniportAdapterHandle, NDIS_HANDL NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES attr = { .Header = { .Type = NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES, - .Revision = NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1, - .Size = NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1 + .Revision = NdisVersion < NDIS_RUNTIME_VERSION_630 ? NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1 : NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2, + .Size = NdisVersion < NDIS_RUNTIME_VERSION_630 ? NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_1 : NDIS_SIZEOF_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2 }, .AttributeFlags = NDIS_MINIPORT_ATTRIBUTES_NO_HALT_ON_SUSPEND, .InterfaceType = NdisInterfaceInternal, @@ -1392,6 +1392,12 @@ DRIVER_INITIALIZE DriverEntry; _Use_decl_annotations_ NTSTATUS DriverEntry(DRIVER_OBJECT *DriverObject, UNICODE_STRING *RegistryPath) { + NdisVersion = NdisGetVersion(); + if (NdisVersion < NDIS_RUNTIME_VERSION_620) + return NDIS_STATUS_UNSUPPORTED_REVISION; + if (NdisVersion > NDIS_RUNTIME_VERSION_630) + NdisVersion = NDIS_RUNTIME_VERSION_630; + NDIS_MINIPORT_DRIVER_CHARACTERISTICS miniport = { .Header = { .Type = NDIS_OBJECT_TYPE_MINIPORT_DRIVER_CHARACTERISTICS, diff --git a/wintun.vcxproj b/wintun.vcxproj index 1ed55a4..aad6164 100644 --- a/wintun.vcxproj +++ b/wintun.vcxproj @@ -26,7 +26,7 @@ </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <TargetVersion>Windows7</TargetVersion> + <TargetVersion>Windows8</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -34,7 +34,7 @@ <SpectreMitigation>false</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <TargetVersion>Windows7</TargetVersion> + <TargetVersion>Windows8</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -42,7 +42,7 @@ <SpectreMitigation>false</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <TargetVersion>Windows7</TargetVersion> + <TargetVersion>Windows8</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -50,7 +50,7 @@ <SpectreMitigation>false</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <TargetVersion>Windows7</TargetVersion> + <TargetVersion>Windows8</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> |