[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

@ -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