user997112
user997112

Reputation: 30615

Where would a driver "output" to if using printf?

If I were to create a driver, which, say hooks the windows function for opening a file. If in my driver I told the hook to printf("something"), when the driver is switched on and I opened a file, where would printf display the text to?

Upvotes: 2

Views: 2281

Answers (3)

dips
dips

Reputation: 114

You can view the debug output of your driver (compiled with debug config)

using DbgView or WinDbg utility available on microsofts website

also to give print statements you could use following functions defined in wdm.h

DbgPrint(...)

DbgPrintEx(...)

Upvotes: 0

dreamlayers
dreamlayers

Reputation: 173

If you want to output text from a driver for debugging and experimental purposes, use DbgPrintEx. The output can be viewed via Sysinternals DebugView or a debugger.

Upvotes: 5

MartyTPS
MartyTPS

Reputation: 530

printf is written to the stream stdout which is declared in stdio.h. It is opened the first time you touch one of the standard streams stdin, stdout, stderr. The standard streams stdin, stdout, and stderr are macros that call a stdio library function which opens the streams and returns an array those streams. The macro definitions index the array to get the right stream out. If the application has no console, the output goes to the "null" device.

Upvotes: 3

Related Questions