Code Example: Driver Unload

In the Minimal driver, an Unload routine is supplied that undoes the work of DriverEntry. Its work is straightforward, as it must delete each symbolic link and device object that has been created. To perform this work, the Unload routine relies on the fact that the driver object points to a linked list of device objects controlled by the driver.

The first device controlled by a driver is pointed to by the field DeviceObject within the driver object. Each device points to the next via the field NextDevice. When examining the Unload routine, remember that the Minimal DEVICE_EXTENSION structure maintains a back pointer to the parent device object.

 //++ // Function: DriverUnload // // Description: // Stops & Deletes devices ...

Get Windows® 2000 Device Driver Book: A Guide for Programmers, Second Edition, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.