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

[core] add ReactOS support

* Use Syslinux v4 and mboot.c32 to chainload setupldr.sys
* Closes #266
This commit is contained in:
Pete Batard 2014-01-02 23:21:30 +00:00
parent 6e1b50b7a0
commit e9e27d7034
8 changed files with 66 additions and 17 deletions

BIN
res/syslinux/mboot.c32 Normal file

Binary file not shown.

View file

@ -1,3 +1,4 @@
o ldlinux_v4.[bss|sys] have been renamed from ldlinux.[bss|sys] found in syslinux-4.07/core/
o ldlinux_v5.[bss|sys] have been renamed from ldlinux.[bss|sys] found in syslinux-5.10/core/
o mboot.c32 comes from syslinux-4.07/com32/mboot
http://www.kernel.org/pub/linux/utils/boot/syslinux/

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* ISO file extraction
* Copyright © 2011-2013 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2014 Pete Batard <pete@akeo.ie>
* Based on libcdio's iso & udf samples:
* Copyright © 2003-2012 Rocky Bernstein <rocky@gnu.org>
*
@ -65,6 +65,7 @@ static const char* efi_dirname = "/efi/boot";
static const char* isolinux_name[] = { "isolinux.cfg", "syslinux.cfg", "extlinux.conf"};
static const char* pe_dirname[] = { "/i386", "/minint" };
static const char* pe_file[] = { "ntdetect.com", "setupldr.bin", "txtsetup.sif" };
static const char* reactos_name = "setupldr.sys"; // TODO: freeldr.sys doesn't seem to work
static const char* autorun_name = "autorun.inf";
static const char* old_c32_name[NB_OLD_C32] = OLD_C32_NAMES;
static const int64_t old_c32_threshold[NB_OLD_C32] = OLD_C32_THRESHOLD;
@ -161,6 +162,10 @@ static BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL
}
}
// Check for ReactOS' setupldr.sys anywhere
if ((iso_report.reactos_path[0] == 0) && (safe_stricmp(psz_basename, reactos_name) == 0))
safe_strcpy(iso_report.reactos_path, sizeof(iso_report.reactos_path), psz_fullpath);
// Check for the EFI boot directory
if (safe_stricmp(psz_dirname, efi_dirname) == 0)
iso_report.has_efi = TRUE;

View file

@ -45,6 +45,7 @@
#define IDR_SL_LDLINUX_V4_SYS 401
#define IDR_SL_LDLINUX_V5_BSS 402
#define IDR_SL_LDLINUX_V5_SYS 403
#define IDR_SL_MBOOT_C32 404
#define IDR_LC_RUFUS_LOC 500
#define IDC_DEVICE 1001
#define IDC_FILESYSTEM 1002

View file

@ -1,6 +1,6 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Copyright © 2011-2013 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2014 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1153,9 +1153,9 @@ DWORD WINAPI ISOScanThread(LPVOID param)
goto out;
}
uprintf("ISO label: '%s'\r\n Size: %lld bytes\r\n Has a >64 chars filename: %s\r\n Has a >4GB file: %s\r\n"
" Uses EFI: %s%s\r\n Uses Bootmgr: %s\r\n Uses WinPE: %s%s\r\n Uses isolinux: %s %s\n",
iso_report.label, iso_report.projected_size, iso_report.has_long_filename?"Yes":"No",
iso_report.has_4GB_file?"Yes":"No", (iso_report.has_efi || iso_report.has_win7_efi)?"Yes":"No",
" ReactOS: %s\r\n Uses EFI: %s%s\r\n Uses Bootmgr: %s\r\n Uses WinPE: %s%s\r\n Uses isolinux: %s %s\r\n",
iso_report.label, iso_report.projected_size, iso_report.has_long_filename?"Yes":"No", iso_report.has_4GB_file?"Yes":"No",
IS_REACTOS(iso_report)?"Yes":"No", (iso_report.has_efi || iso_report.has_win7_efi)?"Yes":"No",
(iso_report.has_win7_efi && (!iso_report.has_efi))?" (win7_x64)":"", iso_report.has_bootmgr?"Yes":"No",
IS_WINPE(iso_report.winpe)?"Yes":"No", (iso_report.uses_minint)?" (with /minint)":"", iso_report.has_isolinux?"Yes":"No",
iso_report.has_syslinux_v5?"(v5.0 or later)":iso_report.has_isolinux?"(v4.x or earlier)":"");
@ -1164,7 +1164,8 @@ DWORD WINAPI ISOScanThread(LPVOID param)
uprintf(" With an old %s: %s\n", old_c32_name[i], iso_report.has_old_c32[i]?"Yes":"No");
}
}
if ((!iso_report.has_bootmgr) && (!iso_report.has_isolinux) && (!IS_WINPE(iso_report.winpe)) && (!iso_report.has_efi)) {
if ( (!iso_report.has_bootmgr) && (!iso_report.has_isolinux) && (!IS_WINPE(iso_report.winpe))
&& (!iso_report.has_efi) && (!IS_REACTOS(iso_report)) ) {
MessageBoxU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK|MB_ICONINFORMATION);
safe_free(iso_path);
SetMBRProps();
@ -1324,7 +1325,7 @@ static BOOL BootCheck(void)
MessageBoxU(hMainDialog, lmprintf(MSG_097), lmprintf(MSG_090), MB_OK|MB_ICONERROR);
}
return FALSE;
} else if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!iso_report.has_isolinux)) {
} else if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!iso_report.has_isolinux) && (!IS_REACTOS(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);
return FALSE;

View file

@ -1,6 +1,6 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Copyright © 2011-2013 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2014 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -212,11 +212,13 @@ typedef struct {
#define WINPE_I386 0x15
#define IS_WINPE(r) (((r&WINPE_MININT) == WINPE_MININT)||((r&WINPE_I386) == WINPE_I386))
#define IS_EFI(r) ((r.has_efi) || (r.has_win7_efi))
#define IS_REACTOS(r) (r.reactos_path[0] != 0)
typedef struct {
char label[192]; /* 3*64 to account for UTF-8 */
char usb_label[192]; /* converted USB label for workaround */
char cfg_path[128]; /* path to the ISO's isolinux.cfg */
char reactos_path[128]; /* path to the ISO's freeldr.sys or setupldr.sys */
uint64_t projected_size;
// TODO: use a bitmask and #define tests for the following
uint8_t winpe;

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.367"
CAPTION "Rufus v1.4.2.368"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -199,6 +199,7 @@ BEGIN
"IDR_SL_LDLINUX_V4_SYS RCDATA ""../res/syslinux/ldlinux_v4.sys""\r\n"
"IDR_SL_LDLINUX_V5_BSS RCDATA ""../res/syslinux/ldlinux_v5.bss""\r\n"
"IDR_SL_LDLINUX_V5_SYS RCDATA ""../res/syslinux/ldlinux_v5.sys""\r\n"
"IDR_SL_MBOOT_C32 RCDATA ""../res/syslinux/mboot.c32""\r\n"
"IDR_BR_MBR_BIN RCDATA ""../res/mbr/mbr.bin""\r\n"
"IDR_FD_COMMAND_COM RCDATA ""../res/freedos/COMMAND.COM""\r\n"
"IDR_FD_KERNEL_SYS RCDATA ""../res/freedos/KERNEL.SYS""\r\n"
@ -288,8 +289,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,2,367
PRODUCTVERSION 1,4,2,367
FILEVERSION 1,4,2,368
PRODUCTVERSION 1,4,2,368
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -306,13 +307,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.2.367"
VALUE "FileVersion", "1.4.2.368"
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.367"
VALUE "ProductVersion", "1.4.2.368"
END
END
BLOCK "VarFileInfo"
@ -352,6 +353,7 @@ IDR_SL_LDLINUX_V4_BSS RCDATA "../res/syslinux/ldlinux_v4.bss"
IDR_SL_LDLINUX_V4_SYS RCDATA "../res/syslinux/ldlinux_v4.sys"
IDR_SL_LDLINUX_V5_BSS RCDATA "../res/syslinux/ldlinux_v5.bss"
IDR_SL_LDLINUX_V5_SYS RCDATA "../res/syslinux/ldlinux_v5.sys"
IDR_SL_MBOOT_C32 RCDATA "../res/syslinux/mboot.c32"
IDR_BR_MBR_BIN RCDATA "../res/mbr/mbr.bin"
IDR_FD_COMMAND_COM RCDATA "../res/freedos/COMMAND.COM"
IDR_FD_KERNEL_SYS RCDATA "../res/freedos/KERNEL.SYS"

View file

@ -2,7 +2,7 @@
*
* Copyright 2003 Lars Munch Christensen - All Rights Reserved
* Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
* Copyright 2012-2013 Pete Batard
* Copyright 2012-2014 Pete Batard
*
* Based on the Linux installer program for SYSLINUX by H. Peter Anvin
*
@ -39,6 +39,8 @@ unsigned char* syslinux_ldlinux = NULL;
DWORD syslinux_ldlinux_len;
unsigned char* syslinux_bootsect = NULL;
DWORD syslinux_bootsect_len;
unsigned char* syslinux_mboot = NULL;
DWORD syslinux_mboot_len;
/*
* Wrapper for ReadFile suitable for libfat
@ -77,12 +79,14 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
FILE* fd;
static unsigned char sectbuf[SECTOR_SIZE];
static LPSTR resource[2][2] = {
{ MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_BSS) },
{ MAKEINTRESOURCEA(IDR_SL_LDLINUX_V5_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V5_BSS) } };
static char* resource[2][2] = {
{ MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_BSS) },
{ MAKEINTRESOURCEA(IDR_SL_LDLINUX_V5_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V5_BSS) } };
static char ldlinux_path[] = "?:\\ldlinux.sys";
static char* ldlinux_sys = &ldlinux_path[3];
const char* ldlinux_c32 = "ldlinux.c32";
const char* mboot_c32 = "mboot.c32";
char path[MAX_PATH];
struct libfat_filesystem *fs;
libfat_sector_t s, *secp;
libfat_sector_t *sectors = NULL;
@ -223,6 +227,39 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
uprintf("Failed to create '%s': %s\n", ldlinux_path, WindowsErrorString());
}
}
} else if (IS_REACTOS(iso_report)) {
uprintf("Setting up ReactOS...\n");
syslinux_mboot = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_SL_MBOOT_C32),
_RT_RCDATA, "mboot.c32", &syslinux_mboot_len, FALSE);
if (syslinux_mboot == NULL) {
goto out;
}
/* Create mboot.c32 file */
safe_sprintf(path, sizeof(path), "%c:\\%s", drive_letter, mboot_c32);
f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (f_handle == INVALID_HANDLE_VALUE) {
uprintf("Unable to create '%s'\n", path);
goto out;
}
if (!WriteFile(f_handle, syslinux_mboot, syslinux_mboot_len,
&bytes_written, NULL) ||
bytes_written != syslinux_mboot_len) {
uprintf("Could not write '%s'\n", path);
goto out;
}
safe_closehandle(f_handle);
safe_sprintf(path, sizeof(path), "%c:\\syslinux.cfg", drive_letter);
fd = fopen(path, "w");
if (fd == NULL) {
uprintf("Could not create ReactOS 'syslinux.cfg'\n");
goto out;
}
/* Write the syslinux.cfg for ReactOS */
fprintf(fd, "DEFAULT ReactOS\nLABEL ReactOS\n KERNEL %s\n APPEND %s\n",
mboot_c32, iso_report.reactos_path);
fclose(fd);
}
if (dt != DT_ISO)