// wdfrequest.h
KPROCESSOR_MODE WdfRequestGetRequestorMode(
[in] WDFREQUEST Request
);
View the official Windows Driver Kit DDI referenceNo description available.
[Applies to KMDF and UMDF]
The WdfRequestGetRequestorMode method returns the processor access mode of the originator of a specified I/O request.
Request [in]A handle to a framework request object.
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.
For more information about WdfRequestGetRequestorMode, see Obtaining Information About an I/O Request.
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;
}