KdPrint macro (wdm.h)

The KdPrint macro sends a message to the kernel debugger.

KdPrint sends a message only if the conditions you specify apply. More info in the section below.

A call to KdPrint requires double parentheses.

Syntax

void KdPrint(
  [in]  _x_
);

Parameters

[in] _x_

Specifies a pointer to the format string to print. The Format string supports most of the printf-style format specification syntax. However, the Unicode format codes (%C, %S, %lc, %ls, %wc, %ws, and %wZ) can only be used with IRQL = PASSIVE_LEVEL. The KdPrint routine does not support any of the floating point types (%f, %e, %E, %g, %G, %a, or %A).

Return value

None

Remarks

KdPrint is identical to the DbgPrint routine in code that is compiled for a debug configuration. This routine has no effect if compiled for a release configuration. Only kernel-mode drivers can call the KdPrint routine.

KdPrint sends a message only if certain conditions apply. Specifically, it behaves like KdPrintEx with the DEFAULT component and a message importance level of DPFLTR_INFO_LEVEL. In other words, the following two function calls are identical:

KdPrint (( Format, arguments ))

KdPrintEx (( DPFLTR_DEFAULT_ID, DPFLTR_INFO_LEVEL, Format, arguments ))

For more information about message filtering, components, and message importance level, see Reading and Filtering Debugging Messages.

Regardless of which version of Windows you are using, it is recommended that you use KdPrintEx instead of KdPrint, since KdPrintEx allows you to control the conditions under which the message is sent.

Unless it is absolutely necessary, you should not obtain a string from user input or another process and pass it to KdPrint. If you do use a string that you did not create, you must verify that this is a valid format string, and that the format codes match the argument list in type and quantity. The best coding practice is for all Format strings to be static and defined at compile time.

There is no upper limit to the size of the Format string or the number of arguments. However, any single call to KdPrint will only transmit 512 bytes of information. There is also a limit to the size of the DbgPrint buffer. See The DbgPrint Buffer and the Debugger for details.

Requirements

Requirement Value
Target Platform Desktop
Header wdm.h (include Wdm.h)
Library NtosKrnl.lib (See DbgPrint.)
DLL NtosKrnl.exe

See also

DbgPrint

DbgPrintEx

KdPrintEx