[适用于 KMDF 和 UMDF]
WdfRequestGetRequestorMode 方法返回指定 I/O 请求发起者的处理器访问模式。
语法
KPROCESSOR_MODE WdfRequestGetRequestorMode(
  [in] WDFREQUEST Request
);
参数
[in] Request
框架请求对象的句柄。
返回值
如果 I/O 请求的发起方在内核模式下执行,WdfRequestGetRequestorMode 返回 KernelMode。 否则,此方法返回 UserMode。 KernelMode 和 UserMode 常量在 wdm.h中定义。
如果驱动程序提供无效的对象句柄,则会发生 bug 检查。
言论
有关 WdfRequestGetRequestorMode的详细信息,请参阅 获取有关 I/O 请求的信息。
例子
以下代码示例来自 NDISProt 示例驱动程序。 此示例检查 I/O 请求是否来自用户模式应用程序的有效 MAC 地址。
//
// 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;
}
要求
| 要求 | 价值 | 
|---|---|
| 目标平台 | 普遍 | 
| 最低 KMDF 版本 | 1.0 | 
| 最低 UMDF 版本 | 2.0 | 
| 标头 | wdfrequest.h (包括 Wdf.h) | 
| 库 | Wdf01000.sys(KMDF):WUDFx02000.dll (UMDF) | 
| IRQL | <=DISPATCH_LEVEL | 
| DDI 符合性规则 | DriverCreate(kmdf),InvalidReqAccess(kmdf),InvalidReqAccessLocal(kmdf),KmdfIrql(kmdf),KmdfIrql2(kmdf),KmdfIrqlExplicit(kmdf) |