阅读:4139回复:1
我使用IoRegisterPlugPlayNotification注册USB拦截函数,为什么U盘不能正常弹出呢?
我使用IoRegisterPlugPlayNotification()注册了U盘的回掉函数,在对U盘进行一系列操作后,为什么不能正常弹出U盘呢?显示的是仍有程序在使用U盘,请问各位怎么回事啊?
相关代码如下: 插入U盘后,回吊函数调用以下函数: void RKGetUsbPointer(IN PDEVICE_OBJECT DeviceObject, IN PUNICODE_STRING HidSymLinkName) { PRK_DEVICE_EXTENSION dx; NTSTATUS status; PDEVICE_OBJECT fdo = DeviceObject; if(fdo == NULL) { DbgPrint(\"Have no device!\"); return; } dx = (PRK_DEVICE_EXTENSION)fdo->DeviceExtension; //得到相应USB设备的设备对象 status= IoGetDeviceObjectPointer( HidSymLinkName, FILE_ALL_ACCESS,&dx->FileObject, &dx->Device); if( !NT_SUCCESS(status)) { DbgPrint(\"IoGetDeviceObjectPointer failed %x\", status); return; } //增加对该USB设备的引用计数 status = ObReferenceObjectByPointer(dx->Device, FILE_ALL_ACCESS, NULL, KernelMode); //进行一系列的操作 ...... //减少U盘的引用 ObDereferenceObject(dx->Device); } 怎么还是弹不出U盘呢? [编辑 - 6/12/05 by vancaho] |
|
沙发#
发布于:2007-05-30 09:46
应该减少U盘的文件对象而不是设备对象.
|
|