Condividi tramite


Funzione RtlZeroVolatileMemory (wdm.h)

La funzione RtlZeroVolatileMemory è un wrapper pratico intorno a RtlFillVolatileMemory.

Sintassi

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

Parametri

[out] Destination

Puntatore all'indirizzo iniziale del blocco di memoria da riempire con zeri.

[in] Length

Dimensione del blocco di memoria da riempire con zeri, in byte.

Valore restituito

Restituisce il valore di Destination.

Commenti

La funzione RtlZeroVolatileMemory è un wrapper pratico intorno a RtlFillVolatileMemory.

Per altre informazioni, vedere la sezione osservazioni di RtlFillVolatileMemory.

Nota

Questa funzione funziona su tutte le versioni di Windows, non solo sulla versione più recente. Per ottenere la dichiarazione di funzione dall'intestazione wdm.h, è necessario utilizzare la chiave WDK più recente. È necessaria anche la libreria (volatileaccessk.lib) dalla versione più recente di WDK. Tuttavia, il driver risultante verrà eseguito correttamente nelle versioni precedenti di Windows.

Esempio

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));

Requisiti

Requisito Valore
Intestazione wdm.h (include Wdm.h)
Libreria volatileaccessk.lib (modalità kernel), volatileaccessu.lib (modalità utente)

Vedi anche

RtlFillVolatileMemory