mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-28 13:44:15 -04:00
[core] detect memory cards in card readers
* Also remove drives with no media from the list * Closes #18
This commit is contained in:
parent
897becd290
commit
36693d2144
6 changed files with 75 additions and 9 deletions
17
src/drive.c
17
src/drive.c
|
@ -450,6 +450,23 @@ uint64_t GetDriveSize(DWORD DriveIndex)
|
|||
return DiskGeometry->DiskSize.QuadPart;
|
||||
}
|
||||
|
||||
/*
|
||||
* GET_DRIVE_GEOMETRY is used to tell if there is an actual media
|
||||
*/
|
||||
BOOL IsMediaPresent(DWORD DriveIndex)
|
||||
{
|
||||
BOOL r;
|
||||
HANDLE hPhysical;
|
||||
DWORD size;
|
||||
BYTE geometry[128];
|
||||
|
||||
hPhysical = GetPhysicalHandle(DriveIndex, FALSE, FALSE);
|
||||
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
|
||||
NULL, 0, geometry, sizeof(geometry), &size, NULL) || (size <= 0);
|
||||
safe_closehandle(hPhysical);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill the drive properties (size, FS, etc)
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue