The ReadPointerFromMode function safely reads a PVOID value from memory based on the specified processor mode.
Syntax
PVOID ReadPointerFromMode(
const PVOID *Source,
KPROCESSOR_MODE Mode
);
Parameters
Source
[in]PVOID 値の読み取り元のメモリ位置へのポインター。
Mode
[in]メモリ アクセスの実行方法を決定するプロセッサ モード。 Mode can be one of the following values.
Value | Meaning |
---|---|
KernelMode | Source points to kernel-mode memory. The function performs a read from the specified address with memory_order_relaxed semantics. 詳細については、「解説」を参照してください。 |
UserMode | Source points to user-mode memory. The function raises an exception if Source doesn't point to user-mode memory; otherwise it performs a read from the specified address with memory_order_relaxed semantics. 詳細については、「解説」を参照してください。 |
Return value
ReadPointerFromMode returns the PVOID value read from the specified memory address.
Remarks
この関数は、ユーザー モード メモリにアクセスするときに安全性チェックを追加して、メモリから PVOID 値を安全に読み取る方法を提供します。 指定されたアドレスが有効であり、指定されたプロセッサ モードに基づいてアクセス可能であることが保証されます。
この関数では、配置は適用されません。
ソース アドレスにアクセスできない場合や、指定されたモードで無効な場合など、メモリ アクセスが失敗した場合に構造化例外が発生します。
この関数はコンパイラによって最適化されることも、関数が呼び出される前または関数が戻った後に (ソース コードが明示的にこれらのアクセスを実行しない限り) このメモリ位置への追加のアクセスを作成することもありません。 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以下 |