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

[core] fix precedence of Syslinux over Grub

* Closes #449
* Also fix Coverity builds
This commit is contained in:
Pete Batard 2015-02-25 01:45:47 +00:00
parent f2f638c60e
commit d22933636c
5 changed files with 84 additions and 49 deletions

View file

@ -1,6 +1,6 @@
@echo off
set PWD=%~dp0
rmdir cov-int /s /q
rmdir cov-int /s /q >NUL 2>NUL
del cov-int.zip >NUL 2>NUL
mkdir cov-int
cov-build --dir cov-int wdk_build.cmd
@ -10,7 +10,7 @@ echo InputFolder = objArgs(0)>> zip.vbs
echo ZipFile = objArgs(1)>> zip.vbs
echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar)>> zip.vbs
echo Set objShell = CreateObject("Shell.Application")>> zip.vbs
echo Set source = objShell.NameSpace(InputFolder).Items>> zip.vbs
echo Set source = objShell.NameSpace(InputFolder)>> zip.vbs
echo objShell.NameSpace(ZipFile).CopyHere(source)>> zip.vbs
echo wScript.Sleep 2000>> zip.vbs
CScript zip.vbs %PWD%cov-int %PWD%cov-int.zip

View file

@ -911,34 +911,66 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
fake_fd._ptr = (char*)hPhysicalDrive;
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
if ((bt == BT_UEFI) && (!allow_dual_uefi_bios)) {
// What follows is really a case statement with complex conditions listed
// by order of preference
if (allow_dual_uefi_bios)
goto windows_mbr;
// Forced UEFI (by zeroing the MBR)
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_ISO) && (iso_report.has_kolibrios) && (fs == FS_FAT32)) {
uprintf(using_msg, "KolibriOS");
r = write_kolibri_mbr(&fake_fd);
} else if (((dt == DT_ISO) && (iso_report.has_grub4dos)) || (dt == DT_GRUB4DOS)) {
uprintf(using_msg, "Grub4DOS");
r = write_grub_mbr(&fake_fd);
} else if (((dt == DT_ISO) && (iso_report.has_grub2)) || (dt == DT_GRUB2)) {
uprintf(using_msg, "Grub 2.0");
r = write_grub2_mbr(&fake_fd);
} 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) && (!allow_dual_uefi_bios) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
r = write_zero_mbr(&fake_fd);
goto notify;
}
// Syslinux
if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V6) ||
((dt == DT_ISO) && (HAS_SYSLINUX(iso_report)) && (IS_FAT(fs))) ) {
uprintf(using_msg, "Syslinux");
r = write_syslinux_mbr(&fake_fd);
} else {
if ((IS_WINPE(iso_report.winpe) && !iso_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) {
uprintf(using_msg, APPLICATION_NAME);
r = write_rufus_mbr(&fake_fd);
} else {
uprintf(using_msg, "Windows 7");
r = write_win7_mbr(&fake_fd);
}
goto notify;
}
// Grub 2.0
if ( ((dt == DT_ISO) && (iso_report.has_grub2)) || (dt == DT_GRUB2) ) {
uprintf(using_msg, "Grub 2.0");
r = write_grub2_mbr(&fake_fd);
goto notify;
}
// Grub4DOS
if ( ((dt == DT_ISO) && (iso_report.has_grub4dos)) || (dt == DT_GRUB4DOS) ) {
uprintf(using_msg, "Grub4DOS");
r = write_grub_mbr(&fake_fd);
goto notify;
}
// ReactOS
if (dt == DT_REACTOS) {
uprintf(using_msg, "ReactOS");
r = write_reactos_mbr(&fake_fd);
goto notify;
}
// KolibriOS
if ( (dt == DT_ISO) && (iso_report.has_kolibrios) && (IS_FAT(fs))) {
uprintf(using_msg, "KolibriOS");
r = write_kolibri_mbr(&fake_fd);
goto notify;
}
// If everything else failed, fall back to a conventional Windows/Rufus MBR
windows_mbr:
if ((IS_WINPE(iso_report.winpe) && !iso_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) {
uprintf(using_msg, APPLICATION_NAME);
r = write_rufus_mbr(&fake_fd);
} else {
uprintf(using_msg, "Windows 7");
r = write_win7_mbr(&fake_fd);
}
notify:
// Tell the system we've updated the disk properties
if (!DeviceIoControl(hPhysicalDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &size, NULL))
uprintf("Failed to notify system about disk properties update: %s\n", WindowsErrorString());
@ -965,10 +997,13 @@ static BOOL WriteSBR(HANDLE hPhysicalDrive)
max_size = IsChecked(IDC_EXTRA_PARTITION) ?
(DWORD)(SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack) : 1024 * 1024;
max_size -= mbr_size;
if ((dt == DT_ISO) && (iso_report.has_grub4dos))
dt = DT_GRUB4DOS;
if ((dt == DT_ISO) && (iso_report.has_grub2))
dt = DT_GRUB2;
// Syslinux has precedence over Grub
if ((dt == DT_ISO) && (!HAS_SYSLINUX(iso_report))) {
if (iso_report.has_grub4dos)
dt = DT_GRUB4DOS;
if (iso_report.has_grub2)
dt = DT_GRUB2;
}
switch (dt) {
case DT_GRUB4DOS:
@ -1776,8 +1811,12 @@ DWORD WINAPI FormatThread(void* param)
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
goto out;
}
} else if ((((dt == DT_WINME) || (dt == DT_FREEDOS) || (dt == DT_GRUB4DOS) || (dt == DT_GRUB2) || (dt == DT_REACTOS)) &&
(!use_large_fat32)) || ((dt == DT_ISO) && ((fs == FS_NTFS)||(iso_report.has_kolibrios||IS_GRUB(iso_report))))) {
} else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V6) ||
((dt == DT_ISO) && (HAS_SYSLINUX(iso_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;
}
} else {
// We still have a lock, which we need to modify the volume boot record
// => no need to reacquire the lock...
hLogicalVolume = GetLogicalHandle(DriveIndex, TRUE, FALSE);
@ -1796,11 +1835,6 @@ 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) && (!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;
}
}
} else {
if (IsChecked(IDC_SET_ICON))

View file

@ -554,7 +554,7 @@ static void EnableAdvancedBootOptions(BOOL enable, BOOL remove_checkboxes)
static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
{
int fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
BOOL actual_enable = ((fs != FS_FAT16) && (fs != FS_FAT32) && (fs != FS_NTFS) && (selection_default == DT_IMG))?FALSE:enable;
BOOL actual_enable = ((!IS_FAT(fs)) && (fs != FS_NTFS) && (selection_default == DT_IMG))?FALSE:enable;
EnableWindow(hBoot, actual_enable);
EnableWindow(hBootType, actual_enable);
@ -1260,7 +1260,7 @@ static BOOL BootCheck(void)
return FALSE;
}
} else if ( ((fs == FS_NTFS) && (!iso_report.has_bootmgr) && (!IS_WINPE(iso_report.winpe)) && (!IS_GRUB(iso_report)))
|| (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!HAS_SYSLINUX(iso_report)) && (!allow_dual_uefi_bios) &&
|| ((IS_FAT(fs)) && (!HAS_SYSLINUX(iso_report)) && (!allow_dual_uefi_bios) &&
(!IS_REACTOS(iso_report)) && (!iso_report.has_kolibrios) && (!IS_GRUB(iso_report))) ) {
// Incompatible FS and ISO
MessageBoxU(hMainDialog, lmprintf(MSG_096), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL);
@ -1270,7 +1270,7 @@ static BOOL BootCheck(void)
MessageBoxU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL);
return FALSE;
}
if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (iso_report.has_4GB_file)) {
if ((IS_FAT(fs)) && (iso_report.has_4GB_file)) {
// This ISO image contains a file larger than 4GB file (FAT32)
MessageBoxU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL);
return FALSE;
@ -1794,14 +1794,14 @@ void SetBoot(int fs, int bt)
char tmp[32];
IGNORE_RETVAL(ComboBox_ResetContent(hBootType));
if ((bt == BT_BIOS) && ((fs == FS_FAT16) || (fs == FS_FAT32))) {
if ((bt == BT_BIOS) && (IS_FAT(fs))) {
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), DT_WINME));
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), DT_FREEDOS));
}
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), DT_ISO));
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_095)), DT_IMG));
// If needed (advanced mode) also append "bare" Syslinux and other options
if ( (bt == BT_BIOS) && (((fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)) && (advanced_mode)) ) {
if ( (bt == BT_BIOS) && ((IS_FAT(fs) || (fs == FS_NTFS)) && (advanced_mode)) ) {
static_sprintf(tmp, "Syslinux %s", embedded_sl_version_str[0]);
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, tmp), DT_SYSLINUX_V4));
static_sprintf(tmp, "Syslinux %s", embedded_sl_version_str[1]);

View file

@ -239,6 +239,7 @@ typedef struct {
#define IS_WIN7_EFI(r) (r.has_efi & 1)
#define IS_REACTOS(r) (r.reactos_path[0] != 0)
#define IS_GRUB(r) ((r.has_grub2) || (r.has_grub4dos))
#define IS_FAT(fs) ((fs == FS_FAT16) || (fs == FS_FAT32))
typedef struct {
char label[192]; /* 3*64 to account for UTF-8 */

View file

@ -32,7 +32,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
CAPTION "Rufus 2.0.631"
CAPTION "Rufus 2.0.632"
FONT 8, "Segoe UI", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,127,339,50,14
@ -157,7 +157,7 @@ END
IDD_DIALOG_XP DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.0.631"
CAPTION "Rufus 2.0.632"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,127,339,50,14
@ -283,7 +283,7 @@ END
IDD_DIALOG_RTL DIALOGEX 12, 12, 242, 376
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 2.0.631"
CAPTION "Rufus 2.0.632"
FONT 8, "Segoe UI", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,127,339,50,14
@ -415,7 +415,7 @@ END
IDD_DIALOG_RTL_XP DIALOGEX 12, 12, 242, 376
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 2.0.631"
CAPTION "Rufus 2.0.632"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,127,339,50,14
@ -671,8 +671,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,631,0
PRODUCTVERSION 2,0,631,0
FILEVERSION 2,0,632,0
PRODUCTVERSION 2,0,632,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -689,13 +689,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.0.631"
VALUE "FileVersion", "2.0.632"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.0.631"
VALUE "ProductVersion", "2.0.632"
END
END
BLOCK "VarFileInfo"