The RtlSetVolatileMemory function provides RtlFillMemory behavior (for example, setting the contents of a buffer) in situations where the developer needs to be sure that the setting operation occurs (for example, isn't subject to compiler optimizations). 함수는 채워진 메모리에 대한 포인터를 반환합니다.
Syntax
volatile void * RtlSetVolatileMemory(
[out] volatile void *Destination,
[in] int Fill,
[in] size_t Length
);
Parameters
[out] Destination
채울 메모리 블록의 시작 주소에 대한 포인터입니다.
[in] Fill
메모리 블록을 채울 바이트 값입니다.
[in] Length
채울 메모리 블록의 크기(바이트)입니다. This value must be less than the size of the Destination buffer.
Return value
Returns a pointer to the filled memory block (Destination).
Remarks
함수는 컴파일러 내장 함수로 인식되지 않으므로 컴파일러가 호출을 최적화하지 않습니다(완전히 또는 동일한 명령 시퀀스로 호출 대체). This differs from RtlFillMemory which is subject to various compiler optimizations.
호출이 반환되면 버퍼를 원하는 값으로 덮어씁니다. This function's memory accesses to the Destination will only be performed within the function (for example, the compiler can't move memory accesses out of this function).
플랫폼이 허용하는 경우 함수는 정렬되지 않은 메모리 액세스를 수행할 수 있습니다.
함수는 작업의 일부로 메모리 위치에 두 번 이상 액세스할 수 있습니다.
이 함수는 최신 버전뿐만 아니라 모든 버전의 Windows에서 작동합니다. wdm.h 헤더에서 함수 선언을 얻으려면 최신 WDK를 사용해야 합니다. 최신 WDK의 라이브러리(volatileaccessk.lib)도 필요합니다. 그러나 결과 드라이버는 이전 버전의 Windows에서 잘 실행됩니다.
Example
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 can use RtlSetVolatileMemory
// to fill the buffer and get a pointer to the filled memory.
// This call will not be optimized away by the compiler.
volatile VOID* clearedBuffer = RtlSetVolatileMemory(&SensitiveData, 0, sizeof(SensitiveData));
Requirements
| Requirement | Value |
|---|---|
| 지원되는 최소 클라이언트 | See Remarks |
| Header | wdm.h(Wdm.h 포함) |
| Library | volatileaccessk.lib(커널 모드), volatileaccessu.lib(사용자 모드) |