Freigeben über


InterlockedOrToMode-Funktion (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] Ein Zeiger auf den Speicherort, der den ersten Operanden enthält. Dieser Wert wird durch das Ergebnis des Vorgangs ersetzt. 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] Der zweite Operand.

Mode

[in] Der Prozessormodus, der bestimmt, wie der Speicherzugriff ausgeführt wird. Mode can be one of the following values.

Value Meaning
KernelMode Destination points to kernel-mode memory. Die Funktion führt eine direkte atome OR-Operation aus. Weitere Informationen finden Sie in den Hinweisen.
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. Weitere Informationen finden Sie in den Hinweisen.

Return value

The function returns the original value of the Destination parameter.

Remarks

Die verriegelten Funktionen bieten einen einfachen Mechanismus zum Synchronisieren des Zugriffs auf eine Variable, die von mehreren Threads gemeinsam genutzt wird. Diese Funktion ist atomar in Bezug auf Aufrufe anderer verzahnter Funktionen. Es generiert eine vollständige Speicherbarriere, um sicherzustellen, dass Speichervorgänge in der Reihenfolge abgeschlossen werden.

This function provides atomic access to a 32-bit value in memory, performing a bitwise OR operation between the value at Destination and Value. Das Verhalten hängt vom angegebenen Prozessormodus ab:

  • 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.

Die Funktion löst eine strukturierte Ausnahme aus, wenn der Vorgang fehlschlägt, z. B. wenn auf die Zieladresse nicht zugegriffen werden kann oder für den angegebenen Modus ungültig ist.

Diese Funktion funktioniert auf allen Versionen von Windows, nicht nur auf dem neuesten. 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. Der resultierende Treiber wird jedoch in älteren Versionen von Windows einwandfrei ausgeführt.

Requirements

Requirement Value
Mindestens unterstützter Client See Remarks
Header usermode_accessors.h
Library umaccess.lib
IRQL Kleiner oder gleich APC_LEVEL

See also

InterlockedOrToUser

InterlockedOr64ToMode

InterlockedAndToMode