From: Timo Kreuzer Date: Fri, 17 Aug 2018 12:50:22 +0000 (+0200) Subject: [USER32] Fix copying from WNDCLASS to WNDCLASSEX X-Git-Tag: 0.4.11-dev~98 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=27c3a4d26a9f00cea3def9d9fc547ff6ea863424 [USER32] Fix copying from WNDCLASS to WNDCLASSEX This must be done field by field, since the alignment of the structures is different on _WIN64 --- diff --git a/win32ss/user/user32/windows/class.c b/win32ss/user/user32/windows/class.c index 7208b36c10e..c7da5f523c6 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;