Unbinding from an Adapter
NDIS calls a protocol driver's ProtocolUnbindAdapterEx function to request that the driver unbind from an underlying adapter. As the reciprocal of ProtocolBindAdapterEx, NDIS calls ProtocolUnbindAdapterEx to close the binding to the adapter and to release the resources that the driver allocated for the binding.
In ProtocolUnbindAdapterEx, a protocol driver calls NdisCloseAdapterEx to close the binding to an underlying adapter. The protocol driver passes NdisCloseAdapterEx the handle that NdisOpenAdapterEx provided at its NdisBindingHandle parameter. This handle identifies the binding that NDIS should close.
Protocol drivers must close an adapter from the ProtocolBindAdapterEx function or ProtocolUnbindAdapterEx function.
If a protocol driver must initiate an operation to close a binding, the driver can call NdisUnbindAdapter. NdisUnbindAdapter schedules a work item that results in an NDIS call to ProtocolUnbindAdapterEx. This work item can run before the call to NdisUnbindAdapter returns. Therefore, driver writers must assume that the binding handle is invalid after NdisUnbindAdapter returns.
If a protocol driver returns NDIS_STATUS_PENDING from ProtocolUnbindAdapterEx, it must call NdisCompleteUnbindAdapterEx with the final status to complete the bind request.
If NDIS returns NDIS_STATUS_PENDING from NdisCloseAdapterEx, NDIS later calls the protocol driver's ProtocolCloseAdapterCompleteEx function.
NDIS can call ProtocolUnbindAdapterEx if the binding is in the Paused state.
After all the unbind operations are complete, the binding is in the Unbound state.