From 420db67ce15f298dd5c5635929f0b22b961396c0 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 18 Dec 2014 20:41:55 +0000 Subject: [PATCH] [misc] add dual UEFI/BIOS cheat mode for Windows * Suggested by Jacob Boyce --- src/format.c | 7 ++++--- src/rufus.c | 10 +++++++++- src/rufus.h | 1 + src/rufus.rc | 16 ++++++++-------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/format.c b/src/format.c index 5f7d68bd..7cf1cff2 100644 --- a/src/format.c +++ b/src/format.c @@ -906,7 +906,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)); bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); - if (bt == BT_UEFI) { + if ((bt == BT_UEFI) && (!allow_dual_uefi_bios)) { uprintf(using_msg, "zeroed"); r = write_zero_mbr(&fake_fd); // Force UEFI boot only by zeroing the MBR } else if ( (dt == DT_ISO) && (iso_report.has_kolibrios) && (fs == FS_FAT32)) { @@ -921,7 +921,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) } else if (dt == DT_REACTOS) { uprintf(using_msg, "ReactOS"); r = write_reactos_mbr(&fake_fd); - } else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V6) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) { + } else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V6) || ((dt == DT_ISO) && (!allow_dual_uefi_bios) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) { uprintf(using_msg, "Syslinux"); r = write_syslinux_mbr(&fake_fd); } else { @@ -1621,7 +1621,8 @@ DWORD WINAPI FormatThread(void* param) } // We must close and unlock the volume to write files to it safe_unlockclose(hLogicalVolume); - } else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V6) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) { + } else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V6) || ((dt == DT_ISO) && (!allow_dual_uefi_bios) && + ((fs == FS_FAT16) || (fs == FS_FAT32))) ) { if (!InstallSyslinux(DriveIndex, drive_name[0], fs)) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; } diff --git a/src/rufus.c b/src/rufus.c index 39ca8b2f..46394f52 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -123,6 +123,7 @@ HWND hISOProgressDlg = NULL, hLogDlg = NULL, hISOProgressBar, hISOFileName, hDis BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, detect_fakes = TRUE, mbr_selected_by_user = FALSE; BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE; BOOL enable_HDDs = FALSE, advanced_mode = TRUE, force_update = FALSE, use_fake_units = TRUE; +BOOL allow_dual_uefi_bios = FALSE; int dialog_showing = 0; uint16_t rufus_version[4], embedded_sl_version[2]; char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; @@ -1170,7 +1171,7 @@ static BOOL BootCheck(void) // KolibriOS doesn't support FAT16 MessageBoxU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL); return FALSE; - } else if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!HAS_SYSLINUX(iso_report)) && + } else if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!HAS_SYSLINUX(iso_report)) && (!allow_dual_uefi_bios) && (!IS_REACTOS(iso_report)) && (!iso_report.has_kolibrios) && (!IS_GRUB(iso_report))) { // FAT/FAT32 can only be used for isolinux based ISO images or when the Target Type is UEFI MessageBoxU(hMainDialog, lmprintf(MSG_098), lmprintf(MSG_090), MB_OK|MB_ICONERROR|MB_IS_RTL); @@ -2471,6 +2472,13 @@ relaunch: existing_key = FALSE; continue; } + // Alt-E => Enhanced installation mode (allow dual UEFI/BIOS mode and FAT32 for Windows) + if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'E')) { + allow_dual_uefi_bios = !allow_dual_uefi_bios; + // TODO: add a localized message + PrintStatus2000("Allow dual UEFI/BIOS mode", allow_dual_uefi_bios); + continue; + } // Alt-F => Toggle detection of USB HDDs // By default Rufus does not list USB HDDs. This is a safety feature aimed at avoiding // unintentional formatting of backup drives instead of USB keys. diff --git a/src/rufus.h b/src/rufus.h index 60d5d807..e0d83844 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -337,6 +337,7 @@ extern DWORD syslinux_ldlinux_len[2]; extern RUFUS_DRIVE_INFO SelectedDrive; extern const int nb_steps[FS_MAX]; extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, iso_op_in_progress, format_op_in_progress, right_to_left_mode; +extern BOOL allow_dual_uefi_bios; extern RUFUS_ISO_REPORT iso_report; extern int64_t iso_blocking_status; extern uint16_t rufus_version[4], embedded_sl_version[2]; diff --git a/src/rufus.rc b/src/rufus.rc index 90954469..bfeaee48 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 1.5.0.558" +CAPTION "Rufus 1.5.0.559" FONT 8, "Segoe UI", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -164,7 +164,7 @@ END IDD_DIALOG_XP DIALOGEX 12, 12, 242, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rufus 1.5.0.558" +CAPTION "Rufus 1.5.0.559" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -297,7 +297,7 @@ END IDD_DIALOG_RTL DIALOGEX 12, 12, 242, 329 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 1.5.0.558" +CAPTION "Rufus 1.5.0.559" FONT 8, "Segoe UI", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -437,7 +437,7 @@ END IDD_DIALOG_RTL_XP DIALOGEX 12, 12, 242, 329 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 1.5.0.558" +CAPTION "Rufus 1.5.0.559" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,127,291,50,14 @@ -702,8 +702,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,5,0,558 - PRODUCTVERSION 1,5,0,558 + FILEVERSION 1,5,0,559 + PRODUCTVERSION 1,5,0,559 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -720,13 +720,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.5.0.558" + VALUE "FileVersion", "1.5.0.559" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.5.0.558" + VALUE "ProductVersion", "1.5.0.559" END END BLOCK "VarFileInfo"