阅读:1184回复:4
IoDeleteDevice (DeviceObject)的问题!
我在响应 IRP_MN_REMOVE_DEVICE:
一调用 IoDeleteDevice (DeviceObject); 就重启,这是为什么? |
|
沙发#
发布于:2002-11-29 17:01
你看看DeviceObject值对不对?
建议你参看DDK里的相应处理例程。 |
|
|
板凳#
发布于:2002-11-29 17:29
在哪儿我怎么没找到呀!!!
|
|
地板#
发布于:2002-12-10 11:21
我也想知道
|
|
|
地下室#
发布于:2002-12-10 11:58
Bulk_USB中的一段程序:
case IRP_MN_REMOVE_DEVICE: // The PnP Manager uses this IRP to direct drivers to remove a device. // For a \"polite\" device removal, the PnP Manager sends an // IRP_MN_QUERY_REMOVE_DEVICE prior to the remove IRP. In this case, // the device is in the remove-pending state when the remove IRP arrives. // For a surprise-style device removal ( i.e. sudden cord yank ), // the physical device has already been removed and the PnP Manager may not // have sent IRP_MN_SURPRISE_REMOVAL. A device can be in any state // when it receives a remove IRP as a result of a surprise-style removal. // match the inc at the begining of the dispatch routine BulkUsb_DecrementIoCount(DeviceObject); // // Once DeviceRemoved is set no new IOCTL or read/write irps will be passed // down the stack to lower drivers; all will be quickly failed // deviceExtension->DeviceRemoved = TRUE; // Cancel any pending io requests; we may not have gotten a query first! BulkUsb_CancelPendingIo( DeviceObject ); // If any pipes are still open, call USBD with URB_FUNCTION_ABORT_PIPE // This call will also close the pipes; if any user close calls get through, // they will be noops BulkUsb_AbortPipes( DeviceObject ); // We don\'t explicitly wait for the below driver to complete, but just make // the call and go on, finishing cleanup IoCopyCurrentIrpStackLocationToNext(Irp); ntStatus = IoCallDriver(stackDeviceObject, Irp); // // The final decrement to device extension PendingIoCount == 0 // will set deviceExtension->RemoveEvent, enabling device removal. // If there is no pending IO at this point, the below decrement will be it. // BulkUsb_DecrementIoCount(DeviceObject); // wait for any io request pending in our driver to // complete for finishing the remove KeWaitForSingleObject( &deviceExtension->RemoveEvent, Suspended, KernelMode, FALSE, NULL); // // Delete the link and FDO we created // BulkUsb_RemoveDevice(DeviceObject); BULKUSB_KdPrint( DBGLVL_DEFAULT,(\"BulkUsb_ProcessPnPIrp() Detaching from %08X\\n\", deviceExtension->TopOfStackDeviceObject)); IoDetachDevice(deviceExtension->TopOfStackDeviceObject); BULKUSB_KdPrint( DBGLVL_DEFAULT,(\"BulkUsb_ProcessPnPIrp() Deleting %08X\\n\", DeviceObject)); IoDeleteDevice (DeviceObject); return ntStatus; // end, case IRP_MN_REMOVE_DEVICE |
|
|