WriteUnicodeStringToMode 函数 (usermode_accessors.h)

The WriteUnicodeStringToMode function safely writes a UNICODE_STRING structure to memory based on the specified processor mode.

Syntax

VOID WriteUnicodeStringToMode(
  UNICODE_STRING  *Destination,
  UNICODE_STRING  Value,
  KPROCESSOR_MODE Mode
);

Parameters

Destination

[out] A pointer to the memory location where the UNICODE_STRING structure will be written.

Value

[in] The UNICODE_STRING structure to write to the destination memory location.

Mode

[in]确定内存访问的执行方式的处理器模式。 Mode can be one of the following values.

Value Meaning
KernelMode Destination points to kernel-mode memory. The function performs a write to the specified address with memory_order_relaxed semantics. 有关更多详细信息,请参阅“备注”。
UserMode Destination points to user-mode memory. The function raises an exception if Destination doesn't point to user-mode memory; otherwise it performs a write to the specified address with memory_order_relaxed semantics. 有关更多详细信息,请参阅“备注”。

Return value

None

Remarks

This function provides a safe way to write a UNICODE_STRING structure to memory, with extra safety checks when accessing user-mode memory. 它确保提供的地址有效且基于指定的处理器模式可访问。

此函数不强制对齐。

如果内存访问失败(例如目标地址不可访问或指定模式无效时),则会引发结构化异常。

编译器永远不会优化此函数,也不会在调用函数或函数返回后(除非源代码显式执行这些访问)之前创建对此内存位置的其他访问权限。 The memory access is performed with memory_order_relaxed semantics.

此函数适用于所有版本的 Windows,而不仅仅是最新版本。 You need to consume the latest WDK to get the function declaration from the usermode_accessors.h header. You also need the library (umaccess.lib) from the latest WDK. 但是,生成的驱动程序将在较旧版本的 Windows 上运行。

Requirements

Requirement Value
最低支持的客户端 See Remarks
Header usermode_accessors.h
Library umaccess.lib
IRQL 小于或等于APC_LEVEL

See also

WriteUnicodeStringToUser

ReadUnicodeStringFromMode