阅读:1209回复:4
如何得到pdo?以便解决驱动中区分usb存储设备这个老难题!
修改sfliter的代码,在xp以上版本已经实现啦!调用相应的函数(win2000不支持),可是如何在2000上得到呢?大家一块出主意,人多力量大嘛,重在参与!
|
|
|
沙发#
发布于:2007-01-10 10:25
怎么没有人来,好冷?版主,toolflat,click,luo大虾,给点建议!
|
|
|
板凳#
发布于:2007-01-11 18:35
文字文字看到如下一种方法,可是不知为什么在win2000下加到sfilter的SfFsControlMountVolume代码中时,老是蓝屏,提示说是未处理的内核句柄,为什么?老大们指点一下!为什么?郁闷中。。。。。。。。。。。。。。。。!
NTSTATUS SfFsControlMountVolume( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) { 。。。。。。。。。。 Mon_GetTargetDevicePdo(..); 。。。。。。。。。。 } NTSTATUS Mon_GetTargetDevicePdo( IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_OBJECT PhysicalDeviceObject ) /*++ Routine Description: This builds and send a pnp irp to get the PDO a device. Arguments: DeviceObject - This is the top of the device in the device stack the irp is to be sent to. PhysicalDeviceObject - Address where the PDO pointer is returned Return Value: NT status code --*/ { KEVENT event; NTSTATUS status; PIRP irp; IO_STATUS_BLOCK ioStatusBlock; PIO_STACK_LOCATION irpStack; PDEVICE_RELATIONS deviceRelations; PAGED_CODE(); KdPrint(("sfilter!SfFsRecogniseUsbDevice: Mon_GetTargetDevicePdo Start!\n")); KeInitializeEvent( &event, NotificationEvent, FALSE ); irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, DeviceObject, NULL, 0, NULL, &event, &ioStatusBlock ); if (irp == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; goto End; } irpStack = IoGetNextIrpStackLocation( irp ); irpStack->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS; irpStack->Parameters.QueryDeviceRelations.Type = TargetDeviceRelation; // // Initialize the status to error in case the bus driver decides not to // set it correctly. // irp->IoStatus.Status = STATUS_NOT_SUPPORTED; status = IoCallDriver( DeviceObject, irp ); if (status == STATUS_PENDING) { KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); status = ioStatusBlock.Status; } KdPrint(("sfilter!SfFsRecogniseUsbDevice: Mon_GetTargetDevicePdo IoCallDriver!\n")); if (NT_SUCCESS( status)) { deviceRelations = (PDEVICE_RELATIONS)ioStatusBlock.Information; ASSERT(deviceRelations); // // You must dereference the PDO when it's no longer // required. // KdPrint(("sfilter!SfFsRecogniseUsbDevice: PhysicalDeviceObject :%0x!\n",deviceRelations->Objects[0])); PhysicalDeviceObject = deviceRelations->Objects[0]; ExFreePool(deviceRelations); } End: return status; }[p:2][p:4] |
|
|
地板#
发布于:2007-01-12 17:53
谢谢楼上。
不过,你说的那个在sfilter源码中不是真正的PhysicdevicePdo, 终于找到问题啦!也已经搞定!忙碌了将近一周就时间,每天对着蓝屏,发现是上述代码的一个小bug,高兴,哈哈,以后有机会再和大家交流! ![]() |
|
|
地下室#
发布于:2007-01-18 06:22
自言自语型???貌似最近压力比较大。。。
![]() |
|
|