阅读:1270回复:5
大虾帮忙,路过看看
The IoGetDeviceAttachmentBaseRef routine returns a pointer to the lowest-level device object in a file system or device driver stack.
IoGetDeviceAttachmentBaseRef函数中能够得到物理设备对象(This routine is available on Microsoft? Windows? XP and later), 如何在win2000中得到物理设备对象?没有一点思路,各位看看,帮帮忙,急需! |
|
|
沙发#
发布于:2007-01-08 20:58
自己向下枚举设备栈,自己反编译下XP的实现,自己实现吧,反正也简单.
![]() |
|
|
板凳#
发布于:2007-01-09 10:03
不是吧!要这么麻烦,有没有简单一点的办法!我看到资料说一般应该把物理设备对象保存在adddevice()中,但是在sfilter的基础上还没有实现,有简单的方法吗?枚举倒也不是很难,不过,怎么区分这个对象是物理设备对象,刚入门不久,望大虾们指点一二!谢谢啦!
|
|
|
地板#
发布于:2007-01-11 18:36
看到如下一种方法,可是不知为什么在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; } |
|
|
地下室#
发布于:2007-01-11 19:17
在ifs中有一个realdeviceObject对象就是
|
|
|
5楼#
发布于:2007-01-12 17:52
谢谢楼上。
不过,你说的那个在sfilter源码中不是真正的PhysicdevicePdo, 终于找到问题啦!也已经搞定!忙碌了将近一周就时间,每天对着蓝屏,发现是上述代码的一个小bug,高兴,哈哈,以后有机会再和大家交流! ![]() |
|
|