From ab6056d6774310162ef268ca6af5e3ad2e556a4e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 11 Sep 2020 14:31:07 +0200 Subject: [PATCH] kernel32: Use IOCTL_CONDRV_WRITE_CONSOLE in WriteConsoleW when possible. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/kernel32/console.c | 7 +++++++ server/console.c | 9 +++++++-- server/trace.c | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 5b5722847fb..afac9be7605 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -794,6 +794,13 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber if (lpNumberOfCharsWritten) *lpNumberOfCharsWritten = 0; + if (DeviceIoControl(hConsoleOutput, IOCTL_CONDRV_WRITE_CONSOLE, (void *)lpBuffer, + nNumberOfCharsToWrite * sizeof(WCHAR), NULL, 0, NULL, NULL)) + { + if (lpNumberOfCharsWritten) *lpNumberOfCharsWritten = nNumberOfCharsToWrite; + return TRUE; + } + if ((fd = get_console_bare_fd(hConsoleOutput)) != -1) { char* ptr; diff --git a/server/console.c b/server/console.c index 6a4a0b60d5f..c9db27935e6 100644 --- a/server/console.c +++ b/server/console.c @@ -2106,8 +2106,13 @@ static int screen_buffer_ioctl( struct fd *fd, ioctl_code_t code, struct async * } default: - set_error( STATUS_INVALID_HANDLE ); - return 0; + if (!screen_buffer->input || !screen_buffer->input->server || code >> 16 != FILE_DEVICE_CONSOLE) + { + set_error( STATUS_INVALID_HANDLE ); + return 0; + } + return queue_host_ioctl( screen_buffer->input->server, code, screen_buffer->id, + async, &screen_buffer->ioctl_q ); } } diff --git a/server/trace.c b/server/trace.c index a0174a1bd6a..c93e4fe3b4e 100644 --- a/server/trace.c +++ b/server/trace.c @@ -128,6 +128,7 @@ static void dump_ioctl_code( const char *prefix, const ioctl_code_t *code ) CASE(IOCTL_CONDRV_READ_OUTPUT); CASE(IOCTL_CONDRV_SET_MODE); CASE(IOCTL_CONDRV_SET_OUTPUT_INFO); + CASE(IOCTL_CONDRV_WRITE_CONSOLE); CASE(IOCTL_CONDRV_WRITE_INPUT); CASE(IOCTL_CONDRV_WRITE_OUTPUT); CASE(FSCTL_DISMOUNT_VOLUME);