Unloading the Pen Device Driver

The device driver's unloading process should ideally comply with the Plug and Play specifications. The Unidriver's exit code currently consists of only the function cVpenD_Device_Exit, which forms a shell for the exit procedure. The virtual pen driver receives a Sys_Critical_Exit message when the system unloads it. In handling this message, the virtual pen driver should place the hardware in a stable state and free any resources it holds.

The unloading process for the pen driver is also quite simple and straight forward. When the system unloads the pen driver, it sends the following three messages in the given order: DRV_CLOSE, DRV_DISABLE, and DRV_FREE. In processing the DRV_DISABLE message, the pen driver calls the virtual driver so it can turn off interrupts. The pen driver should return DRV_SUCCESS for all three messages.

As part of unloading the driver, the system sends a DRV_RemoveEntryPoints message so the system will receive no more pen packets.