Skip to content

Commit 1efb25b

Browse files
committed
[iso] fix Rufus saving images as FFU instead of ISO, when FFU is not supported
* Our image type selection forgot to shift the actual type to ISO when FFU is not supported, leading to dism being invoked instead of oscdimg. * Closes #2889. * Also make sure the UDF label is no more than 32 characters. * Also increase the oscdimg.exe commandline size as 256 characters may not be enough with long paths. * Also try to report 'oscdimg.exe` errors in the log instead of silencing them. * Also fix devices with (non-USB-compliant) VID 0000 being ignored by default.
1 parent 46f9c9e commit 1efb25b

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

src/dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,8 @@ BOOL GetDevices(DWORD devnum)
838838
}
839839
// Also ignore USB devices that have been specifically flagged by the user
840840
for (s = 0; s < ARRAYSIZE(ignore_vid_pid); s++) {
841-
if ((props.vid == (ignore_vid_pid[s] >> 16)) && (props.pid == (ignore_vid_pid[s] & 0xffff))) {
841+
if (ignore_vid_pid[s] != 0 && (props.vid == (ignore_vid_pid[s] >> 16)) &&
842+
(props.pid == (ignore_vid_pid[s] & 0xffff))) {
842843
uprintf("Ignoring '%s' (%s), per user settings", buffer, str);
843844
break;
844845
}

src/iso.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2200,10 +2200,16 @@ DWORD WINAPI IsoSaveImageThread(void* param)
22002200
{
22012201
DWORD r;
22022202
IMG_SAVE* img_save = (IMG_SAVE*)param;
2203-
char cmd[2 * MAX_PATH], letters[27], * label;
2203+
char cmd[2 * KB], letters[27], *label;
22042204

22052205
if (!GetDriveLabel(SelectedDrive.DeviceNumber, letters, &label, TRUE) || letters[0] == '\0')
22062206
ExitThread(ERROR_NOT_FOUND);
2207+
2208+
// UDF labels cannot be more than 32 characters (and if we have more than 32 chars we are
2209+
// using the static modifiable char buffer from GetDriveLabel(), so we can alter it).
2210+
if (strlen(label) > 32)
2211+
label[32] = '\0';
2212+
22072213
// Save to UDF only, as Microsoft's implementation of ISO-9660 doesn't support multiextent
22082214
// and produces BROKEN images if you try to add files larger than 4 GB.
22092215
// Plus ISO-9660/Joliet limits labels to 16 characters and has issues with long paths.

src/rufus.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3333
IDD_DIALOG DIALOGEX 12, 12, 232, 326
3434
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
3535
EXSTYLE WS_EX_ACCEPTFILES
36-
CAPTION "Rufus 4.12.2306"
36+
CAPTION "Rufus 4.12.2307"
3737
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
3838
BEGIN
3939
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -408,8 +408,8 @@ END
408408
//
409409

410410
VS_VERSION_INFO VERSIONINFO
411-
FILEVERSION 4,12,2306,0
412-
PRODUCTVERSION 4,12,2306,0
411+
FILEVERSION 4,12,2307,0
412+
PRODUCTVERSION 4,12,2307,0
413413
FILEFLAGSMASK 0x3fL
414414
#ifdef _DEBUG
415415
FILEFLAGS 0x1L
@@ -427,13 +427,13 @@ BEGIN
427427
VALUE "Comments", "https://rufus.ie"
428428
VALUE "CompanyName", "Akeo Consulting"
429429
VALUE "FileDescription", "Rufus"
430-
VALUE "FileVersion", "4.12.2306"
430+
VALUE "FileVersion", "4.12.2307"
431431
VALUE "InternalName", "Rufus"
432432
VALUE "LegalCopyright", "� 2011-2026 Pete Batard (GPL v3)"
433433
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
434434
VALUE "OriginalFilename", "rufus-4.12.exe"
435435
VALUE "ProductName", "Rufus"
436-
VALUE "ProductVersion", "4.12.2306"
436+
VALUE "ProductVersion", "4.12.2307"
437437
END
438438
END
439439
BLOCK "VarFileInfo"

src/stdfn.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Rufus: The Reliable USB Formatting Utility
33
* Standard Windows function calls
4-
* Copyright © 2013-2025 Pete Batard <[email protected]>
4+
* Copyright © 2013-2026 Pete Batard <[email protected]>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -803,7 +803,7 @@ DWORD RunCommandWithProgress(const char* cmd, const char* dir, BOOL log, int msg
803803
PROCESS_INFORMATION pi = { 0 };
804804
SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
805805
HANDLE hOutputRead = INVALID_HANDLE_VALUE, hOutputWrite = INVALID_HANDLE_VALUE;
806-
static char* output;
806+
static char *output, *p;
807807
cregex_node_t* node = NULL;
808808
cregex_program_t* program = NULL;
809809
char* matches[REGEX_VM_MAX_MATCHES];
@@ -880,6 +880,9 @@ DWORD RunCommandWithProgress(const char* cmd, const char* dir, BOOL log, int msg
880880
} else if (log) {
881881
// output may contain a '%' so don't feed it as a naked format string
882882
uprintf("%s", output);
883+
} else if ((p = strstr(output, "ERROR:")) != NULL) {
884+
// Mostly for oscdimg.exe errors
885+
uprintf("%s", p);
883886
}
884887
}
885888
free(output);

src/vhd.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Rufus: The Reliable USB Formatting Utility
33
* Virtual Disk Handling functions
4-
* Copyright © 2013-2025 Pete Batard <[email protected]>
4+
* Copyright © 2013-2026 Pete Batard <[email protected]>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -564,7 +564,7 @@ static DWORD WINAPI FfuSaveImageThread(void* param)
564564
{
565565
DWORD r;
566566
IMG_SAVE* img_save = (IMG_SAVE*)param;
567-
char cmd[MAX_PATH + 128], letters[27], *label;
567+
char cmd[2 * KB], letters[27], *label;
568568

569569
GetDriveLabel(SelectedDrive.DeviceNumber, letters, &label, TRUE);
570570
static_sprintf(cmd, "dism /Capture-Ffu /CaptureDrive:%s /ImageFile:\"%s\" "
@@ -593,9 +593,10 @@ BOOL SaveImage(void)
593593
static IMG_SAVE img_save;
594594
char filename[128], letters[27], path[MAX_PATH];
595595
int DriveIndex = ComboBox_GetCurSel(hDeviceList);
596-
enum { image_type_vhd = 1, image_type_vhdx = 2, image_type_ffu = 3, image_type_iso = 4 };
596+
enum { image_type_none = 0, image_type_vhd, image_type_vhdx, image_type_ffu, image_type_iso };
597597
static EXT_DECL(img_ext, filename, __VA_GROUP__("*.vhd", "*.vhdx", "*.ffu", "*.iso"),
598598
__VA_GROUP__(lmprintf(MSG_343), lmprintf(MSG_342), lmprintf(MSG_344), lmprintf(MSG_036)));
599+
int i_to_type[5] = { image_type_none, image_type_vhd, image_type_vhdx, image_type_ffu, image_type_iso };
599600
ULARGE_INTEGER free_space;
600601

601602
memset(&img_save, 0, sizeof(IMG_SAVE));
@@ -611,8 +612,10 @@ BOOL SaveImage(void)
611612
img_ext.count += 1;
612613
} else {
613614
// Move the ISO extension one place down
614-
img_ext.extension[2] = img_ext.extension[3];
615-
img_ext.description[2] = img_ext.description[3];
615+
img_ext.extension[image_type_ffu - 1] = img_ext.extension[image_type_iso - 1];
616+
img_ext.description[image_type_ffu - 1] = img_ext.description[image_type_iso - 1];
617+
i_to_type[image_type_ffu] = image_type_iso;
618+
i_to_type[image_type_iso] = image_type_none;
616619
}
617620
// ISO support requires a mounted file system
618621
if (GetDriveLetters(SelectedDrive.DeviceNumber, letters) && letters[0] != '\0')
@@ -632,7 +635,8 @@ BOOL SaveImage(void)
632635
save_image_type = (char*)&img_ext.extension[i - 1][2];
633636
WriteSettingStr(SETTING_PREFERRED_SAVE_IMAGE_TYPE, save_image_type);
634637
}
635-
switch (i) {
638+
assert(i < ARRAYSIZE(i_to_type));
639+
switch (i_to_type[i]) {
636640
case image_type_vhd:
637641
img_save.Type = VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
638642
break;

0 commit comments

Comments
 (0)