//
Create IRP Get The BusType
//
创建IRP 查询设备的BUSTYPE类型 为7 则说明是USB设备
//
status = FltGetDiskDeviceObject(FltObjects->Volume, &DiskDeviceObject);
if
(status == STATUS_FLT_NO_DEVICE_OBJECT )
{
return
STATUS_SUCCESS;
}
else
if
(!NT_SUCCESS(status))
{
return
status;
}
KeInitializeEvent(&WaitEvent, NotificationEvent, FALSE);
Query.PropertyId = StorageDeviceProperty;
//StorageDeviceType
;
//
Query.QueryType = PropertyStandardQuery;
NewIrp = IoBuildDeviceIoControlRequest(IOCTL_STORAGE_QUERY_PROPERTY, DiskDeviceObject,
(PVOID)&Query, sizeof(STORAGE_DEVICE_DESCRIPTOR), (PVOID)pBuffer,
sizeof(STORAGE_DEVICE_DESCRIPTOR) * 4, FALSE, &WaitEvent, &IoStatus);
if
(NULL == NewIrp)
//
can't create new irp
{
DbgPrint(
" BusTypeUnknown \n"
);
return
STATUS_SUCCESS;
}
status = IoCallDriver(DiskDeviceObject, NewIrp);
if
(status == STATUS_PENDING)
{
status = KeWaitForSingleObject(&WaitEvent, Executive, KernelMode, FALSE, NULL);
status = IoStatus.Status;
}
if
(!NT_SUCCESS(status))
{
DbgPrint(
" BusTypeUnknown \n"
);
return
STATUS_SUCCESS;
}
Descriptor = (PSTORAGE_DEVICE_DESCRIPTOR)pBuffer;
if
(Descriptor->BusType == 7)
{
DbgPrint(
"GetStorageDeviceBusType SUCCEED: %d DevType:%x \n "
,
Descriptor->BusType, DiskDeviceObject->DeviceType);
}
else
if
(Descriptor->BusType == 3)
{
DbgPrint(
"GetStorageDeviceBusType SUCCEED: %d DevType:%x \n "
,
Descriptor->BusType, DiskDeviceObject->DeviceType);