#ifndef _NTRTL_H
//
// Memory
//
/**
* The RtlCompareMemory routine compares two blocks of memory and returns the number of leading bytes that are equal.
*
* \param Source1 A pointer to the first block of memory to compare.
* \param Source2 A pointer to the second block of memory to compare.
* \param Length The number of bytes to compare.
* \return SIZE_T The number of bytes that are equal in the two memory blocks.
* \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlcomparememory
* \remarks Returns the number of matching bytes in the initial prefix, not a signed ordering result like memcmp and not necessarily the total number of equal bytes across the buffers. Full equality requires the result to equal Length.
*/
_Check_return_
NTSYSAPI
SIZE_T
NTAPI
RtlCompareMemory(
_In_ const VOID* Source1,
_In_ const VOID* Source2,
_In_ SIZE_T Length
);
View code on GitHub// wdm.h
NTSYSAPI SIZE_T RtlCompareMemory(
[in] const VOID *Source1,
[in] const VOID *Source2,
[in] SIZE_T Length
);
View the official Windows Driver Kit DDI referenceNo description available.
The RtlCompareMemory routine compares two blocks of memory and returns the number of bytes that match until the first difference.
Source1 [in]A pointer to the first block of memory.
Source2 [in]A pointer to the second block of memory.
Length [in]The number of bytes to compare.
RtlCompareMemory 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.
The routine starts by comparing the first byte in the first block to the first byte in the second block, and continues to compare successive bytes in the two blocks while the bytes match. 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.
Callers of RtlCompareMemory can be running at any IRQL if both blocks of memory are resident.