Skip to content

Commit

Permalink
[core] fixed non detection of USB drives on some platforms
Browse files Browse the repository at this point in the history
* STORAGE_DEVICE_NUMBER.DeviceNumber is not unique! Optical drives and
  HDDs can have the same number
* Use GetDriveType() to filter unwanted devices
* closes #32
  • Loading branch information
pbatard committed Feb 2, 2012
1 parent 4eaae9a commit bb0c0ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ HANDLE GetDriveHandle(DWORD DriveIndex, char* DriveLetter, BOOL bWriteAccess, BO
DWORD size;
HANDLE hDrive = INVALID_HANDLE_VALUE;
STORAGE_DEVICE_NUMBER_REDEF device_number = {0};
UINT drive_type;
char drives[26*4]; /* "D:\", "E:\", etc. */
char *drive = drives;
char logical_drive[] = "\\\\.\\#:";
Expand Down Expand Up @@ -94,6 +95,15 @@ HANDLE GetDriveHandle(DWORD DriveIndex, char* DriveLetter, BOOL bWriteAccess, BO
if (*drive < 'C') {
continue;
}

/* IOCTL_STORAGE_GET_DEVICE_NUMBER's STORAGE_DEVICE_NUMBER.DeviceNumber is
not unique! An HDD, a DVD and probably other drives can have the same
value there => Use GetDriveType() to filter out unwanted devices.
See https://github.com/pbatard/rufus/issues/32 for details. */
drive_type = GetDriveTypeA(drive);
if ((drive_type != DRIVE_REMOVABLE) && (drive_type != DRIVE_FIXED))
continue;

safe_sprintf(logical_drive, sizeof(logical_drive), "\\\\.\\%c:", drive[0]);
hDrive = CreateFileA(logical_drive, GENERIC_READ|(bWriteAccess?GENERIC_WRITE:0),
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
Expand Down
12 changes: 6 additions & 6 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.0.7.123"
CAPTION "Rufus v1.0.7.124"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
Expand Down Expand Up @@ -71,7 +71,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.0.7 (Build 123)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.0.7 (Build 124)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
Expand Down Expand Up @@ -222,8 +222,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,7,123
PRODUCTVERSION 1,0,7,123
FILEVERSION 1,0,7,124
PRODUCTVERSION 1,0,7,124
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -240,13 +240,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.7.123"
VALUE "FileVersion", "1.0.7.124"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.7.123"
VALUE "ProductVersion", "1.0.7.124"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit bb0c0ec

Please sign in to comment.