mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[iso] fixes for Joliet and > 4GB ISO9660 images
* scan would fail on lowercase vs mixed case dir name comparison due to Joliet (eg. using Slackware 13.37 ISO) * extraction would fail for 4 GB ISO9660 ISOs * also fixes cases issue when checking for isolinux/bootmgr * also don't restrict NTFS labels
This commit is contained in:
parent
f4ed6e4650
commit
3cd83869c4
5 changed files with 87 additions and 80 deletions
50
src/format.c
50
src/format.c
|
@ -136,6 +136,47 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
|
||||||
return (!IS_ERROR(FormatStatus));
|
return (!IS_ERROR(FormatStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts an UTF-16 label to a valid FAT/NTFS one
|
||||||
|
*/
|
||||||
|
static void ToValidLabel(WCHAR* name, BOOL bFAT)
|
||||||
|
{
|
||||||
|
size_t i, j, k;
|
||||||
|
BOOL found;
|
||||||
|
WCHAR unauthorized[] = L"*?.,;:/\\|+=<>[]";
|
||||||
|
WCHAR to_underscore[] = L"\t";
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i=0, k=0; i<wcslen(name); i++) {
|
||||||
|
if (bFAT) { // NTFS does allows all the FAT unauthorized above
|
||||||
|
found = FALSE;
|
||||||
|
for (j=0; j<wcslen(unauthorized); j++) {
|
||||||
|
if (name[i] == unauthorized[j]) {
|
||||||
|
found = TRUE; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) continue;
|
||||||
|
}
|
||||||
|
found = FALSE;
|
||||||
|
for (j=0; j<wcslen(to_underscore); j++) {
|
||||||
|
if (name[i] == to_underscore[j]) {
|
||||||
|
name[k++] = '_';
|
||||||
|
found = TRUE; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) continue;
|
||||||
|
name[k++] = name[i];
|
||||||
|
}
|
||||||
|
name[k] = 0;
|
||||||
|
if (bFAT) {
|
||||||
|
name[11] = 0;
|
||||||
|
} else {
|
||||||
|
name[32] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call on fmifs.dll's FormatEx() to format the drive
|
* Call on fmifs.dll's FormatEx() to format the drive
|
||||||
*/
|
*/
|
||||||
|
@ -145,7 +186,7 @@ static BOOL FormatDrive(char DriveLetter)
|
||||||
PF_DECL(FormatEx);
|
PF_DECL(FormatEx);
|
||||||
WCHAR wDriveRoot[] = L"?:\\";
|
WCHAR wDriveRoot[] = L"?:\\";
|
||||||
WCHAR wFSType[32];
|
WCHAR wFSType[32];
|
||||||
WCHAR wLabel[128];
|
WCHAR wLabel[64];
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
wDriveRoot[0] = (WCHAR)DriveLetter;
|
wDriveRoot[0] = (WCHAR)DriveLetter;
|
||||||
|
@ -161,11 +202,8 @@ static BOOL FormatDrive(char DriveLetter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel));
|
GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel));
|
||||||
// If using FAT/FAT32, truncate the label to 11 characters
|
// Make sure the label is valid
|
||||||
// TODO: use a wchar_t to_valid_label() here
|
ToValidLabel(wLabel, (wFSType[0] == 'F') && (wFSType[1] == 'A') && (wFSType[2] == 'T'));
|
||||||
if ((wFSType[0] == 'F') && (wFSType[1] == 'A') && (wFSType[2] == 'T')) {
|
|
||||||
wLabel[11] = 0;
|
|
||||||
}
|
|
||||||
uprintf("Using cluster size: %d bytes\n", ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)));
|
uprintf("Using cluster size: %d bytes\n", ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)));
|
||||||
format_percent = 0.0f;
|
format_percent = 0.0f;
|
||||||
task_number = 0;
|
task_number = 0;
|
||||||
|
|
21
src/iso.c
21
src/iso.c
|
@ -66,6 +66,7 @@ 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 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;
|
||||||
|
|
||||||
|
@ -94,7 +95,6 @@ static void log_handler (cdio_log_level_t level, const char *message)
|
||||||
{
|
{
|
||||||
switch(level) {
|
switch(level) {
|
||||||
case CDIO_LOG_DEBUG:
|
case CDIO_LOG_DEBUG:
|
||||||
case CDIO_LOG_INFO:
|
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
uprintf("libcdio: %s\n", message);
|
uprintf("libcdio: %s\n", message);
|
||||||
|
@ -142,11 +142,11 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
|
||||||
i_file_length = udf_get_file_length(p_udf_dirent);
|
i_file_length = udf_get_file_length(p_udf_dirent);
|
||||||
if (scan_only) {
|
if (scan_only) {
|
||||||
// Check for a "bootmgr" file in root (psz_path = "")
|
// Check for a "bootmgr" file in root (psz_path = "")
|
||||||
if ((*psz_path == 0) && (safe_strcmp(psz_basename, bootmgr_name) == 0))
|
if ((*psz_path == 0) && (_stricmp(psz_basename, bootmgr_name) == 0))
|
||||||
iso_report.has_bootmgr = TRUE;
|
iso_report.has_bootmgr = TRUE;
|
||||||
// Check for a syslinux config file anywhere
|
// Check for a syslinux config file anywhere
|
||||||
for (i=0; i<ARRAYSIZE(isolinux_name); i++) {
|
for (i=0; i<ARRAYSIZE(isolinux_name); i++) {
|
||||||
if (safe_strcmp(psz_basename, isolinux_name[i]) == 0)
|
if (_stricmp(psz_basename, isolinux_name[i]) == 0)
|
||||||
iso_report.has_isolinux = TRUE;
|
iso_report.has_isolinux = TRUE;
|
||||||
}
|
}
|
||||||
if (i_file_length >= FOUR_GIGABYTES)
|
if (i_file_length >= FOUR_GIGABYTES)
|
||||||
|
@ -251,7 +251,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
|
||||||
if ( (strcmp(p_statbuf->filename, ".") == 0)
|
if ( (strcmp(p_statbuf->filename, ".") == 0)
|
||||||
|| (strcmp(p_statbuf->filename, "..") == 0) )
|
|| (strcmp(p_statbuf->filename, "..") == 0) )
|
||||||
continue;
|
continue;
|
||||||
iso9660_name_translate(p_statbuf->filename, psz_basename);
|
iso9660_name_translate_ext(p_statbuf->filename, psz_basename, i_joliet_level);
|
||||||
if (p_statbuf->type == _STAT_DIR) {
|
if (p_statbuf->type == _STAT_DIR) {
|
||||||
if (!scan_only) _mkdir(psz_fullpath);
|
if (!scan_only) _mkdir(psz_fullpath);
|
||||||
if (iso_extract_files(p_iso, psz_iso_name))
|
if (iso_extract_files(p_iso, psz_iso_name))
|
||||||
|
@ -260,11 +260,11 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
|
||||||
i_file_length = p_statbuf->size;
|
i_file_length = p_statbuf->size;
|
||||||
if (scan_only) {
|
if (scan_only) {
|
||||||
// Check for a "bootmgr" file in root (psz_path = "")
|
// Check for a "bootmgr" file in root (psz_path = "")
|
||||||
if ((*psz_path == 0) && (safe_strcmp(psz_basename, bootmgr_name) == 0))
|
if ((*psz_path == 0) && (_stricmp(psz_basename, bootmgr_name) == 0))
|
||||||
iso_report.has_bootmgr = TRUE;
|
iso_report.has_bootmgr = TRUE;
|
||||||
// Check for a syslinux config file anywhere
|
// Check for a syslinux config file anywhere
|
||||||
for (i=0; i<ARRAYSIZE(isolinux_name); i++) {
|
for (i=0; i<ARRAYSIZE(isolinux_name); i++) {
|
||||||
if (safe_strcmp(psz_basename, isolinux_name[i]) == 0)
|
if (_stricmp(psz_basename, isolinux_name[i]) == 0)
|
||||||
iso_report.has_isolinux = TRUE;
|
iso_report.has_isolinux = TRUE;
|
||||||
}
|
}
|
||||||
if (i_file_length >= FOUR_GIGABYTES)
|
if (i_file_length >= FOUR_GIGABYTES)
|
||||||
|
@ -276,7 +276,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
|
||||||
} else {
|
} else {
|
||||||
// In case there's an ldlinux.sys on the ISO, prevent it from overwriting ours
|
// In case there's an ldlinux.sys on the ISO, prevent it from overwriting ours
|
||||||
if ((*psz_path == 0) && (safe_strcmp(psz_basename, ldlinux_name) == 0)) {
|
if ((*psz_path == 0) && (safe_strcmp(psz_basename, ldlinux_name) == 0)) {
|
||||||
uprintf("skipping % file from ISO image\n", ldlinux_name);
|
uprintf("Skipping % file from ISO image\n", ldlinux_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,12 +389,15 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, bool scan)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
try_iso:
|
try_iso:
|
||||||
p_iso = iso9660_open(src_iso);
|
p_iso = iso9660_open_ext(src_iso, 0xFF);
|
||||||
if (p_iso == NULL) {
|
if (p_iso == NULL) {
|
||||||
uprintf("Unable to open image '%s'.\n", src_iso);
|
uprintf("Unable to open image '%s'.\n", src_iso);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
uprintf("Disc image is an ISO9660 image\n");
|
i_joliet_level = iso9660_ifs_get_joliet_level(p_iso);
|
||||||
|
uprintf("Disc image is an ISO9660 image (Joliet = %d)\n", i_joliet_level);
|
||||||
|
// FIXME: libcdio's Joliet detection seems broken => override
|
||||||
|
i_joliet_level = ISO_EXTENSION_JOLIET_LEVEL3;
|
||||||
if (scan_only) {
|
if (scan_only) {
|
||||||
if (iso9660_ifs_get_volume_id(p_iso, &vol_id))
|
if (iso9660_ifs_get_volume_id(p_iso, &vol_id))
|
||||||
safe_strcpy(iso_report.label, sizeof(iso_report.label), vol_id);
|
safe_strcpy(iso_report.label, sizeof(iso_report.label), vol_id);
|
||||||
|
|
|
@ -703,7 +703,7 @@ iso9660_seek_read_framesize (const iso9660_t *p_iso, void *ptr,
|
||||||
uint16_t i_framesize)
|
uint16_t i_framesize)
|
||||||
{
|
{
|
||||||
long int ret;
|
long int ret;
|
||||||
long int i_byte_offset;
|
int64_t i_byte_offset;
|
||||||
|
|
||||||
if (!p_iso) return 0;
|
if (!p_iso) return 0;
|
||||||
i_byte_offset = (start * p_iso->i_framesize) + p_iso->i_fuzzy_offset
|
i_byte_offset = (start * p_iso->i_framesize) + p_iso->i_fuzzy_offset
|
||||||
|
|
38
src/rufus.c
38
src/rufus.c
|
@ -952,41 +952,6 @@ BOOL CALLBACK ISOProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Converts a name + ext UTF-8 pair to a valid MS filename.
|
|
||||||
* Returned string is allocated and needs to be freed manually
|
|
||||||
*/
|
|
||||||
void to_valid_label(char* name)
|
|
||||||
{
|
|
||||||
size_t i, j, k;
|
|
||||||
BOOL found;
|
|
||||||
char unauthorized[] = "*?.,;:/\\|+=<>[]";
|
|
||||||
char to_underscore[] = "\t";
|
|
||||||
|
|
||||||
if (name == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i=0, k=0; i<strlen(name); i++) {
|
|
||||||
found = FALSE;
|
|
||||||
for (j=0; j<strlen(unauthorized); j++) {
|
|
||||||
if (name[i] == unauthorized[j]) {
|
|
||||||
found = TRUE; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) continue;
|
|
||||||
found = FALSE;
|
|
||||||
for (j=0; j<strlen(to_underscore); j++) {
|
|
||||||
if (name[i] == to_underscore[j]) {
|
|
||||||
name[k++] = '_';
|
|
||||||
found = TRUE; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) continue;
|
|
||||||
name[k++] = name[i];
|
|
||||||
}
|
|
||||||
name[k] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The scanning process can be blocking for message processing => use a thread
|
// The scanning process can be blocking for message processing => use a thread
|
||||||
DWORD WINAPI ISOScanThread(LPVOID param)
|
DWORD WINAPI ISOScanThread(LPVOID param)
|
||||||
{
|
{
|
||||||
|
@ -1013,7 +978,6 @@ DWORD WINAPI ISOScanThread(LPVOID param)
|
||||||
// Some Linux distros, such as Arch Linux, require the USB drive to have
|
// Some Linux distros, such as Arch Linux, require the USB drive to have
|
||||||
// a specific label => copy the one we got from the ISO image
|
// a specific label => copy the one we got from the ISO image
|
||||||
if (iso_report.label[0] != 0) {
|
if (iso_report.label[0] != 0) {
|
||||||
to_valid_label(iso_report.label);
|
|
||||||
SetWindowTextU(hLabel, iso_report.label);
|
SetWindowTextU(hLabel, iso_report.label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1321,6 +1285,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
FormatStatus = 0;
|
FormatStatus = 0;
|
||||||
nDeviceIndex = ComboBox_GetCurSel(hDeviceList);
|
nDeviceIndex = ComboBox_GetCurSel(hDeviceList);
|
||||||
if (nDeviceIndex != CB_ERR) {
|
if (nDeviceIndex != CB_ERR) {
|
||||||
|
if (IsChecked(IDC_DOS)) {
|
||||||
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
|
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
|
||||||
if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) {
|
if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) {
|
||||||
if (iso_path == NULL) {
|
if (iso_path == NULL) {
|
||||||
|
@ -1344,6 +1309,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
GetWindowTextA(hDeviceList, tmp, sizeof(tmp));
|
GetWindowTextA(hDeviceList, tmp, sizeof(tmp));
|
||||||
safe_sprintf(str, sizeof(str), "WARNING: ALL DATA ON DEVICE %s\r\nWILL BE DESTROYED.\r\n"
|
safe_sprintf(str, sizeof(str), "WARNING: ALL DATA ON DEVICE %s\r\nWILL BE DESTROYED.\r\n"
|
||||||
"To continue with this operation, click OK. To quit click CANCEL.", tmp);
|
"To continue with this operation, click OK. To quit click CANCEL.", tmp);
|
||||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
||||||
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.1.1.134"
|
CAPTION "Rufus v1.1.1.135"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
||||||
|
@ -71,7 +71,7 @@ BEGIN
|
||||||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
||||||
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||||
"SysLink",WS_TABSTOP,46,47,114,9
|
"SysLink",WS_TABSTOP,46,47,114,9
|
||||||
LTEXT "Version 1.1.1 (Build 134)",IDC_STATIC,46,19,78,8
|
LTEXT "Version 1.1.1 (Build 135)",IDC_STATIC,46,19,78,8
|
||||||
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
||||||
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
|
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
|
||||||
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||||
|
@ -222,8 +222,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,1,1,134
|
FILEVERSION 1,1,1,135
|
||||||
PRODUCTVERSION 1,1,1,134
|
PRODUCTVERSION 1,1,1,135
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -240,13 +240,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "akeo.ie"
|
VALUE "CompanyName", "akeo.ie"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "1.1.1.134"
|
VALUE "FileVersion", "1.1.1.135"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011 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.1.1.134"
|
VALUE "ProductVersion", "1.1.1.135"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue