From e43f51640a49683098de02bac0e31e10cb23b555 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 1 Jul 2020 16:27:22 +0200 Subject: [PATCH] kernel32: Return standard input handle in GetConsoleInputWaitHandle. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/kernel32/console.c | 17 +---------------- dlls/kernel32/tests/console.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index ba3e4b0dd88..9414e6e2a36 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -76,9 +76,6 @@ static CRITICAL_SECTION CONSOLE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 }; static const WCHAR coninW[] = {'C','O','N','I','N','$',0}; static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0}; -/* FIXME: this is not thread safe */ -static HANDLE console_wait_event; - /* map input records to ASCII */ static void input_records_WtoA( INPUT_RECORD *buffer, int count ) { @@ -302,16 +299,7 @@ BOOL WINAPI CloseConsoleHandle(HANDLE handle) */ HANDLE WINAPI GetConsoleInputWaitHandle(void) { - if (!console_wait_event) - { - SERVER_START_REQ(get_console_wait_event) - { - if (!wine_server_call_err( req )) - console_wait_event = wine_server_ptr_handle( reply->event ); - } - SERVER_END_REQ; - } - return console_wait_event; + return GetStdHandle( STD_INPUT_HANDLE ); } @@ -630,9 +618,6 @@ BOOL WINAPI AllocConsole(void) return FALSE; } - /* invalidate local copy of input event handle */ - console_wait_event = 0; - GetStartupInfoA(&siCurrent); memset(&siConsole, 0, sizeof(siConsole)); diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 50f80314f0f..45951afef84 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -30,6 +30,8 @@ static HANDLE (WINAPI *pOpenConsoleW)(LPCWSTR,DWORD,BOOL,DWORD); static BOOL (WINAPI *pSetConsoleInputExeNameA)(LPCSTR); static BOOL (WINAPI *pVerifyConsoleIoHandle)(HANDLE handle); +static BOOL skip_nt; + /* DEFAULT_ATTRIB is used for all initial filling of the console. * all modifications are made with TEST_ATTRIB so that we could check * what has to be modified or not @@ -1267,7 +1269,6 @@ static void test_CreateFileW(void) UNICODE_STRING string; IO_STATUS_BLOCK iosb; NTSTATUS status; - BOOL skip_nt = FALSE; for (index = 0; index < ARRAY_SIZE(cf_table); index++) { @@ -3225,6 +3226,16 @@ static void test_FreeConsole(void) ok(handle == INVALID_HANDLE_VALUE && (GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* winxp */)), "CreateFileA failed: %u\n", GetLastError()); + + if (!skip_nt) + { + SetStdHandle( STD_INPUT_HANDLE, (HANDLE)0xdeadbeef ); + handle = GetConsoleInputWaitHandle(); + ok(handle == (HANDLE)0xdeadbeef, "GetConsoleInputWaitHandle returned %p\n", handle); + SetStdHandle( STD_INPUT_HANDLE, NULL ); + handle = GetConsoleInputWaitHandle(); + ok(!handle, "GetConsoleInputWaitHandle returned %p\n", handle); + } } static void test_SetConsoleScreenBufferInfoEx(HANDLE std_output)