WdfRequestGetRequestorMode function (wdfrequest.h)

[Applies to KMDF and UMDF]

The WdfRequestGetRequestorMode method returns the processor access mode of the originator of a specified I/O request.

Syntax

KPROCESSOR_MODE WdfRequestGetRequestorMode(
  [in] WDFREQUEST Request
);

Parameters

[in] Request

A handle to a framework request object.

Return value

WdfRequestGetRequestorMode returns KernelMode if the originator of the I/O request is executing in kernel mode. Otherwise, this method returns UserMode. The KernelMode and UserMode constants are defined in wdm.h.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

For more information about WdfRequestGetRequestorMode, see Obtaining Information About an I/O Request.

Examples

The following code example is from the NDISProt sample driver. This example checks for a valid MAC address if the I/O request came from a user-mode application.

//
// To prevent applications from sending packets with spoofed MAC address,
// perform the following check to make sure the source address 
// in the packet is the same as the current MAC address of the NIC.
//
if ((WdfRequestGetRequestorMode(Request) == UserMode) && 
    !NPROT_MEM_CMP(pEthHeader->SrcAddr, pOpenContext->CurrentAddress, NPROT_MAC_ADDR_LEN))
{
    DEBUGP(DL_WARN, ("Write: Failing with invalid Source address"));
    NtStatus = STATUS_INVALID_PARAMETER;
    break;
}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfrequest.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL <=DISPATCH_LEVEL
DDI compliance rules DriverCreate(kmdf), InvalidReqAccess(kmdf), InvalidReqAccessLocal(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)