共用方式為


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