4.1  TDI Driver Initialization

Every TDI transport driver must provide an initialization routine explicitly named DriverEntry. In addition, a transport driver should have as many TdiDispatchXxx routines and internal driver functions as it needs to satisfy the requests of its kernel-mode clients. A TDI transport driver or one of the underlying protocol drivers in its transport stack also must provide the NDIS driver lower-edge functions described earlier in -Chapter 2 and in the Network Driver Reference.

Every transport driver must have a DriverEntry routine to be called by the I/O Manager when the transport is loaded. DriverEntry must be declared in the driver code to make the transport automatically loadable.

When it loads the driver, the Windows NT I/O Manger creates a driver object to represent the transport and passes a pointer to the driver object when it calls DriverEntry. The transport’s DriverEntry routine does the following:

·Read the registry (using kernel-mode support routines) to retrieve configuration information, under the transport's own ..\DriverName\Parameters subkey. Using the registry information, configure itself as needed.

·Set all the driver's TdiDispatchXxx entry points in the driver object. The driver’s TdiDispatchXxx routines will be called later by the I/O Manager to handle requests from TDI clients.

·Create at least one named device object for itself with IoCreateDevice. The names of each driver’s device objects are the device names stored under the transport driver’s registry section Linkage key in the Export entry. Each transport driver’s Export entry determines what device object(s) will be created by any particular transport driver.

Some transport drivers, such as NWLink, create only one named device object no matter how many NICs they bind themselves to. Other transport drivers create a separate named device object for each bound NIC, such as Nbf_Elnkii1, Nbf_Elnkii2, and so forth.

·Perform any other necessary initialization tasks, such as binding to underlying NDIS intermediate and/or NIC drivers.

Any TDI transport driver must provide an Unload routine unless that driver cannot be unloaded without rendering the system unusable. Most TDI transport drivers declare an Unload routine, and their DriverEntry routines set its entry point in the driver object. For more information about transport Unload routines, see Section 4.1.2.

For more information about the kernel-mode support routines and objects used by TDI drivers, see the Kernel-mode Driver Reference.