api: unify hardware ID string

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-10-13 19:55:41 +02:00 committed by Jason A. Donenfeld
parent 2727d14438
commit a3d9431e70
3 changed files with 6 additions and 10 deletions

View File

@ -5,7 +5,6 @@
#include "pch.h"
#define WINTUN_HWID L"Wintun"
#define WAIT_FOR_REGISTRY_TIMEOUT 10000 /* ms */
#define MAX_POOL_DEVICE_TYPE (MAX_POOL + 8) /* Should accommodate a pool name with " Tunnel" appended */
@ -1024,12 +1023,7 @@ WintunCreateAdapter(
const static DWORD EnableDeadGWDetect = 0;
Result = RegSetKeyValueW(
TcpipInterfaceRegKey,
NULL,
L"EnableDeadGWDetect",
REG_DWORD,
&EnableDeadGWDetect,
sizeof(EnableDeadGWDetect));
TcpipInterfaceRegKey, NULL, L"EnableDeadGWDetect", REG_DWORD, &EnableDeadGWDetect, sizeof(EnableDeadGWDetect));
if (Result != ERROR_SUCCESS)
WINTUN_LOGGER_ERROR(L"Failed to set EnableDeadGWDetect", Result);

View File

@ -302,7 +302,7 @@ InstallDriver(_In_ BOOL UpdateExisting)
BOOL RebootRequired = FALSE;
if (UpdateExisting &&
!UpdateDriverForPlugAndPlayDevicesW(
NULL, L"Wintun", InfPath, INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE, &RebootRequired))
NULL, WINTUN_HWID, InfPath, INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE, &RebootRequired))
WINTUN_LOGGER_LAST_ERROR(L"Could not update existing adapters");
if (RebootRequired)
WINTUN_LOGGER(WINTUN_LOG_WARN, L"A reboot might be required, which really should not be the case");
@ -346,7 +346,7 @@ static WINTUN_STATUS RemoveDriver(VOID)
SP_DRVINFO_DETAIL_DATA_W *DrvInfoDetailData = DriverGetDrvInfoDetail(DevInfo, NULL, &DrvInfoData);
if (!DrvInfoDetailData)
continue;
if (!_wcsicmp(DrvInfoDetailData->HardwareID, L"wintun"))
if (!_wcsicmp(DrvInfoDetailData->HardwareID, WINTUN_HWID))
{
PathStripPathW(DrvInfoDetailData->InfFileName);
WINTUN_LOGGER(WINTUN_LOG_INFO, L"Removing existing driver");
@ -396,7 +396,7 @@ DriverIsWintunAdapter(_In_ HDEVINFO DevInfo, _In_opt_ SP_DEVINFO_DATA *DevInfoDa
SP_DRVINFO_DETAIL_DATA_W *DrvInfoDetailData = DriverGetDrvInfoDetail(DevInfo, DevInfoData, &DrvInfoData);
if (!DrvInfoDetailData)
continue;
Found = !_wcsicmp(DrvInfoDetailData->HardwareID, L"wintun");
Found = !_wcsicmp(DrvInfoDetailData->HardwareID, WINTUN_HWID);
HeapFree(Heap, 0, DrvInfoDetailData);
}
SetupDiDestroyDriverInfoList(DevInfo, DevInfoData, SPDIT_COMPATDRIVER);

View File

@ -9,6 +9,8 @@
#include <Windows.h>
#include <SetupAPI.h>
#define WINTUN_HWID L"Wintun"
_Return_type_success_(return != NULL) SP_DRVINFO_DETAIL_DATA_W *DriverGetDrvInfoDetail(
_In_ HDEVINFO DevInfo,
_In_opt_ SP_DEVINFO_DATA *DevInfoData,