From: Jacek Caban jacek@codeweavers.com
And use it in user32 instead of DEFDLG_GetDlgProc. --- dlls/user32/defdlg.c | 34 ++++------------------------------ dlls/user32/dialog.c | 23 ++++------------------- dlls/user32/user_private.h | 4 ++-- dlls/user32/winproc.c | 36 ++++++++++++++++-------------------- dlls/win32u/class.c | 25 +++++++++++++++++++++++++ dlls/win32u/ntuser_private.h | 1 + dlls/win32u/window.c | 3 +++ include/ntuser.h | 13 +++++++++++++ 8 files changed, 68 insertions(+), 71 deletions(-)
diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c index 1e1ff71b87b..238951aa21c 100644 --- a/dlls/user32/defdlg.c +++ b/dlls/user32/defdlg.c @@ -29,27 +29,6 @@ #include "user_private.h" #include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(dialog); - - -/*********************************************************************** - * DEFDLG_GetDlgProc - */ -static DLGPROC DEFDLG_GetDlgProc( HWND hwnd ) -{ - DLGPROC ret; - WND *wndPtr = WIN_GetPtr( hwnd ); - - if (!wndPtr) return 0; - if (wndPtr == WND_OTHER_PROCESS) - { - ERR( "cannot get dlg proc %p from other process\n", hwnd ); - return 0; - } - ret = *(DLGPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC); - WIN_ReleasePtr( wndPtr ); - return ret; -}
/*********************************************************************** * DEFDLG_SetFocus @@ -343,16 +322,14 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { DIALOGINFO *dlgInfo; - DLGPROC dlgproc; - LRESULT result = 0; + LRESULT result;
/* Perform DIALOGINFO initialization if not done */ if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
- if ((dlgproc = DEFDLG_GetDlgProc( hwnd ))) /* Call dialog procedure */ - result = WINPROC_CallDlgProcA( dlgproc, hwnd, msg, wParam, lParam ); + result = WINPROC_CallDlgProcA( hwnd, msg, wParam, lParam );
if (!result && IsWindow(hwnd)) { @@ -397,16 +374,13 @@ static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar static LRESULT USER_DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { DIALOGINFO *dlgInfo; - DLGPROC dlgproc; - LRESULT result = 0; + LRESULT result;
/* Perform DIALOGINFO initialization if not done */ if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 ); - - if ((dlgproc = DEFDLG_GetDlgProc( hwnd ))) /* Call dialog procedure */ - result = WINPROC_CallDlgProcW( dlgproc, hwnd, msg, wParam, lParam ); + result = WINPROC_CallDlgProcW( hwnd, msg, wParam, lParam );
if (!result && IsWindow(hwnd)) { diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index b804de90df2..5c74de65ac0 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -1038,19 +1038,10 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg ) { while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL) { - WND *pParent; HWND hParent = GetParent(hwndDlg); - if (!hParent) break;
- pParent = WIN_GetPtr(hParent); - if (!pParent || pParent == WND_OTHER_PROCESS || pParent == WND_DESKTOP) break; - - if (!pParent->dlgInfo) - { - WIN_ReleasePtr(pParent); - break; - } - WIN_ReleasePtr(pParent); + if (!hParent || !WIN_IsCurrentProcess( hParent )) break; + if (!NtUserGetDialogInfo( hParent )) break;
hwndDlg = hParent; } @@ -1183,14 +1174,8 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg ) case VK_TAB: if (!(dlgCode & DLGC_WANTTAB)) { - BOOL fIsDialog = TRUE; - WND *pWnd = WIN_GetPtr( hwndDlg ); - - if (pWnd && pWnd != WND_OTHER_PROCESS) - { - fIsDialog = (pWnd->dlgInfo != NULL); - WIN_ReleasePtr(pWnd); - } + BOOL fIsDialog = !WIN_IsCurrentProcess( hwndDlg ) || + NtUserGetDialogInfo( hwndDlg ) != NULL;
/* I am not sure under which circumstances the TAB is handled * each way. All I do know is that it does not always simply diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 81c3c5021ab..3e2cebd99ae 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -86,8 +86,8 @@ extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UIN WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
-extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; -extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; +extern INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; +extern INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; extern void winproc_init(void) DECLSPEC_HIDDEN; extern void dispatch_win_proc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; extern void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index 5fc134c6718..e71b222ce79 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -1361,50 +1361,46 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, WPARAM wParam /********************************************************************** * WINPROC_CallDlgProcA */ -INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) +INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - WINDOWPROC *proc; LRESULT result; - INT_PTR ret; + DLGPROC func;
- if (!func) return 0; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_ANSI ))) return 0;
- if (!(proc = handle_to_proc( (WNDPROC)func ))) - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); - else if (proc == WINPROC_PROC16) + if (func == WINPROC_PROC16) { + INT_PTR ret; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_WIN16 ))) return 0; ret = wow_handlers.call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); + return ret; } - else - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
- return ret; + return call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); }
/********************************************************************** * WINPROC_CallDlgProcW */ -INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) +INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - WINDOWPROC *proc; LRESULT result; - INT_PTR ret; + DLGPROC func;
- if (!func) return 0; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_UNICODE ))) return 0;
- if (!(proc = handle_to_proc( (WNDPROC)func ))) - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); - else if (proc == WINPROC_PROC16) + if (func == WINPROC_PROC16) { + INT_PTR ret; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_WIN16 ))) return 0; ret = WINPROC_CallProcWtoA( wow_handlers.call_dialog_proc, hwnd, msg, wParam, lParam, &result, func ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); + return ret; } - else - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
- return ret; + return call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); }
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 6a3f039bc3b..5fa5436436b 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -203,6 +203,31 @@ void get_winproc_params( struct win_proc_params *params ) } }
+DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type ) +{ + WINDOWPROC *proc; + DLGPROC ret; + WND *win; + + if (!(win = get_win_ptr( hwnd ))) return NULL; + if (win == WND_OTHER_PROCESS || win == WND_DESKTOP) + { + ERR( "cannot get dlg proc %p from other process\n", hwnd ); + return 0; + } + ret = *(DLGPROC *)((char *)win->wExtra + DWLP_DLGPROC); + release_win_ptr( win ); + if (type == DLGPROC_WIN16 || !(proc = get_winproc_ptr( ret ))) return ret; + if (proc == WINPROC_PROC16) return WINPROC_PROC16; + + if (type == DLGPROC_ANSI) + ret = proc->procA ? proc->procA : proc->procW; + else + ret = proc->procW ? proc->procW : proc->procA; + + return ret; +} + /*********************************************************************** * NtUserInitializeClientPfnArrays (win32u.@) */ diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 313382505d4..ecb5ab82164 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -249,6 +249,7 @@ DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN; ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; WORD get_class_word( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; +DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type ) DECLSPEC_HIDDEN; ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN; WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN; void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 71e500abb0f..506af7530d3 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5484,6 +5484,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_GetClientRect: return get_client_rect( hwnd, (RECT *)param );
+ case NtUserCallHwndParam_GetDialogProc: + return (ULONG_PTR)get_dialog_proc( hwnd, param ); + case NtUserCallHwndParam_GetScrollInfo: { struct get_scroll_info_params *params = (void *)param; diff --git a/include/ntuser.h b/include/ntuser.h index 9ba128bdbda..c223d1f2704 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1206,6 +1206,7 @@ enum NtUserCallHwndParam_GetClassLongPtrW, NtUserCallHwndParam_GetClassWord, NtUserCallHwndParam_GetClientRect, + NtUserCallHwndParam_GetDialogProc, NtUserCallHwndParam_GetScrollInfo, NtUserCallHwndParam_GetWindowInfo, NtUserCallHwndParam_GetWindowLongA, @@ -1271,6 +1272,18 @@ static inline BOOL NtUserGetClientRect( HWND hwnd, RECT *rect ) return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetClientRect ); }
+enum dialog_proc_type +{ + DLGPROC_ANSI, + DLGPROC_UNICODE, + DLGPROC_WIN16, +}; + +static inline DLGPROC NtUserGetDialogProc( HWND hwnd, enum dialog_proc_type type ) +{ + return (DLGPROC)NtUserCallHwndParam( hwnd, type, NtUserCallHwndParam_GetDialogProc ); +} + struct get_scroll_info_params { int bar;