mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
Update rufus.c
Lines 686 to 690 fix issue where some devices would not be detected if not in USBSTOR. CM_Get_Device_ID_List_SizeA often returned a list size larger than actually required. Thus causing early termination of the full list. Rest of the code adds MS VHD Loopback mounted drives so you can now indirectly use VHD (and VHDX in Windows 8) images.
This commit is contained in:
parent
5e7830e961
commit
0af098a409
1 changed files with 16 additions and 4 deletions
20
src/rufus.c
20
src/rufus.c
|
@ -627,10 +627,13 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
{
|
||||
// The first two are standard Microsoft drivers (including the Windows 8 UASP one).
|
||||
// The rest are the vendor UASP drivers I know of so far - list may be incomplete!
|
||||
const char* usbstor_name[] = { "USBSTOR", "UASPSTOR", "VUSBSTOR", "EtronSTOR" };
|
||||
// The last is Microsofts VHD Mount driver to mount a VHD to a drive letter.
|
||||
const char* usbstor_name[] = { "USBSTOR", "UASPSTOR", "VUSBSTOR", "EtronSTOR", "vhdmp" };
|
||||
const char* scsi_name = "SCSI";
|
||||
// Microsoft VHD Loopback Controller name
|
||||
const char* msvhd_name = "MsVhdHba";
|
||||
char letter_name[] = " (?:)";
|
||||
BOOL found = FALSE, is_SCSI, is_UASP;
|
||||
BOOL found = FALSE, is_SCSI, is_UASP, is_MSVHD;
|
||||
HDEVINFO dev_info = NULL;
|
||||
SP_DEVINFO_DATA dev_info_data;
|
||||
SP_DEVICE_INTERFACE_DATA devint_data;
|
||||
|
@ -680,7 +683,11 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
for (s=0, i=0; s<ARRAYSIZE(usbstor_name); s++) {
|
||||
if (list_size[s] > 1) {
|
||||
CM_Get_Device_ID_ListA(usbstor_name[s], &devid_list[i], list_size[s], CM_GETIDLIST_FILTER_SERVICE);
|
||||
i += list_size[s]-1;
|
||||
// list_size is sometimes larger than required thus we need to find the real end
|
||||
for (i += list_size[s]; i > 2; i--) {
|
||||
if ((devid_list[i-2] != '\0') && (devid_list[i-1] == '\0') && (devid_list[i] == '\0'))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -699,6 +706,7 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
memset(buffer, 0, sizeof(buffer));
|
||||
vid = 0; pid = 0;
|
||||
is_UASP = FALSE;
|
||||
is_MSVHD = FALSE;
|
||||
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
|
||||
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
|
||||
uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString());
|
||||
|
@ -718,6 +726,10 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
// The ID is in the form USB_VENDOR_BUSID\VID_xxxx&PID_xxxx\...
|
||||
if (devid[j] == '\\')
|
||||
post_backslash = TRUE;
|
||||
// Check if this is a VHD
|
||||
is_MSVHD = (safe_strstr(devid, msvhd_name) != NULL);
|
||||
if (is_MSVHD)
|
||||
break;
|
||||
if (!post_backslash)
|
||||
continue;
|
||||
if (devid[j] == '_') {
|
||||
|
@ -729,7 +741,7 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((vid == 0) && (pid == 0)) {
|
||||
if ((vid == 0) && (pid == 0) && !is_MSVHD) {
|
||||
if (is_SCSI) {
|
||||
// If we have an SCSI drive and couldn't get a VID:PID, we are most likely
|
||||
// dealing with a system drive => eliminate it!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue