次の方法で共有


WriteUInt16ToMode 関数 (usermode_accessors.h)

The WriteUInt16ToMode function safely writes a UINT16 value to memory based on the specified processor mode.

Syntax

VOID WriteUInt16ToMode(
  UINT16          *Destination,
  UINT16          Value,
  KPROCESSOR_MODE Mode
);

Parameters

Destination

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

Value

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

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

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

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

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

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

WriteUInt16ToUser

ReadUInt16FromMode