From b9740fcf4b57204ebc4ea1c52a01a16e3948af6f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 19 Jul 2023 00:49:42 +0200 Subject: [PATCH] win32u: Move more of unpack_message implementation from user32. --- dlls/user32/user_private.h | 2 +- dlls/user32/winproc.c | 127 ++++--------------------------------- dlls/win32u/message.c | 43 +++++++++++++ 3 files changed, 56 insertions(+), 116 deletions(-) diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 1a467712f0e..9330174a778 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -51,7 +51,7 @@ extern BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM const void *buffer, size_t size ) DECLSPEC_HIDDEN; extern void free_cached_data( UINT format, HANDLE handle ) DECLSPEC_HIDDEN; extern HANDLE render_synthesized_format( UINT format, UINT from ) DECLSPEC_HIDDEN; -extern BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, +extern void unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, void *buffer, size_t size, BOOL ansi ); extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index 7d53269dc80..d0ebbb5ea8d 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -176,8 +176,7 @@ LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg, { LRESULT ret = 0; - TRACE_(msg)("(hwnd=%p,msg=%s,wp=%08Ix,lp=%08Ix)\n", - hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam); + TRACE( "(hwnd=%p,msg=%s,wp=%08Ix,lp=%08Ix)\n", hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam ); switch(msg) { @@ -415,8 +414,8 @@ LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg, case WM_PAINTCLIPBOARD: case WM_SIZECLIPBOARD: - FIXME_(msg)( "message %s (0x%x) needs translation, please report\n", - SPY_GetMsgName(msg, hwnd), msg ); + FIXME( "message %s (0x%x) needs translation, please report\n", + SPY_GetMsgName(msg, hwnd), msg ); break; default: @@ -437,8 +436,7 @@ static LRESULT WINPROC_CallProcWtoA( winproc_callback_t callback, HWND hwnd, UIN { LRESULT ret = 0; - TRACE_(msg)("(hwnd=%p,msg=%s,wp=%08Ix,lp=%08Ix)\n", - hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam); + TRACE( "(hwnd=%p,msg=%s,wp=%08Ix,lp=%08Ix)\n", hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam ); switch(msg) { @@ -683,8 +681,8 @@ static LRESULT WINPROC_CallProcWtoA( winproc_callback_t callback, HWND hwnd, UIN case WM_PAINTCLIPBOARD: case WM_SIZECLIPBOARD: - FIXME_(msg)( "message %s (%04x) needs translation, please report\n", - SPY_GetMsgName(msg, hwnd), msg ); + FIXME( "message %s (%04x) needs translation, please report\n", + SPY_GetMsgName(msg, hwnd), msg ); break; default: @@ -738,13 +736,11 @@ static size_t string_size( const void *str, BOOL ansi ) /*********************************************************************** * unpack_message * - * Unpack a message received from another process. + * Unpack a message received from win32u. */ -BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, +void unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, void *buffer, size_t size, BOOL ansi ) { - size_t minsize = 0; - switch(message) { case WM_NCCREATE: @@ -784,7 +780,7 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, DWORD *ptr = buffer; *wparam = (WPARAM)ptr++; *lparam = (LPARAM)ptr; - return TRUE; + return; } case WM_MDICREATE: { @@ -802,108 +798,9 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, } break; } - case WM_GETTEXT: - case WM_ASKCBFORMATNAME: - case WM_WININICHANGE: - case WM_SETTEXT: - case WM_DEVMODECHANGE: - case CB_DIR: - case LB_DIR: - case LB_ADDFILE: - case EM_REPLACESEL: - case WM_GETMINMAXINFO: - case WM_DRAWITEM: - case WM_MEASUREITEM: - case WM_DELETEITEM: - case WM_COMPAREITEM: - case WM_WINDOWPOSCHANGING: - case WM_WINDOWPOSCHANGED: - case WM_HELP: - case WM_STYLECHANGING: - case WM_STYLECHANGED: - case WM_GETDLGCODE: - case SBM_SETSCROLLINFO: - case SBM_GETSCROLLINFO: - case SBM_GETSCROLLBARINFO: - case EM_GETRECT: - case LB_GETITEMRECT: - case CB_GETDROPPEDCONTROLRECT: - case EM_SETRECT: - case EM_SETRECTNP: - case EM_GETLINE: - case EM_SETTABSTOPS: - case LB_SETTABSTOPS: - case CB_ADDSTRING: - case CB_INSERTSTRING: - case CB_FINDSTRING: - case CB_FINDSTRINGEXACT: - case CB_SELECTSTRING: - case LB_ADDSTRING: - case LB_INSERTSTRING: - case LB_FINDSTRING: - case LB_FINDSTRINGEXACT: - case LB_SELECTSTRING: - case CB_GETLBTEXT: - case LB_GETTEXT: - case LB_GETSELITEMS: - case WM_NEXTMENU: - case WM_SIZING: - case WM_MOVING: - case CB_GETCOMBOBOXINFO: - case WM_MDIGETACTIVE: - case WM_DEVICECHANGE: - break; - case WM_NOTIFY: - /* WM_NOTIFY cannot be sent across processes (MSDN) */ - return FALSE; - case WM_NCPAINT: - if (*wparam <= 1) return TRUE; - FIXME( "WM_NCPAINT hdc unpacking not supported\n" ); - return FALSE; - case WM_PAINT: - if (!*wparam) return TRUE; - /* fall through */ - - /* these contain an HFONT */ - case WM_SETFONT: - case WM_GETFONT: - /* these contain an HDC */ - case WM_ERASEBKGND: - case WM_ICONERASEBKGND: - case WM_CTLCOLORMSGBOX: - case WM_CTLCOLOREDIT: - case WM_CTLCOLORLISTBOX: - case WM_CTLCOLORBTN: - case WM_CTLCOLORDLG: - case WM_CTLCOLORSCROLLBAR: - case WM_CTLCOLORSTATIC: - case WM_PRINT: - case WM_PRINTCLIENT: - /* these contain an HGLOBAL */ - case WM_PAINTCLIPBOARD: - case WM_SIZECLIPBOARD: - /* these contain HICON */ - case WM_GETICON: - case WM_SETICON: - case WM_QUERYDRAGICON: - case WM_QUERYPARKICON: - /* these contain pointers */ - case WM_DROPOBJECT: - case WM_QUERYDROPOBJECT: - case WM_DRAGLOOP: - case WM_DRAGSELECT: - case WM_DRAGMOVE: - FIXME( "msg %x (%s) not supported yet\n", message, SPY_GetMsgName(message, hwnd) ); - return FALSE; - - default: - return TRUE; /* message doesn't need any unpacking */ } - /* default exit for most messages: check minsize and store buffer in lparam */ - if (size < minsize) return FALSE; *lparam = (LPARAM)buffer; - return TRUE; } BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size ) @@ -917,9 +814,9 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size ) size -= sizeof(*params); buffer = params + 1; - if (!unpack_message( params->hwnd, params->msg, ¶ms->wparam, - ¶ms->lparam, buffer, size, params->ansi )) - return 0; + if (size) + unpack_message( params->hwnd, params->msg, ¶ms->wparam, + ¶ms->lparam, buffer, size, params->ansi ); result = dispatch_win_proc_params( params ); diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 56a05ba7eac..6e5b686c32e 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -880,6 +880,49 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa if (!(*wparam & 0x8000)) return TRUE; minsize = sizeof(DEV_BROADCAST_HDR); break; + case WM_NOTIFY: + /* WM_NOTIFY cannot be sent across processes (MSDN) */ + return FALSE; + case WM_NCPAINT: + if (*wparam <= 1) return TRUE; + FIXME( "WM_NCPAINT hdc unpacking not supported\n" ); + return FALSE; + case WM_PAINT: + if (!*wparam) return TRUE; + /* fall through */ + + /* these contain an HFONT */ + case WM_SETFONT: + case WM_GETFONT: + /* these contain an HDC */ + case WM_ERASEBKGND: + case WM_ICONERASEBKGND: + case WM_CTLCOLORMSGBOX: + case WM_CTLCOLOREDIT: + case WM_CTLCOLORLISTBOX: + case WM_CTLCOLORBTN: + case WM_CTLCOLORDLG: + case WM_CTLCOLORSCROLLBAR: + case WM_CTLCOLORSTATIC: + case WM_PRINT: + case WM_PRINTCLIENT: + /* these contain an HGLOBAL */ + case WM_PAINTCLIPBOARD: + case WM_SIZECLIPBOARD: + /* these contain HICON */ + case WM_GETICON: + case WM_SETICON: + case WM_QUERYDRAGICON: + case WM_QUERYPARKICON: + /* these contain pointers */ + case WM_DROPOBJECT: + case WM_QUERYDROPOBJECT: + case WM_DRAGLOOP: + case WM_DRAGSELECT: + case WM_DRAGMOVE: + FIXME( "msg %x (%s) not supported yet\n", message, debugstr_msg_name( message, hwnd )); + return FALSE; + default: return TRUE; /* message doesn't need any unpacking */ }