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

[syslinux] improve handling of 4.x C32 files

* Download the files from files/syslinux-4.07 on the server
* Save local copy in rufus_files/syslinux-4.07
* Move menu.c32/vesamenu.c32 check to BootCheck()
This commit is contained in:
Pete Batard 2014-02-04 20:01:28 +00:00
parent d3a0fc9b1d
commit 7d1a3d82cc
4 changed files with 84 additions and 70 deletions

View file

@ -69,7 +69,7 @@ static const char* pe_dirname[] = { "/i386", "/minint" };
static const char* pe_file[] = { "ntdetect.com", "setupldr.bin", "txtsetup.sif" }; 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* reactos_name = "setupldr.sys"; // TODO: freeldr.sys doesn't seem to work
static const char* autorun_name = "autorun.inf"; static const char* autorun_name = "autorun.inf";
static const char* old_c32_name[NB_OLD_C32] = OLD_C32_NAMES; const char* old_c32_name[NB_OLD_C32] = OLD_C32_NAMES;
static const int64_t old_c32_threshold[NB_OLD_C32] = OLD_C32_THRESHOLD; static const int64_t old_c32_threshold[NB_OLD_C32] = OLD_C32_THRESHOLD;
static uint8_t i_joliet_level = 0; static uint8_t i_joliet_level = 0;
static uint64_t total_blocks, nb_blocks; static uint64_t total_blocks, nb_blocks;
@ -218,7 +218,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
BOOL r, is_syslinux_cfg, is_old_c32[NB_OLD_C32]; BOOL r, is_syslinux_cfg, is_old_c32[NB_OLD_C32];
int i_length; int i_length;
size_t i, nul_pos; size_t i, nul_pos;
char* psz_fullpath = NULL; char tmp[128], *psz_fullpath = NULL;
const char* psz_basename; const char* psz_basename;
udf_dirent_t *p_udf_dirent2; udf_dirent_t *p_udf_dirent2;
uint8_t buf[UDF_BLOCKSIZE]; uint8_t buf[UDF_BLOCKSIZE];
@ -266,7 +266,8 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
psz_fullpath[nul_pos] = 0; psz_fullpath[nul_pos] = 0;
for (i=0; i<NB_OLD_C32; i++) { for (i=0; i<NB_OLD_C32; i++) {
if (is_old_c32[i] && use_own_c32[i]) { if (is_old_c32[i] && use_own_c32[i]) {
if (CopyFileA(old_c32_name[i], psz_fullpath, FALSE)) { static_sprintf(tmp, "%s/syslinux-%s/%s", FILES_DIR, embedded_sl_version_str[0], old_c32_name[i]);
if (CopyFileA(tmp, psz_fullpath, FALSE)) {
uprintf(" Replaced with local version\n"); uprintf(" Replaced with local version\n");
break; break;
} }
@ -346,7 +347,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
DWORD buf_size, wr_size, err; DWORD buf_size, wr_size, err;
BOOL s, is_syslinux_cfg, is_old_c32[NB_OLD_C32]; BOOL s, is_syslinux_cfg, is_old_c32[NB_OLD_C32];
int i_length, r = 1; int i_length, r = 1;
char psz_fullpath[1024], *psz_basename; char tmp[128], psz_fullpath[1024], *psz_basename;
const char *psz_iso_name = &psz_fullpath[strlen(psz_extract_dir)]; const char *psz_iso_name = &psz_fullpath[strlen(psz_extract_dir)];
unsigned char buf[ISO_BLOCKSIZE]; unsigned char buf[ISO_BLOCKSIZE];
CdioListNode_t* p_entnode; CdioListNode_t* p_entnode;
@ -406,7 +407,8 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
psz_fullpath[nul_pos] = 0; psz_fullpath[nul_pos] = 0;
for (i=0; i<NB_OLD_C32; i++) { for (i=0; i<NB_OLD_C32; i++) {
if (is_old_c32[i] && use_own_c32[i]) { if (is_old_c32[i] && use_own_c32[i]) {
if (CopyFileA(old_c32_name[i], psz_fullpath, FALSE)) { static_sprintf(tmp, "%s/syslinux-%s/%s", FILES_DIR, embedded_sl_version_str[0], old_c32_name[i]);
if (CopyFileA(tmp, psz_fullpath, FALSE)) {
uprintf(" Replaced with local version\n"); uprintf(" Replaced with local version\n");
break; break;
} }
@ -510,6 +512,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
SendMessage(hISOProgressBar, PBM_SETMARQUEE, TRUE, 0); SendMessage(hISOProgressBar, PBM_SETMARQUEE, TRUE, 0);
} else { } else {
uprintf("Extracting files...\n"); uprintf("Extracting files...\n");
IGNORE_RETVAL(_chdirU(app_dir));
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_231)); SetWindowTextU(hISOProgressDlg, lmprintf(MSG_231));
if (total_blocks == 0) { if (total_blocks == 0) {
uprintf("Error: ISO has not been properly scanned.\n"); uprintf("Error: ISO has not been properly scanned.\n");

View file

@ -118,6 +118,7 @@ static BOOL iso_provided = FALSE;
static BOOL user_notified = FALSE; static BOOL user_notified = FALSE;
static BOOL relaunch = FALSE; static BOOL relaunch = FALSE;
extern BOOL force_large_fat32, enable_joliet, enable_rockridge, enable_ntfs_compression; extern BOOL force_large_fat32, enable_joliet, enable_rockridge, enable_ntfs_compression;
extern const char* old_c32_name[NB_OLD_C32];
static int selection_default; static int selection_default;
static loc_cmd* selected_locale = NULL; static loc_cmd* selected_locale = NULL;
static UINT_PTR UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU; static UINT_PTR UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU;
@ -1184,9 +1185,6 @@ DWORD WINAPI ISOScanThread(LPVOID param)
{ {
int i; int i;
BOOL r; BOOL r;
FILE* fd;
const char* old_c32_name[NB_OLD_C32] = OLD_C32_NAMES;
const char* new_c32_url[NB_OLD_C32] = NEW_C32_URL;
char isolinux_str[16] = "No"; char isolinux_str[16] = "No";
if (iso_path == NULL) if (iso_path == NULL)
@ -1222,30 +1220,6 @@ DWORD WINAPI ISOScanThread(LPVOID param)
safe_free(iso_path); safe_free(iso_path);
SetMBRProps(); SetMBRProps();
} else if (HAS_SYSLINUX(iso_report)) { } else if (HAS_SYSLINUX(iso_report)) {
if (SL_MAJOR(iso_report.sl_version) < 5) {
_chdirU(app_dir);
for (i=0; i<NB_OLD_C32; i++) {
if (iso_report.has_old_c32[i]) {
fd = fopen(old_c32_name[i], "rb");
if (fd != NULL) {
// If a file already exists in the current directory, use that one
uprintf("Will replace obsolete '%s' from ISO with the one found in current directory\n", old_c32_name[i]);
fclose(fd);
use_own_c32[i] = TRUE;
} else {
PrintStatus(0, FALSE, MSG_204, old_c32_name[i]);
if (MessageBoxU(hMainDialog, lmprintf(MSG_084, old_c32_name[i], old_c32_name[i]),
lmprintf(MSG_083, old_c32_name[i]), MB_YESNO|MB_ICONWARNING|MB_IS_RTL) == IDYES) {
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_085, old_c32_name[i]));
SetWindowTextU(hISOFileName, new_c32_url[i]);
if (DownloadFile(new_c32_url[i], old_c32_name[i], hISOProgressDlg))
use_own_c32[i] = TRUE;
}
}
}
}
}
// Enable bootable and set Target System and FS accordingly // Enable bootable and set Target System and FS accordingly
CheckDlgButton(hMainDialog, IDC_BOOT, BST_CHECKED); CheckDlgButton(hMainDialog, IDC_BOOT, BST_CHECKED);
SetTargetSystem(); SetTargetSystem();
@ -1342,6 +1316,7 @@ static BOOL BootCheck(void)
{ {
int i, fs, bt, dt, r; int i, fs, bt, dt, r;
FILE* fd; FILE* fd;
DWORD len;
const char* ldlinux = "ldlinux"; const char* ldlinux = "ldlinux";
const char* syslinux = "syslinux"; const char* syslinux = "syslinux";
const char* ldlinux_ext[3] = { "sys", "bss", "c32" }; const char* ldlinux_ext[3] = { "sys", "bss", "c32" };
@ -1393,40 +1368,77 @@ static BOOL BootCheck(void)
MessageBoxU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL); MessageBoxU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL);
return FALSE; return FALSE;
} }
if ((SL_MAJOR(iso_report.sl_version) >= 5) && (iso_report.sl_version != embedded_sl_version[1])) {
// Unlike what was the case for v4 and earlier, Syslinux v5+ versions are INCOMPATIBLE with one another! if (HAS_SYSLINUX(iso_report)) {
IGNORE_RETVAL(_chdirU(app_dir)); if (SL_MAJOR(iso_report.sl_version) < 5) {
IGNORE_RETVAL(_mkdir(FILES_DIR)); IGNORE_RETVAL(_chdirU(app_dir));
IGNORE_RETVAL(_chdir(FILES_DIR)); for (i=0; i<NB_OLD_C32; i++) {
for (i=0; i<2; i++) { if (iso_report.has_old_c32[i]) {
// Check if we already have the relevant ldlinux_v#.##.sys & ldlinux_v#.##.bss files if (i==0) {
static_sprintf(tmp, "%s-%s/%s.%s", syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]); IGNORE_RETVAL(_mkdir(FILES_DIR));
fd = fopen(tmp, "rb"); IGNORE_RETVAL(_chdir(FILES_DIR));
if (fd != NULL) { }
fseek(fd, 0, SEEK_END); static_sprintf(tmp, "%s-%s/%s", syslinux, embedded_sl_version_str[0], old_c32_name[i]);
syslinux_ldlinux_len[i] = (DWORD)ftell(fd); fd = fopen(tmp, "rb");
fclose(fd); if (fd != NULL) {
// If a file already exists in the current directory, use that one
uprintf("Will replace obsolete '%s' from ISO with the one found in './%s'\n", old_c32_name[i], tmp);
fclose(fd);
use_own_c32[i] = TRUE;
} else {
PrintStatus(0, FALSE, MSG_204, old_c32_name[i]);
if (MessageBoxU(hMainDialog, lmprintf(MSG_084, old_c32_name[i], old_c32_name[i]),
lmprintf(MSG_083, old_c32_name[i]), MB_YESNO|MB_ICONWARNING|MB_IS_RTL) == IDYES) {
static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[0]);
IGNORE_RETVAL(_mkdir(tmp));
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_085, old_c32_name[i]));
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, syslinux, embedded_sl_version_str[0], old_c32_name[i]);
SetWindowTextU(hISOFileName, tmp);
len = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hISOProgressDlg);
if (len == 0) {
uprintf("Couldn't download the files - cancelling\n");
return FALSE;
}
use_own_c32[i] = TRUE;
}
}
}
} }
} } else if (iso_report.sl_version != embedded_sl_version[1]) {
if ((syslinux_ldlinux_len[0] != 0) && (syslinux_ldlinux_len[1] != 0)) { // Unlike what was the case for v4 and earlier, Syslinux v5+ versions are INCOMPATIBLE with one another!
uprintf("Will reuse '%s.%s' and '%s.%s' from './%s/%s-%s/' for Syslinux installation\n", IGNORE_RETVAL(_chdirU(app_dir));
ldlinux, ldlinux_ext[0], ldlinux, ldlinux_ext[1], FILES_DIR, syslinux, iso_report.sl_version_str); IGNORE_RETVAL(_mkdir(FILES_DIR));
} else { IGNORE_RETVAL(_chdir(FILES_DIR));
r = MessageBoxU(hMainDialog, lmprintf(MSG_114, iso_report.sl_version_str, embedded_sl_version_str[1]),
lmprintf(MSG_115), MB_YESNO|MB_ICONWARNING|MB_IS_RTL);
if (r != IDYES)
return FALSE;
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
static_sprintf(tmp, "%s-%s", syslinux, iso_report.sl_version_str); // Check if we already have the relevant ldlinux_v#.##.sys & ldlinux_v#.##.bss files
IGNORE_RETVAL(_mkdir(tmp)); static_sprintf(tmp, "%s-%s/%s.%s", syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]);
static_sprintf(tmp, "%s.%s %s", ldlinux, ldlinux_ext[i], iso_report.sl_version_str); fd = fopen(tmp, "rb");
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_085, tmp)); if (fd != NULL) {
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]); fseek(fd, 0, SEEK_END);
SetWindowTextU(hISOFileName, tmp); syslinux_ldlinux_len[i] = (DWORD)ftell(fd);
syslinux_ldlinux_len[i] = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hISOProgressDlg); fclose(fd);
if (syslinux_ldlinux_len[i] == 0) { }
uprintf("Couldn't download the files - cancelling\n"); }
if ((syslinux_ldlinux_len[0] != 0) && (syslinux_ldlinux_len[1] != 0)) {
uprintf("Will reuse '%s.%s' and '%s.%s' from './%s/%s-%s/' for Syslinux installation\n",
ldlinux, ldlinux_ext[0], ldlinux, ldlinux_ext[1], FILES_DIR, syslinux, iso_report.sl_version_str);
} else {
r = MessageBoxU(hMainDialog, lmprintf(MSG_114, iso_report.sl_version_str, embedded_sl_version_str[1]),
lmprintf(MSG_115), MB_YESNO|MB_ICONWARNING|MB_IS_RTL);
if (r != IDYES)
return FALSE; return FALSE;
for (i=0; i<2; i++) {
static_sprintf(tmp, "%s-%s", syslinux, iso_report.sl_version_str);
IGNORE_RETVAL(_mkdir(tmp));
static_sprintf(tmp, "%s.%s %s", ldlinux, ldlinux_ext[i], iso_report.sl_version_str);
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_085, tmp));
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]);
SetWindowTextU(hISOFileName, tmp);
syslinux_ldlinux_len[i] = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hISOProgressDlg);
if (syslinux_ldlinux_len[i] == 0) {
uprintf("Couldn't download the files - cancelling\n");
return FALSE;
}
} }
} }
} }

View file

@ -214,7 +214,6 @@ typedef struct {
#define NB_OLD_C32 2 #define NB_OLD_C32 2
#define OLD_C32_NAMES { "menu.c32", "vesamenu.c32" } #define OLD_C32_NAMES { "menu.c32", "vesamenu.c32" }
#define OLD_C32_THRESHOLD { 53500, 148000 } #define OLD_C32_THRESHOLD { 53500, 148000 }
#define NEW_C32_URL { DOWNLOAD_URL "/menu.c32", DOWNLOAD_URL "/vesamenu.c32" }
/* ISO details that the application may want */ /* ISO details that the application may want */
#define WINPE_MININT 0x2A #define WINPE_MININT 0x2A

View file

@ -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.4.402" CAPTION "Rufus 1.4.4.403"
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.4.402" CAPTION "Rufus 1.4.4.403"
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,4,402 FILEVERSION 1,4,4,403
PRODUCTVERSION 1,4,4,402 PRODUCTVERSION 1,4,4,403
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.4.402" VALUE "FileVersion", "1.4.4.403"
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.4.402" VALUE "ProductVersion", "1.4.4.403"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"