Unloading and Deregistering a TDI Transport Driver
Before a NIC is removed from the machine, TDI transports for Windows 2000 and later versions that are bound to that NIC are usually given the opportunity to first notify their clients that the NIC might be disabled and removed. That is, unless a "surprise" removal of a NIC occurs, NDIS calls the ProtocolPnPEventfunction at the lower edge of each transport bound to that NIC with the input NetEventQueryRemoveDevicecode so that each such TDI transport can forward this notification to its clients by calling TdiPnPPowerRequest.
Such a PnP-aware TDI transport does not actually tear down its binding or make calls to TdiDeregisterNetAddressand TdiDeregisterDeviceObjectuntil NDIS has called the ProtocolUnbindAdapterfunction at the lower edge of the transport stack. Furthermore, a transport driver cannot be unloaded until it has released all its bindings to all underlying NICs.
However, after a NIC is removed from the machine, the system can unload a TDI transport driver that was either bound directly onlyto that underlying NIC's driver or layered over an NDIS protocol driver that was bound to that NIC driver. To accomplish this, the system calls the TDI transport's Unload routine.
The transport's Unload routine will be called by the I/O manager when the Service Controller unloads the driver from memory. A transport driver's Unload routine frees all remaining driver-allocated resources.
A PnP-aware TDI transport driver must make a reciprocal call to TdiDeregisterProviderfrom its Unload routine. If the TDI driver exports a set of NDIS-defined Protocol Xxxfunctions, it also must call NdisDeregisterProtocolfrom its Unload routine.
For more information about standard intermediate driver Unload routines, see Unload Routine Functionality. For more information about PnP and power-management support for Windows 2000 and later versions of the operating system, see Plug and Playand Power Management. For particulars on how the NDIS library indicates PnP and power events, see Handling PnP Events and PM Events in a Protocol Driver.
Note The TDI feature is deprecated and will be removed in future versions of Microsoft Windows. Depending on how you use TDI, use either the Winsock Kernel (WSK) or Windows Filtering Platform (WFP). For more information about WFP and WSK, see Windows Filtering Platform and Winsock Kernel. For a Windows Core Networking blog entry about WSK and TDI, see Introduction to Winsock Kernel (WSK).