https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d07203ecb700a11c21608…
commit d07203ecb700a11c21608448d2326ea6a6b3f368
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Fri Mar 9 00:04:54 2018 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Fri May 28 08:26:36 2021 +0200
[WIN32K][USER32] Change mechanism for storing dialog info pointer
DLGWINDOWEXTRA is 30 (both on win32 and win64). This has storage for the following
entries: DWLP_MSGRESULT (0), DWLP_DLGPROC (8), DWLP_USER (16)
We used to store the dialog info pointer using SetWindowLongPtr (DWLP_ROS_DIALOGINFO
== DWLP_USER+sizeof(ULONG_PTR) == 24), which was fine on win32, but failed on win64, since
there wasn't enough space left (24 + 8 = 32 > 30).
Rewrite the way the DLGINFO pointer is stored, by adding an additional field to the
WND structure and set it using NtUserxSetDialogPointer (which is what it is for).
Also fix too small cbWndExtra for the button class.
---
win32ss/include/ntuser.h | 2 ++
win32ss/user/ntuser/simplecall.c | 3 ++-
win32ss/user/user32/controls/button.c | 2 +-
win32ss/user/user32/windows/dialog.c | 16 ++++------------
4 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index b997b21c848..22538c84818 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -726,6 +726,8 @@ typedef struct _WND
PSBINFOEX pSBInfoex; // convert to PSBINFO
/* Entry in the list of thread windows. */
LIST_ENTRY ThreadListEntry;
+
+ PVOID DialogPointer;
} WND, *PWND;
#define PWND_BOTTOM ((PWND)1)
diff --git a/win32ss/user/ntuser/simplecall.c b/win32ss/user/ntuser/simplecall.c
index 462bbe15bb7..fdc52c1c478 100644
--- a/win32ss/user/ntuser/simplecall.c
+++ b/win32ss/user/ntuser/simplecall.c
@@ -798,9 +798,10 @@ NtUserCallHwndParam(
UserRefObjectCo(pWnd, &Ref);
if (pWnd->head.pti->ppi == PsGetCurrentProcessWin32Process()
&&
- pWnd->cbwndExtra == DLGWINDOWEXTRA &&
+ pWnd->cbwndExtra >= DLGWINDOWEXTRA &&
!(pWnd->state & WNDS_SERVERSIDEWINDOWPROC))
{
+ pWnd->DialogPointer = (PVOID)Param;
if (Param)
{
if (!pWnd->fnid) pWnd->fnid = FNID_DIALOG;
diff --git a/win32ss/user/user32/controls/button.c
b/win32ss/user/user32/controls/button.c
index 6b65c536795..69377a96b2d 100644
--- a/win32ss/user/user32/controls/button.c
+++ b/win32ss/user/user32/controls/button.c
@@ -72,7 +72,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(button);
#define BUTTON_HFONT_GWL_OFFSET (sizeof(LONG))
#define HIMAGE_GWL_OFFSET (BUTTON_HFONT_GWL_OFFSET+sizeof(HFONT))
#define BUTTON_UISTATE_GWL_OFFSET (HIMAGE_GWL_OFFSET+sizeof(HFONT))
-#define NB_EXTRA_BYTES (BUTTON_UISTATE_GWL_OFFSET+sizeof(LONG))
+#define NB_EXTRA_BYTES (BUTTON_UISTATE_GWL_OFFSET+sizeof(LONG_PTR))
/* undocumented flags */
#define BUTTON_NSTATES 0x0F
diff --git a/win32ss/user/user32/windows/dialog.c b/win32ss/user/user32/windows/dialog.c
index c853e5f8ebd..359cfd150c6 100644
--- a/win32ss/user/user32/windows/dialog.c
+++ b/win32ss/user/user32/windows/dialog.c
@@ -36,9 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
#define DF_END 0x0001
#define DF_DIALOGACTIVE 0x4000 // ReactOS
-#define DWLP_ROS_DIALOGINFO (DWLP_USER+sizeof(ULONG_PTR))
#define GETDLGINFO(hwnd) DIALOG_get_info(hwnd, FALSE)
-#define SETDLGINFO(hwnd, info) SetWindowLongPtrW((hwnd), DWLP_ROS_DIALOGINFO,
(LONG_PTR)(info))
#define GET_WORD(ptr) (*(WORD *)(ptr))
#define GET_DWORD(ptr) (*(DWORD *)(ptr))
#define GET_LONG(ptr) (*(const LONG *)(ptr))
@@ -141,7 +139,7 @@ DIALOGINFO *DIALOG_get_info( HWND hWnd, BOOL create )
return NULL;
}
- dlgInfo = (DIALOGINFO *)GetWindowLongPtrW( hWnd, DWLP_ROS_DIALOGINFO );
+ dlgInfo = pWindow->DialogPointer;
if (!dlgInfo && create)
{
@@ -151,7 +149,7 @@ DIALOGINFO *DIALOG_get_info( HWND hWnd, BOOL create )
return NULL;
dlgInfo->idResult = IDOK;
- SETDLGINFO( hWnd, dlgInfo );
+ NtUserxSetDialogPointer( hWnd, dlgInfo );
}
else
{
@@ -159,13 +157,6 @@ DIALOGINFO *DIALOG_get_info( HWND hWnd, BOOL create )
}
}
- if (dlgInfo)
- {
- if (!(pWindow->state & WNDS_DIALOGWINDOW))
- {
- NtUserxSetDialogPointer( hWnd, dlgInfo );
- }
- }
return dlgInfo;
}
@@ -1258,7 +1249,8 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
}
case WM_NCDESTROY:
//// ReactOS
- if ((dlgInfo = (DIALOGINFO *)SetWindowLongPtrW( hwnd, DWLP_ROS_DIALOGINFO, 0
)))
+ dlgInfo = DIALOG_get_info(hwnd, FALSE);
+ if (dlgInfo != NULL)
{
if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );