mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[vhd] fix Rufus being unable to open .vhd images
* Due to a typo in vhd.c where the second safe_stricmp() should be against ".vhd" and not ".vhdx" again. * Also enable the ignore boot marker bypass for VHD/VHDX/FFU and don't misreport those images as "compressed disk images". * Closes #2309.
This commit is contained in:
parent
5b6574d6f6
commit
9c6b1ad977
3 changed files with 17 additions and 11 deletions
|
@ -1338,7 +1338,8 @@ DWORD WINAPI ImageScanThread(LPVOID param)
|
|||
uprintf(" Image is a FORCED non-bootable image");
|
||||
else
|
||||
uprintf(" Image is a %sbootable %s image",
|
||||
(img_report.compression_type != BLED_COMPRESSION_NONE) ? "compressed " : "", img_report.is_vhd ? "VHD" : "disk");
|
||||
(img_report.compression_type != BLED_COMPRESSION_NONE && img_report.compression_type < BLED_COMPRESSION_MAX) ?
|
||||
"compressed " : "", img_report.is_vhd ? "VHD" : "disk");
|
||||
selection_default = BT_IMAGE;
|
||||
}
|
||||
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 4.3.2076"
|
||||
CAPTION "Rufus 4.3.2077"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -392,8 +392,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,3,2076,0
|
||||
PRODUCTVERSION 4,3,2076,0
|
||||
FILEVERSION 4,3,2077,0
|
||||
PRODUCTVERSION 4,3,2077,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -411,13 +411,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "4.3.2076"
|
||||
VALUE "FileVersion", "4.3.2077"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-4.3.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "4.3.2076"
|
||||
VALUE "ProductVersion", "4.3.2077"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
15
src/vhd.c
15
src/vhd.c
|
@ -101,13 +101,13 @@ static comp_assoc file_assoc[] = {
|
|||
};
|
||||
|
||||
// Look for a boot marker in the MBR area of the image
|
||||
static BOOL IsCompressedBootableImage(const char* path)
|
||||
static int8_t IsCompressedBootableImage(const char* path)
|
||||
{
|
||||
char *ext = NULL, *physical_disk = NULL;
|
||||
unsigned char *buf = NULL;
|
||||
int i;
|
||||
FILE* fd = NULL;
|
||||
BOOL r = FALSE;
|
||||
BOOL r = 0;
|
||||
int64_t dc = 0;
|
||||
|
||||
img_report.compression_type = BLED_COMPRESSION_NONE;
|
||||
|
@ -119,7 +119,7 @@ static BOOL IsCompressedBootableImage(const char* path)
|
|||
img_report.compression_type = file_assoc[i].type;
|
||||
buf = malloc(MBR_SIZE);
|
||||
if (buf == NULL)
|
||||
return FALSE;
|
||||
return 0;
|
||||
FormatStatus = 0;
|
||||
if (img_report.compression_type < BLED_COMPRESSION_MAX) {
|
||||
bled_init(0, uprintf, NULL, NULL, NULL, NULL, &FormatStatus);
|
||||
|
@ -138,6 +138,7 @@ static BOOL IsCompressedBootableImage(const char* path)
|
|||
if (has_ffu_support) {
|
||||
fd = fopenU(path, "rb");
|
||||
if (fd != NULL) {
|
||||
img_report.is_vhd = TRUE;
|
||||
dc = fread(buf, 1, MBR_SIZE, fd);
|
||||
fclose(fd);
|
||||
// The signature may not be constant, but since the only game in town to
|
||||
|
@ -156,6 +157,7 @@ static BOOL IsCompressedBootableImage(const char* path)
|
|||
} else {
|
||||
physical_disk = VhdMountImage(path);
|
||||
if (physical_disk != NULL) {
|
||||
img_report.is_vhd = TRUE;
|
||||
fd = fopenU(physical_disk, "rb");
|
||||
if (fd != NULL) {
|
||||
dc = fread(buf, 1, MBR_SIZE, fd);
|
||||
|
@ -168,7 +170,10 @@ static BOOL IsCompressedBootableImage(const char* path)
|
|||
free(buf);
|
||||
return FALSE;
|
||||
}
|
||||
r = (buf[0x1FE] == 0x55) && (buf[0x1FF] == 0xAA);
|
||||
if ((buf[0x1FE] == 0x55) && (buf[0x1FF] == 0xAA))
|
||||
r = 1;
|
||||
else if (ignore_boot_marker)
|
||||
r = 2;
|
||||
free(buf);
|
||||
return r;
|
||||
}
|
||||
|
@ -935,7 +940,7 @@ char* VhdMountImage(const char* path)
|
|||
for (ext = (char*)&path[safe_strlen(path) - 1]; (*ext != '.') && (ext != path); ext--);
|
||||
if (safe_stricmp(ext, ".vhdx") == 0)
|
||||
vtype.DeviceId = VIRTUAL_STORAGE_TYPE_DEVICE_VHDX;
|
||||
else if (safe_stricmp(ext, ".vhdx") == 0)
|
||||
else if (safe_stricmp(ext, ".vhd") == 0)
|
||||
vtype.DeviceId = VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
|
||||
|
||||
r = pfOpenVirtualDisk(&vtype, wpath, VIRTUAL_DISK_ACCESS_READ | VIRTUAL_DISK_ACCESS_GET_INFO,
|
||||
|
|
Loading…
Reference in a new issue