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


Функция ReadUnicodeStringFromMode (usermode_accessors.h)

The ReadUnicodeStringFromMode function safely reads a UNICODE_STRING structure from memory based on the specified processor mode.

Syntax

UNICODE_STRING ReadUnicodeStringFromMode(
  const UNICODE_STRING *Source,
  KPROCESSOR_MODE      Mode
);

Parameters

Source

[in] A pointer to the memory location from which to read the UNICODE_STRING structure.

Mode

[in] Режим процессора, определяющий, как выполняется доступ к памяти. Mode can be one of the following values.

Value Meaning
KernelMode Source points to kernel-mode memory. The function performs a read from the specified address with memory_order_relaxed semantics. Дополнительные сведения см. в примечаниях.
UserMode Source points to user-mode memory. The function raises an exception if Source doesn't point to user-mode memory; otherwise it performs a read from the specified address with memory_order_relaxed semantics. Дополнительные сведения см. в примечаниях.

Return value

ReadUnicodeStringFromMode returns the UNICODE_STRING structure read from the specified memory address.

Remarks

This function provides a safe way to read a UNICODE_STRING structure from 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

ReadUnicodeStringFromUser

WriteUnicodeStringToMode