Commit 6b592e81 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Use user message packing for CB_GETLBTEXT and LB_GETTEXT.

parent 216979bd
......@@ -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;
......
......@@ -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;
}
......
......@@ -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 */
......
......@@ -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,
......
......@@ -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;
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment