NdisDeregisterProtocol

VOID
NdisDeregisterProtocol(
OUT PNDIS_STATUS
Status,
IN NDIS_HANDLE NdisProtocolHandle
);

NdisDeregisterProtocol releases the resources allocated when the driver called NdisRegisterProtocol.

Parameters

Status

Points to a caller-supplied variable that is set to NDIS_STATUS_SUCCESS on return from this function.

NdisProtocolHandle

Specifies the handle returned by NdisRegisterProtocol when the driver initialized.

Comments

Registered protocol drivers call NdisDeregisterProtocol in any of the following circumstances:

·The driver already called NdisRegisterProtocol successfully but it cannot bind to any underlying NDIS driver in the machine.

·The driver is being unloaded. That is, the Unload routine set up in its driver object during initialization has been called or the ProtocolUnbindAdapter function has been called to release the driver's last remaining binding.

For more information about the Unload routine and other standard Windows NT kernel-mode driver routines, see the Kernel-Mode Driver Design Guide.

·The system is being shut down. Because the driver, which is a highest-level protocol, called IoRegisterShutdownNotification when it initialized, its Shutdown routine has been called.

For more information about IoRegisterShutdownNotification, see the Kernel-Mode Driver Reference.

Before calling NdisDeregisterProtocol, the driver should call NdisCloseAdapter with each binding handle that it obtained from NdisOpenAdapter but has not yet closed.

NdisDeregisterProtocol calls the driver's ProtocolStatus function with NDIS_STATUS_CLOSING to allow its caller to release any resources the protocol driver has allocated for open bindings. If the protocol driver has any outstanding bindings, the NDIS library closes them and NdisDeregisterProtocol forwards close-adapter requests to any underlying driver(s) that registered a close-adapter handler. If such an underlying driver returns NDIS_STATUS_PENDING for a close-adapter request, the caller's ProtocolCloseAdapterComplete function is called before NdisDeregisterProtocol returns control.

When outstanding opens, if any, have been closed, NdisDeregisterProtocol releases all filters its caller has set up and frees the memory NDIS allocated to track bindings and filters for the protocol driver.

Callers of NdisDeregisterProtocol run at IRQL <= DISPATCH_LEVEL.

See Also

NdisCloseAdapter, NdisIMDeInitializeDeviceInstance, NdisOpenAdapter, NdisRegisterProtocol, ProtocolCloseAdapterComplete, ProtocolStatus, ProtocolUnbindAdapter