mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] fix drives not being detected when LVM is in use
* Also use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS to retrieve the disk number as IOCTL_STORAGE_GET_DEVICE_NUMBER will fail for LVM * Closes #290
This commit is contained in:
parent
1af5cc0e41
commit
11917179b9
4 changed files with 29 additions and 33 deletions
20
src/drive.c
20
src/drive.c
|
@ -269,8 +269,8 @@ HANDLE GetLogicalHandle(DWORD DriveIndex, BOOL bWriteAccess, BOOL bLockDrive)
|
|||
static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT* drive_type)
|
||||
{
|
||||
DWORD size;
|
||||
BOOL r = FALSE;
|
||||
STORAGE_DEVICE_NUMBER_REDEF device_number = {0};
|
||||
BOOL s, r = FALSE;
|
||||
VOLUME_DISK_EXTENTS DiskExtents;
|
||||
HANDLE hDrive = INVALID_HANDLE_VALUE;
|
||||
UINT _drive_type;
|
||||
int i = 0;
|
||||
|
@ -293,7 +293,7 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
|
|||
goto out;
|
||||
}
|
||||
|
||||
r = TRUE;
|
||||
r = TRUE; // Required to detect drives that don't have volumes assigned
|
||||
for (drive = drives ;*drive; drive += safe_strlen(drive)+1) {
|
||||
if (!isalpha(*drive))
|
||||
continue;
|
||||
|
@ -318,13 +318,15 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
|
|||
continue;
|
||||
}
|
||||
|
||||
r = DeviceIoControl(hDrive, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL,
|
||||
0, &device_number, sizeof(device_number), &size, NULL) && (size > 0);
|
||||
s = DeviceIoControl(hDrive, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0,
|
||||
&DiskExtents, sizeof(DiskExtents), &size, NULL) && (size > 0) && (DiskExtents.NumberOfDiskExtents >= 1);
|
||||
safe_closehandle(hDrive);
|
||||
if (!r) {
|
||||
uprintf("Could not get device number for device %s: %s\n",
|
||||
logical_drive, WindowsErrorString());
|
||||
} else if (device_number.DeviceNumber == DriveIndex) {
|
||||
if (!s) {
|
||||
uprintf("Could not get device number for %c: - %s\n", drive[0], WindowsErrorString());
|
||||
} else if (DiskExtents.NumberOfDiskExtents >= 2) {
|
||||
uprintf("Ignoring drive %c: as it spans multiple disks (RAID?)", drive[0]);
|
||||
} else if (DiskExtents.Extents[0].DiskNumber == DriveIndex) {
|
||||
r = TRUE;
|
||||
if (drive_letters != NULL)
|
||||
drive_letters[i++] = *drive;
|
||||
// The drive type should be the same for all volumes, so we can overwrite
|
||||
|
|
23
src/rufus.c
23
src/rufus.c
|
@ -642,12 +642,12 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
const char* usbstor_name[] = { "USBSTOR", "UASPSTOR", "VUSBSTOR", "EtronSTOR" };
|
||||
const char* scsi_name = "SCSI";
|
||||
char letter_name[] = " (?:)";
|
||||
BOOL r, found = FALSE, is_SCSI, is_UASP;
|
||||
BOOL found = FALSE, is_SCSI, is_UASP;
|
||||
HDEVINFO dev_info = NULL;
|
||||
SP_DEVINFO_DATA dev_info_data;
|
||||
SP_DEVICE_INTERFACE_DATA devint_data;
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA_A devint_detail_data;
|
||||
STORAGE_DEVICE_NUMBER_REDEF device_number;
|
||||
VOLUME_DISK_EXTENTS DiskExtents;
|
||||
DEVINST parent_inst, device_inst;
|
||||
DWORD size, i, j, k, datatype, drive_index;
|
||||
ULONG list_size[ARRAYSIZE(usbstor_name)], full_list_size;
|
||||
|
@ -798,20 +798,21 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
continue;
|
||||
}
|
||||
|
||||
memset(&device_number, 0, sizeof(device_number));
|
||||
r = DeviceIoControl(hDrive, IOCTL_STORAGE_GET_DEVICE_NUMBER,
|
||||
NULL, 0, &device_number, sizeof(device_number), &size, NULL );
|
||||
if (!r || size <= 0) {
|
||||
uprintf("IOCTL_STORAGE_GET_DEVICE_NUMBER (GetUSBDevices) failed: %s\n", WindowsErrorString());
|
||||
if (!DeviceIoControl(hDrive, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0,
|
||||
&DiskExtents, sizeof(DiskExtents), &size, NULL) || (size <= 0) || (DiskExtents.NumberOfDiskExtents < 1) ) {
|
||||
uprintf("Could not get device number for device %s: %s\n", devint_detail_data->DevicePath, WindowsErrorString());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (device_number.DeviceNumber >= MAX_DRIVES) {
|
||||
if (DiskExtents.NumberOfDiskExtents >= 2) {
|
||||
uprintf("Ignoring drive '%s' as it spans multiple disks (RAID?)", devint_detail_data->DevicePath);
|
||||
continue;
|
||||
} else if (DiskExtents.Extents[0].DiskNumber >= MAX_DRIVES) {
|
||||
uprintf("Device Number %d is too big - ignoring device\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
drive_index = device_number.DeviceNumber + DRIVE_INDEX_MIN;
|
||||
drive_index = DiskExtents.Extents[0].DiskNumber + DRIVE_INDEX_MIN;
|
||||
if (!IsMediaPresent(drive_index)) {
|
||||
uprintf("Device eliminated because it appears to contain no media\n");
|
||||
safe_closehandle(hDrive);
|
||||
|
@ -831,7 +832,7 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
|
||||
// The empty string is returned for drives that don't have any volumes assigned
|
||||
if (drive_letters[0] == 0) {
|
||||
entry = lmprintf(MSG_046, label, device_number.DeviceNumber);
|
||||
entry = lmprintf(MSG_046, label, DiskExtents.Extents[0].DiskNumber);
|
||||
} else {
|
||||
// We have multiple volumes assigned to the same device (multiple partitions)
|
||||
// If that is the case, use "Multiple Volumes" instead of the label
|
||||
|
@ -860,7 +861,7 @@ static BOOL GetUSBDevices(DWORD devnum)
|
|||
StrArrayAdd(&DriveLabel, label);
|
||||
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hDeviceList, ComboBox_AddStringU(hDeviceList, entry),
|
||||
device_number.DeviceNumber + DRIVE_INDEX_MIN));
|
||||
DiskExtents.Extents[0].DiskNumber + DRIVE_INDEX_MIN));
|
||||
maxwidth = max(maxwidth, GetEntryWidth(hDeviceList, entry));
|
||||
safe_closehandle(hDrive);
|
||||
safe_free(devint_detail_data);
|
||||
|
|
|
@ -422,13 +422,6 @@ static __inline HMODULE GetDLLHandle(char* szDLLName)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* We need a redef of this MS structure */
|
||||
typedef struct {
|
||||
DWORD DeviceType;
|
||||
ULONG DeviceNumber;
|
||||
ULONG PartitionNumber;
|
||||
} STORAGE_DEVICE_NUMBER_REDEF;
|
||||
|
||||
/* Custom application errors */
|
||||
#define FAC(f) (f<<16)
|
||||
#define APPERR(err) (APPLICATION_ERROR_MASK|err)
|
||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
|
||||
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Rufus 1.4.4.423"
|
||||
CAPTION "Rufus 1.4.4.424"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -165,7 +165,7 @@ END
|
|||
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||
CAPTION "Rufus 1.4.4.423"
|
||||
CAPTION "Rufus 1.4.4.424"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -427,8 +427,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,4,4,423
|
||||
PRODUCTVERSION 1,4,4,423
|
||||
FILEVERSION 1,4,4,424
|
||||
PRODUCTVERSION 1,4,4,424
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -445,13 +445,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.4.4.423"
|
||||
VALUE "FileVersion", "1.4.4.424"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.4.4.423"
|
||||
VALUE "ProductVersion", "1.4.4.424"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue