Share via


FillVolatileMemory 함수

FillVolatileMemory 함수는 지정된 채우기 값으로 메모리 블록을 채웁니다.

Important

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

매개 변수

Param Destination [out]

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

Param Length [in]

채울 메모리 블록의 크기(바이트)입니다. 이 값은 대상 버퍼의 크기보다 작아야 합니다.

매개 변수 채우기 [in]

메모리 블록을 채울 바이트 값입니다.

구문

volatile void*
  FillVolatileMemory (
    _Out_writes_bytes_all_(Length) volatile void* Destination,
    SIZE_T Length,
    INT Fill
  );

설명

이 API는 개발자가 설정 작업이 발생하는지 확인해야 하는 상황에서 FillMemory 동작(즉, 버퍼의 내용 설정)을 제공하기 위해 존재합니다(즉, 컴파일러 최적화의 대상이 아님). API에는 다음과 같은 속성이 있습니다.

  • API는 컴파일러 내장 함수로 인식되지 않으므로 컴파일러가 호출을 최적화하지 않습니다(호출을 완전히 또는 "동등한" 명령 시퀀스로 대체). 다양한 컴파일러 최적화가 적용되는 FillMemory와 다릅니다.
  • 호출이 반환되면 버퍼를 원하는 값으로 덮어씁니다. 대상대한 이 함수 메모리 액세스는 함수 내에서만 수행됩니다(즉, 컴파일러가 이 함수에서 메모리 액세스를 이동할 수 없음).
  • 플랫폼이 허용하는 경우 API는 정렬되지 않은 메모리 액세스를 수행할 수 있습니다.
  • API는 작업의 일부로 메모리 위치에 두 번 이상 액세스할 수 있습니다.

참고 항목

이 함수는 최신 버전뿐만 아니라 모든 버전의 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 convenience wrappers around the latter). These
// calls will not be optimized away by the compiler.
// Note that SecureZeroMemory2 performs better than the old
// SecureZeroMemory API.

FillVolatileMemory(&SensitiveData, sizeof(SensitiveData), 0);

요구 사항

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

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

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

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

참고 항목