Skip to content

Commit 0d214d7

Browse files
committed
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 <[email protected]>
1 parent 8ec14e5 commit 0d214d7

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

api/adapter.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <devguid.h>
2222
#include <iphlpapi.h>
2323
#include <ndisguid.h>
24-
#include <newdev.h>
2524
#include <NTSecAPI.h>
2625
#include <SetupAPI.h>
2726
#include <Shlwapi.h>
@@ -1146,8 +1145,7 @@ EnsureWintunUnloaded(void)
11461145
static _Return_type_success_(return != FALSE) BOOL SelectDriver(
11471146
_In_ HDEVINFO DevInfo,
11481147
_In_opt_ SP_DEVINFO_DATA *DevInfoData,
1149-
_Inout_ SP_DEVINSTALL_PARAMS_W *DevInstallParams,
1150-
_Inout_ BOOL *RebootRequired)
1148+
_Inout_ SP_DEVINSTALL_PARAMS_W *DevInstallParams)
11511149
{
11521150
static const FILETIME OurDriverDate = WINTUN_INF_FILETIME;
11531151
static const DWORDLONG OurDriverVersion = WINTUN_INF_VERSION;
@@ -1267,12 +1265,6 @@ static _Return_type_success_(return != FALSE) BOOL SelectDriver(
12671265
goto cleanupDelete;
12681266
}
12691267
_Analysis_assume_nullterminated_(InfStorePath);
1270-
BOOL UpdateRebootRequired = FALSE;
1271-
if (ExistingAdapters &&
1272-
!UpdateDriverForPlugAndPlayDevicesW(
1273-
NULL, WINTUN_HWID, InfStorePath, INSTALLFLAG_FORCE | INSTALLFLAG_NONINTERACTIVE, &UpdateRebootRequired))
1274-
LOG(WINTUN_LOG_WARN, L"Could not update existing adapters");
1275-
*RebootRequired = *RebootRequired || UpdateRebootRequired;
12761268

12771269
SetupDiDestroyDriverInfoList(DevInfo, DevInfoData, SPDIT_COMPATDRIVER);
12781270
DestroyDriverInfoListOnCleanup = FALSE;
@@ -1395,7 +1387,7 @@ static _Return_type_success_(return != NULL) WINTUN_ADAPTER *CreateAdapter(
13951387
goto cleanupDevInfo;
13961388
}
13971389

1398-
if (!SelectDriver(DevInfo, &DevInfoData, &DevInstallParams, RebootRequired))
1390+
if (!SelectDriver(DevInfo, &DevInfoData, &DevInstallParams))
13991391
{
14001392
LastError = LOG(WINTUN_LOG_ERR, L"Failed to select driver");
14011393
goto cleanupDevInfo;

api/api.vcxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM64'">_M_ARM64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118118
</ResourceCompile>
119119
<Link>
120-
<DelayLoadDLLs>bcrypt.dll;cfgmgr32.dll;iphlpapi.dll;nci.dll;newdev.dll;version.dll</DelayLoadDLLs>
121-
<AdditionalDependencies>Bcrypt.lib;Crypt32.lib;Cfgmgr32.lib;Iphlpapi.lib;$(IntDir)nci.lib;newdev.lib;ntdll.lib;Setupapi.lib;shlwapi.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
120+
<DelayLoadDLLs>bcrypt.dll;cfgmgr32.dll;iphlpapi.dll;nci.dll;version.dll</DelayLoadDLLs>
121+
<AdditionalDependencies>Bcrypt.lib;Crypt32.lib;Cfgmgr32.lib;Iphlpapi.lib;$(IntDir)nci.lib;ntdll.lib;Setupapi.lib;shlwapi.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
122122
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile>
123123
<SubSystem>Windows</SubSystem>
124124
</Link>
@@ -209,4 +209,4 @@
209209
<Target Name="CleanSignTarget">
210210
<Delete Files="$(IntermediateOutputPath)$(TargetName).sign" />
211211
</Target>
212-
</Project>
212+
</Project>

0 commit comments

Comments
 (0)