From 0d214d72542713c0d716173eab1bc787772026d8 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 9 Nov 2020 14:45:41 +0100 Subject: [PATCH] api: do not call UpdateDriverForPlugAndPlayDevicesW This seems to reset a number of device properties, and our update flow seems to update old adapters without needing to call this. Signed-off-by: Jason A. Donenfeld --- api/adapter.c | 12 ++---------- api/api.vcxproj | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/api/adapter.c b/api/adapter.c index f023ccd..c929b64 100644 --- a/api/adapter.c +++ b/api/adapter.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -1146,8 +1145,7 @@ EnsureWintunUnloaded(void) static _Return_type_success_(return != FALSE) BOOL SelectDriver( _In_ HDEVINFO DevInfo, _In_opt_ SP_DEVINFO_DATA *DevInfoData, - _Inout_ SP_DEVINSTALL_PARAMS_W *DevInstallParams, - _Inout_ BOOL *RebootRequired) + _Inout_ SP_DEVINSTALL_PARAMS_W *DevInstallParams) { static const FILETIME OurDriverDate = WINTUN_INF_FILETIME; static const DWORDLONG OurDriverVersion = WINTUN_INF_VERSION; @@ -1267,12 +1265,6 @@ static _Return_type_success_(return != FALSE) BOOL SelectDriver( goto cleanupDelete; } _Analysis_assume_nullterminated_(InfStorePath); - BOOL UpdateRebootRequired = FALSE; - if (ExistingAdapters && - !UpdateDriverForPlugAndPlayDevicesW( - NULL, WINTUN_HWID, InfStorePath, INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE, &UpdateRebootRequired)) - LOG(WINTUN_LOG_WARN, L"Could not update existing adapters"); - *RebootRequired = *RebootRequired || UpdateRebootRequired; SetupDiDestroyDriverInfoList(DevInfo, DevInfoData, SPDIT_COMPATDRIVER); DestroyDriverInfoListOnCleanup = FALSE; @@ -1395,7 +1387,7 @@ static _Return_type_success_(return != NULL) WINTUN_ADAPTER *CreateAdapter( goto cleanupDevInfo; } - if (!SelectDriver(DevInfo, &DevInfoData, &DevInstallParams, RebootRequired)) + if (!SelectDriver(DevInfo, &DevInfoData, &DevInstallParams)) { LastError = LOG(WINTUN_LOG_ERR, L"Failed to select driver"); goto cleanupDevInfo; diff --git a/api/api.vcxproj b/api/api.vcxproj index f2628a0..214ba6c 100644 --- a/api/api.vcxproj +++ b/api/api.vcxproj @@ -117,8 +117,8 @@ _M_ARM64=1;%(PreprocessorDefinitions) - bcrypt.dll;cfgmgr32.dll;iphlpapi.dll;nci.dll;newdev.dll;version.dll - Bcrypt.lib;Crypt32.lib;Cfgmgr32.lib;Iphlpapi.lib;$(IntDir)nci.lib;newdev.lib;ntdll.lib;Setupapi.lib;shlwapi.lib;version.lib;%(AdditionalDependencies) + bcrypt.dll;cfgmgr32.dll;iphlpapi.dll;nci.dll;version.dll + Bcrypt.lib;Crypt32.lib;Cfgmgr32.lib;Iphlpapi.lib;$(IntDir)nci.lib;ntdll.lib;Setupapi.lib;shlwapi.lib;version.lib;%(AdditionalDependencies) exports.def Windows @@ -209,4 +209,4 @@ - + \ No newline at end of file