waterice_2005
驱动牛犊
驱动牛犊
  • 注册日期2006-02-15
  • 最后登录2007-02-05
  • 粉丝0
  • 关注0
  • 积分250分
  • 威望26点
  • 贡献值0点
  • 好评度25点
  • 原创分0分
  • 专家分0分
阅读:1209回复:4

如何得到pdo?以便解决驱动中区分usb存储设备这个老难题!

楼主#
更多 发布于:2007-01-09 10:30
  修改sfliter的代码,在xp以上版本已经实现啦!调用相应的函数(win2000不支持),可是如何在2000上得到呢?大家一块出主意,人多力量大嘛,重在参与!
冰水混合物
waterice_2005
驱动牛犊
驱动牛犊
  • 注册日期2006-02-15
  • 最后登录2007-02-05
  • 粉丝0
  • 关注0
  • 积分250分
  • 威望26点
  • 贡献值0点
  • 好评度25点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2007-01-10 10:25
怎么没有人来,好冷?版主,toolflat,click,luo大虾,给点建议!
冰水混合物
waterice_2005
驱动牛犊
驱动牛犊
  • 注册日期2006-02-15
  • 最后登录2007-02-05
  • 粉丝0
  • 关注0
  • 积分250分
  • 威望26点
  • 贡献值0点
  • 好评度25点
  • 原创分0分
  • 专家分0分
板凳#
发布于: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]
冰水混合物
waterice_2005
驱动牛犊
驱动牛犊
  • 注册日期2006-02-15
  • 最后登录2007-02-05
  • 粉丝0
  • 关注0
  • 积分250分
  • 威望26点
  • 贡献值0点
  • 好评度25点
  • 原创分0分
  • 专家分0分
地板#
发布于:2007-01-12 17:53
谢谢楼上。
不过,你说的那个在sfilter源码中不是真正的PhysicdevicePdo,
终于找到问题啦!也已经搞定!忙碌了将近一周就时间,每天对着蓝屏,发现是上述代码的一个小bug,高兴,哈哈,以后有机会再和大家交流!
冰水混合物
rayyang2000
管理员
管理员
  • 注册日期2001-03-23
  • 最后登录2012-09-13
  • 粉丝3
  • 关注0
  • 积分1036分
  • 威望925点
  • 贡献值3点
  • 好评度823点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2007-01-18 06:22
自言自语型???貌似最近压力比较大。。。
天天coding-debugging中----超稀饭memory dump file ======================================================== [b]Windows Device Driver Development and Consulting Service[/b] [color=blue][url]http://www.ybwork.com[/url][/color] ========================================================
游客

返回顶部