From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/winproc.c | 32 +++------------------------- dlls/win32u/hook.c | 3 ++- dlls/win32u/message.c | 41 ++++++++++++++++++++++++++++++------ dlls/win32u/tests/win32u.c | 6 ------ dlls/win32u/win32u_private.h | 2 +- dlls/wow64win/user.c | 2 ++ 6 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index ff8f502a0c1..dc59413b048 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -754,20 +754,6 @@ static inline void *get_buffer_space( void **buffer, size_t size, size_t prev_si return *buffer; }
-/* check whether a combobox expects strings or ids in CB_ADDSTRING/CB_INSERTSTRING */ -static inline BOOL combobox_has_strings( HWND hwnd ) -{ - DWORD style = GetWindowLongA( hwnd, GWL_STYLE ); - return (!(style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) || (style & CBS_HASSTRINGS)); -} - -/* check whether a listbox expects strings or ids in LB_ADDSTRING/LB_INSERTSTRING */ -static inline BOOL listbox_has_strings( HWND hwnd ) -{ - DWORD style = GetWindowLongA( hwnd, GWL_STYLE ); - return (!(style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) || (style & LBS_HASSTRINGS)); -} - /* unpack a potentially 64-bit pointer, returning 0 when truncated */ static inline void *unpack_ptr( ULONGLONG ptr64 ) { @@ -802,7 +788,7 @@ static size_t string_size( const void *str, BOOL ansi ) BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, void **buffer, size_t size, BOOL ansi ) { - size_t minsize = 0, prev_size = size; + size_t minsize = 0; union packed_structs *ps = *buffer;
switch(message) @@ -887,23 +873,9 @@ BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, case LB_FINDSTRING: case LB_FINDSTRINGEXACT: case LB_SELECTSTRING: - break; case CB_GETLBTEXT: - { - size = sizeof(ULONG_PTR); - if (combobox_has_strings( hwnd )) - size = (SendMessageW( hwnd, CB_GETLBTEXTLEN, *wparam, 0 ) + 1) * sizeof(WCHAR); - if (!get_buffer_space( buffer, size, prev_size )) return FALSE; - break; - } case LB_GETTEXT: - { - size = sizeof(ULONG_PTR); - if (listbox_has_strings( hwnd )) - size = (SendMessageW( hwnd, LB_GETTEXTLEN, *wparam, 0 ) + 1) * sizeof(WCHAR); - if (!get_buffer_space( buffer, size, prev_size )) return FALSE; break; - } case LB_GETSELITEMS: if (!get_buffer_space( buffer, *wparam * sizeof(UINT), size )) return FALSE; break; @@ -1089,6 +1061,8 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size ) case LB_FINDSTRING: case LB_FINDSTRINGEXACT: case LB_SELECTSTRING: + case CB_GETLBTEXT: + case LB_GETTEXT: { LRESULT *result_ptr = (LRESULT *)buffer - 1; *result_ptr = result; diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c index 8fcb7ef2796..062f10c4702 100644 --- a/dlls/win32u/hook.c +++ b/dlls/win32u/hook.c @@ -246,7 +246,8 @@ static LRESULT call_hook( struct win_hook_params *info, const WCHAR *module, siz if (params->id == WH_CBT && params->code == HCBT_CREATEWND) { CBT_CREATEWNDW *cbtc = (CBT_CREATEWNDW *)params->lparam; - message_size = user_message_size( WM_NCCREATE, 0, (LPARAM)cbtc->lpcs, TRUE, FALSE ); + message_size = user_message_size( (HWND)params->wparam, WM_NCCREATE, + 0, (LPARAM)cbtc->lpcs, TRUE, FALSE ); lparam_size = lparam_ret_size = 0; }
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 0c4b69c9a09..a32d4bfa1cf 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -611,6 +611,26 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa case LB_SELECTSTRING: if (!*buffer) return TRUE; break; + case CB_GETLBTEXT: + { + size_t prev_size = size; + if (combobox_has_strings( hwnd )) + size = (send_message( hwnd, CB_GETLBTEXTLEN, *wparam, 0 ) + 1) * sizeof(WCHAR); + else + size = sizeof(ULONG_PTR); + if (!get_buffer_space( buffer, size, prev_size )) return FALSE; + break; + } + case LB_GETTEXT: + { + size_t prev_size = size; + if (listbox_has_strings( hwnd )) + size = (send_message( hwnd, LB_GETTEXTLEN, *wparam, 0 ) + 1) * sizeof(WCHAR); + else + size = sizeof(ULONG_PTR); + if (!get_buffer_space( buffer, size, prev_size )) return FALSE; + break; + } case WM_WINE_SETWINDOWPOS: { WINDOWPOS wp; @@ -1338,7 +1358,8 @@ static size_t copy_string( void *ptr, const void *str, BOOL ansi ) * * Calculate size of packed message buffer. */ -size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, BOOL other_process, BOOL ansi ) +size_t user_message_size( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, + BOOL other_process, BOOL ansi ) { const void *lparam_ptr = (const void *)lparam; size_t size = 0; @@ -1441,6 +1462,14 @@ size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, BOOL other case LB_SETTABSTOPS: size = wparam * sizeof(UINT); break; + case CB_GETLBTEXT: + size = send_message_timeout( hwnd, CB_GETLBTEXTLEN, wparam, 0, SMTO_NORMAL, 0, ansi ); + size = (size + 1) * char_size( ansi ); + break; + case LB_GETTEXT: + size = send_message_timeout( hwnd, LB_GETTEXTLEN, wparam, 0, SMTO_NORMAL, 0, ansi ); + size = (size + 1) * char_size( ansi ); + break; }
return size; @@ -1566,6 +1595,10 @@ static void copy_user_result( void *buffer, size_t size, LRESULT result, UINT me if (!result) memset( buffer, 0, char_size( ansi )); copy_size = string_size( buffer, ansi ); break; + case CB_GETLBTEXT: + case LB_GETTEXT: + copy_size = size; + break; case WM_ASKCBFORMATNAME: copy_size = string_size( buffer, ansi ); break; @@ -1627,10 +1660,6 @@ static void copy_reply( LRESULT result, HWND hwnd, UINT message, WPARAM wparam,
switch(message) { - case CB_GETLBTEXT: - case LB_GETTEXT: - copy_size = (result + 1) * sizeof(WCHAR); - break; case CB_GETCOMBOBOXINFO: copy_size = sizeof(COMBOBOXINFO); break; @@ -1854,7 +1883,7 @@ static LRESULT call_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar if (!needs_unpack) size = 0; if (!is_current_thread_window( hwnd )) return 0;
- packed_size = user_message_size( msg, wparam, lparam, needs_unpack, ansi ); + packed_size = user_message_size( hwnd, msg, wparam, lparam, needs_unpack, ansi ); if (packed_size) size = packed_size;
/* first the WH_CALLWNDPROC hook */ diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index cbda77f99ac..a435ca47bb4 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -1745,32 +1745,26 @@ static void test_wndproc_hook(void) { "CB_GETLBTEXT", CB_GETLBTEXT, .msg_result = 7, .check_result = 4, .todo_result = TRUE, .lparam_size = sizeof(strbufW), .change_lparam = strbufW, .check_lparam = strbuf4W, - .todo = TRUE }, { "CB_GETLBTEXT2", CB_GETLBTEXT, .msg_result = 9, .check_result = 8, .todo_result = TRUE, .lparam_size = sizeof(strbufW), .change_lparam = strbuf3W, .check_lparam = strbuf3W, - .todo = TRUE }, { "CB_GETLBTEXT3", CB_GETLBTEXT, .lparam_size = sizeof(strbufW), .change_lparam = strbuf3W, .check_lparam = strbuf3W, - .todo = TRUE }, { "LB_GETTEXT", LB_GETTEXT, .msg_result = 7, .check_result = 4, .todo_result = TRUE, .lparam_size = sizeof(strbufW), .change_lparam = strbufW, .check_lparam = strbuf4W, - .todo = TRUE }, { "LB_GETTEXT2", LB_GETTEXT, .msg_result = 9, .check_result = 8, .todo_result = TRUE, .lparam_size = sizeof(strbufW), .change_lparam = strbuf3W, .check_lparam = strbuf3W, - .todo = TRUE }, { "LB_GETTEXT3", LB_GETTEXT, .lparam_size = sizeof(strbufW), .change_lparam = strbuf3W, .check_lparam = strbuf3W, - .todo = TRUE }, { "WM_MDIGETACTIVE", WM_MDIGETACTIVE, .no_wparam_check = TRUE, diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index d23026876da..6380a0808c8 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -140,7 +140,7 @@ extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) extern BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN; extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT flags, UINT timeout, BOOL ansi ) DECLSPEC_HIDDEN; -extern size_t user_message_size( UINT message, WPARAM wparam, LPARAM lparam, +extern size_t user_message_size( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, BOOL other_process, BOOL ansi ) DECLSPEC_HIDDEN; extern void pack_user_message( void *buffer, size_t size, UINT message, WPARAM wparam, LPARAM lparam, BOOL ansi ) DECLSPEC_HIDDEN; diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 14b76649709..c03fd4cabf9 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -844,6 +844,8 @@ static size_t packed_result_32to64( UINT message, WPARAM wparam, const void *par case LB_GETITEMRECT: case CB_GETDROPPEDCONTROLRECT: case EM_GETLINE: + case CB_GETLBTEXT: + case LB_GETTEXT: break;
default: