Share via


ZeroDeviceMemory 함수

ZeroDeviceMemory 함수는 개발자가 디바이스 메모리에 액세스할 때 맞춤 오류가 생성되지 않도록 해야 하는 상황에서 컴파일러 최적화의 간섭 없이 버퍼의 내용을 0으로 설정합니다.

Important

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

매개 변수

Param Destination [out]

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

Param Length [in]

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

구문

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

설명

이 API는 FillDeviceMemory에 대한 편리한 래퍼입니다. 자세한 내용은 FillDeviceMemory발언을 참조하세요.

참고 항목

이 함수는 최신 버전뿐만 아니라 모든 버전의 Windows에서 작동합니다. 헤더에서 함수 선언을 얻으려면 최신 SDK를 winbase.h 사용해야 합니다. 최신 SDK의 라이브러리(volatileaccessu.lib)도 필요합니다. 그러나 결과 이진 파일은 이전 버전의 Windows에서 잘 실행됩니다.

예시

// In this scenario we are setting data on memory mapped
// as "device memory" (i.e. memory not backed by RAM) to the value zero. On
// some platforms like ARM64, device memory cannot tolerate
// memory accesses that are not naturally aligned (i.e. a 4-byte
// load must be 4-byte aligned). Functions like memset, FillMemory,
// and even FillVolatileMemory may perform unaligned memory accesses
// because it is typically faster to do this.
// To ensure only naturally aligned accesses happen, use FillDeviceMemory.
//
// ZeroDeviceMemory is an wrapper around FillDeviceMemory that sets the memory
// to zero.

ZeroDeviceMemory(DeviceMemoryBuffer, 100);

요구 사항

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

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

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

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

참고 항목