HOWTO: Debugging NDIS 4.0 Drivers

ID: Q164459


The information in this article applies to:


SUMMARY

It is often helpful to have as much information as possible from the NDIS wrapper when you debug NDIS 4.0 drivers. Enabling any one of several levels of DbgPrint statements within the wrapper itself will, in most cases, provide enough additional information to successfully debug most NDIS driver problems. This article describes a method enabling different levels of debug trace information within the NDIS wrapper.

NOTE: By enabling the trace levels within the wrapper, you may adversely affect timing and performance parameters, which could cause or contribute to additional failures.


MORE INFORMATION

This process requires a CHECKED version of NDIS.

There are two debugging variables of interest within the NDIS wrapper. The first, ndisDebugSystems, determines which NDIS component(s) will be affected by the second variable, ndisDebugLevel. ndisDebugLevel determines the level, or amount of tracing in the selected component. Acceptable values for both variables are as follows:

ndisDebugLevel


 DBG_LEVEL_INFO 0x00000000
 DBG_LEVEL_WARN 0x00001000
 DBG_LEVEL_ERR 0x00002000
 DBG_LEVEL_FATAL 0x00003000 

ndisDebugSystems


 DBG_COMP_INIT 0x00000001
 DBG_COMP_CONFIG 0x00000002
 DBG_COMP_SEND 0x00000004
 DBG_COMP_RECV 0x00000008
 DBG_COMP_MEMORY 0x00000010
 DBG_COMP_FILTER 0x00000020
 DBG_COMP_PROTOCOL 0x00000040
 DBG_COMP_REQUEST 0x00000080
 DBG_COMP_UNLOAD 0x00000100
 DBG_COMP_WORK_ITEM 0x00000200
 DBG_COMP_OPEN 0x00000400
 DBG_COMP_LOCKS 0x00000800
 DBG_COMP_ALL 0xFFFFFFFF 

These variables may be modified with the debugger any time after you load Ndis.sys. You may choose to break into the target system via ^C, System Request, or by setting a breakpoint at some location in your driver. The only restriction is that Ndis.sys must have loaded in order to have access to these variables.

The following is a WINDBG example of this concept.

  1. Stop the debugger after Ndis has loaded:
    
         ^C <process stopping...> 


  2. Press ^C to break in to the target system after ndis has loaded:
    
         Hard coded breakpoint hit 


  3. To watch the filter components (DBG_COMP_FILTER), edit ndisDebugSystems appropriately:
    
       KDx86> ed ndis!ndisDebugSystems 00000020 


  4. Informational (lowest ) level debugging:
    
         KDx86> ed ndis!ndisDebugLevel 0 


  5. Press the F5 key to restart the system:
    
         Module Load: C:\1234F\system32\USERENV.DLL (symbol loading deferred)
         Module Load: NWLNKIPX.SYS (symbol loading deferred)
         Module Load: NWLNKNB.SYS (symbol loading deferred) 


  6. Error messages would appear here if we used DBG_COMP_PROTOCOL instead of DBG_COMP_FILTER:
    
         Module Load: TCPIP.SYS (symbol loading deferred)
         Module Load: NETBT.SYS (symbol loading deferred)
         Module Load: RASARP.SYS (symbol loading deferred)
         RASARP: GetPnpARPEntryPoints succeeded
         Module Load: IEEPRO.SYS (symbol loading deferred) 


  7. Filter messages appear:
    
         ***NDIS*** (c, 4004) ndisMChangeClass() NetBT!AddressArrival: 0.0.0.0
         ***NDIS*** (c, 3926) Enter ChangeEthAddresses
         ***NDIS*** (c, 3954) ndisMChangeEthAddresses()
    
         IPX: Auto-detected default frame type 802.2, net 6122
    
         Calling NbfAcdBind()
         Reallocating new pools due to new maxpacketsize
         Module Load: NDISWAN.SYS (symbol loading deferred)
         ***NDIS*** (c, 3926) Enter ChangeEthAddresses
         ***NDIS*** (c, 3954) ndisMChangeEthAddresses()
         ***NDIS*** (c, 4004) ndisMChangeClass()
         RASARP: Called to bind to adapter \Device\NdisWan12
         RASARP: Name constructed -> NDISWAN12\Parameters\TCPIP
         ***NDIS*** (c, 4004) ndisMChangeClass()
         NetBT!AddressArrival: 0.0.0.0
         RASARP: IPAddInterface succeeded for adapter
         ***NDIS*** (c, 3926) Enter ChangeEthAddresses
         ***NDIS*** (c, 3954) ndisMChangeEthAddresses()
         ***NDIS*** (c, 4004) ndisMChangeClass()
         ***NDIS*** (c, 3926) Enter ChangeEthAddresses
         ***NDIS*** (c, 3954) ndisMChangeEthAddresses()
         ***NDIS*** (c, 4004) ndisMChangeClass() 


NOTE: By enabling the trace levels within the wrapper, you may adversely affect timing and performance parameters, which could cause or contribute to additional failures.

Additional query words: NDIS NDIS4.0 Miniports Debugging


Keywords          : kbcode kbDDK kbKMode kbNTOS400 kbGrpNTDDK 
Version           : winnt:
Platform          : winnt 
Issue type        : kbhowto 

Last Reviewed: May 26, 1999