[core] add half workaround for an XP issue

* This is not a complete workaround, but it will do for
  until we drop support for XP altogether.
* Closes #810
This commit is contained in:
Pete Batard 2016-08-31 12:21:10 +01:00
parent 9872cad1e8
commit 08566fa127
2 changed files with 16 additions and 9 deletions

View file

@ -1633,6 +1633,10 @@ DWORD WINAPI FormatThread(void* param)
UpdateProgress(OP_ANALYZE_MBR, -1.0f);
}
// Yet another half-workaround needed for XP...
if (nWindowsVersion <= WINDOWS_XP)
InitializeDisk(hPhysicalDrive);
if (zero_drive) {
WriteDrive(hPhysicalDrive, NULL);
goto out;
@ -1642,10 +1646,13 @@ DWORD WINAPI FormatThread(void* param)
// Note, Microsoft's way of cleaning partitions (IOCTL_DISK_CREATE_DISK, which is what we apply
// in InitializeDisk) is *NOT ENOUGH* to reset a disk and can render it inoperable for partitioning
// or formatting under Windows. See https://github.com/pbatard/rufus/issues/759 for details.
if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) || (!InitializeDisk(hPhysicalDrive)) ) {
uprintf("Could not reset partitions\n");
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE;
goto out;
if (nWindowsVersion > WINDOWS_XP) {
if ((!ClearMBRGPT(hPhysicalDrive, SelectedDrive.DiskSize, SelectedDrive.SectorSize, use_large_fat32)) ||
(!InitializeDisk(hPhysicalDrive))) {
uprintf("Could not reset partitions\n");
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_PARTITION_FAILURE;
goto out;
}
}
if (IsChecked(IDC_BADBLOCKS)) {