From 4b0470210dde22e951f33452134d4b902cf52fa2 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 30 Oct 2020 08:17:33 +0100 Subject: [PATCH] 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 Signed-off-by: Simon Rozman --- api/adapter.c | 22 +++++----------------- api/driver.c | 4 ---- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/api/adapter.c b/api/adapter.c index ab42761..5f6b2cd 100644 --- a/api/adapter.c +++ b/api/adapter.c @@ -776,8 +776,6 @@ WintunGetAdapterDeviceObject(_In_ const WINTUN_ADAPTER *Adapter, _Out_ HANDLE *H 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 * 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 HaveWHQL(void) { -# if defined(HAVE_EV) && defined(HAVE_WHQL) +#if defined(HAVE_EV) && defined(HAVE_WHQL) DWORD MajorVersion; RtlGetNtVersionNumbers(&MajorVersion, NULL, NULL); return MajorVersion >= 10; -# elif defined(HAVE_EV) - return FALSE; -# elif defined(HAVE_WHQL) +#elif defined(HAVE_WHQL) return TRUE; -# endif +#else + return FALSE; +#endif } static WINTUN_STATUS @@ -871,10 +869,6 @@ cleanupQueriedStore: return Result; } -#endif - -#if defined(HAVE_EV) || defined(HAVE_WHQL) - static BOOL IsNewer(_In_ const SP_DRVINFO_DATA_W *DrvInfoData, _In_ const FILETIME *DriverDate, _In_ DWORDLONG DriverVersion) { @@ -1238,8 +1232,6 @@ cleanupMutex: return Result; } -#endif - static WINTUN_STATUS CreateTemporaryDirectory(_Out_cap_c_(MAX_PATH) WCHAR *RandomTempSubDirectory) { @@ -1559,7 +1551,6 @@ WintunCreateAdapter( return CreateAdapterNatively(Pool, Name, RequestedGUID, Adapter, RebootRequired); #endif -#if defined(HAVE_EV) || defined(HAVE_WHQL) DWORD Result = ERROR_SUCCESS; WCHAR RandomTempSubDirectory[MAX_PATH]; if ((Result = CreateTemporaryDirectory(RandomTempSubDirectory)) != ERROR_SUCCESS) @@ -1605,9 +1596,6 @@ cleanupDelete: cleanupDirectory: RemoveDirectoryW(RandomTempSubDirectory); return Result; -#else - return ERROR_NOT_SUPPORTED; -#endif } #if defined(_M_IX86) || defined(_M_ARM) diff --git a/api/driver.c b/api/driver.c index 3308794..4b226c4 100644 --- a/api/driver.c +++ b/api/driver.c @@ -24,8 +24,6 @@ DriverIsOurDrvInfoDetail(_In_ const SP_DRVINFO_DETAIL_DATA_W *DrvInfoDetailData) DriverIsOurHardwareID(DrvInfoDetailData->HardwareID + DrvInfoDetailData->CompatIDsOffset); } -#if defined(HAVE_EV) || defined(HAVE_WHQL) - WINTUN_STATUS DriverRemoveAllOurs(void) { @@ -72,5 +70,3 @@ cleanupDeviceInfoSet: SetupDiDestroyDeviceInfoList(DevInfo); return Result; } - -#endif