OutputDebugString in UMDF2 Drivers

Hi, I am new to Windows Driver Development. First I tried the KmdfHelloWorld Driver, built the solution, and installed the driver using: devcon.exe install KmdfHelloWorld.inf Root\KmdfHelloWorld. The device was successfully shown in Device Manager under Sample Drivers. The output message (from KdPrintEx) was successfully shown in WinDbg local kernel-mode debugging (but only after using !dbgprint). Though, no output was shown in DebugView.

But, if I try the same thing with Umdf Drivers, no output is shown, even after changing from KdPrintEx to OutputDebugString. I may be wrong, but I guess Umdf drivers don’t show output in kernel-mode debugging. Also, I want to use user-mode debugging for Umdf driver, but I don’t know how to do that. It would be nice if everything could be done from inside Visual Studio only.

Hmmmm… You debug UMDF drivers much the same as you do any user mode code… but with the addition of the WDFKD debugger extensions in WinDbg, be sure to make use of them!

I don’t see any reason why your OutputDebugStrings don’t appear.

Peter

Hi… here’s what I did next.

Installed the driver using devcon. Started debugging in WinDbg by attaching to process WUDFHost.exe. This is the output I am getting using lm:

start             end                 module name
00007ff6`c1f40000 00007ff6`c1f87000   WUDFHost   (deferred)             
00007ffd`50ab0000 00007ffd`50ab9000   umdfhelloworld   (deferred)             
00007ffd`51810000 00007ffd`518cb000   WUDFx02000   (deferred)             
00007ffd`518e0000 00007ffd`51ac4000   dbghelp    (deferred)             
00007ffd`51c00000 00007ffd`51c13000   kernel_appcore   (deferred)             
00007ffd`52080000 00007ffd`520b2000   WUDFPlatform   (deferred)             
00007ffd`53050000 00007ffd`5307c000   DEVOBJ     (deferred)             
00007ffd`531d0000 00007ffd`53201000   SspiCli    (deferred)             
00007ffd`532e0000 00007ffd`5332d000   cfgmgr32   (deferred)             
00007ffd`53570000 00007ffd`53837000   KERNELBASE   (deferred)             
00007ffd`53840000 00007ffd`538bf000   bcryptPrimitives   (deferred)             
00007ffd`538c0000 00007ffd`539c0000   ucrtbase   (deferred)             
00007ffd`53c00000 00007ffd`53d23000   RPCRT4     (deferred)             
00007ffd`53d30000 00007ffd`53ded000   KERNEL32   (deferred)             
00007ffd`54110000 00007ffd`541ba000   advapi32   (deferred)             
00007ffd`54240000 00007ffd`542de000   msvcrt     (deferred)             
00007ffd`54500000 00007ffd`5459b000   sechost    (deferred)             
00007ffd`54a00000 00007ffd`54d53000   combase    (deferred)             
00007ffd`55b90000 00007ffd`55d84000   ntdll      (pdb symbols)          C:\ProgramData\Dbg\sym\ntdll.pdb\63E12347526A46144B98F8CF61CDED791\ntdll.pdb

Next I used commands !wdfdriverinfo umdfhelloworld and !wdflogdump umdfhelloworld.dll, but they don’t show the logs.

Any idea what to do next? I still don’t know where to see the ouput from OutputDebugString.

By the ways, here’s my code snippet:

#include <Windows.h>
#include <wdf.h>

NTSTATUS UmdfHelloWorldEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
{
    UNREFERENCED_PARAMETER(Driver);

    NTSTATUS status;
    WDFDEVICE hDevice;

    OutputDebugString(L"[UmdfHelloWorld]EvtDeviceAdd");

    status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &hDevice);

    return status;
}

NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
    NTSTATUS status = STATUS_SUCCESS;
    WDF_DRIVER_CONFIG config;

    OutputDebugString(L"[UmdfHelloWorld]DriverEntry");

    WDF_DRIVER_CONFIG_INIT(&config, UmdfHelloWorldEvtDeviceAdd);
    status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);
    
    return status;
}

This link might help:
https://www.osr.com/getting-dbgprint-output-appear-windows-vista-later/
It does not only apply to DbgPrint. It also applies to User Mode function OutputDebugString.

Marcel Ruedinger
datronicsoft