mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-19 09:25:12 -04:00
[core] reinstate the call to DeletePartitions()
* But use IOCTL_DISK_CREATE_DISK and not IOCTL_DISK_DELETE_DRIVE_LAYOUT * Also improve messaging and increase detection timeout to 15 seconds
This commit is contained in:
parent
967ad1da33
commit
d81ca7de24
4 changed files with 59 additions and 17 deletions
30
src/format.c
30
src/format.c
|
@ -576,9 +576,9 @@ static BOOL FormatFAT32(DWORD DriveIndex)
|
|||
// Set the FAT32 volume label
|
||||
GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel));
|
||||
ToValidLabel(wLabel, TRUE);
|
||||
PrintStatus(0, TRUE, "Setting Label (This may take while)...");
|
||||
// Handle must be closed for SetVolumeLabel to work
|
||||
safe_closehandle(hLogicalVolume);
|
||||
PrintStatus(0, TRUE, "Setting Label (This may take while)...");
|
||||
VolumeName = GetLogicalName(DriveIndex, TRUE, TRUE);
|
||||
wVolumeName = utf8_to_wchar(VolumeName);
|
||||
if ((wVolumeName == NULL) || (!SetVolumeLabelW(wVolumeName, wLabel))) {
|
||||
|
@ -708,22 +708,22 @@ static BOOL AnalyzeMBR(HANDLE hPhysicalDrive)
|
|||
return FALSE;
|
||||
}
|
||||
if (is_dos_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a Microsoft DOS/NT/95A master boot record\n");
|
||||
uprintf("Drive has a DOS/NT/95A master boot record\n");
|
||||
} else if (is_dos_f2_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a Microsoft DOS/NT/95A master boot record "
|
||||
uprintf("Drive has a DOS/NT/95A master boot record "
|
||||
"with the undocumented F2 instruction\n");
|
||||
} else if (is_95b_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a Microsoft 95B/98/98SE/ME master boot record\n");
|
||||
uprintf("Drive has a Windows 95B/98/98SE/ME master boot record\n");
|
||||
} else if (is_2000_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a Microsoft 2000/XP/2003 master boot record\n");
|
||||
uprintf("Drive has a Windows 2000/XP/2003 master boot record\n");
|
||||
} else if (is_vista_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a Microsoft Vista master boot record\n");
|
||||
uprintf("Drive has a Windows Vista master boot record\n");
|
||||
} else if (is_win7_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a Microsoft 7 master boot record\n");
|
||||
uprintf("Drive has a Windows 7 master boot record\n");
|
||||
} else if (is_zero_mbr(&fake_fd)) {
|
||||
uprintf("Drive has a zeroed non-bootable master boot record\n");
|
||||
} else {
|
||||
uprintf("Unknown boot record\n");
|
||||
uprintf("Drive has an unknown master boot record\n");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -753,6 +753,8 @@ static BOOL AnalyzePBR(HANDLE hLogicalVolume)
|
|||
} else {
|
||||
uprintf("Drive has an unknown FAT16 or FAT32 partition boot record\n");
|
||||
}
|
||||
} else {
|
||||
uprintf("Drive has an unknown partition boot record\n");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1260,11 +1262,19 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
|
||||
PrintStatus(0, TRUE, "Analyzing existing boot records...\n");
|
||||
AnalyzeMBR(hPhysicalDrive);
|
||||
if (hLogicalVolume != NULL) {
|
||||
if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) {
|
||||
AnalyzePBR(hLogicalVolume);
|
||||
}
|
||||
UpdateProgress(OP_ANALYZE_MBR, -1.0f);
|
||||
|
||||
// Zap any existing partitions. This helps prevent access errors.
|
||||
// As this creates issues with FAT16 formatted MS drives, only do this for other filesystems
|
||||
if ( (fs != FS_FAT16) && (!DeletePartitions(hPhysicalDrive)) ) {
|
||||
uprintf("Could not reset partitions\n");
|
||||
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (IsChecked(IDC_BADBLOCKS)) {
|
||||
do {
|
||||
// create a log file for bad blocks report. Since %USERPROFILE% may
|
||||
|
@ -1325,7 +1335,7 @@ DWORD WINAPI FormatThread(LPVOID param)
|
|||
}
|
||||
}
|
||||
// Close the (unmounted) volume before formatting
|
||||
if (hLogicalVolume != NULL) {
|
||||
if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) {
|
||||
PrintStatus(0, TRUE, "Closing existing volume...\n");
|
||||
if (!CloseHandle(hLogicalVolume)) {
|
||||
uprintf("Could not close volume: %s\n", WindowsErrorString());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue