mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[syslinux] initial Syslinux v5 support
* Use .bss and .sys from Syslinux v5.10 * Advanced options allow you to choose between v4 and v5 * Rufus does not currently copy any ldlinux.c32 to the target
This commit is contained in:
parent
0e1c474ca0
commit
df5bce297d
12 changed files with 53 additions and 37 deletions
BIN
res/syslinux/ldlinux_v5.bss
Normal file
BIN
res/syslinux/ldlinux_v5.bss
Normal file
Binary file not shown.
BIN
res/syslinux/ldlinux_v5.sys
Normal file
BIN
res/syslinux/ldlinux_v5.sys
Normal file
Binary file not shown.
|
@ -1,2 +1,3 @@
|
|||
o ldlinux.bss and ldlinux.sys are from syslinux-4.06/core/
|
||||
o ldlinux_v4.[bss|sys] have been renamed from ldlinux.[bss|sys] found in syslinux-4.06/core/
|
||||
o ldlinux_v5.[bss|sys] have been renamed from ldlinux.[bss|sys] found in syslinux-5.10/core/
|
||||
http://www.kernel.org/pub/linux/utils/boot/syslinux/
|
|
@ -877,7 +877,7 @@ 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) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
|
||||
if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V5) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
|
||||
r = write_syslinux_mbr(&fake_fd);
|
||||
} else {
|
||||
if ((IS_WINPE(iso_report.winpe) && !iso_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) {
|
||||
|
@ -1383,8 +1383,7 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
}
|
||||
// We must close and unlock the volume to write files to it
|
||||
safe_unlockclose(hLogicalVolume);
|
||||
} else if ( (dt == DT_SYSLINUX) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
|
||||
PrintStatus(0, TRUE, "Installing Syslinux...");
|
||||
} else if ( (dt == DT_SYSLINUX_V4) || (dt == DT_SYSLINUX_V5) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) {
|
||||
if (!InstallSyslinux(DriveIndex, drive_name[0])) {
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
|
||||
}
|
||||
|
|
|
@ -42,9 +42,10 @@
|
|||
#define IDR_FD_EGA16_CPX 324
|
||||
#define IDR_FD_EGA17_CPX 325
|
||||
#define IDR_FD_EGA18_CPX 326
|
||||
#define IDR_SL_LDLINUX_BSS 400
|
||||
#define IDR_SL_LDLINUX_SYS 401
|
||||
#define IDR_SL_CHAIN_C32 402
|
||||
#define IDR_SL_LDLINUX_V4_BSS 400
|
||||
#define IDR_SL_LDLINUX_V4_SYS 401
|
||||
#define IDR_SL_LDLINUX_V5_BSS 402
|
||||
#define IDR_SL_LDLINUX_V5_SYS 403
|
||||
#define IDC_DEVICE 1001
|
||||
#define IDC_FILESYSTEM 1002
|
||||
#define IDC_START 1003
|
||||
|
|
13
src/rufus.c
13
src/rufus.c
|
@ -1575,8 +1575,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
if (fs < 0) {
|
||||
EnableBootOptions(TRUE);
|
||||
SetMBRProps();
|
||||
// Remove the SysLinux option if exists
|
||||
if (ComboBox_GetItemData(hBootType, ComboBox_GetCount(hBootType)-1) == DT_SYSLINUX) {
|
||||
// Remove the SysLinux options if they exists
|
||||
if (ComboBox_GetItemData(hBootType, ComboBox_GetCount(hBootType)-1) == DT_SYSLINUX_V5) {
|
||||
IGNORE_RETVAL(ComboBox_DeleteString(hBootType, ComboBox_GetCount(hBootType)-1));
|
||||
IGNORE_RETVAL(ComboBox_DeleteString(hBootType, ComboBox_GetCount(hBootType)-1));
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 1));
|
||||
}
|
||||
|
@ -1601,9 +1602,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
}
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "ISO Image"), DT_ISO));
|
||||
// If needed (advanced mode) also append a Syslinux option
|
||||
if ( (bt == BT_BIOS) && (((fs == FS_FAT16) || (fs == FS_FAT32)) && (advanced_mode)) )
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "SysLinux"), DT_SYSLINUX));
|
||||
if ( ((!advanced_mode) && (selection_default == DT_SYSLINUX)) ) {
|
||||
if ( (bt == BT_BIOS) && (((fs == FS_FAT16) || (fs == FS_FAT32)) && (advanced_mode)) ) {
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "Syslinux 4"), DT_SYSLINUX_V4));
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "Syslinux 5"), DT_SYSLINUX_V5));
|
||||
}
|
||||
if ( ((!advanced_mode) && ((selection_default == DT_SYSLINUX_V4) || (selection_default == DT_SYSLINUX_V5))) ) {
|
||||
selection_default = DT_FREEDOS;
|
||||
CheckDlgButton(hDlg, IDC_DISK_ID, BST_UNCHECKED);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,8 @@ enum dos_type {
|
|||
DT_WINME = 0,
|
||||
DT_FREEDOS,
|
||||
DT_ISO,
|
||||
DT_SYSLINUX,
|
||||
DT_SYSLINUX_V4,
|
||||
DT_SYSLINUX_V5,
|
||||
DT_MAX
|
||||
};
|
||||
|
||||
|
|
22
src/rufus.rc
22
src/rufus.rc
|
@ -30,7 +30,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.3.4.252"
|
||||
CAPTION "Rufus v1.3.4.253"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -185,8 +185,10 @@ END
|
|||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"IDR_SL_LDLINUX_BSS RCDATA ""../res/syslinux/ldlinux.bss""\r\n"
|
||||
"IDR_SL_LDLINUX_SYS RCDATA ""../res/syslinux/ldlinux.sys""\r\n"
|
||||
"IDR_SL_LDLINUX_V4_BSS RCDATA ""../res/syslinux/ldlinux_v4.bss""\r\n"
|
||||
"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_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"
|
||||
|
@ -276,8 +278,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,3,4,252
|
||||
PRODUCTVERSION 1,3,4,252
|
||||
FILEVERSION 1,3,4,253
|
||||
PRODUCTVERSION 1,3,4,253
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -294,13 +296,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.3.4.252"
|
||||
VALUE "FileVersion", "1.3.4.253"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.3.4.252"
|
||||
VALUE "ProductVersion", "1.3.4.253"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -331,8 +333,10 @@ IDI_DOWN ICON "../res/down.ico"
|
|||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
IDR_SL_LDLINUX_BSS RCDATA "../res/syslinux/ldlinux.bss"
|
||||
IDR_SL_LDLINUX_SYS RCDATA "../res/syslinux/ldlinux.sys"
|
||||
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_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"
|
||||
|
|
|
@ -252,7 +252,7 @@ unsigned char* GetResource(HMODULE module, char* name, char* type, const char* d
|
|||
if (duplicate) {
|
||||
p = (unsigned char*)malloc(*len);
|
||||
if (p == NULL) {
|
||||
uprintf("Unable to allocate ldlinux.sys resource\n");
|
||||
uprintf("Unable to allocate resource '%s'\n", desc);
|
||||
goto out;
|
||||
}
|
||||
memcpy(p, LockResource(res_handle), *len);
|
||||
|
|
|
@ -75,7 +75,11 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
|
|||
BOOL r = FALSE;
|
||||
|
||||
static unsigned char sectbuf[SECTOR_SIZE];
|
||||
static char ldlinux_name[] = "?:\\ldlinux.sys";
|
||||
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 ldlinux_path[] = "?:\\ldlinux.sys";
|
||||
static char* ldlinux_sys = &ldlinux_path[3];
|
||||
struct libfat_filesystem *fs;
|
||||
libfat_sector_t s, *secp;
|
||||
libfat_sector_t *sectors = NULL;
|
||||
|
@ -83,30 +87,33 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
|
|||
uint32_t ldlinux_cluster;
|
||||
int nsectors;
|
||||
int dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
||||
BOOL use_v5 = (dt == DT_SYSLINUX_V5) || ((dt == DT_ISO) && (iso_report.has_syslinux_v5));
|
||||
|
||||
ldlinux_name[0] = drive_letter;
|
||||
PrintStatus(0, TRUE, "Installing Syslinux v%d...", use_v5?5:4);
|
||||
|
||||
ldlinux_path[0] = drive_letter;
|
||||
|
||||
/* Initialize the ADV -- this should be smarter */
|
||||
syslinux_reset_adv(syslinux_adv);
|
||||
|
||||
/* Access a copy of the ldlinux.sys & ldlinux.bss resources */
|
||||
syslinux_ldlinux = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_SL_LDLINUX_SYS),
|
||||
_RT_RCDATA, "ldlinux.sys", &syslinux_ldlinux_len, TRUE);
|
||||
syslinux_bootsect = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_SL_LDLINUX_BSS),
|
||||
_RT_RCDATA,"ldlinux.bss", &syslinux_bootsect_len, TRUE);
|
||||
syslinux_ldlinux = GetResource(hMainInstance, resource[use_v5?1:0][0],
|
||||
_RT_RCDATA, ldlinux_sys, &syslinux_ldlinux_len, TRUE);
|
||||
syslinux_bootsect = GetResource(hMainInstance, resource[use_v5?1:0][1],
|
||||
_RT_RCDATA, "ldlinux.bss", &syslinux_bootsect_len, TRUE);
|
||||
if ((syslinux_ldlinux == NULL) || (syslinux_bootsect == NULL)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Create ldlinux.sys file */
|
||||
f_handle = CreateFileA(ldlinux_name, GENERIC_READ | GENERIC_WRITE,
|
||||
f_handle = CreateFileA(ldlinux_path, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM |
|
||||
FILE_ATTRIBUTE_HIDDEN, NULL);
|
||||
|
||||
if (f_handle == INVALID_HANDLE_VALUE) {
|
||||
uprintf("Unable to create ldlinux.sys\n");
|
||||
uprintf("Unable to create '%s'\n", ldlinux_sys);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -114,18 +121,18 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
|
|||
if (!WriteFile(f_handle, syslinux_ldlinux, syslinux_ldlinux_len,
|
||||
&bytes_written, NULL) ||
|
||||
bytes_written != syslinux_ldlinux_len) {
|
||||
uprintf("Could not write ldlinux.sys\n");
|
||||
uprintf("Could not write '%s'\n", ldlinux_sys);
|
||||
goto out;
|
||||
}
|
||||
if (!WriteFile(f_handle, syslinux_adv, 2 * ADV_SIZE,
|
||||
&bytes_written, NULL) ||
|
||||
bytes_written != 2 * ADV_SIZE) {
|
||||
uprintf("Could not write ADV to ldlinux.sys\n");
|
||||
uprintf("Could not write ADV to '%s'\n", ldlinux_sys);
|
||||
goto out;
|
||||
}
|
||||
|
||||
uprintf("Succesfully wrote 'ldlinux.sys'\n");
|
||||
if (dt == DT_SYSLINUX)
|
||||
uprintf("Succesfully wrote '%s'\n", ldlinux_sys);
|
||||
if (dt != DT_ISO)
|
||||
UpdateProgress(OP_DOS, -1.0f);
|
||||
|
||||
/* Now flush the media */
|
||||
|
@ -166,7 +173,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
|
|||
!WriteFile(f_handle, syslinux_ldlinux, syslinux_ldlinux_len,
|
||||
&bytes_written, NULL)
|
||||
|| bytes_written != syslinux_ldlinux_len) {
|
||||
uprintf("Could not write ldlinux.sys: %s\n", WindowsErrorString());
|
||||
uprintf("Could not write '%s': %s\n", ldlinux_sys, WindowsErrorString());
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -195,7 +202,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
|
|||
}
|
||||
|
||||
uprintf("Succesfully wrote Syslinux boot record\n");
|
||||
if (dt == DT_SYSLINUX)
|
||||
if (dt != DT_ISO)
|
||||
UpdateProgress(OP_DOS, -1.0f);
|
||||
|
||||
r = TRUE;
|
||||
|
|
Loading…
Reference in a new issue