mirror of
https://github.com/pbatard/rufus.git
synced 2025-06-02 07:39:54 -04:00
[core] display a notice about Legacy in the protective MBR for GPT
* This should help Windows users who create a GPT/UEFI drive and try to use it in BIOS/Legacy * Also make sure that we take into account the split space for both "SELECT" and "DOWNLOAD"
This commit is contained in:
parent
789373ed59
commit
28c1d6eb31
11 changed files with 200 additions and 10 deletions
14
src/format.c
14
src/format.c
|
@ -889,6 +889,15 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
|
|||
if (SelectedDrive.SectorSize < 512)
|
||||
goto out;
|
||||
|
||||
if (pt == PARTITION_STYLE_GPT) {
|
||||
// Add a notice in the protective MBR
|
||||
fake_fd._handle = (char*)hPhysicalDrive;
|
||||
set_bytes_per_sector(SelectedDrive.SectorSize);
|
||||
uprintf(using_msg, "Rufus protective");
|
||||
r = write_rufus_gpt_mbr(fp);
|
||||
goto notify;
|
||||
}
|
||||
|
||||
// FormatEx rewrites the MBR and removes the LBA attribute of FAT16
|
||||
// and FAT32 partitions - we need to correct this in the MBR
|
||||
buffer = (unsigned char*)_mm_malloc(SelectedDrive.SectorSize, 16);
|
||||
|
@ -1018,6 +1027,9 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
|
|||
FAKE_FD fake_fd = { 0 };
|
||||
FILE* fp = (FILE*)&fake_fd;
|
||||
|
||||
if (pt == PARTITION_STYLE_GPT)
|
||||
return TRUE;
|
||||
|
||||
fake_fd._handle = (char*)hPhysicalDrive;
|
||||
set_bytes_per_sector(SelectedDrive.SectorSize);
|
||||
// Ensure that we have sufficient space for the SBR
|
||||
|
@ -1997,7 +2009,7 @@ DWORD WINAPI FormatThread(void* param)
|
|||
}
|
||||
|
||||
// Thanks to Microsoft, we must fix the MBR AFTER the drive has been formatted
|
||||
if (pt == PARTITION_STYLE_MBR) {
|
||||
if ((pt == PARTITION_STYLE_MBR) || ((bt != BT_NON_BOOTABLE) && (pt == PARTITION_STYLE_GPT))) {
|
||||
PrintInfoDebug(0, MSG_228); // "Writing master boot record..."
|
||||
if ((!WriteMBR(hPhysicalDrive)) || (!WriteSBR(hPhysicalDrive))) {
|
||||
if (!IS_ERROR(FormatStatus))
|
||||
|
|
|
@ -148,6 +148,15 @@ int is_rufus_mbr(FILE *fp)
|
|||
is_br(fp);
|
||||
} /* is_rufus_mbr */
|
||||
|
||||
int is_rufus_gpt_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_gpt_rufus.h"
|
||||
|
||||
return
|
||||
contains_data(fp, 0x0, mbr_gpt_rufus_0x0, sizeof(mbr_gpt_rufus_0x0)) &&
|
||||
is_br(fp);
|
||||
} /* is_rufus_gpt_mbr */
|
||||
|
||||
int is_reactos_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_reactos.h"
|
||||
|
@ -289,6 +298,15 @@ int write_rufus_mbr(FILE *fp)
|
|||
write_bootmark(fp);
|
||||
} /* write_rufus_mbr */
|
||||
|
||||
int write_rufus_gpt_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_gpt_rufus.h"
|
||||
|
||||
return
|
||||
write_data(fp, 0x0, mbr_gpt_rufus_0x0, sizeof(mbr_gpt_rufus_0x0)) &&
|
||||
write_bootmark(fp);
|
||||
} /* write_rufus_gpt_mbr */
|
||||
|
||||
int write_reactos_mbr(FILE *fp)
|
||||
{
|
||||
#include "mbr_reactos.h"
|
||||
|
|
|
@ -54,6 +54,10 @@ int is_win7_mbr(FILE *fp);
|
|||
FALSE.The file position will change when this function is called! */
|
||||
int is_rufus_mbr(FILE *fp);
|
||||
|
||||
/* returns TRUE if the file has a Rufus GPT master boot record, otherwise
|
||||
FALSE.The file position will change when this function is called! */
|
||||
int is_rufus_gpt_mbr(FILE *fp);
|
||||
|
||||
/* returns TRUE if the file has a ReactOS master boot record, otherwise
|
||||
FALSE.The file position will change when this function is called! */
|
||||
int is_reactos_mbr(FILE *fp);
|
||||
|
@ -107,6 +111,10 @@ int write_win7_mbr(FILE *fp);
|
|||
FALSE */
|
||||
int write_rufus_mbr(FILE *fp);
|
||||
|
||||
/* Writes a Rufus GPT master boot record to a file, returns TRUE on success, otherwise
|
||||
FALSE */
|
||||
int write_rufus_gpt_mbr(FILE *fp);
|
||||
|
||||
/* Writes a ReactOS master boot record to a file, returns TRUE on success, otherwise
|
||||
FALSE */
|
||||
int write_reactos_mbr(FILE *fp);
|
||||
|
|
41
src/ms-sys/inc/mbr_gpt_rufus.h
Normal file
41
src/ms-sys/inc/mbr_gpt_rufus.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Rufus Protective MBR for GPT systems
|
||||
* https://github.com/pbatard/rufus/tree/master/res/mbr
|
||||
* Copyright © 2019 Pete Batard <pete@akeo.ie>
|
||||
*/
|
||||
|
||||
unsigned char mbr_gpt_rufus_0x0[] = {
|
||||
0x41, 0x4B, 0x45, 0x4F, 0xFC, 0x31, 0xC0, 0x8E, 0xD8, 0xBE, 0x31, 0x7C,
|
||||
0xE8, 0x13, 0x00, 0xBE, 0x5C, 0x7C, 0xE8, 0x0D, 0x00, 0xBE, 0x31, 0x7C,
|
||||
0xE8, 0x07, 0x00, 0xBE, 0x87, 0x7C, 0xE8, 0x01, 0x00, 0xF4, 0xAC, 0x3C,
|
||||
0x00, 0x74, 0x09, 0xB4, 0x0E, 0xBB, 0x07, 0x00, 0xCD, 0x10, 0xEB, 0xF2,
|
||||
0xC3, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x0D, 0x0A, 0x00, 0x2A, 0x2A, 0x2A, 0x20,
|
||||
0x45, 0x52, 0x52, 0x4F, 0x52, 0x3A, 0x20, 0x4C, 0x45, 0x47, 0x41, 0x43,
|
||||
0x59, 0x20, 0x42, 0x4F, 0x4F, 0x54, 0x20, 0x4F, 0x46, 0x20, 0x55, 0x45,
|
||||
0x46, 0x49, 0x20, 0x4D, 0x45, 0x44, 0x49, 0x41, 0x20, 0x2A, 0x2A, 0x2A,
|
||||
0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x54, 0x68, 0x69, 0x73, 0x20, 0x64, 0x72,
|
||||
0x69, 0x76, 0x65, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x6F, 0x6E, 0x6C, 0x79,
|
||||
0x20, 0x62, 0x6F, 0x6F, 0x74, 0x20, 0x69, 0x6E, 0x20, 0x55, 0x45, 0x46,
|
||||
0x49, 0x20, 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0A, 0x49, 0x74, 0x20,
|
||||
0x63, 0x61, 0x6E, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x62, 0x6F, 0x6F, 0x74,
|
||||
0x20, 0x69, 0x6E, 0x20, 0x42, 0x49, 0x4F, 0x53, 0x2F, 0x4C, 0x65, 0x67,
|
||||
0x61, 0x63, 0x79, 0x20, 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0A, 0x0D,
|
||||
0x0A, 0x49, 0x66, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x77, 0x61, 0x6E, 0x74,
|
||||
0x20, 0x74, 0x6F, 0x20, 0x62, 0x6F, 0x6F, 0x74, 0x20, 0x74, 0x68, 0x69,
|
||||
0x73, 0x20, 0x64, 0x72, 0x69, 0x76, 0x65, 0x20, 0x69, 0x6E, 0x20, 0x42,
|
||||
0x49, 0x4F, 0x53, 0x2F, 0x4C, 0x65, 0x67, 0x61, 0x63, 0x79, 0x20, 0x6D,
|
||||
0x6F, 0x64, 0x65, 0x2C, 0x20, 0x79, 0x6F, 0x75, 0x0D, 0x0A, 0x73, 0x68,
|
||||
0x6F, 0x75, 0x6C, 0x64, 0x20, 0x72, 0x65, 0x63, 0x72, 0x65, 0x61, 0x74,
|
||||
0x65, 0x20, 0x69, 0x74, 0x20, 0x69, 0x6E, 0x20, 0x52, 0x75, 0x66, 0x75,
|
||||
0x73, 0x20, 0x75, 0x73, 0x69, 0x6E, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x66, 0x6F, 0x6C, 0x6C, 0x6F, 0x77, 0x69, 0x6E, 0x67, 0x20, 0x73, 0x65,
|
||||
0x74, 0x74, 0x69, 0x6E, 0x67, 0x73, 0x3A, 0x0D, 0x0A, 0x2A, 0x20, 0x50,
|
||||
0x61, 0x72, 0x74, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x73, 0x63, 0x68,
|
||||
0x65, 0x6D, 0x65, 0x20, 0x2D, 0x3E, 0x20, 0x4D, 0x42, 0x52, 0x0D, 0x0A,
|
||||
0x2A, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x73, 0x79, 0x73,
|
||||
0x74, 0x65, 0x6D, 0x20, 0x2D, 0x3E, 0x20, 0x42, 0x49, 0x4F, 0x53, 0x2E,
|
||||
0x2E, 0x2E, 0x0D, 0x0A, 0x00
|
||||
};
|
10
src/rufus.rc
10
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 3.5.1472"
|
||||
CAPTION "Rufus 3.5.1473"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -394,8 +394,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,5,1472,0
|
||||
PRODUCTVERSION 3,5,1472,0
|
||||
FILEVERSION 3,5,1473,0
|
||||
PRODUCTVERSION 3,5,1473,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -413,13 +413,13 @@ BEGIN
|
|||
VALUE "Comments", "https://akeo.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.5.1472"
|
||||
VALUE "FileVersion", "3.5.1473"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus-3.5.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.5.1472"
|
||||
VALUE "ProductVersion", "3.5.1473"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
6
src/ui.c
6
src/ui.c
|
@ -155,8 +155,10 @@ void GetMainButtonsWidth(HWND hDlg)
|
|||
MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2);
|
||||
bw = rc.right - rc.left;
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(main_button_ids); i++)
|
||||
bw = max(bw, GetTextWidth(hDlg, main_button_ids[i]) + cbw);
|
||||
for (i = 0; i < ARRAYSIZE(main_button_ids); i++) {
|
||||
// Make sure we add extra space for the SELECT split button (i == 0) if Fido is enabled
|
||||
bw = max(bw, GetTextWidth(hDlg, main_button_ids[i]) + ((enable_fido && i == 0) ? (3 * cbw) / 2 : cbw));
|
||||
}
|
||||
// The 'CLOSE' button is also be used to display 'CANCEL' and we sometimes
|
||||
// want to add "DOWNLOAD" into the Select split button => measure that too.
|
||||
bw = max(bw, GetTextSize(GetDlgItem(hDlg, IDCANCEL), lmprintf(MSG_007)).cx + cbw);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue