diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 69bf2e8c0ac..625ecdcbae6 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -272,6 +272,8 @@ HWND WINAPI GetCapture(void) */ SHORT WINAPI GetAsyncKeyState(INT nKey) { + if (nKey < 0 || nKey > 256) + return 0; return USER_Driver->pGetAsyncKeyState( nKey ); } diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 8211cdb6c41..a242fbabb25 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1240,6 +1240,13 @@ static void test_ToUnicode(void) todo_wine ok(ret == 0, "ToUnicode for CTRL + SHIFT + Return didn't return 0 (was %i)\n", ret); } +static void test_get_async_key_state(void) +{ + /* input value sanity checks */ + ok(0 == GetAsyncKeyState(1000000), "GetAsyncKeyState did not return 0\n"); + ok(0 == GetAsyncKeyState(-1000000), "GetAsyncKeyState did not return 0\n"); +} + START_TEST(input) { init_function_pointers(); @@ -1254,6 +1261,7 @@ START_TEST(input) test_mouse_ll_hook(); test_key_map(); test_ToUnicode(); + test_get_async_key_state(); if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx();