25.1 TDI Driver Initialization
The transport driver must expose a DriverEntry entry point to be called by the Windows NT I/O system at the time that the driver is loaded into memory. The DriverEntry routine is declared in the driver code and its entry point is made known to the Windows NT I/O system by internal convention.
When it loads the driver, the Windows NT I/O system creates a driver object for the transport driver and passes a pointer to the driver object when it calls the transport driver's DriverEntry routine. The transport driver's DriverEntry routine performs the following tasks:
·Read the registry (using kernel-mode support routines) to retrieve configuration information from the transport driver's registry key, usually stored under the Parameters subkey. Using the registry information, configure itself as needed.
·Write all dispatch entry points (that will be called later by the I/O Manager on behalf of TDI clients) into the driver object.
·Create at least one named device object for itself with IoCreateDevice. The names of the device objects are the device names that are included in the transport driver's registry section linkage key "Export" line.
Some transport drivers, such as the streams type transport drivers and NWLink, only create and expose one device object no matter how many network adapters they are bound to (example: "\streams\Mcsxns"). Other transport drivers create and expose one device object for each bound network adapter (example: "\Nbf_Elnkii1, Nbf_Elnkii2"). A transport driver's registry section linkage key "Export" line determines what devices will be created by any particular transport driver.
·Perform other initialization tasks such as binding to underlying NDIS NIC drivers.
If the TDI transport driver is to be unloadable using the Windows NT service controller, the driver code must also declare an Unload routine and store its address in the DriverUnload field of the driver object. The Unload routine will be called by the I/O system when the service controller unloads the driver from memory. The transport driver's Unload routine unbinds from underlying NIC drivers and frees all allocated resources. A transport driver is not required to provide an Unload routine, although it is recommended. If a driver has no Unload routine, the DriverUnload field of the driver object is set to NULL. For more information about the kernel-mode support routines and objects used by TDI drivers, see the Kernel-mode Driver Reference.