阅读:2784回复:5
VPB中的deviceObject和realDevice两者之间有什么区别?
rt
彻底昏头了 究竟哪一个才是卷设备,另一个是什么,如果想发送IOCTL_STORAGE_QUERY_PROPERTY询问,应该发给哪个设备? |
|
沙发#
发布于:2009-09-28 21:42
我在向realDevice发送IOCTL_STORAGE_QUERY_PROPERTY询问时,出现了死锁的情况;
在向deviceObject发送时,就直接蓝屏了 |
|
板凳#
发布于:2009-09-28 21:50
BOOLEAN
QueryStorageDeviceDescriptor( IN PDEVICE_OBJECT pStorageDevice, OUT PSTORAGE_DEVICE_DESCRIPTOR pStorageDeviceDescriptor ) { //#if DBG // _asm int 3 //#endif KEVENT myEvent; KeInitializeEvent(&myEvent, NotificationEvent, FALSE); STORAGE_PROPERTY_QUERY query; IO_STATUS_BLOCK iostatus; // KIRQL CurrentIRQL; CurrentIRQL = KeGetCurrentIrql(); if(CurrentIRQL >= DISPATCH_LEVEL) { KdPrint(("USBFilter!GetStorageDeviceBusType CurrentIRQL != PASSIVE_LEVEL\n")); return FALSE; } // first set the query properties query.PropertyId = StorageDeviceProperty; query.QueryType = PropertyStandardQuery; PIRP Irp = NULL; Irp = IoBuildDeviceIoControlRequest( IOCTL_STORAGE_QUERY_PROPERTY, pStorageDevice, (PVOID)(&query), sizeof(STORAGE_PROPERTY_QUERY), (PVOID)pStorageDeviceDescriptor, sizeof(STORAGE_DEVICE_DESCRIPTOR), FALSE, &myEvent, &iostatus ); if( !Irp ) { KdPrint(("Error in build IRP!")); return FALSE; } NTSTATUS status = IoCallDriver(pStorageDevice, Irp); if (status == STATUS_PENDING) { KeWaitForSingleObject(&myEvent, Executive, KernelMode, FALSE, NULL); ///////////////////////这一步锁死了 status = iostatus.Status; } if( NT_SUCCESS(status) ) return TRUE; else return FALSE; } |
|
地板#
发布于:2009-09-28 22:15
As I remember, VPB->DeviceObject is for the file system volume and VPB->RealDevice is for the physical disk device.
Why don't you use ZwDeviceIoControlFile() or FltDeviceIoControlFile() |
|
地下室#
发布于:2009-09-29 09:55
谢谢回答!
我是在sfilter的例子上进行修改的,想法是在卷mount的时候通过判断设备的STORAGE_DEVICE_DESCRIPTOR中的bustype来把所有的移动设备、光驱等找出来,在这些设备上加载过滤设备,下一步进行监测。 现在是如果对vpb的deviceobject一发iocalldriver,就立刻蓝屏.... |
|
5楼#
发布于:2009-09-29 16:48
死锁的原因找到了,是因为代码在ExAcquireFastMutex函数作用范围内
|
|