From f04167c51c9a8478f10a1484f3dde13f13343d49 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 26 Jun 2015 22:49:32 +0100 Subject: [PATCH] [core] add enumeration debugging * Alt-. to toggle * Also add configure option for test releases --- configure | 16 +++++++++++++++- configure.ac | 8 +++++++- res/localization/rufus.loc | 1 + src/localization_data.h | 10 ++++++++++ src/resource.h | 12 +++++++++++- src/rufus.c | 16 +++++++++++++++- src/rufus.h | 3 +++ src/rufus.rc | 16 ++++++++-------- src/usb.c | 23 ++++++++++++++++++++++- 9 files changed, 92 insertions(+), 13 deletions(-) diff --git a/configure b/configure index 2beff5cf..061a0a64 100644 --- a/configure +++ b/configure @@ -678,6 +678,7 @@ enable_silent_rules enable_debug enable_alpha enable_beta +enable_test ' ac_precious_vars='build_alias host_alias @@ -1306,6 +1307,7 @@ Optional Features: --enable-debug keep debug symbols for gdb (default=yes) --enable-alpha build an ALPHA release (default=no) --enable-beta build a BETA release (default=no) + --enable-test=# build a TEST release (default=no) Some influential environment variables: CC C compiler command @@ -3831,7 +3833,7 @@ else LDFLAGS="-s" fi -# Alpha/Beta +# Alpha/Beta/Test # Check whether --enable-alpha was given. if test "${enable_alpha+set}" = set; then : enableval=$enable_alpha; alpha_enabled=$enableval @@ -3854,6 +3856,18 @@ if test "x$beta_enabled" != "xno" ; then CFLAGS+=" -DBETA" SUFFIX=_BETA fi +# Check whether --enable-test was given. +if test "${enable_test+set}" = set; then : + enableval=$enable_test; test_enabled=$enableval +else + test_enabled='no' +fi + +if test "x$test_enabled" != "xno" ; then + if test "x$test_enabled" == "xyes" ; then $enableval="" ; fi + CFLAGS+=" -DTEST=$enableval" + SUFFIX=_TEST$enableval +fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabling Large File Support (ISO support)" >&5 $as_echo "enabling Large File Support (ISO support)" >&6; } diff --git a/configure.ac b/configure.ac index 994dc404..7dc9174d 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ else LDFLAGS="-s" fi -# Alpha/Beta +# Alpha/Beta/Test AC_ARG_ENABLE([alpha],[AS_HELP_STRING([--enable-alpha], [build an ALPHA release (default=no)])], [alpha_enabled=$enableval], [alpha_enabled='no']) if test "x$alpha_enabled" != "xno" ; then CFLAGS+=" -DALPHA" @@ -46,6 +46,12 @@ if test "x$beta_enabled" != "xno" ; then CFLAGS+=" -DBETA" SUFFIX=_BETA fi +AC_ARG_ENABLE([test],[AS_HELP_STRING([--enable-test=#], [build a TEST release (default=no)])], [test_enabled=$enableval], [test_enabled='no']) +if test "x$test_enabled" != "xno" ; then + if test "x$test_enabled" == "xyes" ; then $enableval="" ; fi + CFLAGS+=" -DTEST=$enableval" + SUFFIX=_TEST$enableval +fi AC_MSG_RESULT([enabling Large File Support (ISO support)]) AM_CFLAGS="$AM_CFLAGS -D_FILE_OFFSET_BITS=64 -D_OFF_T_ -D_off_t=off64_t -Doff_t=off64_t -Doff32_t=long" diff --git a/res/localization/rufus.loc b/res/localization/rufus.loc index 09156e02..26a626ac 100644 --- a/res/localization/rufus.loc +++ b/res/localization/rufus.loc @@ -516,6 +516,7 @@ t MSG_266 "Dual UEFI/BIOS mode" t MSG_267 "Applying Windows image: %0.1f%% completed" t MSG_268 "Applying Windows image..." t MSG_269 "Preserve timestamps" +t MSG_270 "USB debug" ################################################################################ ############################# TRANSLATOR END COPY ############################## diff --git a/src/localization_data.h b/src/localization_data.h index f2d5881c..bd48431e 100644 --- a/src/localization_data.h +++ b/src/localization_data.h @@ -367,6 +367,16 @@ const loc_control_id control_id[] = { LOC_CTRL(MSG_267), LOC_CTRL(MSG_268), LOC_CTRL(MSG_269), + LOC_CTRL(MSG_270), + LOC_CTRL(MSG_271), + LOC_CTRL(MSG_272), + LOC_CTRL(MSG_273), + LOC_CTRL(MSG_274), + LOC_CTRL(MSG_275), + LOC_CTRL(MSG_276), + LOC_CTRL(MSG_277), + LOC_CTRL(MSG_278), + LOC_CTRL(MSG_279), LOC_CTRL(MSG_MAX), LOC_CTRL(IDOK), LOC_CTRL(IDCANCEL), diff --git a/src/resource.h b/src/resource.h index 56f4f14a..7b5823c3 100644 --- a/src/resource.h +++ b/src/resource.h @@ -405,7 +405,17 @@ #define MSG_267 3267 #define MSG_268 3268 #define MSG_269 3269 -#define MSG_MAX 3270 +#define MSG_270 3270 +#define MSG_271 3271 +#define MSG_272 3272 +#define MSG_273 3273 +#define MSG_274 3274 +#define MSG_275 3275 +#define MSG_276 3276 +#define MSG_277 3277 +#define MSG_278 3278 +#define MSG_279 3279 +#define MSG_MAX 3280 // Next default values for new objects // diff --git a/src/rufus.c b/src/rufus.c index b00de2ae..0aa393d0 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -103,7 +103,7 @@ static BOOL log_displayed = FALSE; static BOOL iso_provided = FALSE; static BOOL user_notified = FALSE; static BOOL relaunch = FALSE; -extern BOOL force_large_fat32, enable_iso, enable_joliet, enable_rockridge, enable_ntfs_compression, preserve_timestamps; +extern BOOL force_large_fat32, enable_iso, enable_joliet, enable_rockridge, enable_ntfs_compression, preserve_timestamps, usb_debug; extern uint8_t* grub2_buf; extern long grub2_len; extern const char* old_c32_name[NB_OLD_C32]; @@ -1541,6 +1541,9 @@ static __inline const char* IsAlphaOrBeta(void) return " (Alpha) "; #elif defined(BETA) return " (Beta) "; +#elif defined(TEST) +# define TEST_STR(x) " (Test" STRINGIFY(x) ")" + return TEST_STR(TEST); #else return " "; #endif @@ -2039,6 +2042,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA // Add a VERY ANNOYING popup for Alpha releases, so that people don't start redistributing them Notification(MSG_INFO, NULL, "ALPHA VERSION", "This is an Alpha version of " APPLICATION_NAME " - It is meant to be used for testing ONLY and should NOT be distributed as a release."); +#elif defined(TEST) + // Same thing for Test releases + Notification(MSG_INFO, NULL, "TEST VERSION", "This is a Test version of " APPLICATION_NAME + " - It is meant to be used for testing ONLY and should NOT be distributed as a release."); #endif return (INT_PTR)FALSE; @@ -2821,6 +2828,13 @@ relaunch: // Might also need ES_NOHIDESEL property if you want to select when not active SendMessage(hLog, EM_SETSEL, 0, -1); } + // Alt-. => Enable USB enumeration debug + if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_PERIOD)) { + usb_debug = !usb_debug; + PrintStatus2000(lmprintf(MSG_270), usb_debug); + GetUSBDevices(0); + continue; + } // Alt-B => Toggle fake drive detection during bad blocks check // By default, Rufus will check for fake USB flash drives that mistakenly present // more capacity than they already have by looping over the flash. This check which diff --git a/src/rufus.h b/src/rufus.h index 4a0141ae..1aabdc5c 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -77,6 +77,9 @@ #ifndef ARRAYSIZE #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) #endif +#ifndef STRINGIFY +#define STRINGIFY(x) #x +#endif #define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED) #define MB_IS_RTL (right_to_left_mode?MB_RTLREADING:0) #define IDD_OFFSET ((right_to_left_mode?100:0) + ((nWindowsVersion <= WINDOWS_XP)?50:0)) diff --git a/src/rufus.rc b/src/rufus.rc index 051eaff9..db093007 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 2.3.682" +CAPTION "Rufus 2.3.683" FONT 8, "Segoe UI", 400, 0, 0x1 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -157,7 +157,7 @@ END IDD_DIALOG_XP DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 2.3.682" +CAPTION "Rufus 2.3.683" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -283,7 +283,7 @@ END IDD_DIALOG_RTL DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL -CAPTION "Rufus 2.3.682" +CAPTION "Rufus 2.3.683" FONT 8, "Segoe UI", 400, 0, 0x1 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -415,7 +415,7 @@ END IDD_DIALOG_RTL_XP DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL -CAPTION "Rufus 2.3.682" +CAPTION "Rufus 2.3.683" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -671,8 +671,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,3,682,0 - PRODUCTVERSION 2,3,682,0 + FILEVERSION 2,3,683,0 + PRODUCTVERSION 2,3,683,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -689,13 +689,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.3.682" + VALUE "FileVersion", "2.3.683" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.3.682" + VALUE "ProductVersion", "2.3.683" END END BLOCK "VarFileInfo" diff --git a/src/usb.c b/src/usb.c index 5c393634..06577dab 100644 --- a/src/usb.c +++ b/src/usb.c @@ -42,6 +42,7 @@ extern StrArray DriveID, DriveLabel; extern BOOL enable_HDDs, use_fake_units, enable_vmdk; +BOOL usb_debug = FALSE; /* * Get the VID, PID and current device speed @@ -169,7 +170,8 @@ BOOL GetUSBDevices(DWORD devnum) if (htab_create(DEVID_HTAB_SIZE, &htab_devid)) { dev_info_data.cbSize = sizeof(dev_info_data); for (i=0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) { - + if (usb_debug) + uprintf("Processing Hub %d:", i + 1); devint_detail_data = NULL; devint_data.cbSize = sizeof(devint_data); // Only care about the first interface (MemberIndex 0) @@ -188,12 +190,16 @@ BOOL GetUSBDevices(DWORD devnum) if ((k = htab_hash(device_id, &htab_devid)) != 0) { htab_devid.table[k].data = (void*)(uintptr_t)s; } + if (usb_debug) + uprintf(" Found ID[%03d]: %s", k, device_id); while (CM_Get_Sibling(&device_inst, device_inst, 0) == CR_SUCCESS) { device_id[0] = 0; if (CM_Get_Device_IDA(device_inst, device_id, MAX_PATH, 0) == CR_SUCCESS) { if ((k = htab_hash(device_id, &htab_devid)) != 0) { htab_devid.table[k].data = (void*)(uintptr_t)s; } + if (usb_debug) + uprintf(" Found ID[%03d]: %s", k, device_id); } } } @@ -233,6 +239,11 @@ BOOL GetUSBDevices(DWORD devnum) if (list_size[s] > 1) { if (CM_Get_Device_ID_ListA(storage_name[s], &devid_list[i], list_size[s], ulFlags) != CR_SUCCESS) continue; + if (usb_debug) { + uprintf("Processing IDs belonging to %s:", storage_name[s]); + for (device_id = &devid_list[i]; *device_id != 0; device_id += strlen(device_id) + 1) + uprintf(" %s", device_id); + } // The 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')) @@ -268,6 +279,8 @@ BOOL GetUSBDevices(DWORD devnum) memset(buffer, 0, sizeof(buffer)); props.is_VHD = SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_HARDWAREID, &datatype, (LPBYTE)buffer, sizeof(buffer), &size) && IsVHD(buffer); + if (usb_debug) + uprintf("Processing Device: '%s'", buffer); memset(buffer, 0, sizeof(buffer)); if (!SetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME, @@ -287,6 +300,8 @@ BOOL GetUSBDevices(DWORD devnum) 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 j = htab_hash(device_id, &htab_devid); + if (usb_debug) + uprintf(" Matched with ID[%03d]: %s", j, device_id); // If the hash didn't match a populated string in dev_if_path[] (htab_devid.table[j].data > 0), // we might have an extra vendor driver in between (e.g. "ASUS USB 3.0 Boost Storage Driver" // for UASP devices in ASUS "Turbo Mode" or "Apple Mobile Device USB Driver" for iPods) @@ -297,9 +312,13 @@ BOOL GetUSBDevices(DWORD devnum) device_id = str; method_str = "[GP]"; j = htab_hash(device_id, &htab_devid); + if (usb_debug) + uprintf(" Matched with (GP) ID[%03d]: %s", j, device_id); } if ((uint32_t)htab_devid.table[j].data > 0) GetUSBProperties(dev_if_path.String[(uint32_t)htab_devid.table[j].data], device_id, &props); + if (usb_debug) + uprintf(" Props VID:PID = %04X:%04X", props.vid, props.pid); // If previous calls still didn't succeed, try reading the VID:PID from the device_id if ((props.vid == 0) && (props.pid == 0)) { @@ -328,6 +347,8 @@ BOOL GetUSBDevices(DWORD devnum) 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! + if (usb_debug) + uprintf(" Non USB => Eliminated"); continue; } safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID