Share via


SecureZeroMemory2 함수

SecureZeroMemory2 함수는 안전한 방식으로 메모리 블록을 0으로 채웁니다.

Important

일부 정보는 상용 출시되기 전에 실질적으로 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.

매개 변수

Param Destination [out]

0으로 채울 메모리 블록의 시작 주소에 대한 포인터입니다.

Param Length [in]

0으로 채울 메모리 블록의 크기(바이트)입니다.

구문

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

설명

이 API는 FillVolatileMemory에 대한 편리한 래퍼이며 ZeroVolatileMemory와 동일합니다. 자세한 내용은 FillVolatileMemory발언을 참조하세요.

참고 항목

이 함수는 최신 버전뿐만 아니라 모든 버전의 Windows에서 작동합니다. 헤더에서 함수 선언을 얻으려면 최신 SDK를 winbase.h 사용해야 합니다. 최신 SDK의 라이브러리(volatileaccessu.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 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));

요구 사항

지원되는 최소 클라이언트: Windows 11 Insider Preview 빌드 TBD

헤더: winbase.h(Winbase.h 포함)

커널 모드 라이브러리: volatileaccessk.lib

사용자 모드 라이브러리: volatileaccessu.lib

참고 항목