Поделиться через


Функция 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