MacUnload

VOID
    MacUnload(
        IN NDIS_HANDLE  MacMacContext
        );

MacUnload is called by NDIS to remove the NIC driver.

Parameters

MacMacContext
Specifies the context that the NIC driver associates with itself.

Comments

Before calling MacUnload, NDIS calls the NIC driver’s MacRemoveAdapter function to deregister all the driver’s NICs that were registered.

The unload process for a NIC driver is OS-dependent. Windows NT NIC drivers must have a MacUnload function. Windows NT protocol drivers also have an Unload routine, which they set in the driver object during initialization.

MacUnload first frees any resources that were allocated for the driver itself. It decrements the reference count in the NIC driver block to zero. MacUnload then calls NdisDeregisterMac to release the resources NDIS allocated when the driver originally called NdisRegisterMac. The call to NdisDeregisterMac renders the MacMacContext handle invalid.

After NDIS informs bound protocols of the NIC driver’s termination, all bound protocol drivers call NdisDeregisterProtocol to release the resources that NDIS allocated when they registered themselves.

The last driver being unloaded when the network is shutting down should make a final call to NdisTerminateWrapper to close the NDIS interface library.

If the operating system does not support unloading drivers, MacUnload simply returns control and NDIS unloads the NIC driver.

MacUnload runs at IRQL PASSIVE_LEVEL.

See Also

MacRemoveAdapter, NdisDeregisterMac, NdisDeregisterProtocol, NdisTerminateWrapper