Skip to content

Commit 27c3a4d

Browse files
committed
[USER32] Fix copying from WNDCLASS to WNDCLASSEX
This must be done field by field, since the alignment of the structures is different on _WIN64
1 parent 094a90a commit 27c3a4d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

win32ss/user/user32/windows/class.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,19 @@ RegisterClassA(CONST WNDCLASSA *lpWndClass)
15951595
if (lpWndClass == NULL)
15961596
return 0;
15971597

1598-
RtlCopyMemory(&Class.style, lpWndClass, sizeof(WNDCLASSA));
1598+
/* These MUST be copied manually, since on 64 bit architectures the
1599+
alignment of the members is different between the 2 structs! */
1600+
Class.style = lpWndClass->style;
1601+
Class.lpfnWndProc = lpWndClass->lpfnWndProc;
1602+
Class.cbClsExtra = lpWndClass->cbClsExtra;
1603+
Class.cbWndExtra = lpWndClass->cbWndExtra;
1604+
Class.hInstance = lpWndClass->hInstance;
1605+
Class.hIcon = lpWndClass->hIcon;
1606+
Class.hCursor = lpWndClass->hCursor;
1607+
Class.hbrBackground = lpWndClass->hbrBackground;
1608+
Class.lpszMenuName = lpWndClass->lpszMenuName;
1609+
Class.lpszClassName = lpWndClass->lpszClassName;
1610+
15991611
Class.cbSize = sizeof(WNDCLASSEXA);
16001612
Class.hIconSm = NULL;
16011613

@@ -1613,7 +1625,19 @@ RegisterClassW(CONST WNDCLASSW *lpWndClass)
16131625
if (lpWndClass == NULL)
16141626
return 0;
16151627

1616-
RtlCopyMemory(&Class.style, lpWndClass, sizeof(WNDCLASSW));
1628+
/* These MUST be copied manually, since on 64 bit architectures the
1629+
alignment of the members is different between the 2 structs! */
1630+
Class.style = lpWndClass->style;
1631+
Class.lpfnWndProc = lpWndClass->lpfnWndProc;
1632+
Class.cbClsExtra = lpWndClass->cbClsExtra;
1633+
Class.cbWndExtra = lpWndClass->cbWndExtra;
1634+
Class.hInstance = lpWndClass->hInstance;
1635+
Class.hIcon = lpWndClass->hIcon;
1636+
Class.hCursor = lpWndClass->hCursor;
1637+
Class.hbrBackground = lpWndClass->hbrBackground;
1638+
Class.lpszMenuName = lpWndClass->lpszMenuName;
1639+
Class.lpszClassName = lpWndClass->lpszClassName;
1640+
16171641
Class.cbSize = sizeof(WNDCLASSEXW);
16181642
Class.hIconSm = NULL;
16191643

0 commit comments

Comments
 (0)