diff --git a/res/loc/ChangeLog.txt b/res/loc/ChangeLog.txt index dcfce95a..efce0fcb 100644 --- a/res/loc/ChangeLog.txt +++ b/res/loc/ChangeLog.txt @@ -5,7 +5,9 @@ To edit a translation, please make sure to follow: https://github.com/pbatard/rufus/wiki/Localization#Editing_an_existing_translation Or simply download https://files.akeo.ie/pollock/pollock-1.5.exe and follow its directions. -o v4.?? (202?.??.??) +o v4.5 (202?.??.??) + - *UPDATED* IDC_RUFUS_MBR -> IDC_UEFI_MEDIA_VALIDATION "Enable runtime UEFI media validation" + - *UPDATED* MSG_167 "Install a UEFI bootloader, that will perform MD5Sum file validation of the media" - *NEW* MSG_337 "An additional file ('diskcopy.dll') must be downloaded from Microsoft to install MS-DOS (...)" - *NEW* MSG_338 "Revoked UEFI bootloader detected" - *NEW* MSG_339 "Rufus detected that the ISO you have selected contains a UEFI bootloader that has been revoked (...)" @@ -18,6 +20,7 @@ o v4.?? (202?.??.??) - *NEW* MSG_346 "Restrict Windows to S-Mode (INCOMPATIBLE with online account bypass)" - *NEW* MSG_347 "Expert Mode" - *NEW* MSG_348 "Extracting archive files: %s" + - *NEW* MSG_349 "Use Rufus MBR" o v3.22 (2023.??.??) // MSG_144 is aimed the the ISO download feature diff --git a/res/loc/rufus.loc b/res/loc/rufus.loc index 9dae05e7..689e89e2 100644 --- a/res/loc/rufus.loc +++ b/res/loc/rufus.loc @@ -61,7 +61,7 @@ t IDC_OLD_BIOS_FIXES "Add fixes for old BIOSes (extra partition, align, etc.)" # 'MBR': See http://en.wikipedia.org/wiki/Master_boot_record # Rufus can install it's own custom MBR (the Rufus MBR), which also allows users to # specify a custom disk ID for the BIOS. The tooltip for this control is MSG_167. -t IDC_RUFUS_MBR "Use Rufus MBR with BIOS ID" +t IDC_UEFI_MEDIA_VALIDATION "Enable runtime UEFI media validation" t IDS_FORMAT_OPTIONS_TXT "Format Options" t IDS_FILE_SYSTEM_TXT "File system" t IDS_CLUSTER_SIZE_TXT "Cluster size" @@ -370,9 +370,7 @@ t MSG_164 "Method that will be used to make the drive bootable" t MSG_165 "Click to select or download an image..." t MSG_166 "Check this box to allow the display of international labels " "and set a device icon (creates an autorun.inf)" -t MSG_167 "Install an MBR that allows boot selection and can masquerade the BIOS USB drive ID" -t MSG_168 "Try to masquerade first bootable USB drive (usually 0x80) as a different disk.\n" - "This should only be necessary if you install Windows XP and have more than one disk." +t MSG_167 "Install a UEFI bootloader, that will perform MD5Sum file validation of the media" t MSG_169 "Create an extra hidden partition and try to align partitions boundaries.\n" "This can improve boot detection for older BIOSes." t MSG_170 "Enable the listing of USB Hard Drive enclosures. USE AT YOUR OWN RISKS!!!" @@ -574,7 +572,8 @@ t MSG_313 "Save to VHD" t MSG_314 "Compute image checksums" t MSG_315 "Multiple buttons" t MSG_316 "Number of passes" -t MSG_317 "Disk ID" +# TODO: Use this with 168 for UEFI validation label and tooltip +t MSG_317 "Disk ID" t MSG_318 "Default thread priority: %d" t MSG_319 "Ignore Boot Marker" t MSG_320 "Refreshing partition layout (%s)..." @@ -612,6 +611,7 @@ t MSG_345 "Some additional data must be downloaded from Microsoft to use this fu t MSG_346 "Restrict Windows to S-Mode (INCOMPATIBLE with online account bypass)" t MSG_347 "Expert Mode" t MSG_348 "Extracting archive files: %s" +t MSG_349 "Use Rufus MBR" # The following messages are for the Windows Store listing only and are not used by the application t MSG_900 "Rufus is a utility that helps format and create bootable USB flash drives, such as USB keys/pendrives, memory sticks, etc." t MSG_901 "Official site: %s" diff --git a/src/format.c b/src/format.c index 8126a639..3dea7808 100644 --- a/src/format.c +++ b/src/format.c @@ -75,7 +75,7 @@ extern const char* md5sum_name[2]; extern uint32_t dur_mins, dur_secs; extern uint32_t wim_nb_files, wim_proc_files, wim_extra_files; extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, fast_zeroing, enable_file_indexing; -extern BOOL write_as_image, use_vds, write_as_esp, is_vds_available, has_ffu_support; +extern BOOL write_as_image, use_vds, write_as_esp, is_vds_available, has_ffu_support, use_rufus_mbr; extern char* archive_path; uint8_t *grub2_buf = NULL, *sec_buf = NULL; long grub2_len; @@ -771,6 +771,7 @@ out: static BOOL WriteMBR(HANDLE hPhysicalDrive) { BOOL r = FALSE; + BOOL needs_masquerading = HAS_WINPE(img_report) && (!img_report.uses_minint); uint8_t* buffer = NULL; FAKE_FD fake_fd = { 0 }; FILE* fp = (FILE*)&fake_fd; @@ -822,8 +823,8 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) break; } if ((boot_type != BT_NON_BOOTABLE) && (target_type == TT_BIOS)) { - // Set first partition bootable - masquerade as per the DiskID selected - buffer[0x1be] = IsChecked(IDC_RUFUS_MBR) ? (BYTE)ComboBox_GetCurItemData(hDiskID) : 0x80; + // Set first partition bootable or masquerade as second disk + buffer[0x1be] = needs_masquerading ? 0x81 : 0x80; uprintf("Set bootable USB partition as 0x%02X", buffer[0x1be]); } @@ -886,7 +887,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) // If everything else failed, fall back to a conventional Windows/Rufus MBR windows_mbr: - if ((HAS_WINPE(img_report) && !img_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) { + if (needs_masquerading || use_rufus_mbr) { uprintf(using_msg, APPLICATION_NAME); r = write_rufus_mbr(fp); } else { diff --git a/src/iso.c b/src/iso.c index 33ab2497..02be4c37 100644 --- a/src/iso.c +++ b/src/iso.c @@ -1383,8 +1383,10 @@ out: uprintf("Could not move %s → %s", path, dst_path, WindowsErrorString()); } } - if (fd_md5sum != NULL) + if (fd_md5sum != NULL) { + uprintf("Created: %s\\%s (%s)", dest_dir, md5sum_name[0], SizeToHumanReadable(ftell(fd_md5sum), FALSE, FALSE)); fclose(fd_md5sum); + } } iso9660_close(p_iso); udf_close(p_udf); diff --git a/src/localization_data.h b/src/localization_data.h index e556f339..6c308ffe 100644 --- a/src/localization_data.h +++ b/src/localization_data.h @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * Localization tables - autogenerated from resource.h - * Copyright © 2013-2021 Pete Batard + * Copyright © 2013-2024 Pete Batard * * 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 @@ -52,11 +52,10 @@ const loc_control_id control_id[] = { LOC_CTRL(IDC_TEST), LOC_CTRL(IDC_SELECT), LOC_CTRL(IDC_EXTENDED_LABEL), - LOC_CTRL(IDC_RUFUS_MBR), + LOC_CTRL(IDC_UEFI_MEDIA_VALIDATION), LOC_CTRL(IDC_TARGET_SYSTEM), LOC_CTRL(IDC_PERSISTENCE_SIZE), LOC_CTRL(IDC_PERSISTENCE_UNITS), - LOC_CTRL(IDC_DISK_ID), LOC_CTRL(IDC_OLD_BIOS_FIXES), LOC_CTRL(IDC_LIST_USB_HDD), LOC_CTRL(IDC_STATUS_TOOLBAR), @@ -510,6 +509,55 @@ const loc_control_id control_id[] = { LOC_CTRL(MSG_348), LOC_CTRL(MSG_349), LOC_CTRL(MSG_350), + LOC_CTRL(MSG_351), + LOC_CTRL(MSG_352), + LOC_CTRL(MSG_353), + LOC_CTRL(MSG_354), + LOC_CTRL(MSG_355), + LOC_CTRL(MSG_356), + LOC_CTRL(MSG_357), + LOC_CTRL(MSG_358), + LOC_CTRL(MSG_359), + LOC_CTRL(MSG_360), + LOC_CTRL(MSG_361), + LOC_CTRL(MSG_362), + LOC_CTRL(MSG_363), + LOC_CTRL(MSG_364), + LOC_CTRL(MSG_365), + LOC_CTRL(MSG_366), + LOC_CTRL(MSG_367), + LOC_CTRL(MSG_368), + LOC_CTRL(MSG_369), + LOC_CTRL(MSG_370), + LOC_CTRL(MSG_371), + LOC_CTRL(MSG_372), + LOC_CTRL(MSG_373), + LOC_CTRL(MSG_374), + LOC_CTRL(MSG_375), + LOC_CTRL(MSG_376), + LOC_CTRL(MSG_377), + LOC_CTRL(MSG_378), + LOC_CTRL(MSG_379), + LOC_CTRL(MSG_380), + LOC_CTRL(MSG_381), + LOC_CTRL(MSG_382), + LOC_CTRL(MSG_383), + LOC_CTRL(MSG_384), + LOC_CTRL(MSG_385), + LOC_CTRL(MSG_386), + LOC_CTRL(MSG_387), + LOC_CTRL(MSG_388), + LOC_CTRL(MSG_389), + LOC_CTRL(MSG_390), + LOC_CTRL(MSG_391), + LOC_CTRL(MSG_392), + LOC_CTRL(MSG_393), + LOC_CTRL(MSG_394), + LOC_CTRL(MSG_395), + LOC_CTRL(MSG_396), + LOC_CTRL(MSG_397), + LOC_CTRL(MSG_398), + LOC_CTRL(MSG_399), LOC_CTRL(MSG_MAX), LOC_CTRL(IDOK), LOC_CTRL(IDCANCEL), diff --git a/src/resource.h b/src/resource.h index 7166067f..90646d70 100644 --- a/src/resource.h +++ b/src/resource.h @@ -93,12 +93,11 @@ #define IDC_TEST 1013 #define IDC_SELECT 1014 #define IDC_EXTENDED_LABEL 1015 -#define IDC_RUFUS_MBR 1016 #define IDC_TARGET_SYSTEM 1017 #define IDC_PERSISTENCE_SIZE 1018 #define IDC_PERSISTENCE_UNITS 1019 -#define IDC_DISK_ID 1020 -#define IDC_OLD_BIOS_FIXES 1021 +#define IDC_OLD_BIOS_FIXES 1020 +#define IDC_UEFI_MEDIA_VALIDATION 1021 #define IDC_LIST_USB_HDD 1022 #define IDC_STATUS_TOOLBAR 1023 #define IDC_SAVE 1024 @@ -552,7 +551,56 @@ #define MSG_348 3348 #define MSG_349 3349 #define MSG_350 3350 -#define MSG_MAX 3351 +#define MSG_351 3351 +#define MSG_352 3352 +#define MSG_353 3353 +#define MSG_354 3354 +#define MSG_355 3355 +#define MSG_356 3356 +#define MSG_357 3357 +#define MSG_358 3358 +#define MSG_359 3359 +#define MSG_360 3360 +#define MSG_361 3361 +#define MSG_362 3362 +#define MSG_363 3363 +#define MSG_364 3364 +#define MSG_365 3365 +#define MSG_366 3366 +#define MSG_367 3367 +#define MSG_368 3368 +#define MSG_369 3369 +#define MSG_370 3370 +#define MSG_371 3371 +#define MSG_372 3372 +#define MSG_373 3373 +#define MSG_374 3374 +#define MSG_375 3375 +#define MSG_376 3376 +#define MSG_377 3377 +#define MSG_378 3378 +#define MSG_379 3379 +#define MSG_380 3380 +#define MSG_381 3381 +#define MSG_382 3382 +#define MSG_383 3383 +#define MSG_384 3384 +#define MSG_385 3385 +#define MSG_386 3386 +#define MSG_387 3387 +#define MSG_388 3388 +#define MSG_389 3389 +#define MSG_390 3390 +#define MSG_391 3391 +#define MSG_392 3392 +#define MSG_393 3393 +#define MSG_394 3394 +#define MSG_395 3395 +#define MSG_396 3396 +#define MSG_397 3397 +#define MSG_398 3398 +#define MSG_399 3399 +#define MSG_MAX 3400 // Next default values for new objects // diff --git a/src/rufus.c b/src/rufus.c index 920bacb8..e8035da1 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -86,7 +86,6 @@ static int64_t last_iso_blocking_status; static int selected_pt = -1, selected_fs = FS_UNKNOWN, preselected_fs = FS_UNKNOWN; static int image_index = 0, select_index = 0; static RECT relaunch_rc = { -65536, -65536, 0, 0}; -static UINT uMBRChecked = BST_UNCHECKED; static HWND hSelectImage = NULL, hStart = NULL; static char szTimer[12] = "00:00:00"; static unsigned int timer; @@ -120,7 +119,7 @@ loc_cmd* selected_locale = NULL; WORD selected_langid = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); DWORD MainThreadId; HWND hDeviceList, hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog = NULL; -HWND hImageOption, hLogDialog = NULL, hProgress = NULL, hDiskID; +HWND hImageOption, hLogDialog = NULL, hProgress = NULL; HANDLE dialog_handle = NULL, format_thread = NULL; BOOL is_x86_64, use_own_c32[NB_OLD_C32] = { FALSE, FALSE }, mbr_selected_by_user = FALSE, lock_drive = TRUE; BOOL op_in_progress = TRUE, right_to_left_mode = FALSE, has_uefi_csm = FALSE, its_a_me_mario = FALSE; @@ -130,7 +129,7 @@ BOOL usb_debug, use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALS BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE; BOOL write_as_image = FALSE, write_as_esp = FALSE, use_vds = FALSE, ignore_boot_marker = FALSE; BOOL appstore_version = FALSE, is_vds_available = TRUE, persistent_log = FALSE, has_ffu_support = FALSE; -BOOL expert_mode = FALSE; +BOOL expert_mode = FALSE, use_rufus_mbr = TRUE; float fScale = 1.0f; int dialog_showing = 0, selection_default = BT_IMAGE, persistence_unit_selection = -1, imop_win_sel = 0; int default_fs, fs_type, boot_type, partition_type, target_type; @@ -214,11 +213,6 @@ static void SetAllowedFileSystems(void) allowed_filesystem[FS_EXFAT] = TRUE; break; } - - // Reset disk ID to 0x80 if Rufus MBR is used - if (selection_default != BT_IMAGE) { - IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); - } } // Populate the Boot selection dropdown @@ -246,10 +240,8 @@ static void SetBootOptions(void) "Grub4DOS " GRUB4DOS_VERSION), BT_GRUB4DOS)); IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "UEFI:NTFS"), BT_UEFI_NTFS)); } - if ((!advanced_mode_device) && (selection_default >= BT_SYSLINUX_V4)) { + if ((!advanced_mode_device) && (selection_default >= BT_SYSLINUX_V4)) selection_default = BT_IMAGE; - CheckDlgButton(hMainDialog, IDC_DISK_ID, BST_UNCHECKED); - } SetComboEntry(hBootType, selection_default); } @@ -681,24 +673,6 @@ static void SetFSFromISO(void) ComboBox_GetCurSel(hFileSystem)); } -static void SetMBRProps(void) -{ - BOOL needs_masquerading = HAS_WINPE(img_report) && (!img_report.uses_minint); - fs_type = (int)ComboBox_GetCurItemData(hFileSystem); - - if ((!mbr_selected_by_user) && ((image_path == NULL) || (boot_type != BT_IMAGE) || (fs_type != FS_NTFS) || HAS_GRUB(img_report) || - ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurItemData(hImageOption) == IMOP_WIN_TO_GO)) )) { - CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, BST_UNCHECKED); - IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); - return; - } - - uMBRChecked = (needs_masquerading || HAS_BOOTMGR(img_report) || mbr_selected_by_user)?BST_CHECKED:BST_UNCHECKED; - if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_RUFUS_MBR))) - CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, uMBRChecked); - IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, needs_masquerading?1:0)); -} - static void SetProposedLabel(int ComboIndex) { const char no_label[] = STR_NO_LABEL, empty[] = ""; @@ -730,45 +704,49 @@ static void SetProposedLabel(int ComboIndex) } } -// This handles the enabling/disabling of the "Add fixes for old BIOSes" and "Use Rufus MBR" controls -static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes) +static void EnableOldBiosFixes(BOOL enable, BOOL remove_checkboxes) { - BOOL actual_enable_mbr = (boot_type > BT_IMAGE) ? FALSE: enable; - BOOL actual_enable_fix = enable; - static UINT uXPartChecked = BST_UNCHECKED; + static UINT checked, state = 0; + HWND hCtrl = GetDlgItem(hMainDialog, IDC_OLD_BIOS_FIXES); + // The fix for old BIOSes option cannot apply if we aren't targetting BIOS, or are using an image that isn't BIOS bootable if ((partition_type != PARTITION_STYLE_MBR) || (target_type != TT_BIOS) || (boot_type == BT_NON_BOOTABLE) || ((boot_type == BT_IMAGE) && (!IS_BIOS_BOOTABLE(img_report) || IS_DD_ONLY(img_report)))) { - // These options cannot apply if we aren't using MBR+BIOS, or are using an image that isn't BIOS bootable - actual_enable_mbr = FALSE; - actual_enable_fix = FALSE; - } else { - // If we are using an image, the Rufus MBR only applies if it's for Windows - if ((boot_type == BT_IMAGE) && !HAS_WINPE(img_report) && !HAS_BOOTMGR(img_report)) { - actual_enable_mbr = FALSE; - mbr_selected_by_user = FALSE; - } + enable = FALSE; } if (remove_checkboxes) { - // Store/Restore the checkbox states - if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_RUFUS_MBR)) && !actual_enable_mbr) { - uMBRChecked = IsChecked(IDC_RUFUS_MBR); - CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, BST_UNCHECKED); - } else if (!IsWindowEnabled(GetDlgItem(hMainDialog, IDC_RUFUS_MBR)) && actual_enable_mbr) { - CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, uMBRChecked); - } - if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_OLD_BIOS_FIXES)) && !actual_enable_fix) { - uXPartChecked = IsChecked(IDC_OLD_BIOS_FIXES); + if (!enable && (state != 1)) { + checked = IsChecked(IDC_OLD_BIOS_FIXES); CheckDlgButton(hMainDialog, IDC_OLD_BIOS_FIXES, BST_UNCHECKED); - } else if (!IsWindowEnabled(GetDlgItem(hMainDialog, IDC_OLD_BIOS_FIXES)) && actual_enable_fix) { - CheckDlgButton(hMainDialog, IDC_OLD_BIOS_FIXES, uXPartChecked); + state = 1; + } else if (enable && !IsWindowEnabled(hCtrl) && (state != 2)) { + if (state != 0) + CheckDlgButton(hMainDialog, IDC_OLD_BIOS_FIXES, checked); + state = 2; } } + EnableWindow(hCtrl, enable); +} - EnableWindow(GetDlgItem(hMainDialog, IDC_OLD_BIOS_FIXES), actual_enable_fix); - EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), actual_enable_mbr); - EnableWindow(hDiskID, actual_enable_mbr); +static void EnableUefiValidation(BOOL enable, BOOL remove_checkboxes) +{ + UINT checked = validate_md5sum ? BST_CHECKED : BST_UNCHECKED; + HWND hCtrl = GetDlgItem(hMainDialog, IDC_UEFI_MEDIA_VALIDATION); + + // The UEFI validation bootloader cannot apply if we don't write an ISO, or if the ISO is not UEFI bootable + // or if it's a Windows To Go installation or if DD or BIOS/CSM only are enforced. + if ((boot_type != BT_IMAGE) || (!IS_EFI_BOOTABLE(img_report)) || IS_DD_ONLY(img_report) || + ((image_options & IMOP_WINTOGO) && (ComboBox_GetCurItemData(hImageOption) == IMOP_WIN_TO_GO)) || + ((target_type == TT_BIOS) && HAS_WINDOWS(img_report) && (!allow_dual_uefi_bios))) { + enable = FALSE; + } + + if (!enable && remove_checkboxes) + CheckDlgButton(hMainDialog, IDC_UEFI_MEDIA_VALIDATION, BST_UNCHECKED); + else + CheckDlgButton(hMainDialog, IDC_UEFI_MEDIA_VALIDATION, checked); + EnableWindow(hCtrl, enable); } static void EnableExtendedLabel(BOOL enable, BOOL remove_checkboxes) @@ -847,7 +825,8 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes) SetPersistenceSize(); EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), (persistence_size != 0) && actual_enable); EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS), (persistence_size != 0) && actual_enable); - EnableMBRBootOptions(actual_enable, remove_checkboxes); + EnableOldBiosFixes(actual_enable, remove_checkboxes); + EnableUefiValidation(actual_enable, remove_checkboxes); EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), actual_enable); if (boot_type == BT_IMAGE) { @@ -1302,7 +1281,6 @@ DWORD WINAPI ImageScanThread(LPVOID param) safe_free(image_path); SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0); UpdateImage(FALSE); - SetMBRProps(); PopulateProperties(); PrintInfoDebug(0, MSG_203); PrintStatus(0, MSG_203); @@ -1376,7 +1354,6 @@ DWORD WINAPI ImageScanThread(LPVOID param) MessageBoxExU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK | MB_ICONINFORMATION | MB_IS_RTL, selected_langid); PrintStatus(0, MSG_086); EnableControls(TRUE, FALSE); - SetMBRProps(); } else { if (!dont_display_image_name) { for (i = (int)safe_strlen(image_path); (i > 0) && (image_path[i] != '\\'); i--); @@ -1395,7 +1372,6 @@ DWORD WINAPI ImageScanThread(LPVOID param) SetPartitionSchemeAndTargetSystem(FALSE); SetFileSystemAndClusterSize(NULL); SetFSFromISO(); - SetMBRProps(); user_changed_label = FALSE; SetProposedLabel(ComboBox_GetCurSel(hDeviceList)); } else { @@ -1441,7 +1417,6 @@ static DWORD WINAPI BootCheckThread(LPVOID param) syslinux_ldlinux_len[0] = 0; syslinux_ldlinux_len[1] = 0; is_bootloader_revoked = FALSE; - validate_md5sum = FALSE; safe_free(grub2_buf); if (ComboBox_GetCurSel(hDeviceList) == CB_ERR) @@ -1568,9 +1543,6 @@ static DWORD WINAPI BootCheckThread(LPVOID param) ShellExecuteA(hMainDialog, "open", SEVENZIP_URL, NULL, NULL, SW_SHOWNORMAL); goto out; } - // TODO: Move this option to a user selection - validate_md5sum = TRUE; - uprintf("Will add runtime UEFI media validation through 'md5sum.txt'"); } else if ( ((fs_type == FS_NTFS) && !HAS_WINDOWS(img_report) && !HAS_GRUB(img_report) && (!HAS_SYSLINUX(img_report) || (SL_MAJOR(img_report.sl_version) <= 5))) || ((IS_FAT(fs_type)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && !IS_EFI_BOOTABLE(img_report) && @@ -1980,7 +1952,6 @@ static void InitDialog(HWND hDlg) hImageOption = GetDlgItem(hDlg, IDC_IMAGE_OPTION); hSelectImage = GetDlgItem(hDlg, IDC_SELECT); hNBPasses = GetDlgItem(hDlg, IDC_NB_PASSES); - hDiskID = GetDlgItem(hDlg, IDC_DISK_ID); hStart = GetDlgItem(hDlg, IDC_START); // Convert the main button labels to uppercase @@ -2009,7 +1980,6 @@ static void InitDialog(HWND hDlg) // Set some missing labels SetAccessibleName(hNBPasses, lmprintf(MSG_316)); - SetAccessibleName(hDiskID, lmprintf(MSG_317)); // Create the font and brush for the progress messages hInfoFont = CreateFontA(lfHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, @@ -2107,13 +2077,6 @@ static void InitDialog(HWND hDlg) // Fill up the boot options dropdown SetBootOptions(); - // Fill up the MBR masqueraded disk IDs ("8 disks should be enough for anybody") - IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_030, LEFT_TO_RIGHT_EMBEDDING "0x80" POP_DIRECTIONAL_FORMATTING)), 0x80)); - for (i=1; i<=7; i++) { - IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_109, 0x80+i, i+1)), 0x80+i)); - } - IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); - // Create the string arrays StrArrayCreate(&BlockingProcessList, 16); StrArrayCreate(&ImageList, 16); @@ -2143,8 +2106,7 @@ static void InitDialog(HWND hDlg) CreateTooltip(hBootType, lmprintf(MSG_164), -1); CreateTooltip(hSelectImage, lmprintf(MSG_165), -1); CreateTooltip(GetDlgItem(hDlg, IDC_EXTENDED_LABEL), lmprintf(MSG_166), 10000); - CreateTooltip(GetDlgItem(hDlg, IDC_RUFUS_MBR), lmprintf(MSG_167), 10000); - CreateTooltip(hDiskID, lmprintf(MSG_168), 10000); + CreateTooltip(GetDlgItem(hDlg, IDC_UEFI_MEDIA_VALIDATION), lmprintf(MSG_167), 10000); CreateTooltip(GetDlgItem(hDlg, IDC_OLD_BIOS_FIXES), lmprintf(MSG_169), -1); CreateTooltip(GetDlgItem(hDlg, IDC_LIST_USB_HDD), lmprintf(MSG_170), -1); CreateTooltip(hStart, lmprintf(MSG_171), -1); @@ -2398,6 +2360,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; SetFileSystemAndClusterSize(NULL); imop_win_sel = ComboBox_GetCurSel(hImageOption); + EnableUefiValidation((imop_win_sel == 0), TRUE); break; case IDC_PERSISTENCE_SIZE: if (HIWORD(wParam) == EN_CHANGE) { @@ -2467,6 +2430,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA target_type = (int)ComboBox_GetCurItemData(hTargetSystem); SendMessage(hMainDialog, UM_UPDATE_CSM_TOOLTIP, 0, 0); SetFileSystemAndClusterSize(NULL); + EnableUefiValidation(TRUE, TRUE); break; case IDC_PARTITION_TYPE: if (HIWORD(wParam) != CBN_SELCHANGE) @@ -2474,8 +2438,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA partition_type = (int)ComboBox_GetCurItemData(hPartitionScheme); SetPartitionSchemeAndTargetSystem(TRUE); SetFileSystemAndClusterSize(NULL); - SetMBRProps(); - EnableMBRBootOptions(TRUE, TRUE); + EnableOldBiosFixes(TRUE, TRUE); + EnableUefiValidation(TRUE, TRUE); selected_pt = partition_type; break; case IDC_FILE_SYSTEM: @@ -2488,8 +2452,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA selected_fs = fs_type; // Some FS's (such as ReFS or Large FAT32) only have QuickFormat so make sure we reflect that EnableQuickFormat(TRUE, TRUE); - EnableMBRBootOptions(TRUE, TRUE); - SetMBRProps(); + EnableOldBiosFixes(TRUE, TRUE); EnableExtendedLabel(TRUE, TRUE); break; case IDC_BOOT_SELECTION: @@ -2560,9 +2523,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA } } break; - case IDC_RUFUS_MBR: - if ((HIWORD(wParam)) == BN_CLICKED) - mbr_selected_by_user = IsChecked(IDC_RUFUS_MBR); + case IDC_UEFI_MEDIA_VALIDATION: + if ((HIWORD(wParam)) == BN_CLICKED) { + validate_md5sum = IsChecked(IDC_UEFI_MEDIA_VALIDATION); + WriteSettingBool(SETTING_ENABLE_RUNTIME_VALIDATION, validate_md5sum); + } break; case IDC_LIST_USB_HDD: if ((HIWORD(wParam)) == BN_CLICKED) { @@ -3522,6 +3487,8 @@ skip_args_processing: use_vds = ReadSettingBool(SETTING_USE_VDS) && is_vds_available; usb_debug = ReadSettingBool(SETTING_ENABLE_USB_DEBUG); cdio_loglevel_default = usb_debug ? CDIO_LOG_DEBUG : CDIO_LOG_WARN; + use_rufus_mbr = !ReadSettingBool(SETTING_DISABLE_RUFUS_MBR); + validate_md5sum = ReadSettingBool(SETTING_ENABLE_RUNTIME_VALIDATION); detect_fakes = !ReadSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK); allow_dual_uefi_bios = ReadSettingBool(SETTING_ENABLE_WIN_DUAL_EFI_BIOS); force_large_fat32 = ReadSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT); @@ -3730,7 +3697,7 @@ relaunch: while(GetMessage(&msg, NULL, 0, 0)) { static BOOL ctrl_without_focus = FALSE; BOOL no_focus = (msg.message == WM_SYSKEYDOWN) && !(msg.lParam & 0x20000000); - // ** *************************** + // ****************************** // .,ABCDEFGHIJKLMNOPQRSTUVWXYZ+- // Sigh... The things one need to do to detect standalone use of the 'Alt' key. @@ -3822,6 +3789,13 @@ extern int TestHashes(void); PrintStatusTimeout(lmprintf(MSG_282), lock_drive); continue; } + // Alt-A => Toggle use of Rufus MBR for Windows boot + if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'A')) { + use_rufus_mbr = !use_rufus_mbr; + WriteSettingBool(SETTING_DISABLE_RUFUS_MBR, !use_rufus_mbr); + PrintStatusTimeout(lmprintf(MSG_349), use_rufus_mbr); + 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 72ddf8c9..b4f460c7 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -662,7 +662,7 @@ extern RUFUS_IMG_REPORT img_report; extern HINSTANCE hMainInstance; extern HWND hMainDialog, hLogDialog, hStatus, hDeviceList, hCapacity, hImageOption; extern HWND hPartitionScheme, hTargetSystem, hFileSystem, hClusterSize, hLabel, hBootType; -extern HWND hNBPasses, hLog, hInfo, hProgress, hDiskID; +extern HWND hNBPasses, hLog, hInfo, hProgress; extern WORD selected_langid; extern DWORD ErrorStatus, DownloadStatus, MainThreadId, LastWriteError; extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, op_in_progress, right_to_left_mode; diff --git a/src/rufus.rc b/src/rufus.rc index db1b85e5..b829733e 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -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 4.5.2122" +CAPTION "Rufus 4.5.2123" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -59,8 +59,8 @@ BEGIN CONTROL "List USB Hard Drives",IDC_LIST_USB_HDD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,119,216,10 CONTROL "Add fixes for old BIOSes (extra partition, align, etc.)",IDC_OLD_BIOS_FIXES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,129,216,10 - CONTROL "Use Rufus MBR with BIOS ID",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,139,110,10 - COMBOBOX IDC_DISK_ID,128,139,96,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Enable runtime UEFI media validation",IDC_UEFI_MEDIA_VALIDATION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,139,216,10 LTEXT "Format Options",IDS_FORMAT_OPTIONS_TXT,8,152,57,12,NOT WS_GROUP LTEXT "Volume label",IDS_LABEL_TXT,8,167,216,8 EDITTEXT IDC_LABEL,8,176,216,12,ES_AUTOHSCROLL @@ -397,8 +397,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,5,2122,0 - PRODUCTVERSION 4,5,2122,0 + FILEVERSION 4,5,2123,0 + PRODUCTVERSION 4,5,2123,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -416,13 +416,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.5.2122" + VALUE "FileVersion", "4.5.2123" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.5.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.5.2122" + VALUE "ProductVersion", "4.5.2123" END END BLOCK "VarFileInfo" diff --git a/src/settings.h b/src/settings.h index 0a95d1f6..734a9584 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * Settings access, through either registry or INI file - * Copyright © 2015-2023 Pete Batard + * Copyright © 2015-2024 Pete Batard * * 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 @@ -35,10 +35,12 @@ extern char* ini_file; #define SETTING_DEFAULT_THREAD_PRIORITY "DefaultThreadPriority" #define SETTING_DISABLE_FAKE_DRIVES_CHECK "DisableFakeDrivesCheck" #define SETTING_DISABLE_LGP "DisableLGP" +#define SETTING_DISABLE_RUFUS_MBR "DisableRufusMBR" #define SETTING_DISABLE_SECURE_BOOT_NOTICE "DisableSecureBootNotice" #define SETTING_DISABLE_VHDS "DisableVHDs" #define SETTING_ENABLE_EXTRA_HASHES "EnableExtraHashes" #define SETTING_ENABLE_FILE_INDEXING "EnableFileIndexing" +#define SETTING_ENABLE_RUNTIME_VALIDATION "EnableRuntimeValidation" #define SETTING_ENABLE_USB_DEBUG "EnableUsbDebug" #define SETTING_ENABLE_VMDK_DETECTION "EnableVmdkDetection" #define SETTING_ENABLE_WIN_DUAL_EFI_BIOS "EnableWindowsDualUefiBiosMode" diff --git a/src/ui.c b/src/ui.c index 2536f523..166e2b0a 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * UI-related function calls - * Copyright © 2018-2023 Pete Batard + * Copyright © 2018-2024 Pete Batard * * 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 @@ -223,9 +223,8 @@ void GetHalfDropwdownWidth(HWND hDlg) hw = max(hw, GetTextSize(GetDlgItem(hDlg, IDC_TARGET_SYSTEM), msg).cx); } - // Finally, we must ensure that we'll have enough space for the 2 checkbox controls + // Finally, we must ensure that we'll have enough space for the checkbox controls // that end up with a half dropdown - hw = max(hw, GetTextWidth(hDlg, IDC_RUFUS_MBR) - sw); hw = max(hw, GetTextWidth(hDlg, IDC_BAD_BLOCKS) - sw); // Add the width of a blank dropdown @@ -351,7 +350,7 @@ void PositionMainControls(HWND hDlg) GetWindowRect(hCtrl, &rc); MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2); advanced_device_section_height = rc.top; - hCtrl = GetDlgItem(hDlg, IDC_RUFUS_MBR); + hCtrl = GetDlgItem(hDlg, IDC_UEFI_MEDIA_VALIDATION); GetWindowRect(hCtrl, &rc); MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2); advanced_device_section_height = rc.bottom - advanced_device_section_height; @@ -474,10 +473,10 @@ void PositionMainControls(HWND hDlg) hCtrl = GetDlgItem(hDlg, half_width_ids[i]); GetWindowRect(hCtrl, &rc); MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2); - // First 5 controls are on the left handside + // First 4 controls are on the left handside // First 2 controls may overflow into separator hPrevCtrl = GetNextWindow(hCtrl, GW_HWNDPREV); - SetWindowPos(hCtrl, hPrevCtrl, (i < 5) ? rc.left : mw + hw + sw, rc.top, + SetWindowPos(hCtrl, hPrevCtrl, (i < 4) ? rc.left : mw + hw + sw, rc.top, (i <2) ? hw + sw : hw, rc.bottom - rc.top, 0); } diff --git a/src/ui_data.h b/src/ui_data.h index 9442ae5c..be33e8c1 100644 --- a/src/ui_data.h +++ b/src/ui_data.h @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * UI element lists - * Copyright © 2018-2020 Pete Batard + * Copyright © 2018-2024 Pete Batard * * 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 @@ -49,8 +49,7 @@ static int image_option_move_ids[] = { IDC_ADVANCED_DEVICE_TOOLBAR, IDC_LIST_USB_HDD, IDC_OLD_BIOS_FIXES, - IDC_RUFUS_MBR, - IDC_DISK_ID, + IDC_UEFI_MEDIA_VALIDATION, IDS_FORMAT_OPTIONS_TXT, IDS_LABEL_TXT, IDC_LABEL, @@ -86,7 +85,7 @@ static int image_option_toggle_ids[][2] = { static int advanced_device_move_ids[] = { IDC_LIST_USB_HDD, IDC_OLD_BIOS_FIXES, - IDC_RUFUS_MBR, + IDC_UEFI_MEDIA_VALIDATION, IDS_FORMAT_OPTIONS_TXT, IDS_LABEL_TXT, IDC_LABEL, @@ -115,8 +114,7 @@ static int advanced_device_toggle_ids[] = { IDC_SAVE_TOOLBAR, IDC_LIST_USB_HDD, IDC_OLD_BIOS_FIXES, - IDC_RUFUS_MBR, - IDC_DISK_ID, + IDC_UEFI_MEDIA_VALIDATION, }; static int advanced_format_move_ids[] = { @@ -155,6 +153,7 @@ static int full_width_controls[] = { IDC_ADVANCED_DRIVE_PROPERTIES, IDC_LIST_USB_HDD, IDC_OLD_BIOS_FIXES, + IDC_UEFI_MEDIA_VALIDATION, IDC_ADVANCED_FORMAT_OPTIONS, IDC_QUICK_FORMAT, IDC_EXTENDED_LABEL, @@ -164,19 +163,18 @@ static int full_width_controls[] = { static int full_width_checkboxes[] = { IDC_LIST_USB_HDD, IDC_OLD_BIOS_FIXES, + IDC_UEFI_MEDIA_VALIDATION, IDC_QUICK_FORMAT, IDC_EXTENDED_LABEL, }; static int half_width_ids[] = { IDC_BAD_BLOCKS, - IDC_RUFUS_MBR, IDS_PARTITION_TYPE_TXT, IDC_PARTITION_TYPE, IDC_FILE_SYSTEM, IDS_TARGET_SYSTEM_TXT, IDC_TARGET_SYSTEM, - IDC_DISK_ID, IDS_CLUSTER_SIZE_TXT, IDC_CLUSTER_SIZE, IDC_NB_PASSES, @@ -190,7 +188,7 @@ static int adjust_dpi_ids[][5] = { { IDC_ADVANCED_DEVICE_TOOLBAR, 0, 0, 0, 0 }, { IDC_LIST_USB_HDD, 0, 0, 0, 0 }, { IDC_OLD_BIOS_FIXES, 0, 0, 0, 0 }, - { IDC_RUFUS_MBR, IDC_DISK_ID, 0, 0, 0 }, + { IDC_UEFI_MEDIA_VALIDATION, 0, 0, 0, 0 }, { IDS_FORMAT_OPTIONS_TXT, 0, 0, 0, 0 }, { IDS_LABEL_TXT, IDC_LABEL, 0, 0, 0 }, { IDS_FILE_SYSTEM_TXT, IDC_FILE_SYSTEM, IDS_CLUSTER_SIZE_TXT, IDC_CLUSTER_SIZE, 0 }, diff --git a/src/wue.c b/src/wue.c index 01dec290..150b2ba8 100644 --- a/src/wue.c +++ b/src/wue.c @@ -258,10 +258,10 @@ BOOL SetupWinPE(char drive_letter) const char* patch_str_org[2] = { "\\minint\\txtsetup.sif", "\\minint\\system32\\" }; const char* patch_str_rep[2][2] = { { "\\i386\\txtsetup.sif", "\\i386\\system32\\" } , { "\\amd64\\txtsetup.sif", "\\amd64\\system32\\" } }; + const char* setupsrcdev = "SetupSourceDevice = \"\\device\\harddisk1\\partition1\""; const char* win_nt_bt_org = "$win_nt$.~bt"; const char* rdisk_zero = "rdisk(0)"; const LARGE_INTEGER liZero = { {0, 0} }; - char setupsrcdev[64]; HANDLE handle = INVALID_HANDLE_VALUE; DWORD i, j, size, read_size, index = 0; BOOL r = FALSE; @@ -271,9 +271,6 @@ BOOL SetupWinPE(char drive_letter) index = 1; else if ((img_report.winpe & WINPE_MININT) == WINPE_MININT) index = 2; - // Allow other values than harddisk 1, as per user choice for disk ID - static_sprintf(setupsrcdev, "SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"", - ComboBox_GetCurSel(hDiskID)); // Copy of ntdetect.com in root static_sprintf(src, "%c:\\%s\\ntdetect.com", toupper(drive_letter), basedir[2 * (index / 2)]); static_sprintf(dst, "%c:\\ntdetect.com", toupper(drive_letter)); @@ -359,7 +356,7 @@ BOOL SetupWinPE(char drive_letter) // rdisk(0) -> rdisk(#) disk masquerading // NB: only the first one seems to be needed if (safe_strnicmp(&buffer[i], rdisk_zero, strlen(rdisk_zero) - 1) == 0) { - buffer[i + 6] = 0x30 + ComboBox_GetCurSel(hDiskID); + buffer[i + 6] = 0x31; uprintf(" 0x%08X: '%s' -> 'rdisk(%c)'\n", i, rdisk_zero, buffer[i + 6]); } // $WIN_NT$_~BT -> i386/amd64