mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] eliminate querying of floppy drives during enumeration
This commit is contained in:
parent
efe7ccb43c
commit
9545123711
3 changed files with 51 additions and 11 deletions
14
src/drive.c
14
src/drive.c
|
@ -53,6 +53,8 @@ const GUID PARTITION_SYSTEM_GUID =
|
|||
{ 0xc12a7328L, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} };
|
||||
#endif
|
||||
|
||||
PF_TYPE_DECL(NTAPI, NTSTATUS, NtQueryVolumeInformationFile, (HANDLE, PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS));
|
||||
|
||||
/*
|
||||
* Globals
|
||||
*/
|
||||
|
@ -401,10 +403,14 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
|
|||
BOOL r = FALSE;
|
||||
HANDLE hDrive = INVALID_HANDLE_VALUE;
|
||||
UINT _drive_type;
|
||||
IO_STATUS_BLOCK io_status_block;
|
||||
FILE_FS_DEVICE_INFORMATION file_fs_device_info;
|
||||
int i = 0, drive_number;
|
||||
char *drive, drives[26*4 + 1]; /* "D:\", "E:\", etc., plus one NUL */
|
||||
char logical_drive[] = "\\\\.\\#:";
|
||||
|
||||
PF_INIT(NtQueryVolumeInformationFile, Ntdll);
|
||||
|
||||
if (drive_letters != NULL)
|
||||
drive_letters[0] = 0;
|
||||
if (drive_type != NULL)
|
||||
|
@ -451,6 +457,14 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
|
|||
continue;
|
||||
}
|
||||
|
||||
// Eliminate floppy drives
|
||||
if ((pfNtQueryVolumeInformationFile != NULL) &&
|
||||
(pfNtQueryVolumeInformationFile(hDrive, &io_status_block, &file_fs_device_info,
|
||||
sizeof(file_fs_device_info), FileFsDeviceInformation) == NO_ERROR) &&
|
||||
(file_fs_device_info.Characteristics & FILE_FLOPPY_DISKETTE) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
drive_number = GetDriveNumber(hDrive, logical_drive);
|
||||
safe_closehandle(hDrive);
|
||||
if (drive_number == DriveIndex) {
|
||||
|
|
38
src/drive.h
38
src/drive.h
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Drive access function calls
|
||||
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2011-2018 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -19,7 +19,8 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
#include <winioctl.h> // for DISK_GEOMETRY
|
||||
#include <winioctl.h> // for DISK_GEOMETRY
|
||||
#include <winternl.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -31,10 +32,28 @@
|
|||
#define IOCTL_MOUNTMGR_SET_AUTO_MOUNT \
|
||||
CTL_CODE(MOUNTMGRCONTROLTYPE, 16, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define XP_MSR 0x01
|
||||
#define XP_EFI 0x02
|
||||
#define XP_UEFI_NTFS 0x04
|
||||
#define XP_COMPAT 0x08
|
||||
#define XP_MSR 0x01
|
||||
#define XP_EFI 0x02
|
||||
#define XP_UEFI_NTFS 0x04
|
||||
#define XP_COMPAT 0x08
|
||||
|
||||
#define FILE_FLOPPY_DISKETTE 0x00000004
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
typedef enum _FSINFOCLASS {
|
||||
FileFsVolumeInformation = 1,
|
||||
FileFsLabelInformation,
|
||||
FileFsSizeInformation,
|
||||
FileFsDeviceInformation,
|
||||
FileFsAttributeInformation,
|
||||
FileFsControlInformation,
|
||||
FileFsFullSizeInformation,
|
||||
FileFsObjectIdInformation,
|
||||
FileFsDriverPathInformation,
|
||||
FileFsVolumeFlagsInformation,
|
||||
FileFsMaximumInformation
|
||||
} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS;
|
||||
#endif
|
||||
|
||||
/* We need a redef of these MS structure */
|
||||
typedef struct {
|
||||
|
@ -49,6 +68,13 @@ typedef struct {
|
|||
DISK_EXTENT Extents[8];
|
||||
} VOLUME_DISK_EXTENTS_REDEF;
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
typedef struct _FILE_FS_DEVICE_INFORMATION {
|
||||
DEVICE_TYPE DeviceType;
|
||||
ULONG Characteristics;
|
||||
} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
|
||||
#endif
|
||||
|
||||
static __inline BOOL UnlockDrive(HANDLE hDrive) {
|
||||
DWORD size;
|
||||
return DeviceIoControl(hDrive, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &size, NULL);
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 3.0.1238"
|
||||
CAPTION "Rufus 3.0.1239"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -371,8 +371,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,18,1238,0
|
||||
PRODUCTVERSION 2,18,1238,0
|
||||
FILEVERSION 2,18,1239,0
|
||||
PRODUCTVERSION 2,18,1239,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -389,13 +389,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "2.18.1238"
|
||||
VALUE "FileVersion", "2.18.1239"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "2.18.1238"
|
||||
VALUE "ProductVersion", "2.18.1239"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue