Commit 30554d4e authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Check structure size in GetGUIThreadInfo.

parent b8d0c0dc
......@@ -160,6 +160,7 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
GetGUIThreadInfo( GetCurrentThreadId(), &info );
/* Do not change focus if the window is no more active */
if (hwnd == info.hwndActive)
......
......@@ -2359,6 +2359,7 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H
/* find the window to dispatch this mouse message to */
info.cbSize = sizeof(info);
GetGUIThreadInfo( GetCurrentThreadId(), &info );
if (info.hwndCapture)
{
......@@ -4235,6 +4236,12 @@ BOOL WINAPI GetGUIThreadInfo( DWORD id, GUITHREADINFO *info )
{
BOOL ret;
if (info->cbSize != sizeof(*info))
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
SERVER_START_REQ( get_thread_input )
{
req->tid = id;
......
......@@ -801,6 +801,7 @@ static HWND fix_caret(HWND hWnd, const RECT *scroll_rect, INT dx, INT dy,
RECT rect, mapped_rcCaret;
BOOL hide_caret = FALSE;
info.cbSize = sizeof(info);
if (!GetGUIThreadInfo( GetCurrentThreadId(), &info )) return 0;
if (!info.hwndCaret) return 0;
......
......@@ -611,6 +611,22 @@ static DWORD CALLBACK enum_thread( void *arg )
BOOL ret;
MSG msg;
if (pGetGUIThreadInfo)
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
ret = pGetGUIThreadInfo( GetCurrentThreadId(), &info );
ok( ret || broken(!ret), /* win9x */
"GetGUIThreadInfo failed without message queue\n" );
SetLastError( 0xdeadbeef );
info.cbSize = sizeof(info) + 1;
ret = pGetGUIThreadInfo( GetCurrentThreadId(), &info );
ok( !ret, "GetGUIThreadInfo succeeded with wrong size\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER ||
broken(GetLastError() == 0xdeadbeef), /* win9x */
"wrong error %u\n", GetLastError() );
}
PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */
count = 0;
......
......@@ -1587,6 +1587,7 @@ static void WIN_SendDestroyMsg( HWND hwnd )
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
if (GetGUIThreadInfo( GetCurrentThreadId(), &info ))
{
if (hwnd == info.hwndCaret) DestroyCaret();
......
......@@ -497,6 +497,7 @@ static void set_focus( Display *display, HWND hwnd, Time time )
TRACE( "setting foreground window to %p\n", hwnd );
SetForegroundWindow( hwnd );
threadinfo.cbSize = sizeof(threadinfo);
GetGUIThreadInfo(0, &threadinfo);
focus = threadinfo.hwndFocus;
if (!focus) focus = threadinfo.hwndActive;
......
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