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


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

The InterlockedOrToMode function performs an atomic OR operation on a 32-bit value, based on the specified processor mode.

Syntax

LONG InterlockedOrToMode(
  LONG volatile   *Destination,
  LONG            Value,
  KPROCESSOR_MODE Mode
);

Parameters

Destination

[in, out] Указатель на расположение памяти, содержащее первый операнд. Это значение будет заменено результатом операции. The pointer must be naturally aligned for the data type; that is, the memory location must be 4-byte aligned since Destination points to a 4-byte type.

Value

[in] Второй операнд.

Mode

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

Value Meaning
KernelMode Destination points to kernel-mode memory. Функция выполняет прямую атомарную ОПЕРАЦИЮ OR. Дополнительные сведения см. в примечаниях.
UserMode Destination points to user-mode memory. The function raises an exception if Destination doesn't point to user-mode memory; otherwise it performs an atomic OR operation at the specified address. Дополнительные сведения см. в примечаниях.

Return value

The function returns the original value of the Destination parameter.

Remarks

Межблокированные функции предоставляют простой механизм синхронизации доступа к переменной, к которой используется несколько потоков. Эта функция атомарна относительно вызовов других взаимоблокируемых функций. Он создает полный барьер памяти, чтобы обеспечить выполнение операций памяти в порядке.

This function provides atomic access to a 32-bit value in memory, performing a bitwise OR operation between the value at Destination and Value. Поведение зависит от указанного режима процессора:

  • When Mode is UserMode, the function ensures that the destination address is a valid user-mode address and performs the operation safely for user-mode memory access.
  • When Mode is KernelMode, the function operates directly on kernel-mode addresses.

Функция вызывает структурированное исключение, если операция завершается ошибкой, например если целевой адрес недоступен или недопустим для указанного режима.

Эта функция работает во всех версиях 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

InterlockedOrToUser

InterlockedOr64ToMode

InterlockedAndToMode