Special debugging routines are available for both user-mode and kernel-mode drivers. By using these routines in your driver code, you can send messages to the debugger and set breakpoints to aid in debugging.
You should conditionally compile the debugging code in your driver by testing the DBG preprocessor flag. If you create your driver by running the Build utility from the Checked Build Environment or Checked 64-Bit Build Environment window, the DBG flag will equal 1. If you create your driver by running the Build utility from the Free Build Environment window, DBG will equal 0 (or will be undefined if neither wdm.h nor ntddk.h is included).
The following sections summarize the debugging routines:
Kernel-Mode Debugging Routines
The Platform SDK provides complete information on the user-mode routines. See Kernel-Mode Debugging Routine Reference for complete information on the kernel-mode routines.