Threads inherit WinEvent hooks, which means that checking GetCurrentThreadId() inside of win_event_proc will fail when run in another thread. So, store the thread id of the thread we're watching.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/user32/tests/msg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index f4d38dc966c..2305fab4c07 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -110,6 +110,7 @@ static HWINEVENTHOOK hEvent_hook; static HHOOK hKBD_hook; static HHOOK hCBT_hook; static DWORD cbt_hook_thread_id; +static DWORD winevent_hook_thread_id;
static const WCHAR testWindowClassW[] = { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 }; @@ -10338,7 +10339,7 @@ static void CALLBACK win_event_proc(HWINEVENTHOOK hevent, DWORD thread_id, DWORD event_time) { - ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n"); + ok(thread_id == winevent_hook_thread_id, "we didn't ask for events from other threads\n");
/* ignore mouse cursor events */ if (object_id == OBJID_CURSOR) return; @@ -18529,7 +18530,7 @@ START_TEST(msg) } if (!hEvent_hook) win_skip( "no win event hook support\n" );
- cbt_hook_thread_id = GetCurrentThreadId(); + cbt_hook_thread_id = winevent_hook_thread_id = GetCurrentThreadId(); hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId()); if (!hCBT_hook) win_skip( "cannot set global hook, will skip hook tests\n" );