diff --git a/src/format.c b/src/format.c index a5516115..f7619929 100644 --- a/src/format.c +++ b/src/format.c @@ -916,7 +916,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) // What follows is really a case statement with complex conditions listed // by order of preference - if (IS_WINDOWS(img_report) && (allow_dual_uefi_bios) && (tt == TT_BIOS)) + if (HAS_WINDOWS(img_report) && (allow_dual_uefi_bios) && (tt == TT_BIOS)) goto windows_mbr; // Forced UEFI (by zeroing the MBR) @@ -956,7 +956,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) } // KolibriOS - if ( (bt == BT_ISO) && (img_report.has_kolibrios) && (IS_FAT(fs))) { + if ( (bt == BT_ISO) && HAS_KOLIBRIOS(img_report) && (IS_FAT(fs))) { uprintf(using_msg, "KolibriOS"); r = write_kolibrios_mbr(fp); goto notify; @@ -964,7 +964,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) // If everything else failed, fall back to a conventional Windows/Rufus MBR windows_mbr: - if ((IS_WINPE(img_report.winpe) && !img_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) { + if ((HAS_WINPE(img_report) && !img_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) { uprintf(using_msg, APPLICATION_NAME); r = write_rufus_mbr(fp); } else { @@ -1056,7 +1056,7 @@ static __inline const char* bt_to_name(int bt) { case BT_FREEDOS: return "FreeDOS"; case BT_REACTOS: return "ReactOS"; default: - return ((bt==BT_ISO)&&(img_report.has_kolibrios))?"KolibriOS":"Standard"; + return ((bt==BT_ISO) && HAS_KOLIBRIOS(img_report)) ? "KolibriOS" : "Standard"; } } static BOOL WritePBR(HANDLE hLogicalVolume) @@ -1082,7 +1082,7 @@ static BOOL WritePBR(HANDLE hLogicalVolume) if (!write_fat_16_fd_br(fp, 0)) break; } else if (bt == BT_REACTOS) { if (!write_fat_16_ros_br(fp, 0)) break; - } else if ((bt == BT_ISO) && (img_report.has_kolibrios)) { + } else if ((bt == BT_ISO) && HAS_KOLIBRIOS(img_report)) { uprintf("FAT16 is not supported for KolibriOS\n"); break; } else { if (!write_fat_16_br(fp, 0)) break; @@ -1104,7 +1104,7 @@ static BOOL WritePBR(HANDLE hLogicalVolume) if (!write_fat_32_fd_br(fp, 0)) break; } else if (bt == BT_REACTOS) { if (!write_fat_32_ros_br(fp, 0)) break; - } else if ((bt == BT_ISO) && (img_report.has_kolibrios)) { + } else if ((bt == BT_ISO) && HAS_KOLIBRIOS(img_report)) { if (!write_fat_32_kos_br(fp, 0)) break; } else { if (!write_fat_32_br(fp, 0)) break; @@ -1598,7 +1598,7 @@ DWORD WINAPI FormatThread(void* param) pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); use_large_fat32 = (fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)); - windows_to_go = (togo_mode) && HAS_TOGO(img_report) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED); + windows_to_go = (togo_mode) && HAS_WINTOGO(img_report) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED); large_drive = (SelectedDrive.DiskSize > (1*TB)); if (large_drive) uprintf("Notice: Large drive detected (may produce short writes)"); @@ -1608,7 +1608,7 @@ DWORD WINAPI FormatThread(void* param) // http://msdn.microsoft.com/en-us/library/windows/hardware/dn640535.aspx#gpt_faq_what_disk_require_msr extra_partitions = XP_MSR | XP_EFI; else if ( (fs == FS_NTFS) && ((bt == BT_UEFI_NTFS) || - ((bt == BT_ISO) && (img_report.has_efi) && ((tt == TT_UEFI) || (windows_to_go) || (allow_dual_uefi_bios)))) ) + ((bt == BT_ISO) && IS_EFI_BOOTABLE(img_report) && ((tt == TT_UEFI) || (windows_to_go) || (allow_dual_uefi_bios)))) ) extra_partitions = XP_UEFI_NTFS; else if (IsChecked(IDC_EXTRA_PARTITION)) extra_partitions = XP_COMPAT; @@ -1883,14 +1883,14 @@ DWORD WINAPI FormatThread(void* param) // All good } else if (tt == TT_UEFI) { // For once, no need to do anything - just check our sanity - if ( (bt != BT_ISO) || (!img_report.has_efi) || (fs > FS_NTFS) ) { + if ( (bt != BT_ISO) || !IS_EFI_BOOTABLE(img_report) || (fs > FS_NTFS) ) { uprintf("Spock gone crazy error in %s:%d", __FILE__, __LINE__); FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; goto out; } } else if ( (bt == BT_SYSLINUX_V4) || (bt == BT_SYSLINUX_V6) || - ((bt == BT_ISO) && (HAS_SYSLINUX(img_report) || IS_REACTOS(img_report)) && - (!IS_WINDOWS(img_report) || !allow_dual_uefi_bios) && (IS_FAT(fs))) ) { + ((bt == BT_ISO) && (HAS_SYSLINUX(img_report) || HAS_REACTOS(img_report)) && + (!HAS_WINDOWS(img_report) || !allow_dual_uefi_bios) && (IS_FAT(fs))) ) { if (!InstallSyslinux(DriveIndex, drive_name[0], fs)) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; } @@ -1960,7 +1960,7 @@ DWORD WINAPI FormatThread(void* param) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_ISO_EXTRACT); goto out; } - if (img_report.has_kolibrios) { + if (HAS_KOLIBRIOS(img_report)) { kolibri_dst[0] = drive_name[0]; uprintf("Installing: %s (KolibriOS loader)\n", kolibri_dst); if (ExtractISOFile(image_path, "HD_Load/USB_Boot/MTLD_F32", kolibri_dst, @@ -1969,7 +1969,7 @@ DWORD WINAPI FormatThread(void* param) } } // EFI mode selected, with no 'boot###.efi' but Windows 7 x64's 'bootmgr.efi' (bit #0) - if ((tt == TT_UEFI) && IS_WIN7_EFI(img_report)) { + if ((tt == TT_UEFI) && HAS_WIN7_EFI(img_report)) { PrintInfoDebug(0, MSG_232); img_report.install_wim_path[0] = drive_name[0]; efi_dst[0] = drive_name[0]; @@ -1985,7 +1985,7 @@ DWORD WINAPI FormatThread(void* param) } } } - if ( (tt == TT_BIOS) && (IS_WINPE(img_report.winpe)) ) { + if ( (tt == TT_BIOS) && HAS_WINPE(img_report) ) { // Apply WinPe fixup if (!SetupWinPE(drive_name[0])) FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_PATCH); diff --git a/src/iso.c b/src/iso.c index 9da84280..cfca7d51 100644 --- a/src/iso.c +++ b/src/iso.c @@ -835,7 +835,7 @@ out: img_report.sl_version_str); } } - if (IS_WINPE(img_report.winpe)) { + if (HAS_WINPE(img_report)) { // In case we have a WinPE 1.x based iso, we extract and parse txtsetup.sif // during scan, to see if /minint was provided for OsLoadOptions, as it decides // whether we should use 0x80 or 0x81 as the disk ID in the MBR diff --git a/src/rufus.c b/src/rufus.c index 1487e022..3aaa343f 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -363,25 +363,36 @@ static BOOL SetClusterSizes(int FSType) // This call sets the first option for the "partition type and target system" field // according to whether we will be running in UEFI/CSM mode or standard UEFI -static void SetMBRForUEFI(BOOL replace) +// Return value is -1 if the image is pure EFI (non BIOS bootable), 0 otherwise. +static int SetMBRForUEFI(BOOL replace) { + static BOOL pure_efi = FALSE; BOOL useCSM = FALSE; if (ComboBox_GetCurSel(hDeviceList) < 0) - return; + return 0; if (image_path != NULL) { - if ( (!img_report.has_efi) || ((img_report.has_bootmgr) && (!allow_dual_uefi_bios) && + if ( !IS_EFI_BOOTABLE(img_report) || (HAS_BOOTMGR(img_report) && (!allow_dual_uefi_bios) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) != BST_CHECKED)) ) useCSM = TRUE; } - if (replace) + if (replace && !pure_efi) ComboBox_DeleteString(hPartitionScheme, 0); + + if ((image_path != NULL) && IS_EFI_BOOTABLE(img_report) && !IS_BIOS_BOOTABLE(img_report)) { + pure_efi = TRUE; + return -1; + } else { + pure_efi = FALSE; + } + IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, ComboBox_InsertStringU(hPartitionScheme, 0, lmprintf(MSG_031, PartitionTypeLabel[PARTITION_STYLE_MBR], useCSM?"UEFI-CSM":"UEFI")), (TT_BIOS<<16)|PARTITION_STYLE_MBR)); if (replace) IGNORE_RETVAL(ComboBox_SetCurSel(hPartitionScheme, max(ComboBox_GetCurSel(hPartitionScheme), 0))); + return 0; } /* @@ -457,7 +468,7 @@ static void SetFSFromISO(void) int i, fs, selected_fs = FS_UNKNOWN; uint32_t fs_mask = 0; int tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); - BOOL windows_to_go = (togo_mode) && HAS_TOGO(img_report) && + BOOL windows_to_go = (togo_mode) && HAS_WINTOGO(img_report) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED); if (image_path == NULL) @@ -470,14 +481,14 @@ static void SetFSFromISO(void) } // Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type) - if ((HAS_SYSLINUX(img_report)) || (IS_REACTOS(img_report)) || (img_report.has_kolibrios) || - ((img_report.has_efi) && (tt == TT_UEFI) && (!img_report.has_4GB_file) && (!windows_to_go))) { + if ((HAS_SYSLINUX(img_report)) || (HAS_REACTOS(img_report)) || HAS_KOLIBRIOS(img_report) || + (IS_EFI_BOOTABLE(img_report) && (tt == TT_UEFI) && (!img_report.has_4GB_file) && (!windows_to_go))) { if (fs_mask & (1<> 24) & 0xff, (img_report.install_wim_version >> 16) & 0xff, (img_report.install_wim_version >> 8) & 0xff); @@ -989,7 +997,7 @@ static void DisplayISOProps(void) // We don't support ToGo on Windows 7 or earlier, for lack of native ISO mounting capabilities if (nWindowsVersion >= WINDOWS_8) - if ( ((!togo_mode) && (HAS_TOGO(img_report))) || ((togo_mode) && (!HAS_TOGO(img_report))) ) + if ( ((!togo_mode) && (HAS_WINTOGO(img_report))) || ((togo_mode) && (!HAS_WINTOGO(img_report))) ) ToggleToGo(); } @@ -1026,8 +1034,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) if (img_report.is_iso) { DisplayISOProps(); // If we have an ISOHybrid, but without an ISO method we support, disable ISO support altogether - if ((img_report.is_bootable_img) && (!img_report.has_bootmgr) && (!HAS_SYSLINUX(img_report)) && (!IS_WINPE(img_report.winpe)) - && (!IS_GRUB(img_report)) && (!img_report.has_efi) && (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios)) { + if (IS_DD_BOOTABLE(img_report) && !IS_BIOS_BOOTABLE(img_report) && !IS_EFI_BOOTABLE(img_report)) { uprintf("This ISOHybrid is not compatible with any of the ISO boot methods we support"); img_report.is_iso = FALSE; } else { @@ -1037,8 +1044,7 @@ DWORD WINAPI ISOScanThread(LPVOID param) } // Only enable AFTER we have determined the image type EnableControls(TRUE); - if ( (!img_report.has_bootmgr) && (!HAS_SYSLINUX(img_report)) && (!IS_WINPE(img_report.winpe)) && (!IS_GRUB(img_report)) - && (!img_report.has_efi) && (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios) && (!img_report.is_bootable_img) ) { + if (!IS_DD_BOOTABLE(img_report) && !IS_BIOS_BOOTABLE(img_report) && !IS_EFI_BOOTABLE(img_report)) { // No boot method that we support PrintInfo(0, MSG_081); safe_free(image_path); @@ -1274,10 +1280,10 @@ static BOOL BootCheck(void) return FALSE; } if (bt == BT_IMG) { - if (!img_report.is_bootable_img) + if (!IS_DD_BOOTABLE(img_report)) // The selected image doesn't match the boot option selected. MessageBoxExU(hMainDialog, lmprintf(MSG_188), lmprintf(MSG_187), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); - return (img_report.is_bootable_img); + return IS_DD_BOOTABLE(img_report); } fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); @@ -1299,25 +1305,25 @@ static BOOL BootCheck(void) return FALSE; } } else if (tt == TT_UEFI) { - if (!img_report.has_efi) { + if (!IS_EFI_BOOTABLE(img_report)) { // Unsupported ISO MessageBoxExU(hMainDialog, lmprintf(MSG_091), lmprintf(MSG_090), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; } - if (IS_WIN7_EFI(img_report) && (!WimExtractCheck())) { + if (HAS_WIN7_EFI(img_report) && (!WimExtractCheck())) { // Your platform cannot extract files from WIM archives => download 7-zip? if (MessageBoxExU(hMainDialog, lmprintf(MSG_102), lmprintf(MSG_101), MB_YESNO|MB_ICONERROR|MB_IS_RTL, selected_langid) == IDYES) ShellExecuteA(hMainDialog, "open", SEVENZIP_URL, NULL, NULL, SW_SHOWNORMAL); return FALSE; } - } else if ( ((fs == FS_NTFS) && (!IS_WINDOWS(img_report)) && (!IS_GRUB(img_report))) - || ((IS_FAT(fs)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && (!img_report.has_efi) && - (!IS_REACTOS(img_report)) && (!img_report.has_kolibrios) && (!IS_GRUB(img_report))) - || ((IS_FAT(fs)) && (IS_WINDOWS(img_report) || HAS_INSTALL_WIM(img_report))) ) { + } else if ( ((fs == FS_NTFS) && (!HAS_WINDOWS(img_report)) && (!HAS_GRUB(img_report))) + || ((IS_FAT(fs)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && !IS_EFI_BOOTABLE(img_report) && + (!HAS_REACTOS(img_report)) && !HAS_KOLIBRIOS(img_report) && (!HAS_GRUB(img_report))) + || ((IS_FAT(fs)) && (HAS_WINDOWS(img_report) || HAS_INSTALL_WIM(img_report))) ) { // Incompatible FS and ISO MessageBoxExU(hMainDialog, lmprintf(MSG_096), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; - } else if ((fs == FS_FAT16) && (img_report.has_kolibrios)) { + } else if ((fs == FS_FAT16) && HAS_KOLIBRIOS(img_report)) { // KolibriOS doesn't support FAT16 MessageBoxExU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid); return FALSE; diff --git a/src/rufus.h b/src/rufus.h index bd1ab458..4bbdcfa4 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -249,14 +249,19 @@ enum checksum_type { #define WINPE_MININT 0x2A #define WINPE_I386 0x15 #define MAX_WIM_VERSION 0x000E0000 +#define HAS_KOLIBRIOS(r) (r.has_kolibrios) +#define HAS_REACTOS(r) (r.reactos_path[0] != 0) +#define HAS_GRUB(r) ((r.has_grub2) || (r.has_grub4dos)) #define HAS_SYSLINUX(r) (r.sl_version != 0) +#define HAS_BOOTMGR(r) (r.has_bootmgr) #define HAS_INSTALL_WIM(r) (r.install_wim_path[0] != 0) -#define HAS_TOGO(r) (r.has_bootmgr && r.has_efi && HAS_INSTALL_WIM(r) && (r.install_wim_version < MAX_WIM_VERSION)) -#define IS_WINPE(r) (((r & WINPE_MININT) == WINPE_MININT)||(( r & WINPE_I386) == WINPE_I386)) -#define IS_WINDOWS(r) ((r.has_bootmgr) || (r.uses_minint) || IS_WINPE(r.winpe)) -#define IS_WIN7_EFI(r) ((r.has_efi == 1) && HAS_INSTALL_WIM(r)) -#define IS_REACTOS(r) (r.reactos_path[0] != 0) -#define IS_GRUB(r) ((r.has_grub2) || (r.has_grub4dos)) +#define HAS_WINPE(r) (((r.winpe & WINPE_MININT) == WINPE_MININT)||((r.winpe & WINPE_I386) == WINPE_I386)) +#define HAS_WINDOWS(r) (HAS_BOOTMGR(r) || (r.uses_minint) || HAS_WINPE(r)) +#define HAS_WIN7_EFI(r) ((r.has_efi == 1) && HAS_INSTALL_WIM(r)) +#define IS_DD_BOOTABLE(r) (r.is_bootable_img) +#define IS_EFI_BOOTABLE(r) (r.has_efi) +#define IS_BIOS_BOOTABLE(r) (HAS_BOOTMGR(r) || HAS_SYSLINUX(r) || HAS_WINPE(r) || HAS_GRUB(r) || HAS_REACTOS(r) || HAS_KOLIBRIOS(r)) +#define HAS_WINTOGO(r) (HAS_BOOTMGR(r) && IS_EFI_BOOTABLE(r) && HAS_INSTALL_WIM(r) && (r.install_wim_version < MAX_WIM_VERSION)) #define IS_FAT(fs) ((fs == FS_FAT16) || (fs == FS_FAT32)) typedef struct { diff --git a/src/rufus.rc b/src/rufus.rc index adeb71cd..176c89b7 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,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 EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.12.1008" +CAPTION "Rufus 2.12.1009" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -334,8 +334,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,12,1008,0 - PRODUCTVERSION 2,12,1008,0 + FILEVERSION 2,12,1009,0 + PRODUCTVERSION 2,12,1009,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -352,13 +352,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.12.1008" + VALUE "FileVersion", "2.12.1009" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.12.1008" + VALUE "ProductVersion", "2.12.1009" END END BLOCK "VarFileInfo" diff --git a/src/syslinux.c b/src/syslinux.c index 4b737a9c..57b01ba8 100644 --- a/src/syslinux.c +++ b/src/syslinux.c @@ -342,7 +342,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int fs_type) uprintf("Failed to create '%s': %s", path, WindowsErrorString()); } } - } else if (IS_REACTOS(img_report)) { + } else if (HAS_REACTOS(img_report)) { uprintf("Setting up ReactOS..."); syslinux_mboot = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_SL_MBOOT_C32), _RT_RCDATA, "mboot.c32", &syslinux_mboot_len, FALSE);