kernelbase: Use a direct server call instead of GetConsoleInputWaitHandle().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-12-12 11:47:00 +01:00
parent 4118697829
commit 1ec0769cf6
1 changed files with 18 additions and 2 deletions

View File

@ -37,6 +37,7 @@
#include "kernelbase.h"
#include "wine/asm.h"
#include "wine/exception.h"
#include "wine/server.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(sync);
@ -128,6 +129,8 @@ static BOOL get_open_object_attributes( OBJECT_ATTRIBUTES *attr, UNICODE_STRING
static HANDLE normalize_handle_if_console( HANDLE handle )
{
static HANDLE wait_event;
if ((handle == (HANDLE)STD_INPUT_HANDLE) ||
(handle == (HANDLE)STD_OUTPUT_HANDLE) ||
(handle == (HANDLE)STD_ERROR_HANDLE))
@ -136,9 +139,22 @@ static HANDLE normalize_handle_if_console( HANDLE handle )
/* even screen buffer console handles are waitable, and are
* handled as a handle to the console itself
*/
if (is_console_handle( handle ) && VerifyConsoleIoHandle( handle ))
handle = GetConsoleInputWaitHandle();
if (is_console_handle( handle ))
{
HANDLE event = 0;
SERVER_START_REQ( get_console_wait_event )
{
req->handle = wine_server_obj_handle( console_handle_map( handle ));
if (!wine_server_call( req )) event = wine_server_ptr_handle( reply->event );
}
SERVER_END_REQ;
if (event)
{
if (InterlockedCompareExchangePointer( &wait_event, event, 0 )) NtClose( event );
handle = wait_event;
}
}
return handle;
}