Implement dynamic NDIS 6.30 detection
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
934923bbc1
commit
58900a4841
16
wintun.c
16
wintun.c
@ -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,
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user