1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[usb] fix default listing for ADATA USB HDDs

* Also improve debug print statement in USB enumeration
* Closes #610
This commit is contained in:
Pete Batard 2015-10-03 23:47:06 +01:00
parent 2cfb53c34e
commit e1d0ab73a5
4 changed files with 18 additions and 27 deletions

View file

@ -77,7 +77,6 @@ static str_score_t str_score[] = {
{ "TOSHIBA", 5 }, { "TOSHIBA", 5 },
{ "QUANTUM", 10 }, { "QUANTUM", 10 },
{ "EXCELSTOR", 10 }, { "EXCELSTOR", 10 },
{ "ADATA", -15 },
{ "CORSAIR", -15 }, { "CORSAIR", -15 },
{ "KINGMAX", -15 }, { "KINGMAX", -15 },
{ "KINGSTON", -15 }, { "KINGSTON", -15 },

View file

@ -115,6 +115,7 @@ extern void _uprintf(const char *format, ...);
#define vuprintf(...) if (verbose) _uprintf(__VA_ARGS__) #define vuprintf(...) if (verbose) _uprintf(__VA_ARGS__)
#define vvuprintf(...) if (verbose > 1) _uprintf(__VA_ARGS__) #define vvuprintf(...) if (verbose > 1) _uprintf(__VA_ARGS__)
#define suprintf(...) if (!bSilent) _uprintf(__VA_ARGS__) #define suprintf(...) if (!bSilent) _uprintf(__VA_ARGS__)
#define uuprintf(...) if (usb_debug) _uprintf(__VA_ARGS__)
#ifdef _DEBUG #ifdef _DEBUG
#define duprintf(...) _uprintf(__VA_ARGS__) #define duprintf(...) _uprintf(__VA_ARGS__)
#else #else

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376 IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.5.764" CAPTION "Rufus 2.5.765"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0 FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -319,8 +319,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,5,764,0 FILEVERSION 2,5,765,0
PRODUCTVERSION 2,5,764,0 PRODUCTVERSION 2,5,765,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -337,13 +337,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.5.764" VALUE "FileVersion", "2.5.765"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.5.764" VALUE "ProductVersion", "2.5.765"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -136,9 +136,9 @@ static __inline BOOL IsVHD(const char* buffer)
/* For debugging user reports of HDDs vs UFDs */ /* For debugging user reports of HDDs vs UFDs */
//#define FORCED_DEVICE //#define FORCED_DEVICE
#ifdef FORCED_DEVICE #ifdef FORCED_DEVICE
#define FORCED_VID 0x0930 #define FORCED_VID 0x125F
#define FORCED_PID 0x6544 #define FORCED_PID 0xA11A
#define FORCED_NAME "TOSHIBA TransMemory USB Device" #define FORCED_NAME "ABATA CH11 USB Device"
#endif #endif
/* /*
@ -189,8 +189,7 @@ BOOL GetUSBDevices(DWORD devnum)
if (htab_create(DEVID_HTAB_SIZE, &htab_devid)) { if (htab_create(DEVID_HTAB_SIZE, &htab_devid)) {
dev_info_data.cbSize = sizeof(dev_info_data); dev_info_data.cbSize = sizeof(dev_info_data);
for (i=0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) { for (i=0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
if (usb_debug) uuprintf("Processing Hub %d:", i + 1);
uprintf("Processing Hub %d:", i + 1);
devint_detail_data = NULL; devint_detail_data = NULL;
devint_data.cbSize = sizeof(devint_data); devint_data.cbSize = sizeof(devint_data);
// Only care about the first interface (MemberIndex 0) // Only care about the first interface (MemberIndex 0)
@ -205,22 +204,19 @@ BOOL GetUSBDevices(DWORD devnum)
if (CM_Get_Child(&device_inst, dev_info_data.DevInst, 0) == CR_SUCCESS) { if (CM_Get_Child(&device_inst, dev_info_data.DevInst, 0) == CR_SUCCESS) {
device_id[0] = 0; device_id[0] = 0;
s = StrArrayAdd(&dev_if_path, devint_detail_data->DevicePath); s = StrArrayAdd(&dev_if_path, devint_detail_data->DevicePath);
if (usb_debug) uuprintf(" Hub[%d] = '%s'", s, devint_detail_data->DevicePath);
uprintf(" Hub[%d] = '%s'", s, devint_detail_data->DevicePath);
if ((s>= 0) && (CM_Get_Device_IDA(device_inst, device_id, MAX_PATH, 0) == CR_SUCCESS)) { if ((s>= 0) && (CM_Get_Device_IDA(device_inst, device_id, MAX_PATH, 0) == CR_SUCCESS)) {
if ((k = htab_hash(device_id, &htab_devid)) != 0) { if ((k = htab_hash(device_id, &htab_devid)) != 0) {
htab_devid.table[k].data = (void*)(uintptr_t)s; htab_devid.table[k].data = (void*)(uintptr_t)s;
} }
if (usb_debug) uuprintf(" Found ID[%03d]: %s", k, device_id);
uprintf(" Found ID[%03d]: %s", k, device_id);
while (CM_Get_Sibling(&device_inst, device_inst, 0) == CR_SUCCESS) { while (CM_Get_Sibling(&device_inst, device_inst, 0) == CR_SUCCESS) {
device_id[0] = 0; device_id[0] = 0;
if (CM_Get_Device_IDA(device_inst, device_id, MAX_PATH, 0) == CR_SUCCESS) { if (CM_Get_Device_IDA(device_inst, device_id, MAX_PATH, 0) == CR_SUCCESS) {
if ((k = htab_hash(device_id, &htab_devid)) != 0) { if ((k = htab_hash(device_id, &htab_devid)) != 0) {
htab_devid.table[k].data = (void*)(uintptr_t)s; htab_devid.table[k].data = (void*)(uintptr_t)s;
} }
if (usb_debug) uuprintf(" Found ID[%03d]: %s", k, device_id);
uprintf(" Found ID[%03d]: %s", k, device_id);
} }
} }
} }
@ -300,8 +296,7 @@ BOOL GetUSBDevices(DWORD devnum)
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
props.is_VHD = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_HARDWAREID, props.is_VHD = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_HARDWAREID,
&datatype, (LPBYTE)buffer, sizeof(buffer), &size) && IsVHD(buffer); &datatype, (LPBYTE)buffer, sizeof(buffer), &size) && IsVHD(buffer);
if (usb_debug) uuprintf("Processing Device: '%s'", buffer);
uprintf("Processing Device: '%s'", buffer);
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME, if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
@ -324,8 +319,7 @@ BOOL GetUSBDevices(DWORD devnum)
props.is_UASP = ((((uintptr_t)device_id)+2) >= ((uintptr_t)devid_list)+list_start[1]); props.is_UASP = ((((uintptr_t)device_id)+2) >= ((uintptr_t)devid_list)+list_start[1]);
// Now get the properties of the device, and its Device ID, which we need to populate the properties // Now get the properties of the device, and its Device ID, which we need to populate the properties
j = htab_hash(device_id, &htab_devid); j = htab_hash(device_id, &htab_devid);
if (usb_debug) uuprintf(" Matched with ID[%03d]: %s", j, device_id);
uprintf(" Matched with ID[%03d]: %s", j, device_id);
// Try to parse the current device_id string for VID:PID // Try to parse the current device_id string for VID:PID
// We'll use that if we can't get anything better // We'll use that if we can't get anything better
@ -354,12 +348,10 @@ BOOL GetUSBDevices(DWORD devnum)
device_id = str; device_id = str;
method_str = "[GP]"; method_str = "[GP]";
j = htab_hash(device_id, &htab_devid); j = htab_hash(device_id, &htab_devid);
if (usb_debug) uuprintf(" Matched with (GP) ID[%03d]: %s", j, device_id);
uprintf(" Matched with (GP) ID[%03d]: %s", j, device_id);
} }
if ((uintptr_t)htab_devid.table[j].data > 0) { if ((uintptr_t)htab_devid.table[j].data > 0) {
if (usb_debug) uuprintf(" Matched with Hub[%d]: '%s'", (uintptr_t)htab_devid.table[j].data,
uprintf(" Matched with Hub[%d]: '%s'", (uintptr_t)htab_devid.table[j].data,
dev_if_path.String[(uintptr_t)htab_devid.table[j].data]); dev_if_path.String[(uintptr_t)htab_devid.table[j].data]);
if (GetUSBProperties(dev_if_path.String[(uintptr_t)htab_devid.table[j].data], device_id, &props)) if (GetUSBProperties(dev_if_path.String[(uintptr_t)htab_devid.table[j].data], device_id, &props))
method_str = ""; method_str = "";
@ -380,8 +372,7 @@ BOOL GetUSBDevices(DWORD devnum)
if (is_SCSI) { if (is_SCSI) {
// If we have an SCSI drive and couldn't get a VID:PID, we are most likely // If we have an SCSI drive and couldn't get a VID:PID, we are most likely
// dealing with a system drive => eliminate it! // dealing with a system drive => eliminate it!
if (usb_debug) uuprintf(" Non USB => Eliminated");
uprintf(" Non USB => Eliminated");
continue; continue;
} }
safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID