From b84f2a1cdc492dc9402c684ad677035b633bd8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 3 Jun 2024 21:12:35 +0200 Subject: [PATCH] [KDVM] Fix definition of RtlEqualMemory() (#6988) Comply with the standard documented behaviour: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlequalmemory#return-value > RtlEqualMemory returns TRUE if Source1 and Source2 are equivalent; otherwise, it returns FALSE. and https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlcomparememory#return-value > [...] If all bytes match up to the specified Length value, the Length value is returned. --- drivers/base/kdvm/kdvm.c | 2 +- drivers/base/kdvm/kdvm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/kdvm/kdvm.c b/drivers/base/kdvm/kdvm.c index f9838878b9c..fa73c5cba7b 100644 --- a/drivers/base/kdvm/kdvm.c +++ b/drivers/base/kdvm/kdvm.c @@ -121,7 +121,7 @@ KdVmSendReceive( return NULL; } - if (RtlEqualMemory(ReceiveHeader->Magic, KdVmReplyMagic, 9)) + if (!RtlEqualMemory(ReceiveHeader->Magic, KdVmReplyMagic, 9)) { KDDBGPRINT("KdVmSendReceive: got invalid Magic: '%*s'\n", sizeof(KdVmReplyMagic), ReceiveHeader->Magic); diff --git a/drivers/base/kdvm/kdvm.h b/drivers/base/kdvm/kdvm.h index 2636577ec6f..14bb21ac696 100644 --- a/drivers/base/kdvm/kdvm.h +++ b/drivers/base/kdvm/kdvm.h @@ -15,7 +15,7 @@ #include #undef RtlEqualMemory -#define RtlEqualMemory(a, b, c) (RtlCompareMemory(a, b, c) != c) +#define RtlEqualMemory(dst, src, len) (RtlCompareMemory((dst), (src), (len)) == (len)) //#define KDDEBUG /* uncomment to enable debugging this dll */