[enum] minor improvements to drive size handling

* Also fix a typo when trying to detect x86 running on ARM
This commit is contained in:
Pete Batard 2023-04-04 10:28:01 +02:00
parent af8f68c305
commit e86523e024
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
3 changed files with 15 additions and 12 deletions

View File

@ -492,6 +492,7 @@ BOOL GetDevices(DWORD devnum)
char drive_letters[27], *device_id, *devid_list = NULL, display_msg[128]; char drive_letters[27], *device_id, *devid_list = NULL, display_msg[128];
char *p, *label, *display_name, buffer[MAX_PATH], str[MAX_PATH], device_instance_id[MAX_PATH], *method_str, *hub_path; char *p, *label, *display_name, buffer[MAX_PATH], str[MAX_PATH], device_instance_id[MAX_PATH], *method_str, *hub_path;
uint32_t ignore_vid_pid[MAX_IGNORE_USB]; uint32_t ignore_vid_pid[MAX_IGNORE_USB];
uint64_t drive_size = 0;
usb_device_props props; usb_device_props props;
IGNORE_RETVAL(ComboBox_ResetContent(hDeviceList)); IGNORE_RETVAL(ComboBox_ResetContent(hDeviceList));
@ -879,7 +880,8 @@ BOOL GetDevices(DWORD devnum)
safe_free(devint_detail_data); safe_free(devint_detail_data);
break; break;
} }
if (GetDriveSize(drive_index) < (MIN_DRIVE_SIZE*MB)) { drive_size = GetDriveSize(drive_index);
if (drive_size < (MIN_DRIVE_SIZE * MB)) {
uprintf("Device eliminated because it is smaller than %d MB", MIN_DRIVE_SIZE); uprintf("Device eliminated because it is smaller than %d MB", MIN_DRIVE_SIZE);
safe_free(devint_detail_data); safe_free(devint_detail_data);
break; break;
@ -916,7 +918,7 @@ BOOL GetDevices(DWORD devnum)
uprintf("NOTE: You can enable the listing of Hard Drives under 'advanced drive properties'"); uprintf("NOTE: You can enable the listing of Hard Drives under 'advanced drive properties'");
safe_free(devint_detail_data); safe_free(devint_detail_data);
break; break;
} else if ((!enable_HDDs) && (props.is_CARD) && (GetDriveSize(drive_index) > MAX_DEFAULT_LIST_CARD_SIZE * GB)) { } else if ((!enable_HDDs) && (props.is_CARD) && (drive_size > MAX_DEFAULT_LIST_CARD_SIZE * GB)) {
uprintf("Device eliminated because it was detected as a card larger than %d GB", MAX_DEFAULT_LIST_CARD_SIZE); uprintf("Device eliminated because it was detected as a card larger than %d GB", MAX_DEFAULT_LIST_CARD_SIZE);
uprintf("To use such a card, check 'List USB Hard Drives' under 'advanced drive properties'"); uprintf("To use such a card, check 'List USB Hard Drives' under 'advanced drive properties'");
safe_free(devint_detail_data); safe_free(devint_detail_data);
@ -937,7 +939,7 @@ BOOL GetDevices(DWORD devnum)
// The empty string is returned for drives that don't have any volumes assigned // The empty string is returned for drives that don't have any volumes assigned
if (drive_letters[0] == 0) { if (drive_letters[0] == 0) {
display_name = lmprintf(MSG_046, label, drive_number, display_name = lmprintf(MSG_046, label, drive_number,
SizeToHumanReadable(GetDriveSize(drive_index), FALSE, use_fake_units)); SizeToHumanReadable(drive_size, FALSE, use_fake_units));
} else { } else {
// Find the UEFI:TOGO partition(s) (and eliminate them form our listing) // Find the UEFI:TOGO partition(s) (and eliminate them form our listing)
for (k = 0; drive_letters[k]; k++) { for (k = 0; drive_letters[k]; k++) {
@ -971,7 +973,8 @@ BOOL GetDevices(DWORD devnum)
break; break;
} }
safe_sprintf(&display_msg[strlen(display_msg)], sizeof(display_msg) - strlen(display_msg), safe_sprintf(&display_msg[strlen(display_msg)], sizeof(display_msg) - strlen(display_msg),
"%s [%s]", (right_to_left_mode)?RIGHT_TO_LEFT_MARK:"", SizeToHumanReadable(GetDriveSize(drive_index), FALSE, use_fake_units)); "%s [%s]", (right_to_left_mode)?RIGHT_TO_LEFT_MARK:"",
SizeToHumanReadable(drive_size, FALSE, use_fake_units));
display_name = display_msg; display_name = display_msg;
} }
@ -980,7 +983,7 @@ BOOL GetDevices(DWORD devnum)
rufus_drive[num_drives].name = safe_strdup(buffer); rufus_drive[num_drives].name = safe_strdup(buffer);
rufus_drive[num_drives].display_name = safe_strdup(display_name); rufus_drive[num_drives].display_name = safe_strdup(display_name);
rufus_drive[num_drives].label = safe_strdup(label); rufus_drive[num_drives].label = safe_strdup(label);
rufus_drive[num_drives].size = GetDriveSize(drive_index); rufus_drive[num_drives].size = drive_size;
assert(rufus_drive[num_drives].size != 0); assert(rufus_drive[num_drives].size != 0);
if (hub_path != NULL) { if (hub_path != NULL) {
rufus_drive[num_drives].hub = safe_strdup(hub_path); rufus_drive[num_drives].hub = safe_strdup(hub_path);

View File

@ -2026,7 +2026,7 @@ static void InitDialog(HWND hDlg)
// available on Windows 10 1511 or later... // available on Windows 10 1511 or later...
if ((pfIsWow64Process2 != NULL) && pfIsWow64Process2(GetCurrentProcess(), &ProcessMachine, &NativeMachine)) { if ((pfIsWow64Process2 != NULL) && pfIsWow64Process2(GetCurrentProcess(), &ProcessMachine, &NativeMachine)) {
if ((NativeMachine == IMAGE_FILE_MACHINE_ARM || NativeMachine == IMAGE_FILE_MACHINE_ARM64) && if ((NativeMachine == IMAGE_FILE_MACHINE_ARM || NativeMachine == IMAGE_FILE_MACHINE_ARM64) &&
(ProcessMachine == IMAGE_FILE_MACHINE_I386 || ProcessMachine == IMAGE_FILE_MACHINE_I386)) (ProcessMachine == IMAGE_FILE_MACHINE_I386 || ProcessMachine == IMAGE_FILE_MACHINE_AMD64))
uprintf("Notice: Running emulated on %s platform", GetArchName(NativeMachine)); uprintf("Notice: Running emulated on %s platform", GetArchName(NativeMachine));
} }
for (i = 0; i < ARRAYSIZE(resource); i++) { for (i = 0; i < ARRAYSIZE(resource); i++) {

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
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
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.23.2014" CAPTION "Rufus 3.23.2015"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,23,2014,0 FILEVERSION 3,23,2015,0
PRODUCTVERSION 3,23,2014,0 PRODUCTVERSION 3,23,2015,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.23.2014" VALUE "FileVersion", "3.23.2015"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.23.exe" VALUE "OriginalFilename", "rufus-3.23.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.23.2014" VALUE "ProductVersion", "3.23.2015"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"