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

[iso] add support for VMWare ESXi 5.1

* Closes #98
* Also closes #113
* Also improves on the ISO analysis report
This commit is contained in:
Pete Batard 2012-12-15 03:27:14 +00:00
parent 638f7876c4
commit 13a6b6b751
5 changed files with 86 additions and 60 deletions

View file

@ -58,10 +58,10 @@ static const char* psz_extract_dir;
static const char* bootmgr_name = "bootmgr"; static const char* bootmgr_name = "bootmgr";
static const char* ldlinux_name = "ldlinux.sys"; static const char* ldlinux_name = "ldlinux.sys";
static const char* isolinux_name[] = { "isolinux.cfg", "syslinux.cfg", "extlinux.conf"}; static const char* isolinux_name[] = { "isolinux.cfg", "syslinux.cfg", "extlinux.conf"};
static const char* vesamenu_name = "vesamenu.c32";
static const char* pe_dirname[] = { "/i386", "/minint" }; 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 int64_t old_vesamenu_threshold = 145000; 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;
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;
static BOOL scan_only = FALSE; static BOOL scan_only = FALSE;
@ -102,7 +102,7 @@ static void log_handler (cdio_log_level_t level, const char *message)
* Scan and set ISO properties * Scan and set ISO properties
* Returns true if the the current file does not need to be processed further * Returns true if the the current file does not need to be processed further
*/ */
static __inline BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL* is_old_vesamenu, static __inline BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_cfg, BOOL* is_old_c32,
int64_t i_file_length, const char* psz_basename, const char* psz_fullpath) int64_t i_file_length, const char* psz_basename, const char* psz_fullpath)
{ {
size_t i, j; size_t i, j;
@ -114,10 +114,11 @@ static __inline BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_
*is_syslinux_cfg = TRUE; *is_syslinux_cfg = TRUE;
} }
// Check for an old vesamenu.c32 file anywhere // Check for an old incompatible c32 file anywhere
*is_old_vesamenu = FALSE; for (i=0; i<NB_OLD_C32; i++) {
if ((safe_stricmp(psz_basename, vesamenu_name) == 0) && (i_file_length <= old_vesamenu_threshold)) { is_old_c32[i] = FALSE;
*is_old_vesamenu = TRUE; if ((safe_stricmp(psz_basename, old_c32_name[i]) == 0) && (i_file_length <= old_c32_threshold[i]))
is_old_c32[i] = TRUE;
} }
if (scan_only) { if (scan_only) {
@ -137,8 +138,10 @@ static __inline BOOL check_iso_props(const char* psz_dirname, BOOL* is_syslinux_
// Maintain a list of all the isolinux/syslinux configs identified so far // Maintain a list of all the isolinux/syslinux configs identified so far
StrArrayAdd(&config_path, psz_fullpath); StrArrayAdd(&config_path, psz_fullpath);
} }
if (*is_old_vesamenu) for (i=0; i<NB_OLD_C32; i++) {
iso_report.has_old_vesamenu = TRUE; if (is_old_c32[i])
iso_report.has_old_c32[i] = TRUE;
}
if (i_file_length >= FOUR_GIGABYTES) if (i_file_length >= FOUR_GIGABYTES)
iso_report.has_4GB_file = TRUE; iso_report.has_4GB_file = TRUE;
// Compute projected size needed // Compute projected size needed
@ -161,7 +164,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
{ {
HANDLE file_handle = NULL; HANDLE file_handle = NULL;
DWORD buf_size, wr_size; DWORD buf_size, wr_size;
BOOL r, is_syslinux_cfg, is_old_vesamenu; 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* psz_fullpath = NULL;
@ -195,7 +198,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
} }
} else { } else {
i_file_length = udf_get_file_length(p_udf_dirent); i_file_length = udf_get_file_length(p_udf_dirent);
if (check_iso_props(psz_path, &is_syslinux_cfg, &is_old_vesamenu, i_file_length, psz_basename, psz_fullpath)) { if (check_iso_props(psz_path, &is_syslinux_cfg, is_old_c32, i_file_length, psz_basename, psz_fullpath)) {
safe_free(psz_fullpath); safe_free(psz_fullpath);
continue; continue;
} }
@ -207,13 +210,17 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
SetWindowTextU(hISOFileName, psz_fullpath); SetWindowTextU(hISOFileName, psz_fullpath);
// Remove the appended size for extraction // Remove the appended size for extraction
psz_fullpath[nul_pos] = 0; psz_fullpath[nul_pos] = 0;
if (is_old_vesamenu && use_own_vesamenu) { for (i=0; i<NB_OLD_C32; i++) {
if (CopyFileA("vesamenu.c32", psz_fullpath, FALSE)) { if (is_old_c32[i] && use_own_c32[i]) {
uprintf(" Replaced with local version\n"); if (CopyFileA(old_c32_name[i], psz_fullpath, FALSE)) {
continue; uprintf(" Replaced with local version\n");
break;
}
uprintf(" Could not replace file: %s\n", WindowsErrorString());
} }
uprintf(" Could not replace file: %s\n", WindowsErrorString());
} }
if (i < NB_OLD_C32)
continue;
file_handle = CreateFileU(psz_fullpath, GENERIC_READ | GENERIC_WRITE, file_handle = CreateFileU(psz_fullpath, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE) { if (file_handle == INVALID_HANDLE_VALUE) {
@ -270,7 +277,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
{ {
HANDLE file_handle = NULL; HANDLE file_handle = NULL;
DWORD buf_size, wr_size; DWORD buf_size, wr_size;
BOOL s, is_syslinux_cfg, is_old_vesamenu; 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 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)];
@ -310,7 +317,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
goto out; goto out;
} else { } else {
i_file_length = p_statbuf->size; i_file_length = p_statbuf->size;
if (check_iso_props(psz_path, &is_syslinux_cfg, &is_old_vesamenu, i_file_length, psz_basename, psz_fullpath)) { if (check_iso_props(psz_path, &is_syslinux_cfg, is_old_c32, i_file_length, psz_basename, psz_fullpath)) {
continue; continue;
} }
// Replace slashes with backslashes and append the size to the path for UI display // Replace slashes with backslashes and append the size to the path for UI display
@ -322,13 +329,17 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
// ISO9660 cannot handle backslashes // ISO9660 cannot handle backslashes
for (i=0; i<nul_pos; i++) if (psz_fullpath[i] == '\\') psz_fullpath[i] = '/'; for (i=0; i<nul_pos; i++) if (psz_fullpath[i] == '\\') psz_fullpath[i] = '/';
psz_fullpath[nul_pos] = 0; psz_fullpath[nul_pos] = 0;
if (is_old_vesamenu && use_own_vesamenu) { for (i=0; i<NB_OLD_C32; i++) {
if (CopyFileA("vesamenu.c32", psz_fullpath, FALSE)) { if (is_old_c32[i] && use_own_c32[i]) {
uprintf(" Replaced with local version\n"); if (CopyFileA(old_c32_name[i], psz_fullpath, FALSE)) {
continue; uprintf(" Replaced with local version\n");
break;
}
uprintf(" Could not replace file: %s\n", WindowsErrorString());
} }
uprintf(" Could not replace file: %s\n", WindowsErrorString());
} }
if (i < NB_OLD_C32)
continue;
file_handle = CreateFileU(psz_fullpath, GENERIC_READ | GENERIC_WRITE, file_handle = CreateFileU(psz_fullpath, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (file_handle == INVALID_HANDLE_VALUE) { if (file_handle == INVALID_HANDLE_VALUE) {

View file

@ -81,7 +81,7 @@ static wchar_t* get_token_data_line(const wchar_t* wtoken, wchar_t* wline)
// locate end of string or quote // locate end of string or quote
while ( (wline[i] != 0) && ((wline[i] != L'"') || ((wline[i] == L'"') && (!quoteth))) ) while ( (wline[i] != 0) && ((wline[i] != L'"') || ((wline[i] == L'"') && (!quoteth))) )
i++; i++;
wline[i] = 0; wline[i--] = 0;
// Eliminate trailing EOL characters // Eliminate trailing EOL characters
while ((i>=r) && ((wline[i] == L'\r') || (wline[i] == L'\n'))) while ((i>=r) && ((wline[i] == L'\r') || (wline[i] == L'\n')))

View file

@ -103,7 +103,7 @@ float fScale = 1.0f;
int default_fs; int default_fs;
HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses, hLog = NULL; HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses, hLog = NULL;
HWND hISOProgressDlg = NULL, hLogDlg = NULL, hISOProgressBar, hISOFileName, hDiskID; HWND hISOProgressDlg = NULL, hLogDlg = NULL, hISOProgressBar, hISOFileName, hDiskID;
BOOL use_own_vesamenu = FALSE, detect_fakes = TRUE, mbr_selected_by_user = FALSE; BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, detect_fakes = TRUE, mbr_selected_by_user = FALSE;
BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE; BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE;
int dialog_showing = 0; int dialog_showing = 0;
uint16_t rufus_version[4]; uint16_t rufus_version[4];
@ -1247,7 +1247,9 @@ DWORD WINAPI ISOScanThread(LPVOID param)
{ {
int i; int i;
FILE* fd; FILE* fd;
const char* vesamenu_filename = "vesamenu.c32"; const char* old_c32_name[NB_OLD_C32] = OLD_C32_NAMES;
const char* new_c32_url[NB_OLD_C32] = NEW_C32_URL;
char msg[1024], msg_title[32];
if (iso_path == NULL) if (iso_path == NULL)
goto out; goto out;
@ -1258,10 +1260,14 @@ DWORD WINAPI ISOScanThread(LPVOID param)
safe_free(iso_path); safe_free(iso_path);
goto out; goto out;
} }
uprintf("ISO label: '%s'\r\n size: %lld bytes, 4GB:%c, bootmgr:%c, winpe:%c (/minint:%c), isolinux:%c, old vesa:%c\n", uprintf("ISO label: '%s'\r\n Size: %lld bytes\r\n Has a >4GB file: %s\r\n Uses Bootmgr: %s\r\n Uses WinPE: %s%s\r\n Uses isolinux: %s\n",
iso_report.label, iso_report.projected_size, iso_report.has_4GB_file?'Y':'N', iso_report.label, iso_report.projected_size, iso_report.has_4GB_file?"Yes":"No", iso_report.has_bootmgr?"Yes":"No",
iso_report.has_bootmgr?'Y':'N', IS_WINPE(iso_report.winpe)?'Y':'N', (iso_report.uses_minint)?'Y':'N', IS_WINPE(iso_report.winpe)?"Yes":"No", (iso_report.uses_minint)?" (with /minint)":"", iso_report.has_isolinux?"Yes":"No");
iso_report.has_isolinux?'Y':'N', iso_report.has_old_vesamenu?'Y':'N'); if (iso_report.has_isolinux) {
for (i=0; i<NB_OLD_C32; i++) {
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))) { if ((!iso_report.has_bootmgr) && (!iso_report.has_isolinux) && (!IS_WINPE(iso_report.winpe))) {
MessageBoxU(hMainDialog, "This version of Rufus only supports bootable ISOs\n" MessageBoxU(hMainDialog, "This version of Rufus only supports bootable ISOs\n"
"based on 'bootmgr/WinPE' or 'isolinux'.\n" "based on 'bootmgr/WinPE' or 'isolinux'.\n"
@ -1269,29 +1275,31 @@ DWORD WINAPI ISOScanThread(LPVOID param)
safe_free(iso_path); safe_free(iso_path);
SetMBRProps(); SetMBRProps();
} else { } else {
if (iso_report.has_old_vesamenu) { for(i=0; i<NB_OLD_C32; i++) {
fd = fopen(vesamenu_filename, "rb"); if (iso_report.has_old_c32[i]) {
if (fd != NULL) { fd = fopen(old_c32_name[i], "rb");
// If a file already exists in the current directory, use that one if (fd != NULL) {
uprintf("Will replace obsolete '%s' from ISO with the one found in current directory\n", vesamenu_filename); // If a file already exists in the current directory, use that one
fclose(fd); uprintf("Will replace obsolete '%s' from ISO with the one found in current directory\n", old_c32_name[i]);
use_own_vesamenu = TRUE; fclose(fd);
} else { use_own_c32[i] = TRUE;
PrintStatus(0, FALSE, "Obsolete vesamenu.c32 detected"); } else {
if (MessageBoxA(hMainDialog, PrintStatus(0, FALSE, "Obsolete %s detected", old_c32_name[i]);
"This ISO image seems to use an obsolete version of vesamenu.c32\n" safe_sprintf(msg, sizeof(msg), "This ISO image seems to use an obsolete version of %s\n"
"that may prevent boot menus from displaying properly...\n\n" "that may prevent boot menus from displaying properly...\n\n"
"Rufus can fix this issue by downloading a newer version for you:\n" "Rufus can fix this issue by downloading a newer version for you:\n"
"- Select 'Yes' to connect to the internet and replace the file.\n" "- Select 'Yes' to connect to the internet and replace the file.\n"
"- Select 'No' to leave the existing ISO file unmodified.\n" "- Select 'No' to leave the existing ISO file unmodified.\n"
"If you don't know what to do, you should select 'Yes'.\n\n" "If you don't know what to do, you should select 'Yes'.\n\n"
"Note: the file will be downloaded in the current directory. Once a\n" "Note: the file will be downloaded in the current directory. Once a\n"
"vesamenu.c32 exists there, it will always be used as replacement.\n", "Replace vesamenu.c32?", "%s exists there, it will always be used as replacement.\n", old_c32_name[i], old_c32_name[i]);
MB_YESNO|MB_ICONWARNING) == IDYES) { safe_sprintf(msg_title, sizeof(msg_title), "Replace %s?", old_c32_name[i]);
SetWindowTextU(hISOProgressDlg, "Downloading file..."); if (MessageBoxA(hMainDialog, msg, msg_title, MB_YESNO|MB_ICONWARNING) == IDYES) {
SetWindowTextU(hISOFileName, VESAMENU_URL); SetWindowTextU(hISOProgressDlg, "Downloading file...");
if (DownloadFile(VESAMENU_URL, vesamenu_filename, hISOProgressDlg)) SetWindowTextU(hISOFileName, new_c32_url[i]);
use_own_vesamenu = TRUE; if (DownloadFile(new_c32_url[i], old_c32_name[i], hISOProgressDlg))
use_own_c32[i] = TRUE;
}
} }
} }
} }

View file

@ -43,7 +43,6 @@
#define WHITE RGB(255,255,255) #define WHITE RGB(255,255,255)
#define SEPARATOR_GREY RGB(223,223,223) #define SEPARATOR_GREY RGB(223,223,223)
#define RUFUS_URL "http://rufus.akeo.ie" #define RUFUS_URL "http://rufus.akeo.ie"
#define VESAMENU_URL "http://cloud.github.com/downloads/pbatard/rufus/vesamenu.c32"
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0) #define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
#ifndef ARRAYSIZE #ifndef ARRAYSIZE
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
@ -157,10 +156,17 @@ typedef struct {
} ClusterSize[FS_MAX]; } ClusterSize[FS_MAX];
} RUFUS_DRIVE_INFO; } RUFUS_DRIVE_INFO;
/* Special handling for old .c32 files we need to replace */
#define NB_OLD_C32 2
#define OLD_C32_NAMES {"menu.c32", "vesamenu.c32"}
#define OLD_C32_THRESHOLD {53500, 145000}
#define NEW_C32_URL {RUFUS_URL "/downloads/menu.c32", RUFUS_URL "/downloads/vesamenu.c32"}
/* ISO details that the application may want */ /* ISO details that the application may want */
#define WINPE_MININT 0x2A #define WINPE_MININT 0x2A
#define WINPE_I386 0x15 #define WINPE_I386 0x15
#define IS_WINPE(r) (((r&WINPE_MININT) == WINPE_MININT)||((r&WINPE_I386) == WINPE_I386)) #define IS_WINPE(r) (((r&WINPE_MININT) == WINPE_MININT)||((r&WINPE_I386) == WINPE_I386))
typedef struct { typedef struct {
char label[192]; /* 3*64 to account for UTF-8 */ char label[192]; /* 3*64 to account for UTF-8 */
char usb_label[192]; /* converted USB label for workaround */ char usb_label[192]; /* converted USB label for workaround */
@ -171,6 +177,7 @@ typedef struct {
BOOL has_bootmgr; BOOL has_bootmgr;
BOOL has_isolinux; BOOL has_isolinux;
BOOL has_autorun; BOOL has_autorun;
BOOL has_old_c32[NB_OLD_C32];
BOOL has_old_vesamenu; BOOL has_old_vesamenu;
BOOL uses_minint; BOOL uses_minint;
} RUFUS_ISO_REPORT; } RUFUS_ISO_REPORT;
@ -217,7 +224,7 @@ extern char* iso_path;
extern DWORD FormatStatus; extern DWORD FormatStatus;
extern RUFUS_DRIVE_INFO SelectedDrive; extern RUFUS_DRIVE_INFO SelectedDrive;
extern const int nb_steps[FS_MAX]; extern const int nb_steps[FS_MAX];
extern BOOL use_own_vesamenu, detect_fakes, iso_op_in_progress, format_op_in_progress; extern BOOL use_own_c32[NB_OLD_C32], detect_fakes, iso_op_in_progress, format_op_in_progress;
extern RUFUS_ISO_REPORT iso_report; extern RUFUS_ISO_REPORT iso_report;
extern int64_t iso_blocking_status; extern int64_t iso_blocking_status;
extern uint16_t rufus_version[4]; extern uint16_t rufus_version[4];

View file

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 316 IDD_DIALOG DIALOGEX 12, 12, 206, 316
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_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.3.0.210" CAPTION "Rufus v1.3.0.211"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14 DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
@ -274,8 +274,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,210 FILEVERSION 1,3,0,211
PRODUCTVERSION 1,3,0,210 PRODUCTVERSION 1,3,0,211
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -292,13 +292,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.3.0.210" VALUE "FileVersion", "1.3.0.211"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)" VALUE "LegalCopyright", "(c) 2011-2012 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.3.0.210" VALUE "ProductVersion", "1.3.0.211"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"