Funzione SecureZeroMemory2

La funzione SecureZeroMemory2 riempie un blocco di memoria con zeri in modo da garantire la sicurezza.

Importante

Alcune informazioni riguardano un prodotto in versione preliminare che può essere modificato in modo sostanziale prima che venga rilasciato commercialmente. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.

Parametri

Destinazione param [out]

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

Lunghezza param [in]

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

Sintassi

volatile void*
  SecureZeroMemory2 (
    _Out_writes_bytes_all_(Length) volatile void* Destination,
    SIZE_T Length
  );

Osservazioni:

Questa API è un wrapper pratico per FillVolatileMemory ed è identico a ZeroVolatileMemory. Per altre informazioni, vedere le osservazioni di FillVolatileMemory .

Nota

Questa funzione funziona su tutte le versioni di Windows, non solo sulla versione più recente. È necessario usare l'SDK più recente per ottenere la dichiarazione di funzione dall'intestazione winbase.h . È necessaria anche la libreria (volatileaccessu.lib) dall'SDK più recente. Tuttavia, il file binario 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 FillMemory because
// if the compiler realizes that "SensitiveData" is not
// referenced again the compiler can remove the call to FillMemory.
// Instead we can call SecureZeroMemory2, ZeroVolatileMemory, or FillVolatileMemory
// (the former two are convienence wrappers around the latter). These
// calls will not be optimized away by the compiler.
// Note that SecureZeroMemory2 performs better than the old
// SecureZeroMemory API.

SecureZeroMemory2(&SensitiveData, sizeof(SensitiveData));

Requisiti

Client minimo supportato: Windows 11 Insider Preview Build TBD

Intestazione: winbase.h (include Winbase.h)

Libreria in modalità kernel: volatileaccessk.lib

Libreria in modalità utente: volatileaccessu.lib

Vedi anche