次の方法で共有


WriteLongToMode 関数 (usermode_accessors.h)

The WriteLongToMode function safely writes a LONG value to memory based on the specified processor mode.

Syntax

VOID WriteLongToMode(
  LONG            *Destination,
  LONG            Value,
  KPROCESSOR_MODE Mode
);

Parameters

Destination

[out]LONG 値が書き込まれるメモリ位置へのポインター。

Value

[in]宛先メモリの場所に書き込む LONG 値。

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

この関数は、LONG 値をメモリに書き込む安全な方法を提供し、ユーザー モード メモリにアクセスするときに追加の安全性チェックを行います。 指定されたアドレスが有効であり、指定されたプロセッサ モードに基づいてアクセス可能であることが保証されます。

この関数では、配置は適用されません。

宛先アドレスが有効でない場合や、指定されたプロセッサ モードでアクセスできない場合など、メモリ アクセスが失敗した場合に構造化例外が発生します。

この関数はコンパイラによって最適化されることも、関数が呼び出される前または関数が戻った後に (ソース コードが明示的にこれらのアクセスを実行しない限り) このメモリ位置への追加のアクセスを作成することもありません。 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

WriteLongToUser

ReadLongFromMode