api: cleanup driver selection logic

With all the platforms (including ARM) having at least one driver now,
the dead-code removal #ifdef-s are no longer required.

Suggested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-10-30 08:17:33 +01:00
parent 77459a130a
commit 4b0470210d
2 changed files with 5 additions and 21 deletions

View File

@ -776,8 +776,6 @@ WintunGetAdapterDeviceObject(_In_ const WINTUN_ADAPTER *Adapter, _Out_ HANDLE *H
return GetDeviceObject(Adapter->DevInstanceID, Handle); return GetDeviceObject(Adapter->DevInstanceID, Handle);
} }
#if defined(HAVE_EV) || defined(HAVE_WHQL)
/* We can't use RtlGetVersion, because appcompat's aclayers.dll shims it to report Vista /* We can't use RtlGetVersion, because appcompat's aclayers.dll shims it to report Vista
* when run from legacy contexts. So, we instead use the undocumented RtlGetNtVersionNumbers. * when run from legacy contexts. So, we instead use the undocumented RtlGetNtVersionNumbers.
* *
@ -792,15 +790,15 @@ RtlGetNtVersionNumbers(_Out_opt_ DWORD *MajorVersion, _Out_opt_ DWORD *MinorVers
static BOOL static BOOL
HaveWHQL(void) HaveWHQL(void)
{ {
# if defined(HAVE_EV) && defined(HAVE_WHQL) #if defined(HAVE_EV) && defined(HAVE_WHQL)
DWORD MajorVersion; DWORD MajorVersion;
RtlGetNtVersionNumbers(&MajorVersion, NULL, NULL); RtlGetNtVersionNumbers(&MajorVersion, NULL, NULL);
return MajorVersion >= 10; return MajorVersion >= 10;
# elif defined(HAVE_EV) #elif defined(HAVE_WHQL)
return FALSE;
# elif defined(HAVE_WHQL)
return TRUE; return TRUE;
# endif #else
return FALSE;
#endif
} }
static WINTUN_STATUS static WINTUN_STATUS
@ -871,10 +869,6 @@ cleanupQueriedStore:
return Result; return Result;
} }
#endif
#if defined(HAVE_EV) || defined(HAVE_WHQL)
static BOOL static BOOL
IsNewer(_In_ const SP_DRVINFO_DATA_W *DrvInfoData, _In_ const FILETIME *DriverDate, _In_ DWORDLONG DriverVersion) IsNewer(_In_ const SP_DRVINFO_DATA_W *DrvInfoData, _In_ const FILETIME *DriverDate, _In_ DWORDLONG DriverVersion)
{ {
@ -1238,8 +1232,6 @@ cleanupMutex:
return Result; return Result;
} }
#endif
static WINTUN_STATUS static WINTUN_STATUS
CreateTemporaryDirectory(_Out_cap_c_(MAX_PATH) WCHAR *RandomTempSubDirectory) CreateTemporaryDirectory(_Out_cap_c_(MAX_PATH) WCHAR *RandomTempSubDirectory)
{ {
@ -1559,7 +1551,6 @@ WintunCreateAdapter(
return CreateAdapterNatively(Pool, Name, RequestedGUID, Adapter, RebootRequired); return CreateAdapterNatively(Pool, Name, RequestedGUID, Adapter, RebootRequired);
#endif #endif
#if defined(HAVE_EV) || defined(HAVE_WHQL)
DWORD Result = ERROR_SUCCESS; DWORD Result = ERROR_SUCCESS;
WCHAR RandomTempSubDirectory[MAX_PATH]; WCHAR RandomTempSubDirectory[MAX_PATH];
if ((Result = CreateTemporaryDirectory(RandomTempSubDirectory)) != ERROR_SUCCESS) if ((Result = CreateTemporaryDirectory(RandomTempSubDirectory)) != ERROR_SUCCESS)
@ -1605,9 +1596,6 @@ cleanupDelete:
cleanupDirectory: cleanupDirectory:
RemoveDirectoryW(RandomTempSubDirectory); RemoveDirectoryW(RandomTempSubDirectory);
return Result; return Result;
#else
return ERROR_NOT_SUPPORTED;
#endif
} }
#if defined(_M_IX86) || defined(_M_ARM) #if defined(_M_IX86) || defined(_M_ARM)

View File

@ -24,8 +24,6 @@ DriverIsOurDrvInfoDetail(_In_ const SP_DRVINFO_DETAIL_DATA_W *DrvInfoDetailData)
DriverIsOurHardwareID(DrvInfoDetailData->HardwareID + DrvInfoDetailData->CompatIDsOffset); DriverIsOurHardwareID(DrvInfoDetailData->HardwareID + DrvInfoDetailData->CompatIDsOffset);
} }
#if defined(HAVE_EV) || defined(HAVE_WHQL)
WINTUN_STATUS WINTUN_STATUS
DriverRemoveAllOurs(void) DriverRemoveAllOurs(void)
{ {
@ -72,5 +70,3 @@ cleanupDeviceInfoSet:
SetupDiDestroyDeviceInfoList(DevInfo); SetupDiDestroyDeviceInfoList(DevInfo);
return Result; return Result;
} }
#endif