https://git.reactos.org/?p=reactos.git;a=commitdiff;h=27c3a4d26a9f00cea3def9d9fc547ff6ea863424

commit 27c3a4d26a9f00cea3def9d9fc547ff6ea863424
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Fri Aug 17 14:50:22 2018 +0200
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Fri Aug 17 22:13:18 2018 +0200

    [USER32] Fix copying from WNDCLASS to WNDCLASSEX
    This must be done field by field, since the alignment of the structures is 
different on _WIN64
---
 win32ss/user/user32/windows/class.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/win32ss/user/user32/windows/class.c 
b/win32ss/user/user32/windows/class.c
index 7208b36c10..c7da5f523c 100644
--- a/win32ss/user/user32/windows/class.c
+++ b/win32ss/user/user32/windows/class.c
@@ -1595,7 +1595,19 @@ RegisterClassA(CONST WNDCLASSA *lpWndClass)
     if (lpWndClass == NULL)
         return 0;
 
-    RtlCopyMemory(&Class.style, lpWndClass, sizeof(WNDCLASSA));
+    /* These MUST be copied manually, since on 64 bit architectures the
+       alignment of the members is different between the 2 structs! */
+    Class.style = lpWndClass->style;
+    Class.lpfnWndProc = lpWndClass->lpfnWndProc;
+    Class.cbClsExtra = lpWndClass->cbClsExtra;
+    Class.cbWndExtra = lpWndClass->cbWndExtra;
+    Class.hInstance = lpWndClass->hInstance;
+    Class.hIcon = lpWndClass->hIcon;
+    Class.hCursor = lpWndClass->hCursor;
+    Class.hbrBackground = lpWndClass->hbrBackground;
+    Class.lpszMenuName = lpWndClass->lpszMenuName;
+    Class.lpszClassName = lpWndClass->lpszClassName;
+
     Class.cbSize = sizeof(WNDCLASSEXA);
     Class.hIconSm = NULL;
 
@@ -1613,7 +1625,19 @@ RegisterClassW(CONST WNDCLASSW *lpWndClass)
     if (lpWndClass == NULL)
         return 0;
 
-    RtlCopyMemory(&Class.style, lpWndClass, sizeof(WNDCLASSW));
+    /* These MUST be copied manually, since on 64 bit architectures the
+       alignment of the members is different between the 2 structs! */
+    Class.style = lpWndClass->style;
+    Class.lpfnWndProc = lpWndClass->lpfnWndProc;
+    Class.cbClsExtra = lpWndClass->cbClsExtra;
+    Class.cbWndExtra = lpWndClass->cbWndExtra;
+    Class.hInstance = lpWndClass->hInstance;
+    Class.hIcon = lpWndClass->hIcon;
+    Class.hCursor = lpWndClass->hCursor;
+    Class.hbrBackground = lpWndClass->hbrBackground;
+    Class.lpszMenuName = lpWndClass->lpszMenuName;
+    Class.lpszClassName = lpWndClass->lpszClassName;
+
     Class.cbSize = sizeof(WNDCLASSEXW);
     Class.hIconSm = NULL;
 

Reply via email to