mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] fix UEFI bootable DD images
* A DD image may have a zeroed MBR, yet be bootable through UEFI * Also improve AnalyzePBR() * Closes #320
This commit is contained in:
parent
6390aa3968
commit
9aa308213d
2 changed files with 39 additions and 37 deletions
64
src/drive.c
64
src/drive.c
|
@ -505,17 +505,17 @@ BOOL IsMediaPresent(DWORD DriveIndex)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct {int (*fn)(FILE *fp); char* str; BOOL bootable;} known_mbr[] = {
|
const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = {
|
||||||
{ is_dos_mbr, "DOS/NT/95A", TRUE },
|
{ is_dos_mbr, "DOS/NT/95A" },
|
||||||
{ is_dos_f2_mbr, "DOS/NT/95A (F2)", TRUE },
|
{ is_dos_f2_mbr, "DOS/NT/95A (F2)" },
|
||||||
{ is_95b_mbr, "Windows 95B/98/98SE/ME", TRUE },
|
{ is_95b_mbr, "Windows 95B/98/98SE/ME" },
|
||||||
{ is_2000_mbr, "Windows 2000/XP/2003", TRUE },
|
{ is_2000_mbr, "Windows 2000/XP/2003" },
|
||||||
{ is_vista_mbr, "Windows Vista", TRUE },
|
{ is_vista_mbr, "Windows Vista" },
|
||||||
{ is_win7_mbr, "Windows 7", TRUE },
|
{ is_win7_mbr, "Windows 7" },
|
||||||
{ is_rufus_mbr, "Rufus", TRUE },
|
{ is_rufus_mbr, "Rufus" },
|
||||||
{ is_syslinux_mbr, "Syslinux", TRUE },
|
{ is_syslinux_mbr, "Syslinux" },
|
||||||
{ is_reactos_mbr, "Reactos", TRUE },
|
{ is_reactos_mbr, "Reactos" },
|
||||||
{ is_zero_mbr, "Zeroed", FALSE },
|
{ is_zero_mbr, "Zeroed" },
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns TRUE if the drive seems bootable, FALSE otherwise
|
// Returns TRUE if the drive seems bootable, FALSE otherwise
|
||||||
|
@ -535,7 +535,7 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName)
|
||||||
for (i=0; i<ARRAYSIZE(known_mbr); i++) {
|
for (i=0; i<ARRAYSIZE(known_mbr); i++) {
|
||||||
if (known_mbr[i].fn(&fake_fd)) {
|
if (known_mbr[i].fn(&fake_fd)) {
|
||||||
uprintf("%s has a %s %s\n", TargetName, known_mbr[i].str, mbr_name);
|
uprintf("%s has a %s %s\n", TargetName, known_mbr[i].str, mbr_name);
|
||||||
return known_mbr[i].bootable;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,38 +543,40 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use an (fn,str) table and simplify this whole thing
|
const struct {int (*fn)(FILE *fp); char* str;} known_pbr[] = {
|
||||||
|
{ entire_fat_16_br_matches, "FAT16 DOS" },
|
||||||
|
{ entire_fat_16_fd_br_matches, "FAT16 FreeDOS" },
|
||||||
|
{ entire_fat_16_ros_br_matches, "FAT16 ReactOS" },
|
||||||
|
{ entire_fat_32_br_matches, "FAT32 DOS" },
|
||||||
|
{ entire_fat_32_nt_br_matches, "FAT32 NT" },
|
||||||
|
{ entire_fat_32_fd_br_matches, "FAT32 FreeDOS" },
|
||||||
|
{ entire_fat_32_ros_br_matches, "FAT32 ReactOS" },
|
||||||
|
};
|
||||||
|
|
||||||
BOOL AnalyzePBR(HANDLE hLogicalVolume)
|
BOOL AnalyzePBR(HANDLE hLogicalVolume)
|
||||||
{
|
{
|
||||||
|
const char* pbr_name = "Partition Boot Record";
|
||||||
FILE fake_fd = { 0 };
|
FILE fake_fd = { 0 };
|
||||||
|
int i;
|
||||||
|
|
||||||
fake_fd._ptr = (char*)hLogicalVolume;
|
fake_fd._ptr = (char*)hLogicalVolume;
|
||||||
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
|
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
|
||||||
|
|
||||||
if (!is_br(&fake_fd)) {
|
if (!is_br(&fake_fd)) {
|
||||||
uprintf("Volume does not have an x86 partition boot record\n");
|
uprintf("Volume does not have an x86 %s\n", pbr_name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_fat_16_br(&fake_fd) || is_fat_32_br(&fake_fd)) {
|
if (is_fat_16_br(&fake_fd) || is_fat_32_br(&fake_fd)) {
|
||||||
if (entire_fat_16_br_matches(&fake_fd)) {
|
for (i=0; i<ARRAYSIZE(known_pbr); i++) {
|
||||||
uprintf("Drive has a FAT16 DOS partition boot record\n");
|
if (known_pbr[i].fn(&fake_fd)) {
|
||||||
} else if (entire_fat_16_fd_br_matches(&fake_fd)) {
|
uprintf("Drive has a %s %s\n", known_pbr[i].str, pbr_name);
|
||||||
uprintf("Drive has a FAT16 FreeDOS partition boot record\n");
|
return TRUE;
|
||||||
} else if (entire_fat_16_ros_br_matches(&fake_fd)) {
|
}
|
||||||
uprintf("Drive has a FAT16 ReactOS partition boot record\n");
|
|
||||||
} else if (entire_fat_32_br_matches(&fake_fd)) {
|
|
||||||
uprintf("Drive has a FAT32 DOS partition boot record\n");
|
|
||||||
} else if (entire_fat_32_nt_br_matches(&fake_fd)) {
|
|
||||||
uprintf("Drive has a FAT32 NT partition boot record\n");
|
|
||||||
} else if (entire_fat_32_fd_br_matches(&fake_fd)) {
|
|
||||||
uprintf("Drive has a FAT32 FreeDOS partition boot record\n");
|
|
||||||
} else if (entire_fat_32_ros_br_matches(&fake_fd)) {
|
|
||||||
uprintf("Drive has a FAT32 ReactOS partition boot record\n");
|
|
||||||
} else {
|
|
||||||
uprintf("Drive has an unknown FAT16 or FAT32 partition boot record\n");
|
|
||||||
}
|
}
|
||||||
|
uprintf("Volume has an unknown FAT16 or FAT32 %s\n", pbr_name);
|
||||||
} else {
|
} else {
|
||||||
uprintf("Drive has an unknown partition boot record\n");
|
uprintf("Volume has an unknown %s\n", pbr_name);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
|
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Rufus 1.4.7.459"
|
CAPTION "Rufus 1.4.7.460"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||||
|
@ -165,7 +165,7 @@ END
|
||||||
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||||
CAPTION "Rufus 1.4.7.459"
|
CAPTION "Rufus 1.4.7.460"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||||
|
@ -427,8 +427,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,4,7,459
|
FILEVERSION 1,4,7,460
|
||||||
PRODUCTVERSION 1,4,7,459
|
PRODUCTVERSION 1,4,7,460
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -445,13 +445,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "1.4.7.459"
|
VALUE "FileVersion", "1.4.7.460"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus.exe"
|
VALUE "OriginalFilename", "rufus.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "1.4.7.459"
|
VALUE "ProductVersion", "1.4.7.460"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue