2

I want to write a UMDF2 windows driver, I don't know where to see the output from OutputDebugString.

This is my code, similar to KMDF Hello World.

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

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

    NTSTATUS status;
    WDFDEVICE hDevice;

    OutputDebugString((LPCWSTR)"UmdfHelloWorld: EvtDeviceAdd\n");

    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((LPCWSTR)"UmdfHelloWorld: DriverEntry\n");

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

Running the KMDF Hello World driver is giving me output successfully on windbg kernel-mode debugging. However, the UMDF Hello World driver shows no output.

This is how I'm (un)installing drivers:

devcon.exe install UmdfHelloWorld.inf Root\UmdfHelloWorld
devcon.exe remove Root\UmdfHelloWorld

Also, I want to use user-mode debugging, but I don't know how to do that for UMDF drivers.

Akshdeep Singh
  • 1,301
  • 1
  • 19
  • 34

1 Answers1

0

Umdf2 Hello World Driver, Where to see output?

Just as Lex said, you could use DebugView to view the output for UMDF drivers.

Besdies, you can try to use WPP Software Tracing in UMDF Drivers.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Or you can use WPP Software to trace in UMDF Drivers. See [this document](https://learn.microsoft.com/en-us/windows-hardware/drivers/wdf/using-wpp-software-tracing-in-umdf-drivers). Hope it could help you. – Mr Qian Jul 16 '20 at 09:45
  • @AkshdeepSingh did you try to click on the ```Capture``` menu in Debug View and try enabling the various options? – kvr Jul 16 '20 at 18:22
  • You can just attach Visual Studio to the WDFhost.exe process, then you can see all debug-messages and you also can debug through your UMDF2 driver. See https://stackoverflow.com/questions/26655392/debug-umdf-driver-without-two-machines for more details. – robotrovsky Sep 13 '22 at 08:15