Windows Driver Kit: Driver Development Tools
KdPrint

In Microsoft Windows Server 2003 and earlier versions of Windows, the KdPrint macro sends a message to the kernel debugger. In Windows Vista and later versions of Windows, KdPrint sends a message only if certain conditions apply.

A call to KdPrint requires double parentheses.

ULONG
  KdPrint ( (
    IN PCHAR  Format,
    . . . .  [arguments] 
    ) ) ; 


Parameters

Format
Specifies a pointer to the format string to print. The Format string supports all the printf-style formatting codes. However, the Unicode format codes (%C, %S, %lc, %ls, %wc, %ws, and %wZ) can only be used with IRQL = PASSIVE_LEVEL.
arguments
Specifies arguments for the format string, as in printf.

Return Value

If successful, KdPrint returns the NTSTATUS code STATUS_SUCCESS; otherwise it returns the appropriate error code.

Comments

KdPrint is identical to the DbgPrint routine in code that is compiled in a checked build environment. This routine has no effect if compiled in a free build environment. Only kernel-mode drivers can call the KdPrint routine.

In Windows Vista and later versions of Windows, 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.

Note  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

Versions: Available in in Microsoft Windows 2000 and later.

Headers: This routine is defined in ntddk.h, wdm.h, and ndis.h. Include ntddk.h, wdm.h, or ndis.h.

See Also

DbgPrint, DbgPrintEx, KdPrintEx


Send feedback on this topic
Built on November 19, 2009
Page view tracker