阅读:1289回复:2
卸载的问题
为什么我的驱动程序在停止或者卸载的时候就会蓝屏
说是什么KOMDE_EXCEPTION_NOT_HANDLED的问题什么的 用softice跟踪时到iodeletedevice函数时有问题。 有哪位大哥知道什么原因救救小弟。 附部分源程序(dispatchpnp函数): case STATE_REMOVE_PENDING + IRP_MN_REMOVE_DEVICE: // // All queued and active IRPs are complete at this point. // // // Return any resources we're using. // PciReturnResources(devExt); // // Fall through... // // // STATE: SURPRISE_REMOVED // IRP_MN: _REMOVE_DEVICE // // We're here because we've previously received notification // of a "surprise" removal. At this point, we just tear down // our device object // case STATE_SURPRISE_REMOVED + IRP_MN_REMOVE_DEVICE: // // Removing the device at this point is NOT optional. // #if DBG DbgPrint("PciPnp: REMOVE_DEVICE\n"); #endif // // Device has been removed // devExt->State = STATE_REMOVED; // // Decrement our reference on the device here, and then // wait until we can remove the device. Because we would // have gotten a prior warning of this removal (via an // IRP_MN_SUPRISE_REMOVAL or an IRP_MN_QUERY_REMOVE) and // at that time transitioned state appropriately, there // should be no requests outstanding here. // PciRequestDecrement(devExt); #if DBG DbgPrint("PciPnp: Waiting for pending requests to complete. %d. remain\n", devExt->OutstandingIO); #endif PciWaitForRemove(devExt); // // WE process this request first // // // Detach from the PDO // IoDetachDevice(devExt->DeviceToSendIrpsTo); targetDevice = devExt->DeviceToSendIrpsTo; #if DBG devExt->DeviceToSendIrpsTo = NULL; devExt = NULL; #endif // // Return our device object // IoDeleteDevice(devExt->FunctionalDeviceObject);//?????????????崩溃!!!!! // // Indidcate that we've successfully processed the IRP // Irp->IoStatus.Status = STATUS_SUCCESS; // // Pass this request on down to the bus driver // IoSkipCurrentIrpStackLocation(Irp); code = IoCallDriver(targetDevice, Irp); ASSERT(code != STATUS_PENDING); // // IMPORTANT: We decremented our I/O In Progress count // above... We don't want to decrement it again, so we // return right here. // #if DBG DbgPrint("PciPnp: Leaving with state: STATE_REMOVE"); #endif return(code); break; |
|
沙发#
发布于:2004-03-30 18:17
经常发生这样的情况在于你有未完成的IRP,你删除了以后,就会出问题的。
|
|
|
板凳#
发布于:2004-03-30 19:04
可是我删除设备的IRP能够立即被
dispatchpnp例程执行呀。 我是采用排队方式来处理IRP请求的。 |
|