InterlockedOr64ToMode 函数 (usermode_accessors.h)

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

Syntax

LONG64 InterlockedOr64ToMode(
  LONG64 volatile *Destination,
  LONG64          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 8-byte aligned since Destination points to an 8-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 64-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

InterlockedOr64ToUser

InterlockedOrToMode

InterlockedAnd64ToMode