From 9f50d049ea9ab846d63441766cab425a687b6575 Mon Sep 17 00:00:00 2001
From: Juergen Schmied <juergen.schmied@debitel.net>
Date: Sat, 26 Feb 2000 19:35:50 +0000
Subject: [PATCH] Fixed definition of the RtlMemory functions. Use macros
 internally and for Winelib, use real functions for exports from ntdll.

---
 dlls/ntdll/ntdll.spec |  2 +-
 dlls/ntdll/rtl.c      | 47 +++++++++++++++++++++++++++++++++++++++++++
 include/winbase.h     | 13 +++++-------
 include/winnt.h       |  6 ++++++
 memory/string.c       | 28 --------------------------
 5 files changed, 59 insertions(+), 37 deletions(-)

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 8aaf826d03d..f9e723820e7 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -291,7 +291,7 @@ type	win32
 @ stub RtlClearAllBits
 @ stdcall RtlClearBits(long long long) RtlClearBits
 @ stub RtlCompactHeap
-@ stub RtlCompareMemory
+@ stdcall RtlCompareMemory(ptr ptr long) RtlCompareMemory
 @ stub RtlCompareMemoryUlong
 @ stub RtlCompareString
 @ stdcall RtlCompareUnicodeString (ptr ptr long) RtlCompareUnicodeString
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index 4b379c4aabe..f3dd60ab345 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -502,6 +502,53 @@ NTSTATUS WINAPI RtlClearBits(DWORD x1,DWORD x2,DWORD x3)
 	return 0;
 }
 
+/******************************************************************************
+ *  RtlCopyMemory   [NTDLL] 
+ * 
+ */
+#undef RtlCopyMemory
+VOID WINAPI RtlCopyMemory( VOID *Destination, CONST VOID *Source, SIZE_T Length )
+{
+    memcpy(Destination, Source, Length);
+}	
+
+/******************************************************************************
+ *  RtlMoveMemory   [NTDLL] 
+ */
+#undef RtlMoveMemory
+VOID WINAPI RtlMoveMemory( VOID *Destination, CONST VOID *Source, SIZE_T Length )
+{
+    memmove(Destination, Source, Length);
+}
+
+/******************************************************************************
+ *  RtlFillMemory   [NTDLL] 
+ */
+#undef RtlFillMemory
+VOID WINAPI RtlFillMemory( VOID *Destination, SIZE_T Length, BYTE Fill )
+{
+    memset(Destination, Fill, Length);
+}
+
+/******************************************************************************
+ *  RtlZeroMemory   [NTDLL] 
+ */
+#undef RtlZeroMemory
+VOID WINAPI RtlZeroMemory( VOID *Destination, SIZE_T Length )
+{
+    memset(Destination, 0, Length);
+}
+
+/******************************************************************************
+ *  RtlCompareMemory   [NTDLL] 
+ */
+SIZE_T WINAPI RtlCompareMemory( const VOID *Source1, const VOID *Source2, SIZE_T Length)
+{
+    int i;
+    for(i=0; (i<Length) && (((LPBYTE)Source1)[i]==((LPBYTE)Source2)[i]); i++);
+    return i;
+}
+
 /******************************************************************************
  *  RtlAssert                           [NTDLL]
  *
diff --git a/include/winbase.h b/include/winbase.h
index 329a1438bf2..5cc91ffd44e 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1439,14 +1439,6 @@ BOOL        WINAPI ReportEventW(HANDLE,WORD,WORD,DWORD,PSID,WORD,DWORD,LPCWSTR *
 #define     ReportEvent WINELIB_NAME_AW(ReportEvent)
 BOOL      WINAPI ResetEvent(HANDLE);
 DWORD       WINAPI ResumeThread(HANDLE);
-VOID        WINAPI RtlFillMemory(LPVOID,UINT,UINT);
-#define     FillMemory RtlFillMemory
-VOID        WINAPI RtlMoveMemory(LPVOID,LPCVOID,UINT);
-#define     MoveMemory RtlMoveMemory
-VOID        WINAPI RtlZeroMemory(LPVOID,UINT);
-#define     ZeroMemory RtlZeroMemory
-VOID        WINAPI RtlCopyMemory(LPVOID,const VOID*, DWORD);
-#define     CopyMemory RtlCopyMemory
 BOOL        WINAPI RevertToSelf(void);
 DWORD       WINAPI SearchPathA(LPCSTR,LPCSTR,LPCSTR,DWORD,LPSTR,LPSTR*);
 DWORD       WINAPI SearchPathW(LPCWSTR,LPCWSTR,LPCWSTR,DWORD,LPWSTR,LPWSTR*);
@@ -1765,6 +1757,11 @@ INT       WINAPI lstrcmpiA(LPCSTR,LPCSTR);
 INT       WINAPI lstrcmpiW(LPCWSTR,LPCWSTR);
 #define     lstrcmpi WINELIB_NAME_AW(lstrcmpi)
 
+/* compatibility macros */
+#define     FillMemory RtlFillMemory
+#define     MoveMemory RtlMoveMemory
+#define     ZeroMemory RtlZeroMemory
+#define     CopyMemory RtlCopyMemory
 
 /* the following may be macros when compiling Wine */
 #ifndef SetLastError
diff --git a/include/winnt.h b/include/winnt.h
index f22e81b2cb3..0812239e2a5 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -1625,6 +1625,12 @@ typedef enum tagSID_NAME_USE {
 #define DACL_SECURITY_INFORMATION   0x00000004
 #define SACL_SECURITY_INFORMATION   0x00000008
 
+#define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
+#define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
+#define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
+#define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
+#define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
+
 #include "poppack.h"
 
 #endif  /* __WINE_WINNT_H */
diff --git a/memory/string.c b/memory/string.c
index c28849b045c..744f61b5c4c 100644
--- a/memory/string.c
+++ b/memory/string.c
@@ -477,34 +477,6 @@ void WINAPI Copy16( LPVOID src, LPVOID dst, WORD size )
     memcpy( dst, src, size );
 }
 
-
-/***********************************************************************
- *           RtlFillMemory   (KERNEL32.441)
- */
-VOID WINAPI RtlFillMemory( LPVOID ptr, UINT len, UINT fill )
-{
-    memset( ptr, fill, len );
-}
-
-
-/***********************************************************************
- *           RtlMoveMemory   (KERNEL32.442)
- */
-VOID WINAPI RtlMoveMemory( LPVOID dst, LPCVOID src, UINT len )
-{
-    memmove( dst, src, len );
-}
-
-
-/***********************************************************************
- *           RtlZeroMemory   (KERNEL32.444)
- */
-VOID WINAPI RtlZeroMemory( LPVOID ptr, UINT len )
-{
-    memset( ptr, 0, len );
-}
-
-
 /***********************************************************************
  *           AnsiToOem16   (KEYBOARD.5)
  */
-- 
GitLab