Commit f5f633e7 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

server: Validate the filter window handle in get_message.

parent 7c768d90
......@@ -12173,6 +12173,31 @@ todo_wine {
qstatus = GetQueueStatus(qs_all_input);
ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
}
PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0);
ret = PeekMessageA(&msg, (HWND)-1, 0, 0, PM_NOREMOVE);
ok(ret == TRUE, "wrong ret %d\n", ret);
ok(msg.message == WM_USER, "wrong message %u\n", msg.message);
ret = GetMessageA(&msg, (HWND)-1, 0, 0);
ok(ret == TRUE, "wrong ret %d\n", ret);
ok(msg.message == WM_USER, "wrong message %u\n", msg.message);
PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0);
ret = PeekMessageA(&msg, (HWND)1, 0, 0, PM_NOREMOVE);
ok(ret == TRUE, "wrong ret %d\n", ret);
ok(msg.message == WM_USER, "wrong message %u\n", msg.message);
ret = GetMessageA(&msg, (HWND)1, 0, 0);
ok(ret == TRUE, "wrong ret %d\n", ret);
ok(msg.message == WM_USER, "wrong message %u\n", msg.message);
PostThreadMessageA(GetCurrentThreadId(), WM_USER, 0, 0);
ret = PeekMessageA(&msg, (HWND)0xffff, 0, 0, PM_NOREMOVE);
ok(ret == TRUE, "wrong ret %d\n", ret);
ok(msg.message == WM_USER, "wrong message %u\n", msg.message);
ret = GetMessageA(&msg, (HWND)0xffff, 0, 0);
ok(ret == TRUE, "wrong ret %d\n", ret);
ok(msg.message == WM_USER, "wrong message %u\n", msg.message);
done:
trace("signalling to exit\n");
SetEvent(info.hevent[EV_STOP]);
......@@ -17666,6 +17691,22 @@ done:
DestroyWindow(hwnd);
}
static void test_invalid_window(void)
{
MSG msg;
BOOL ret;
SetLastError(0xdeadbeef);
ret = GetMessageA(&msg, (HWND)0xdeadbeef, 0, 0);
ok(ret == -1, "wrong ret %d\n", ret);
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = PeekMessageA(&msg, (HWND)0xdeadbeef, 0, 0, PM_REMOVE);
ok(!ret, "wrong ret %d\n", ret);
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError());
}
static void init_funcs(void)
{
HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
......@@ -17791,6 +17832,7 @@ START_TEST(msg)
test_notify_message();
test_SetActiveWindow();
test_restore_messages();
test_invalid_window();
if (!pTrackMouseEvent)
win_skip("TrackMouseEvent is not available\n");
......
......@@ -2394,6 +2394,12 @@ DECL_HANDLER(get_message)
reply->active_hooks = get_active_hooks();
if (get_win && get_win != 1 && get_win != -1 && !get_user_object( get_win, USER_WINDOW ))
{
set_win32_error( ERROR_INVALID_WINDOW_HANDLE );
return;
}
if (!queue) return;
queue->last_get_msg = current_time;
if (!filter) filter = QS_ALLINPUT;
......
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