Unloading an Intermediate Driver
NDIS calls the MiniportDriverUnload function to unload an intermediate driver. Intermediate drivers must perform the same operations in MiniportDriverUnload as other miniport drivers. In addition to calling the NdisMDeregisterMiniportDriver function, an intermediate driver also calls NdisDeregisterProtocolDriver. MiniportDriverUnload should also perform any necessary cleanup operations, such as deallocating any protocol driver resources.
To perform cleanup operations before a intermediate driver is uninstalled, an intermediate driver can register a ProtocolUninstall function. For example, the protocol lower edge of an intermediate driver might require a ProtocolUninstall function. The intermediate driver can release its protocol edge resources in ProtocolUninstall before NDIS calls its MiniportDriverUnload function.
A miniport-intermediate driver calls NdisMDeregisterMiniportDriver twice, once for its physical device interface, and again for its virtual device interface.