Jacek Caban : win32u: Introduce NtUserGetDialogInfo and NtUserSetDialogInfo.
Alexandre Julliard
julliard at winehq.org
Thu Jul 28 16:01:11 CDT 2022
Module: wine
Branch: master
Commit: 1cd5702d9f4787f56a342b52ae9b4dcf5356b8e9
URL: https://gitlab.winehq.org/wine/wine/-/commit/1cd5702d9f4787f56a342b52ae9b4dcf5356b8e9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Jul 26 19:12:12 2022 +0200
win32u: Introduce NtUserGetDialogInfo and NtUserSetDialogInfo.
And use it instead of accessing window object from user32.
---
dlls/user32/defdlg.c | 22 ++++------------------
dlls/win32u/window.c | 32 ++++++++++++++++++++++++++++++++
include/ntuser.h | 12 ++++++++++++
3 files changed, 48 insertions(+), 18 deletions(-)
diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c
index e330cf6603d..1e1ff71b87b 100644
--- a/dlls/user32/defdlg.c
+++ b/dlls/user32/defdlg.c
@@ -237,15 +237,11 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
case WM_NCDESTROY:
if (dlgInfo)
{
- WND *wndPtr;
-
if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
if (dlgInfo->hMenu) NtUserDestroyMenu( dlgInfo->hMenu );
HeapFree( GetProcessHeap(), 0, dlgInfo );
- wndPtr = WIN_GetPtr( hwnd );
- wndPtr->dlgInfo = NULL;
- WIN_ReleasePtr( wndPtr );
+ NtUserSetDialogInfo( hwnd, NULL );
}
/* Window clean-up */
return DefWindowProcA( hwnd, msg, wParam, lParam );
@@ -323,22 +319,14 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
*/
DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create )
{
- WND* wndPtr;
DIALOGINFO* dlgInfo;
- wndPtr = WIN_GetPtr( hwnd );
- if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
- {
- SetLastError( ERROR_INVALID_WINDOW_HANDLE );
- return NULL;
- }
-
- dlgInfo = wndPtr->dlgInfo;
+ dlgInfo = NtUserGetDialogInfo( hwnd );
if (!dlgInfo && create)
{
if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) )))
- goto out;
+ return NULL;
dlgInfo->hwndFocus = 0;
dlgInfo->hUserFont = 0;
dlgInfo->hMenu = 0;
@@ -346,11 +334,9 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create )
dlgInfo->yBaseUnit = 0;
dlgInfo->idResult = IDOK;
dlgInfo->flags = 0;
- wndPtr->dlgInfo = dlgInfo;
+ NtUserSetDialogInfo( hwnd, dlgInfo );
}
-out:
- WIN_ReleasePtr( wndPtr );
return dlgInfo;
}
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c
index 1b72635e99c..71e500abb0f 100644
--- a/dlls/win32u/window.c
+++ b/dlls/win32u/window.c
@@ -5359,6 +5359,32 @@ failed:
return 0;
}
+static void *get_dialog_info( HWND hwnd )
+{
+ WND *win;
+ void *ret;
+
+ if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS || win == WND_DESKTOP)
+ {
+ SetLastError( ERROR_INVALID_WINDOW_HANDLE );
+ return NULL;
+ }
+
+ ret = win->dlgInfo;
+ release_win_ptr( win );
+ return ret;
+}
+
+static BOOL set_dialog_info( HWND hwnd, void *info )
+{
+ WND *win;
+
+ if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE;
+ win->dlgInfo = info;
+ release_win_ptr( win );
+ return TRUE;
+}
+
/*****************************************************************************
* NtUserCallHwnd (win32u.@)
*/
@@ -5381,6 +5407,9 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code )
case NtUserCallHwnd_GetParent:
return HandleToUlong( get_parent( hwnd ));
+ case NtUserCallHwnd_GetDialogInfo:
+ return (ULONG_PTR)get_dialog_info( hwnd );
+
case NtUserCallHwnd_GetWindowContextHelpId:
return get_window_context_help_id( hwnd );
@@ -5510,6 +5539,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code )
case NtUserCallHwndParam_ScreenToClient:
return screen_to_client( hwnd, (POINT *)param );
+ case NtUserCallHwndParam_SetDialogInfo:
+ return set_dialog_info( hwnd, (void *)param );
+
case NtUserCallHwndParam_SetWindowContextHelpId:
return set_window_context_help_id( hwnd, param );
diff --git a/include/ntuser.h b/include/ntuser.h
index dc5f5ee501a..9ba128bdbda 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -1101,6 +1101,7 @@ enum
NtUserCallHwnd_ArrangeIconicWindows,
NtUserCallHwnd_DrawMenuBar,
NtUserCallHwnd_GetDefaultImeWindow,
+ NtUserCallHwnd_GetDialogInfo,
NtUserCallHwnd_GetDpiForWindow,
NtUserCallHwnd_GetParent,
NtUserCallHwnd_GetWindowContextHelpId,
@@ -1138,6 +1139,11 @@ static inline HWND NtUserGetDefaultImeWindow( HWND hwnd )
return UlongToHandle( NtUserCallHwnd( hwnd, NtUserCallHwnd_GetDefaultImeWindow ));
}
+static inline void *NtUserGetDialogInfo( HWND hwnd )
+{
+ return (void *)NtUserCallHwnd( hwnd, NtUserCallHwnd_GetDialogInfo );
+}
+
static inline UINT NtUserGetDpiForWindow( HWND hwnd )
{
return NtUserCallHwnd( hwnd, NtUserCallHwnd_GetDpiForWindow );
@@ -1216,6 +1222,7 @@ enum
NtUserCallHwndParam_MirrorRgn,
NtUserCallHwndParam_MonitorFromWindow,
NtUserCallHwndParam_ScreenToClient,
+ NtUserCallHwndParam_SetDialogInfo,
NtUserCallHwndParam_SetWindowContextHelpId,
NtUserCallHwndParam_SetWindowPixelFormat,
NtUserCallHwndParam_ShowOwnedPopups,
@@ -1365,6 +1372,11 @@ static inline BOOL NtUserScreenToClient( HWND hwnd, POINT *pt )
return NtUserCallHwndParam( hwnd, (UINT_PTR)pt, NtUserCallHwndParam_ScreenToClient );
}
+static inline void NtUserSetDialogInfo( HWND hwnd, void *info )
+{
+ NtUserCallHwndParam( hwnd, (UINT_PTR)info, NtUserCallHwndParam_SetDialogInfo );
+}
+
static inline BOOL NtUserSetWindowContextHelpId( HWND hwnd, DWORD id )
{
return NtUserCallHwndParam( hwnd, id, NtUserCallHwndParam_SetWindowContextHelpId );
More information about the wine-cvs
mailing list