阅读:1119回复:4
Driver Unload 例程问题!
小弟刚学驱动。问题弱智大家不要笑啊 :)
我的DEVICE_EXTENSION是这样的 typedef struct _DEVICE_EXTENSION { CSHORT Type; CSHORT Size; PDRIVER_OBJECT MyDriver; //pointer to my DriverObject PDEVICE_OBJECT NextDeviceObject; PDEVICE_OBJECT RealDeviceObject; BOOLEAN Attached; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; 然后,我写了一个unload例程,如下 VOID DriverUnload ( IN PDRIVER_OBJECT DriverObject ) { PDEVICE_OBJECT pDevObj; PDEVICE_EXTENSION pDevExt; // Loop through each device controlled by Driver pDevObj = DriverObject->DeviceObject; // Dig out the Device Extension from the // Device Object while(pDevObj!=NULL) { pDevExt = (PDEVICE_EXTENSION) pDevObj->DeviceExtension; pDevObj=pDevExt->NextDeviceObject; if (pDevExt!=NULL) IoDeleteDevice(pDevExt->RealDeviceObject); } IoDeleteDevice(pDevExt->NextDeviceObject); } 一调试就机器就重起!怎么样都改过,除非不要IoDeleteDevice和while语句,各位大哥,是哪里出了问题啊,因该怎么写这个驱动啊? |
|
|
沙发#
发布于:2002-05-30 10:49
你创建了几个设备对象?你删除了几个设备对象?
在驱动程序栈中,devextension有几个是属于你的? 你只卸载你自己的设备对象就可以了,为什么卸载那么多? |
|
板凳#
发布于:2002-05-30 10:57
我自己创建的EXTENSION里面的device不都是我的吗?
|
|
|
地板#
发布于:2002-05-30 11:22
你只需这样作即可:
VOID DriverUnload ( IN PDRIVER_OBJECT DriverObject ) { PDEVICE_OBJECT pDevObj; PDEVICE_EXTENSION pDevExt; // Loop through each device controlled by Driver pDevObj = DriverObject->DeviceObject; //将中断、Port、linkname等资源释放 // Dig out the Device Extension from the // Device Object IoDeleteDevice(pDevObj ); } 那些都不是你创建的,不要管它。 |
|
地下室#
发布于:2002-05-30 19:16
我就把你那个程序拷上去,什么都没有添,
还是重起,不过好点,没有立即就重起, 而是过了一会儿 :D :D :D |
|
|