Fungsi SecureZeroMemory2
Fungsi SecureZeroMemory2 mengisi blok memori dengan nol dengan cara yang dijamin aman.
Penting
Beberapa informasi berkaitan dengan produk prarilis yang mungkin dimodifikasi secara substansial sebelum dirilis secara komersial. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Parameter
Tujuan Param [keluar]
Penunjuk ke alamat awal blok memori untuk diisi dengan nol.
Panjang Param [in]
Ukuran blok memori untuk diisi dengan nol, dalam byte.
Sintaks
volatile void*
SecureZeroMemory2 (
_Out_writes_bytes_all_(Length) volatile void* Destination,
SIZE_T Length
);
Keterangan
API ini adalah pembungkus kenyamanan di sekitar FillVolatileMemory dan identik dengan ZeroVolatileMemory. Lihat keterangan FillVolatileMemory untuk informasi selengkapnya.
Catatan
Fungsi ini berfungsi pada semua versi Windows, bukan hanya yang terbaru. Anda perlu menggunakan SDK terbaru untuk mendapatkan deklarasi fungsi dari winbase.h
header. Anda juga memerlukan pustaka (volatileaccessu.lib
) dari SDK terbaru. Namun, biner yang dihasilkan akan berjalan dengan baik pada versi Windows yang lebih lama.
Contoh
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));
Persyaratan
Klien minimum yang didukung: Windows 11 Insider Preview Build TBD
Header: winbase.h (termasuk Winbase.h)
Pustaka mode kernel: volatileaccessk.lib
Pustaka mode pengguna: volatileaccessu.lib