From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/user_private.h | 2 ++ dlls/user32/win.c | 27 +++++++++++++++++++++++++-- dlls/user32/winproc.c | 31 +++++++++++++++++++++---------- dlls/win32u/class.c | 22 +++------------------- dlls/win32u/ntuser_private.h | 2 +- dlls/win32u/sysparams.c | 3 +++ dlls/win32u/window.c | 7 ------- include/ntuser.h | 19 ++++++------------- 8 files changed, 61 insertions(+), 52 deletions(-)
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 5944187d686..a67c22cdc39 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -33,6 +33,8 @@ #define GET_DWORD(ptr) (*(const DWORD *)(ptr)) #define GET_LONG(ptr) (*(const LONG *)(ptr))
+#define WINPROC_PROC16 ((void *)1) /* placeholder for 16-bit window procs */ + /* data to store state for A/W mappings of WM_CHAR */ struct wm_char_mapping_data { diff --git a/dlls/user32/win.c b/dlls/user32/win.c index d0a34841ce0..0060247f6b6 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -626,6 +626,17 @@ DPI_AWARENESS_CONTEXT WINAPI GetWindowDpiAwarenessContext( HWND hwnd ) }
+static LONG_PTR get_window_long_ptr( HWND hwnd, int offset, LONG_PTR ret, BOOL ansi ) +{ + if (offset == DWLP_DLGPROC && NtUserGetDialogInfo( hwnd )) + { + DLGPROC proc = NtUserGetDialogProc( (DLGPROC)ret, ansi ); + if (proc && proc != WINPROC_PROC16) return (LONG_PTR)proc; + } + return ret; +} + + /*********************************************************************** * GetDpiForWindow (USER32.@) */ @@ -660,6 +671,11 @@ LONG WINAPI GetWindowLongA( HWND hwnd, INT offset ) return 0; #endif default: + if (sizeof(void *) == sizeof(LONG)) + { + LONG_PTR ret = NtUserGetWindowLongA( hwnd, offset ); + return get_window_long_ptr( hwnd, offset, ret, TRUE ); + } return NtUserGetWindowLongA( hwnd, offset ); } } @@ -681,6 +697,11 @@ LONG WINAPI GetWindowLongW( HWND hwnd, INT offset ) return 0; #endif default: + if (sizeof(void *) == sizeof(LONG)) + { + LONG_PTR ret = NtUserGetWindowLongW( hwnd, offset ); + return get_window_long_ptr( hwnd, offset, ret, FALSE ); + } return NtUserGetWindowLongW( hwnd, offset ); } } @@ -1411,7 +1432,8 @@ BOOL WINAPI SetProcessDefaultLayout( DWORD layout ) */ LONG_PTR WINAPI GetWindowLongPtrW( HWND hwnd, INT offset ) { - return NtUserGetWindowLongPtrW( hwnd, offset ); + LONG_PTR ret = NtUserGetWindowLongPtrW( hwnd, offset ); + return get_window_long_ptr( hwnd, offset, ret, FALSE ); }
/***************************************************************************** @@ -1419,7 +1441,8 @@ LONG_PTR WINAPI GetWindowLongPtrW( HWND hwnd, INT offset ) */ LONG_PTR WINAPI GetWindowLongPtrA( HWND hwnd, INT offset ) { - return NtUserGetWindowLongPtrA( hwnd, offset ); + LONG_PTR ret = NtUserGetWindowLongPtrA( hwnd, offset ); + return get_window_long_ptr( hwnd, offset, ret, TRUE ); }
/***************************************************************************** diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index a22262b037b..7e2be5b1be0 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -37,8 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msg); WINE_DECLARE_DEBUG_CHANNEL(relay);
-#define WINPROC_PROC16 ((void *)1) /* placeholder for 16-bit window procs */ - union packed_structs { struct packed_CREATESTRUCTW cs; @@ -1286,16 +1284,22 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, WPARAM wParam */ INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { + DLGPROC func, proc; LRESULT result; - DLGPROC func;
- if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_ANSI ))) return 0; +#ifdef _WIN64 + proc = (DLGPROC)NtUserGetWindowLongPtrA( hwnd, DWLP_DLGPROC ); +#else + proc = (DLGPROC)NtUserGetWindowLongA( hwnd, DWLP_DLGPROC ); +#endif + if (!proc) return 0; + if (!(func = NtUserGetDialogProc( proc, TRUE )) && + !(func = NtUserGetDialogProc( proc, FALSE ))) return 0;
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 ); + ret = wow_handlers.call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); return ret; } @@ -1309,16 +1313,23 @@ INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam */ INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { + DLGPROC func, proc; LRESULT result; - DLGPROC func;
- if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_UNICODE ))) return 0; +#ifdef _WIN64 + proc = (DLGPROC)NtUserGetWindowLongPtrW( hwnd, DWLP_DLGPROC ); +#else + proc = (DLGPROC)NtUserGetWindowLongW( hwnd, DWLP_DLGPROC ); +#endif + if (!proc) return 0; + if (!(func = NtUserGetDialogProc( proc, FALSE )) && + !(func = NtUserGetDialogProc( proc, TRUE ))) return 0;
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 ); + ret = WINPROC_CallProcWtoA( wow_handlers.call_dialog_proc, + hwnd, msg, wParam, lParam, &result, proc ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); return ret; } diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 6058617b80e..6f368b50431 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -237,29 +237,13 @@ void get_winproc_params( struct win_proc_params *params, BOOL fixup_ansi_dst ) if (!params->procW) params->procW = params->func; }
-DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type ) +DLGPROC get_dialog_proc( DLGPROC ret, BOOL ansi ) { 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 = 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; + return ansi ? proc->procA : proc->procW; }
/*********************************************************************** diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 9f93feea407..8287126258e 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -223,7 +223,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; +DLGPROC get_dialog_proc( DLGPROC proc, BOOL ansi ) 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, BOOL fixup_ansi_dst ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 52665f7a641..201004e1447 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -5054,6 +5054,9 @@ ULONG_PTR WINAPI NtUserCallTwoParam( ULONG_PTR arg1, ULONG_PTR arg2, ULONG code { switch(code) { + case NtUserCallTwoParam_GetDialogProc: + return (ULONG_PTR)get_dialog_proc( (DLGPROC)arg1, arg2 ); + case NtUserCallTwoParam_GetMenuInfo: return get_menu_info( UlongToHandle(arg1), (MENUINFO *)arg2 );
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 0aa10d9ec65..997f6359917 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1056,10 +1056,6 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans return 0; } retval = get_win_data( (char *)win->wExtra + offset, size ); - - /* Special case for dialog window procedure */ - if ((offset == DWLP_DLGPROC) && (size == sizeof(LONG_PTR)) && win->dlgInfo) - retval = (LONG_PTR)get_winproc( (WNDPROC)retval, ansi ); release_win_ptr( win ); return retval; } @@ -5481,9 +5477,6 @@ 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 326d0371998..963b02dfd8c 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1066,6 +1066,7 @@ static inline UINT NtUserSetProcessDefaultLayout( DWORD layout ) /* NtUserCallTwoParam codes, not compatible with Windows */ enum { + NtUserCallTwoParam_GetDialogProc, NtUserCallTwoParam_GetMenuInfo, NtUserCallTwoParam_GetMonitorInfo, NtUserCallTwoParam_GetSystemMetricsForDpi, @@ -1077,6 +1078,11 @@ enum NtUserAllocWinProc, };
+static inline DLGPROC NtUserGetDialogProc( DLGPROC proc, BOOL ansi ) +{ + return (DLGPROC)NtUserCallTwoParam( (UINT_PTR)proc, ansi, NtUserCallTwoParam_GetDialogProc ); +} + static inline BOOL NtUserGetMenuInfo( HMENU menu, MENUINFO *info ) { return NtUserCallTwoParam( HandleToUlong(menu), (ULONG_PTR)info, @@ -1239,7 +1245,6 @@ enum NtUserCallHwndParam_GetClassLongPtrW, NtUserCallHwndParam_GetClassWord, NtUserCallHwndParam_GetClientRect, - NtUserCallHwndParam_GetDialogProc, NtUserCallHwndParam_GetScrollInfo, NtUserCallHwndParam_GetWindowInfo, NtUserCallHwndParam_GetWindowLongA, @@ -1310,18 +1315,6 @@ 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;