mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-25 12:14:33 -04:00
[core] work around Windows handling of ESP for removable drives
* Remove early locking of logical volume (no longer necessary due to previous commits). * Relax exclusive locking of physical drive when an ESP is created. * This should help with #1637 and #1640 * Also add an extra check for sector size in WriteDrive()
This commit is contained in:
parent
b2b621cec7
commit
f027e562b3
2 changed files with 15 additions and 22 deletions
27
src/format.c
27
src/format.c
|
@ -1485,6 +1485,11 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
|
||||||
uint8_t *cmp_buffer = NULL;
|
uint8_t *cmp_buffer = NULL;
|
||||||
int i, *ptr, zero_data, throttle_fast_zeroing = 0;
|
int i, *ptr, zero_data, throttle_fast_zeroing = 0;
|
||||||
|
|
||||||
|
if (SelectedDrive.SectorSize < 512) {
|
||||||
|
uprintf("Unexpected sector size (%d) - Aborting", SelectedDrive.SectorSize);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// We poked the MBR and other stuff, so we need to rewind
|
// We poked the MBR and other stuff, so we need to rewind
|
||||||
li.QuadPart = 0;
|
li.QuadPart = 0;
|
||||||
if (!SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN))
|
if (!SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN))
|
||||||
|
@ -1697,8 +1702,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
else if (IsChecked(IDC_OLD_BIOS_FIXES))
|
else if (IsChecked(IDC_OLD_BIOS_FIXES))
|
||||||
extra_partitions = XP_COMPAT;
|
extra_partitions = XP_COMPAT;
|
||||||
// On pre 1703 platforms (and even on later ones), anything with ext2/ext3 doesn't sit
|
// On pre 1703 platforms (and even on later ones), anything with ext2/ext3 doesn't sit
|
||||||
// too well with Windows. Relaxing our locking rules seems to help...
|
// too well with Windows. Same with ESPs. Relaxing our locking rules seems to help...
|
||||||
if ((extra_partitions == XP_CASPER) || (fs_type >= FS_EXT2))
|
if ((extra_partitions & (XP_ESP | XP_CASPER)) || (fs_type >= FS_EXT2))
|
||||||
actual_lock_drive = FALSE;
|
actual_lock_drive = FALSE;
|
||||||
|
|
||||||
PrintInfoDebug(0, MSG_225);
|
PrintInfoDebug(0, MSG_225);
|
||||||
|
@ -1737,26 +1742,13 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// An extra refresh of the (now empty) partition data here appears to be helpful
|
// An extra refresh of the (now empty) partition data here appears to be helpful
|
||||||
GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_name, sizeof(fs_name), TRUE);
|
GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_name, sizeof(fs_name), TRUE);
|
||||||
|
|
||||||
// Now get RW access to the physical drive...
|
// Now get RW access to the physical drive
|
||||||
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
||||||
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_OPEN_FAILED;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
RefreshDriveLayout(hPhysicalDrive);
|
RefreshDriveLayout(hPhysicalDrive);
|
||||||
|
|
||||||
// ...and get a lock to the logical drive so that we can actually write something
|
|
||||||
hLogicalVolume = GetLogicalHandle(DriveIndex, 0, TRUE, FALSE, !actual_lock_drive);
|
|
||||||
if (hLogicalVolume == INVALID_HANDLE_VALUE) {
|
|
||||||
uprintf("Could not lock volume");
|
|
||||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OPEN_FAILED;
|
|
||||||
goto out;
|
|
||||||
} else if (hLogicalVolume == NULL) {
|
|
||||||
// NULL is returned for cases where the drive is not yet partitioned
|
|
||||||
uprintf("Drive does not appear to be partitioned");
|
|
||||||
} else if (!UnmountVolume(hLogicalVolume)) {
|
|
||||||
uprintf("Trying to continue regardless...");
|
|
||||||
}
|
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
|
|
||||||
if (!zero_drive && !write_as_image) {
|
if (!zero_drive && !write_as_image) {
|
||||||
|
@ -1877,7 +1869,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
UpdateProgress(OP_ZERO_MBR, -1.0f);
|
UpdateProgress(OP_ZERO_MBR, -1.0f);
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
|
|
||||||
if (!CreatePartition(hPhysicalDrive, partition_type, fs_type, (partition_type==PARTITION_STYLE_MBR) && (target_type==TT_UEFI), extra_partitions)) {
|
if (!CreatePartition(hPhysicalDrive, partition_type, fs_type, (partition_type == PARTITION_STYLE_MBR)
|
||||||
|
&& (target_type == TT_UEFI), extra_partitions)) {
|
||||||
FormatStatus = (LastWriteError != 0) ? LastWriteError : (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE);
|
FormatStatus = (LastWriteError != 0) ? LastWriteError : (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
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.13.1714"
|
CAPTION "Rufus 3.13.1715"
|
||||||
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
|
||||||
|
@ -395,8 +395,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,13,1714,0
|
FILEVERSION 3,13,1715,0
|
||||||
PRODUCTVERSION 3,13,1714,0
|
PRODUCTVERSION 3,13,1715,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -414,13 +414,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.13.1714"
|
VALUE "FileVersion", "3.13.1715"
|
||||||
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.13.exe"
|
VALUE "OriginalFilename", "rufus-3.13.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.13.1714"
|
VALUE "ProductVersion", "3.13.1715"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue