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

Alexandre Julliard julliard at winehq.org
Thu Dec 12 16:29:41 CST 2019


Module: wine
Branch: master
Commit: 1ec0769cf6d029bc4a088a7e3354fe3152ab5354
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1ec0769cf6d029bc4a088a7e3354fe3152ab5354

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 12 11:47:00 2019 +0100

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

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernelbase/sync.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c
index b64c43dc05..0ae3aadde9 100644
--- a/dlls/kernelbase/sync.c
+++ b/dlls/kernelbase/sync.c
@@ -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;
 }
 




More information about the wine-cvs mailing list