mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-28 13:44:15 -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
32
src/drive.c
32
src/drive.c
|
@ -579,6 +579,10 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
}
|
||||
break;
|
||||
case PARTITION_STYLE_GPT:
|
||||
// TODO: (?) As per MSDN: "When specifying a GUID partition table (GPT) as the PARTITION_STYLE of the CREATE_DISK
|
||||
// structure, an application should wait for the MSR partition arrival before sending the IOCTL_DISK_SET_DRIVE_LAYOUT_EX
|
||||
// control code. For more information about device notification, see RegisterDeviceNotification."
|
||||
|
||||
CreateDisk.PartitionStyle = PARTITION_STYLE_GPT;
|
||||
IGNORE_RETVAL(CoCreateGuid(&CreateDisk.Gpt.DiskId));
|
||||
CreateDisk.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS;
|
||||
|
@ -676,6 +680,34 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Delete the disk partition table */
|
||||
BOOL DeletePartitions(HANDLE hDrive)
|
||||
{
|
||||
BOOL r;
|
||||
DWORD size;
|
||||
CREATE_DISK CreateDisk = {PARTITION_STYLE_RAW, {{0}}};
|
||||
|
||||
PrintStatus(0, TRUE, "Deleting partitions...");
|
||||
|
||||
size = sizeof(CreateDisk);
|
||||
r = DeviceIoControl(hDrive, IOCTL_DISK_CREATE_DISK,
|
||||
(BYTE*)&CreateDisk, size, NULL, 0, &size, NULL );
|
||||
if (!r) {
|
||||
uprintf("Could not delete drive layout: %s\n", WindowsErrorString());
|
||||
safe_closehandle(hDrive);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
r = DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &size, NULL );
|
||||
if (!r) {
|
||||
uprintf("Could not refresh drive layout: %s\n", WindowsErrorString());
|
||||
safe_closehandle(hDrive);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a partition type to its human readable form using
|
||||
* (slightly modified) entries from GNU fdisk
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue