Is Usb Drive () ? DeviceIoControl, IOCTL_STORAGE_QUERY_PROPERTY
http://banderlogi.blogspot.com/2011/06/enum-drive-letters-attached-for-usb.html
typedef enum _STORAGE_BUS_TYPE {
BusTypeUnknown = 0x00,
BusTypeScsi = 0x01,
BusTypeAtapi = 0x02,
BusTypeAta = 0x03,
BusType1394 = 0x04,
BusTypeSsa = 0x05,
BusTypeFibre = 0x06,
BusTypeUsb = 0x07,
BusTypeRAID = 0x08,
BusTypeiSCSI = 0x09,
BusTypeSas = 0x0A,
BusTypeSata = 0x0B,
BusTypeMaxReserved = 0x7F
} STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
typedef struct _STORAGE_DEVICE_DESCRIPTOR {
DWORD Version;
DWORD Size;
BYTE DeviceType;
BYTE DeviceTypeModifier;
BOOLEAN RemovableMedia;
BOOLEAN CommandQueueing;
DWORD VendorIdOffset;
DWORD ProductIdOffset;
DWORD ProductRevisionOffset;
DWORD SerialNumberOffset;
STORAGE_BUS_TYPE BusType;
DWORD RawPropertiesLength;
BYTE RawDeviceProperties[];
} STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
bool IsUsbDevice( wchar_t letter )
{
wchar_t volumeAccessPath[ ] = L"\\\\.\\X:";
volumeAccessPath[ ] = letter; HANDLE deviceHandle = CreateFileW( volumeAccessPath, , // no access to the drive
FILE_SHARE_READ | // share mode
FILE_SHARE_WRITE, NULL, // default security attributes
OPEN_EXISTING, // disposition
, // file attributes
NULL ); // do not copy file attributes // setup query
STORAGE_PROPERTY_QUERY query;
memset( &query, , sizeof( query ) );
query.PropertyId = StorageDeviceProperty;
query.QueryType = PropertyStandardQuery; // issue query
DWORD bytes;
STORAGE_DEVICE_DESCRIPTOR devd;
STORAGE_BUS_TYPE busType = BusTypeUnknown; if ( DeviceIoControl( deviceHandle, IOCTL_STORAGE_QUERY_PROPERTY, &query,
sizeof( query ), &devd, sizeof( devd ), &bytes, NULL ) )
{
busType = devd.BusType;
}
else
{
std
::wcout << L"Failed to define bus type for: " << letter;
} CloseHandle( deviceHandle ); return BusTypeUsb == busType;
}
Is Usb Drive () ? DeviceIoControl, IOCTL_STORAGE_QUERY_PROPERTY的更多相关文章
- [OrangePi] Booting from USB drive
You can also boot from USB drive partition. The file named cmdline.txt must exist on BOOT (fat) part ...
- Does anyone successfully use USB drive in Windows7 guest?
Hi, Does anyone successfully use USB drive in Windows7 guest? If I pass a USB drive to Windows7 gues ...
- Removing bad blocks from the USB drive with fsck
An easy way to repair a flash drive, or any drive really, is to use the fsck tool. This tool is grea ...
- How to Mount a USB Drive in Ubuntu
Read more : http://www.ehow.com/how_6762235_mount-usb-drive-ubuntu.html Most USB drives will automou ...
- How to match between physical usb device and its drive letter?
struct tagDrives { WCHAR letter; WCHAR volume[ BUFFER_SIZE ]; } g_drives[ ]; // WCHAR GetUSBDrive( ) ...
- Install Slax on USB device (Slax U 盘安装)
Slax is a modern, portable, small and fast Linux operating system with a modular approach and outsta ...
- 用UNetbootin来安装USB LINUX,好像比ULTRA ISO省事
UNetbootin can create a bootable Live USB drive, or it can make a "frugal install" on your ...
- fuel iso光盘刻录机usb Driver 烧录
ISO image to a DVD or burn the IMG file to a USB drive For a bare-metal installation ipmitool, HP iL ...
- 设备管理 USB ID
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
随机推荐
- GO里的“指针”
指针 *T即为类型T的指针 &t即为获取变量t的地址 *p即为获取指针变量所指向的内容 var p *int 指针的*在左边 类型在右边.这里的 *int就是一个指针类型. 跟int str ...
- 缓存数据库-redis(管道)
一:Redis 管道技术 Redis是一种基于客户端-服务端模型以及请求/响应协议的TCP服务.这意味着通常情况下一个请求会遵循以下步骤: 客户端向服务端发送一个查询请求,并监听Socket返回,通常 ...
- mysql慢sql报警系统
前言:最近有同事反应有的接口响应时间时快时慢,经过排查有的数据层响应时间过长,为了加快定位定位慢sql的准确性,决定简单地搭建一个慢sql报警系统 具体流程如下架构图 第一步:记录日志 每个业务系统都 ...
- Centos7.3安装和配置jre1.8
在正式环境里 我们可以不安装jdk ,仅仅安装Java运行环境 jre即可: 第一步:下载jre 我们去oracle官方下载下jre http://www.oracle.com/technetwork ...
- 关于文件格式Fuzzing测试与漏洞挖掘的学习
最近对于文件的漏洞挖掘比较感兴趣,所以在找资料来看.顺带记录笔记,把这些笔记贴在博客中分享一下.最近打算把精力放在mp3格式的漏洞发掘上,一来这是常见的文件格式格式也比较清晰.二来这也是学长推荐的入手 ...
- CentOS 7不能联网解决办法
在使用 Ubuntu 一段时间之后想体验一下 CentOS,就去下载了 CentOS 7 安装到了虚拟机里面,结果发现不能联网,一直提示Cannot find a valid baseurl for ...
- hdu 1007 N个点中输出2点的最小距离的一半
分治法 Sample Input20 01 121 11 13-1.5 00 00 1.50 Sample Output0.710.000.75 # include <iostream> ...
- bms_output.put_line使用方法
https://blog.csdn.net/sxww321/article/details/4020300
- 【LOJ】#2205. 「HNOI2014」画框
题解 我原来根本不会KM 更新每个节点增加的最小值的时候,要忽略那个方访问过的右节点!!! 然后就和最小乘积生成树一样了 代码 #include <iostream> #include & ...
- 【Codeforces】113 D. Museum
题解 我们设\(f(i,j)\)是\((i,j)\)这个点期望被经过多少次 我们可以列出方程组来消元,由于终点只会被经过0次或者1次,期望就是概率 对于起点的话我们期望经过次数多加一个1 复杂度\(O ...