Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
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). A função retorna um ponteiro para a memória preenchida.
Syntax
volatile void * RtlSetVolatileMemory(
[out] volatile void *Destination,
[in] int Fill,
[in] size_t Length
);
Parameters
[out] Destination
Um ponteiro para o endereço inicial do bloco de memória a ser preenchido.
[in] Fill
O valor de byte com o qual preencher o bloco de memória.
[in] Length
O tamanho do bloco de memória a ser preenchido, em bytes. This value must be less than the size of the Destination buffer.
Return value
Returns a pointer to the filled memory block (Destination).
Remarks
A função não é reconhecida como um compilador intrínseco, portanto, o compilador nunca otimizará a chamada (totalmente ou substituirá a chamada por uma sequência equivalente de instruções). This differs from RtlFillMemory which is subject to various compiler optimizations.
Quando a chamada é retornada, o buffer foi substituído com o valor desejado. 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).
A função poderá executar acessos de memória não assinados se a plataforma permitir.
A função pode acessar locais de memória mais de uma vez como parte de sua operação.
Essa função funciona em todas as versões do Windows, não apenas nas mais recentes. Você precisa consumir o WDK mais recente para obter a declaração de função do cabeçalho wdm.h. Você também precisa da biblioteca (volatileaccessk.lib) do WDK mais recente. No entanto, o driver resultante será executado bem em versões mais antigas do 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 |
|---|---|
| Cliente mínimo suportado | See Remarks |
| Header | wdm.h (inclua Wdm.h) |
| Library | volatileaccessk.lib (modo Kernel), volatileaccessu.lib (modo usuário) |