Search code examples
c++windowskmdf

KMDF 1.11 Get process that initiates request


I'm writing a driver that listens for requests on specific devices by registering for EvtIoDeviceControl.

DF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&IoCallbacks, WdfIoQueueDispatchParallel);
IoCallbacks.PowerManaged = WdfFalse;
IoCallbacks.EvtIoDeviceControl = EvtIoDeviceControlCallback;

On Windows 10 (KMDF 1.21), I can use WdfRequestGetRequestorProcessId to get the process ID of the process that made the request in the EvtIoDeviceControlCallback, but I'm having trouble finding a way to do this one earlier versions of KMDF. Any insight?


Solution

  • you can use WdfRequestWdmGetIrp (Minimum KMDF version 1.0) and IoGetRequestorProcessId

    so simply use

    ULONG WdfRequestGetRequestorProcessId_1_0(WDFREQUEST Request)
    {
        return IoGetRequestorProcessId(WdfRequestWdmGetIrp(Request));
    }