mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] fix format error when trying to use old BIOS fixes with VHDs
* And other improvements * Closes #1409
This commit is contained in:
parent
0dc13e5283
commit
500172a7a3
6 changed files with 38 additions and 15 deletions
25
src/drive.c
25
src/drive.c
|
@ -22,6 +22,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -507,7 +508,7 @@ BOOL RefreshLayout(DWORD DriveIndex)
|
||||||
*/
|
*/
|
||||||
BOOL DeletePartitions(DWORD DriveIndex)
|
BOOL DeletePartitions(DWORD DriveIndex)
|
||||||
{
|
{
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE, bNeverFound = TRUE;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ULONG ulFetched;
|
ULONG ulFetched;
|
||||||
wchar_t wPhysicalName[24];
|
wchar_t wPhysicalName[24];
|
||||||
|
@ -642,6 +643,7 @@ BOOL DeletePartitions(DWORD DriveIndex)
|
||||||
IVdsDisk_Release(pDisk);
|
IVdsDisk_Release(pDisk);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
bNeverFound = FALSE;
|
||||||
|
|
||||||
// Instantiate the AdvanceDisk interface for our disk.
|
// Instantiate the AdvanceDisk interface for our disk.
|
||||||
hr = IVdsDisk_QueryInterface(pDisk, &IID_IVdsAdvancedDisk, (void **)&pAdvancedDisk);
|
hr = IVdsDisk_QueryInterface(pDisk, &IID_IVdsAdvancedDisk, (void **)&pAdvancedDisk);
|
||||||
|
@ -707,6 +709,8 @@ BOOL DeletePartitions(DWORD DriveIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (bNeverFound)
|
||||||
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_PATH_NOT_FOUND;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1354,10 +1358,6 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
// GCC 4.9 bugs us about the fact that MS defined an expandable array as array[1]
|
|
||||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
|
||||||
#endif
|
|
||||||
switch (DriveLayout->PartitionStyle) {
|
switch (DriveLayout->PartitionStyle) {
|
||||||
case PARTITION_STYLE_MBR:
|
case PARTITION_STYLE_MBR:
|
||||||
SelectedDrive.PartitionStyle = PARTITION_STYLE_MBR;
|
SelectedDrive.PartitionStyle = PARTITION_STYLE_MBR;
|
||||||
|
@ -1716,8 +1716,19 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
||||||
// Go with the MS 1 MB wastage at the beginning...
|
// Go with the MS 1 MB wastage at the beginning...
|
||||||
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = MB;
|
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = MB;
|
||||||
} else {
|
} else {
|
||||||
// Align on Cylinder
|
// Some folks appear to think that 'Fixes for old BIOSes' is some kind of magic
|
||||||
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = bytes_per_track;
|
// wand and are adamant to try to apply them when creating *MODERN* VHD drives.
|
||||||
|
// This, however, wrecks havok on MS' internal format calls because, as opposed
|
||||||
|
// to what is the case for regular drives, VHDs require each cluster block to
|
||||||
|
// be aligned to the cluster size, and that may not be the case with the stupid
|
||||||
|
// CHS sizes that IBM imparted upon us. Long story short, we now align to a
|
||||||
|
// cylinder size that is itself aligned to the cluster size.
|
||||||
|
// If this actually breaks old systems, please send your complaints to IBM.
|
||||||
|
LONGLONG ClusterSize = (LONGLONG)ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize));
|
||||||
|
if (ClusterSize == 0)
|
||||||
|
ClusterSize = 0x200;
|
||||||
|
DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart =
|
||||||
|
((bytes_per_track + (ClusterSize - 1)) / ClusterSize) * ClusterSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If required, set the MSR partition (GPT only - must be created before the data part)
|
// If required, set the MSR partition (GPT only - must be created before the data part)
|
||||||
|
|
|
@ -181,8 +181,12 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
|
||||||
uprintf("No media in drive");
|
uprintf("No media in drive");
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NO_MEDIA_IN_DRIVE;
|
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NO_MEDIA_IN_DRIVE;
|
||||||
break;
|
break;
|
||||||
|
case FCC_ALIGNMENT_VIOLATION:
|
||||||
|
uprintf("Partition start offset is not aligned to the cluster size");
|
||||||
|
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OFFSET_ALIGNMENT_VIOLATION;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
uprintf("FormatExCallback: Received unhandled command 0x02%X - aborting", Command);
|
uprintf("FormatExCallback: Received unhandled command 0x%02X - aborting", Command);
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_SUPPORTED;
|
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_SUPPORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* Callback command types (some errorcode were filled from HPUSBFW V2.2.3 and their
|
/* Callback command types (some errorcode were filled from HPUSBFW V2.2.3 and their
|
||||||
designation from msdn.microsoft.com/en-us/library/windows/desktop/aa819439.aspx */
|
designation from docs.microsoft.com/windows/win32/api/vds/nf-vds-ivdsvolumemf2-formatex */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FCC_PROGRESS,
|
FCC_PROGRESS,
|
||||||
FCC_DONE_WITH_STRUCTURE,
|
FCC_DONE_WITH_STRUCTURE,
|
||||||
|
@ -57,6 +57,11 @@ typedef enum {
|
||||||
FCC_UNKNOWN1E,
|
FCC_UNKNOWN1E,
|
||||||
FCC_UNKNOWN1F,
|
FCC_UNKNOWN1F,
|
||||||
FCC_READ_ONLY_MODE,
|
FCC_READ_ONLY_MODE,
|
||||||
|
FCC_UNKNOWN21,
|
||||||
|
FCC_UNKNOWN22,
|
||||||
|
FCC_UNKNOWN23,
|
||||||
|
FCC_UNKNOWN24,
|
||||||
|
FCC_ALIGNMENT_VIOLATION,
|
||||||
} FILE_SYSTEM_CALLBACK_COMMAND;
|
} FILE_SYSTEM_CALLBACK_COMMAND;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -118,6 +118,9 @@ static __inline void *_reallocf(void *ptr, size_t size) {
|
||||||
#ifndef HTTP_PROTOCOL_FLAG_HTTP2
|
#ifndef HTTP_PROTOCOL_FLAG_HTTP2
|
||||||
#define HTTP_PROTOCOL_FLAG_HTTP2 2
|
#define HTTP_PROTOCOL_FLAG_HTTP2 2
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef ERROR_OFFSET_ALIGNMENT_VIOLATION
|
||||||
|
#define ERROR_OFFSET_ALIGNMENT_VIOLATION 327
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following is used for native ISO mounting in Windows 8 or later */
|
/* The following is used for native ISO mounting in Windows 8 or later */
|
||||||
#define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \
|
#define VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT \
|
||||||
|
|
|
@ -2230,7 +2230,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
// Try to reselect current FS from the drive for non-bootable
|
// Try to reselect current FS from the drive for non-bootable
|
||||||
tmp[0] = 0;
|
tmp[0] = 0;
|
||||||
if ((selected_fs == FS_UNKNOWN) && (SelectedDrive.DeviceNumber != 0))
|
if ((selected_fs == FS_UNKNOWN) && (SelectedDrive.DeviceNumber != 0))
|
||||||
GetDrivePartitionData(SelectedDrive.DeviceNumber, tmp, sizeof(tmp), TRUE);
|
GetDrivePartitionData(SelectedDrive.DeviceNumber, tmp, sizeof(tmp), !usb_debug);
|
||||||
SetFileSystemAndClusterSize(tmp);
|
SetFileSystemAndClusterSize(tmp);
|
||||||
ToggleImageOptions();
|
ToggleImageOptions();
|
||||||
SetProposedLabel(ComboBox_GetCurSel(hDeviceList));
|
SetProposedLabel(ComboBox_GetCurSel(hDeviceList));
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.12.1686"
|
CAPTION "Rufus 3.12.1687"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -397,8 +397,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,12,1686,0
|
FILEVERSION 3,12,1687,0
|
||||||
PRODUCTVERSION 3,12,1686,0
|
PRODUCTVERSION 3,12,1687,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -416,13 +416,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.12.1686"
|
VALUE "FileVersion", "3.12.1687"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2020 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.12.exe"
|
VALUE "OriginalFilename", "rufus-3.12.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.12.1686"
|
VALUE "ProductVersion", "3.12.1687"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue