[vds] enable device cycling when using VDS

* Hopefully using DICS_FLAG_CONFIGSPECIFIC instead of DICS_FLAG_GLOBAL is all that was needed
  to get device disabling/re-enabling work without creating zombie devices, because we sure
  need to force Windows' hand when it comes to detecting logical volumes...
This commit is contained in:
Pete Batard 2020-02-15 14:44:34 +00:00
parent 4ee90a9546
commit 761953fdbf
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
3 changed files with 13 additions and 14 deletions

View File

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Device detection and enumeration
* Copyright © 2014-2019 Pete Batard <pete@akeo.ie>
* Copyright © 2014-2020 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -181,7 +181,7 @@ out:
/*
* Forces a refresh by disabling and then re-enabling the device using SetupAPI.
* Returns the Windows error code from the operation.
* Note: Currently, this may leave the device disabled after re-plug or reboot...
* Note: In some circumstances, this may leave the device disabled after re-plug or reboot...
*/
int CycleDevice(int index)
{
@ -226,7 +226,7 @@ int CycleDevice(int index)
memset(&propchange_params, 0, sizeof(propchange_params));
propchange_params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
propchange_params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
propchange_params.Scope = DICS_FLAG_GLOBAL;
propchange_params.Scope = DICS_FLAG_CONFIGSPECIFIC;
propchange_params.StateChange = DICS_DISABLE;
if (!SetupDiSetClassInstallParams(dev_info, &dev_info_data,
@ -247,7 +247,7 @@ int CycleDevice(int index)
memset(&propchange_params, 0, sizeof(propchange_params));
propchange_params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
propchange_params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
propchange_params.Scope = DICS_FLAG_GLOBAL;
propchange_params.Scope = DICS_FLAG_CONFIGSPECIFIC;
propchange_params.StateChange = DICS_ENABLE;
if (!SetupDiSetClassInstallParams(dev_info, &dev_info_data,
(SP_CLASSINSTALL_HEADER*)&propchange_params, sizeof(propchange_params))) {

View File

@ -1680,7 +1680,7 @@ DWORD WINAPI FormatThread(void* param)
{
int i, r;
BOOL ret, use_large_fat32, windows_to_go, actual_lock_drive = lock_drive;
DWORD DriveIndex = (DWORD)(uintptr_t)param, ClusterSize, Flags;
DWORD cr, DriveIndex = (DWORD)(uintptr_t)param, ClusterSize, Flags;
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
HANDLE hSourceImage = INVALID_HANDLE_VALUE;
@ -1932,9 +1932,9 @@ DWORD WINAPI FormatThread(void* param)
if (use_vds) {
safe_unlockclose(hPhysicalDrive);
uprintf("Refreshing drive layout...");
#if 0
// **DON'T USE** This may leave the device disabled on re-plug or reboot
DWORD cr = CycleDevice(ComboBox_GetCurSel(hDeviceList));
// Note: This may leave the device disabled on re-plug or reboot
// so only do this for the experimental VDS path for now...
cr = CycleDevice(ComboBox_GetCurSel(hDeviceList));
if (cr == ERROR_DEVICE_REINITIALIZATION_NEEDED) {
uprintf("Zombie device detected, trying again...");
Sleep(1000);
@ -1944,7 +1944,6 @@ DWORD WINAPI FormatThread(void* param)
uprintf("Successfully cycled device");
else
uprintf("Cycling device failed!");
#endif
RefreshLayout(DriveIndex);
}

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.9.1612"
CAPTION "Rufus 3.9.1613"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -394,8 +394,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,9,1612,0
PRODUCTVERSION 3,9,1612,0
FILEVERSION 3,9,1613,0
PRODUCTVERSION 3,9,1613,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -413,13 +413,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.9.1612"
VALUE "FileVersion", "3.9.1613"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.9.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.9.1612"
VALUE "ProductVersion", "3.9.1613"
END
END
BLOCK "VarFileInfo"