Expand Minimize

RtlCompareMemory routine

The RtlCompareMemory routine compares two blocks of memory and returns the number of bytes that match.


SIZE_T RtlCompareMemory(
  _In_  const VOID *Source1,
  _In_  const VOID *Source2,
  _In_  SIZE_T Length


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.

Return value

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.



Available starting with Windows 2000.


Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)




Any level (See Remarks section)

DDI compliance rules

BufAfterReqCompletedIntIoctlA, BufAfterReqCompletedIoctlA, BufAfterReqCompletedReadA, BufAfterReqCompletedWriteA



Send comments about this topic to Microsoft

© 2015 Microsoft