[core] add workaround for Windows 11's locking issue

* Windows 11 appears to be a lot more proactive in locking system partitions (ESPs, MSRs)
  than previous versions of Windows were, resulting in format or access errors.
* Try to work around these by disabling exclusive drive locking as needed.
This commit is contained in:
Pete Batard 2021-09-28 16:17:35 +01:00
parent fba24170e1
commit df8058b4f3
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
3 changed files with 12 additions and 6 deletions

View File

@ -11,7 +11,7 @@
<Identity
Name="19453.net.Rufus"
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
Version="3.16.1825.0" />
Version="3.16.1826.0" />
<Properties>
<DisplayName>Rufus</DisplayName>

View File

@ -1807,6 +1807,10 @@ DWORD WINAPI FormatThread(void* param)
// too well with Windows. Same with ESPs. Relaxing our locking rules seems to help...
if ((extra_partitions & (XP_ESP | XP_CASPER)) || (fs_type >= FS_EXT2))
actual_lock_drive = FALSE;
// Windows 11 is a lot more proactive in locking ESPs and MSRs than previous versions
// were, meaning that we also can't lock the drive without incurring errors...
if ((nWindowsVersion >= WINDOWS_11) && extra_partitions)
actual_lock_drive = FALSE;
PrintInfoDebug(0, MSG_225);
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, FALSE, !actual_lock_drive);
@ -1841,6 +1845,8 @@ DWORD WINAPI FormatThread(void* param)
// If we couldn't delete partitions, Windows give us trouble unless we
// request access to the logical drive. Don't ask me why!
need_logical = TRUE;
// Also, since we couldn't clean the disk, we need to disable drive locking
actual_lock_drive = FALSE;
}
// An extra refresh of the (now empty) partition data here appears to be helpful

View File

@ -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 3.16.1825"
CAPTION "Rufus 3.16.1826"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,16,1825,0
PRODUCTVERSION 3,16,1825,0
FILEVERSION 3,16,1826,0
PRODUCTVERSION 3,16,1826,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.16.1825"
VALUE "FileVersion", "3.16.1826"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.16.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.16.1825"
VALUE "ProductVersion", "3.16.1826"
END
END
BLOCK "VarFileInfo"