Jacek Caban : kernel32: Use IOCTL_CONDRV_READ_CONSOLE in ReadConsoleW when possible.

Alexandre Julliard julliard at winehq.org
Mon Sep 14 14:58:24 CDT 2020


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Sep 14 18:46:48 2020 +0200

kernel32: Use IOCTL_CONDRV_READ_CONSOLE in ReadConsoleW when possible.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/console.c |  7 +++++++
 server/console.c        | 10 +++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index afac9be760..47083b27af 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -541,6 +541,13 @@ BOOL WINAPI ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer,
         return FALSE;
     }
 
+    if (DeviceIoControl(hConsoleInput, IOCTL_CONDRV_READ_CONSOLE, NULL, 0, lpBuffer,
+                        nNumberOfCharsToRead * sizeof(WCHAR), lpNumberOfCharsRead, NULL))
+    {
+        *lpNumberOfCharsRead /= sizeof(WCHAR);
+        return TRUE;
+    }
+
     if (!GetConsoleMode(hConsoleInput, &mode))
         return FALSE;
     if ((fd = get_console_bare_fd(hConsoleInput)) != -1)
diff --git a/server/console.c b/server/console.c
index c9db27935e..c2328f9da9 100644
--- a/server/console.c
+++ b/server/console.c
@@ -1693,7 +1693,7 @@ static struct object *create_console_server( void )
 
 static int is_blocking_read_ioctl( unsigned int code )
 {
-    return code == IOCTL_CONDRV_READ_INPUT;
+    return code == IOCTL_CONDRV_READ_INPUT || code == IOCTL_CONDRV_READ_CONSOLE;
 }
 
 static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
@@ -1898,8 +1898,12 @@ static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async *
         }
 
     default:
-        set_error( STATUS_INVALID_HANDLE );
-        return 0;
+        if (!console->server || code >> 16 != FILE_DEVICE_CONSOLE)
+        {
+            set_error( STATUS_INVALID_HANDLE );
+            return 0;
+        }
+        return queue_host_ioctl( console->server, code, 0, async, &console->ioctl_q );
     }
 }
 




More information about the wine-cvs mailing list