diff options
author | Simon Rozman <simon@rozman.si> | 2020-07-22 13:20:48 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-10-30 16:50:59 +0100 |
commit | 0adf0fab8d890e230845b19f87cbfd651d244a8e (patch) | |
tree | 39f4f354da98b3d216dd16b4294f77fcbe766999 | |
parent | api: cleanup (diff) | |
download | wintun-0adf0fab8d890e230845b19f87cbfd651d244a8e.tar.xz wintun-0adf0fab8d890e230845b19f87cbfd651d244a8e.zip |
api: do the set-quiet-install later
Rather than setting the "quiet" flag to each and every device in the
process of iterating, set it when actually creating/deleting it.
Signed-off-by: Simon Rozman <simon@rozman.si>
-rw-r--r-- | api/devmgmt.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/api/devmgmt.c b/api/devmgmt.c index 88d435e..c4ef0e2 100644 --- a/api/devmgmt.c +++ b/api/devmgmt.c @@ -345,12 +345,6 @@ GetDevInfoData(_In_ const GUID *CfgInstanceID, _Out_ HDEVINFO *DevInfo, _Out_ SP if (Result != ERROR_SUCCESS || memcmp(CfgInstanceID, &CfgInstanceID2, sizeof(GUID)) != 0) continue; - Result = SetQuietInstall(*DevInfo, DevInfoData); - if (Result != ERROR_SUCCESS) - { - SetupDiDestroyDeviceInfoList(*DevInfo); - return Result; - } return ERROR_SUCCESS; } SetupDiDestroyDeviceInfoList(*DevInfo); @@ -1150,6 +1144,9 @@ WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequ return ERROR_SUCCESS; if (Result != ERROR_SUCCESS) return Result; + Result = SetQuietInstall(DevInfo, &DevInfoData); + if (Result != ERROR_SUCCESS) + goto cleanupDevInfo; SP_REMOVEDEVICE_PARAMS RemoveDeviceParams = { .ClassInstallHeader = { .cbSize = sizeof(SP_CLASSINSTALL_HEADER), .InstallFunction = DIF_REMOVE }, .Scope = DI_REMOVEDEVICE_GLOBAL }; @@ -1159,6 +1156,7 @@ WintunDeleteAdapter(_In_ const WINTUN_ADAPTER *Adapter, _Inout_ BOOL *RebootRequ *RebootRequired = *RebootRequired || CheckReboot(DevInfo, &DevInfoData); else Result = GetLastError(); +cleanupDevInfo: SetupDiDestroyDeviceInfoList(DevInfo); return Result; } @@ -1229,8 +1227,6 @@ WintunEnumAdapters(_In_z_count_c_(MAX_POOL) const WCHAR *Pool, _In_ WINTUN_ENUMP if (!IsMember) continue; - SetQuietInstall(DevInfo, &DevInfoData); /* Ignore errors */ - WINTUN_ADAPTER *Adapter; Result = CreateAdapterData(Pool, DevInfo, &DevInfoData, &Adapter); if (Result != ERROR_SUCCESS) |