Alexandre Julliard : user32: Check structure size in GetGUIThreadInfo.
Alexandre Julliard
julliard at winehq.org
Wed Nov 17 10:38:01 CST 2010
Module: wine
Branch: master
Commit: 30554d4ef12038e07961b16013c5dacb0fca3503
URL: http://source.winehq.org/git/wine.git/?a=commit;h=30554d4ef12038e07961b16013c5dacb0fca3503
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Nov 16 20:57:27 2010 +0100
user32: Check structure size in GetGUIThreadInfo.
---
dlls/user32/focus.c | 1 +
dlls/user32/message.c | 7 +++++++
dlls/user32/painting.c | 1 +
dlls/user32/tests/win.c | 16 ++++++++++++++++
dlls/user32/win.c | 1 +
dlls/winex11.drv/event.c | 1 +
6 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index f086584..70a2a8a 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -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)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index b073e1c..c6daf31 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -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;
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c
index e7ce2ec..c3a25fb 100644
--- a/dlls/user32/painting.c
+++ b/dlls/user32/painting.c
@@ -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;
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 5a378de..ab06687 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -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;
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index f9b6be2..f1da48b 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -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();
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index ae0875b..5447a40 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -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;
More information about the wine-cvs
mailing list