1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[efi] zero the MBR when MBR/UEFI is used

* This ensures that an MBR/UEFI UFD can only ever be booted in EFI mode
* Also fix an issue where the same drive was not properly detected ("U:" vs "U:\")
* Also update ReactOS copyright and fix a warning from Cppcheck in parser.c
This commit is contained in:
Pete Batard 2014-01-11 00:19:03 +00:00
parent 642d797ff1
commit 14fbbfaa2e
5 changed files with 21 additions and 16 deletions

View file

@ -504,7 +504,7 @@ BOOL AnalyzeMBR(HANDLE hPhysicalDrive)
} else if (is_reactos_mbr(&fake_fd)) {
uprintf("Drive has a ReactOS master boot record\n");
} else if (is_zero_mbr(&fake_fd)) {
uprintf("Drive has a zeroed non-bootable master boot record\n");
uprintf("Drive has a zeroed master boot record\n");
} else {
uprintf("Drive has an unknown master boot record\n");
}
@ -702,8 +702,8 @@ BOOL MountVolume(char* drive_name, char *drive_guid)
// For fixed disks, Windows may already have remounted the volume, but with a different letter
// than the one we want. If that's the case, we need to unmount first.
if ( (GetVolumePathNamesForVolumeNameA(drive_guid, mounted_letter, sizeof(mounted_letter), &size))
&& (size > 2) && (safe_strcmp(mounted_letter, drive_name) != 0) ) {
uprintf("Volume is already mounted, but as %s instead of %s - Unmounting...\n", mounted_letter, drive_name);
&& (size > 1) && (mounted_letter[0] != drive_name[0]) ) {
uprintf("Volume is already mounted, but as %c: instead of %c: - Unmounting...\n", mounted_letter[0], drive_name[0]);
if (!DeleteVolumeMountPointA(mounted_letter))
uprintf("Failed to unmount volume: %s", WindowsErrorString());
Sleep(200);

View file

@ -810,7 +810,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
{
BOOL r = FALSE;
DWORD size;
int dt, fs;
int dt, fs, bt;
unsigned char* buf = NULL;
size_t SecSize = SelectedDrive.Geometry.BytesPerSector;
size_t nSecs = (0x200 + SecSize -1) / SecSize;
@ -868,7 +868,11 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V5) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
bt = GETBIOSTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
if (bt == BT_UEFI) {
uprintf(using_msg, "zeroed");
r = write_zero_mbr(&fake_fd); // Force UEFI boot only by zeroing the MBR
} else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V5) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
uprintf(using_msg, "Syslinux");
r = write_syslinux_mbr(&fake_fd);
} else if (dt == DT_REACTOS) {

View file

@ -54,6 +54,11 @@ const char* additional_copyrights =
"http://www.syslinux.org\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"
"\\line\n"
"ReactOS support & additional FAT and time-conversion handling by ReactOS:\\line\n"
"http://www.reactos.org\\line\n"
"http://svn.reactos.org/svn/reactos/trunk/reactos\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"
"\\line\n"
"Bad blocks testing from e2fsprogs by Theodore T'so et al:\\line\n"
"http://e2fsprogs.sourceforge.net\\line\n"
"GNU General Public License (GPL) v3 compatible\\line\n"
@ -71,10 +76,6 @@ const char* additional_copyrights =
"http://www.codeguru.com/forum/showthread.php?p=1951973\\line\n"
"Public Domain\\line\n"
"\\line\n"
"Some FAT and time-conversion handling by ReactOS:\\line\n"
"http://svn.reactos.org/svn/reactos/trunk/reactos\\line\n"
"GNU General Public License (GPL) v3 compatible\\line\n"
"\\line\n"
"USB vs HDD and additional functions calls derived from smartmontools:\\line\n"
"https://sourceforge.net/projects/smartmontools\\line\n"
"GNU General Public License (GPL) v2 or later\\line\n"

View file

@ -768,7 +768,7 @@ char* insert_section_data(const char* filename, const char* section, const char*
wchar_t buf[1024];
FILE *fd_in = NULL, *fd_out = NULL;
size_t i, size;
int mode;
int mode = 0;
char *ret = NULL, tmp[2];
if ((filename == NULL) || (section == NULL) || (data == NULL))
@ -897,7 +897,7 @@ char* replace_in_token_data(const char* filename, const char* token, const char*
wchar_t buf[1024], *torep;
FILE *fd_in = NULL, *fd_out = NULL;
size_t i, size;
int mode;
int mode = 0;
char *ret = NULL, tmp[2];
if ((filename == NULL) || (token == NULL) || (src == NULL) || (rep == NULL))

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.4.2.376"
CAPTION "Rufus v1.4.2.377"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -288,8 +288,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,2,376
PRODUCTVERSION 1,4,2,376
FILEVERSION 1,4,2,377
PRODUCTVERSION 1,4,2,377
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -306,13 +306,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.2.376"
VALUE "FileVersion", "1.4.2.377"
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.4.2.376"
VALUE "ProductVersion", "1.4.2.377"
END
END
BLOCK "VarFileInfo"