RtlZeroVolatileMemory 関数 (wdm.h)

RtlZeroVolatileMemory 関数は、RtlFillVolatileMemory に関する便利なラッパーです。

構文

volatile void * RtlZeroVolatileMemory(
  [out] volatile void *Destination,
  [in]  size_t        Length
);

パラメーター

[out] Destination

0 で埋めるメモリ ブロックの開始アドレスへのポインター。

[in] Length

0 で埋めるメモリ ブロックのサイズ (バイト単位)。

戻り値

Destination の値を返 します

注釈

RtlZeroVolatileMemory 関数は、RtlFillVolatileMemory に関する便利なラッパーです。

詳細については、 RtlFillVolatileMemory の「解説」セクションを参照してください。

注意

この関数は、最新バージョンだけでなく、すべてのバージョンの Windows で動作します。 wdm.h ヘッダーから関数宣言を取得するには、最新の WDK を使用する必要があります。 また、最新の WDK のライブラリ (volatileaccessk.lib) も必要です。 ただし、結果として得られるドライバーは、古いバージョンの Windows では正常に実行されます。

UCHAR SensitiveData[100];

// Imagine we temporarily store some sensitive cryptographic
// material in a buffer.

StoreCryptographicKey(&SensitiveData);
DoCryptographicOperation(&SensitiveData);

// Now that we are done using the sensitive data we want to
// erase it from the stack. We cannot call RtlFillMemory because
// if the compiler realizes that "SensitiveData" is not
// referenced again the compiler can remove the call to RtlFillMemory.
// Instead we can call RtlSecureZeroMemory2, RtlZeroVolatileMemory, or RtlFillVolatileMemory
// (the former two are convenience wrappers around the latter). These
// calls will not be optimized away by the compiler.
// Note that RtlSecureZeroMemory2 performs better than the
// RtlSecureZeroMemory function.

RtlZeroVolatileMemory(&SensitiveData, sizeof(SensitiveData));

要件

要件
Header wdm.h (Wdm.h を含む)
Library volatileaccessk.lib (カーネル モード)、volatileaccessu.lib (ユーザー モード)

こちらもご覧ください

RtlFillVolatileMemory