Nota
O acesso a esta página requer autorização. Podes tentar iniciar sessão ou mudar de diretório.
O acesso a esta página requer autorização. Podes tentar mudar de diretório.
The RtlCompareDeviceMemory function compares two blocks of device memory and returns the number of bytes that match until the first difference. Essa função é segura para uso na memória do dispositivo porque usa acessos no nível de bytes que têm a garantia de serem executados conforme especificado.
Syntax
SIZE_T RtlCompareDeviceMemory(
[in] const VOID *Source1,
[in] const VOID *Source2,
[in] SIZE_T Length
);
Parameters
[in] Source1
Um ponteiro para o primeiro bloco de memória a ser comparado.
[in] Source2
Um ponteiro para o segundo bloco de memória a ser comparado.
[in] Length
O número de bytes a serem comparados.
Return value
RtlCompareDeviceMemory returns the number of bytes in the two blocks that match. If all bytes match up to the specified Length value, the Length value is returned.
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 RtlCompareMemory which is subject to various compiler optimizations.
A função usa acessos em nível de byte para garantir o tratamento adequado da memória do dispositivo que pode ter efeitos colaterais ou requisitos especiais de acesso.
A rotina começa comparando o primeiro byte no primeiro bloco com o primeiro byte no segundo bloco e continua comparando bytes sucessivos nos dois blocos enquanto os bytes correspondem. The routine stops comparing bytes when it encounters the first pair of bytes that are not equal, or when the number of matching bytes equals the Length parameter value, whichever occurs first.
A função poderá executar acessos de memória não assinados se a plataforma permitir.
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 DeviceBuffer1[256];
UCHAR DeviceBuffer2[256];
// Read data from device memory into buffers
ReadFromDevice(DeviceBuffer1, sizeof(DeviceBuffer1));
ReadFromDevice(DeviceBuffer2, sizeof(DeviceBuffer2));
// Compare the device memory buffers
size_t matchingBytes = RtlCompareDeviceMemory(DeviceBuffer1, DeviceBuffer2, sizeof(DeviceBuffer1));
if (matchingBytes == sizeof(DeviceBuffer1)) {
// All bytes matched
DbgPrint("Device buffers are identical\n");
} else {
// Difference found at byte offset 'matchingBytes'
DbgPrint("Device buffers differ starting at byte %zu\n", matchingBytes);
}
Requirements
| Requirement | Value |
|---|---|
| Header | wdm.h (inclua Wdm.h) |
| Library | volatileaccessk.lib (modo Kernel), volatileaccessu.lib (modo usuário) |