Smart Card Driver Debugging

Both libraries supports several debugging features. These debugging features let you see what the library does internally and let you write debugging output to a connected debugger. To set up a remote debug session under Windows NT, refer to the Windows NT DDK documentation. The header file smclib.h defines the following constants used for debugging:

#define DEBUG_IOCTL     ((ULONG) 0x00000001)
#define DEBUG_ATR       ((ULONG) 0x00000002)
#define DEBUG_PROTOCOL  ((ULONG) 0x00000004)
#define DEBUG_DRIVER    ((ULONG) 0x00000008)
#define DEBUG_TRACE     ((ULONG) 0x00000010)
#define DEBUG_ERROR     ((ULONG) 0x00000020)
#define DEBUG_BREAK     ((ULONG) 0x80000000)
#define DEBUG_ALL       ((ULONG) 0x7FFFFFFF)

These can be used to select the level of debugging that you want. You can either use the function,

SmartcardSetDebugLevel(
    ULONG DebugLevel
);
 

in your driver and provide a mask of constants that are combined with the bitwise OR operator to select the level of debugging that you want, or you can use the smart card driver test program scdrvtst that comes with the smart card DDK. Note that you must have installed the checked version of Windows NT and the checked version of the driver to get debugging messages.

To write your own driver debugging messages, it is recommended that you use the function,

SmartcardDebug(
    ULONG DebugLevel,
    PCHAR Message
);
 

This lets you write messages to the remote debugger. To write error messages, use the constant DEBUG_ERROR for the DebugLevel. To write standard driver messages, use the constant DEBUG_DRIVER. To write trace messages, such as when entering and exiting a function, use DEBUG_TRACE as the DebugLevel.

It is recommended during development of your driver that you use the checked version of the smart card driver library and set the debugging level to the maximum using SmartcardSetDebugLevel(DEBUG_ALL) in your DriverEntry routine.