From 640773aa9ee64201dd4985254bb259b14f7f640b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 7 Jul 2020 16:07:36 +0200 Subject: [PATCH] kernelbase: Use ioctl for WriteConsoleInputW implementation. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/kernelbase/console.c | 21 +++++++-------------- include/wine/condrv.h | 1 + server/console.c | 3 +++ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 59285f75e18..f5612de4075 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -1501,9 +1501,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputA( HANDLE handle, const INPUT_REC BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputW( HANDLE handle, const INPUT_RECORD *buffer, DWORD count, DWORD *written ) { - DWORD events_written = 0; - BOOL ret; - TRACE( "(%p,%p,%d,%p)\n", handle, buffer, count, written ); if (count > 0 && !buffer) @@ -1511,21 +1508,17 @@ BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleInputW( HANDLE handle, const INPUT_REC SetLastError( ERROR_INVALID_ACCESS ); return FALSE; } - SERVER_START_REQ( write_console_input ) - { - req->handle = console_handle_unmap( handle ); - wine_server_add_data( req, buffer, count * sizeof(INPUT_RECORD) ); - if ((ret = !wine_server_call_err( req ))) events_written = reply->written; - } - SERVER_END_REQ; - if (written) *written = events_written; - else + if (!DeviceIoControl( handle, IOCTL_CONDRV_WRITE_INPUT, (void *)buffer, count * sizeof(*buffer), NULL, 0, NULL, NULL )) + return FALSE; + + if (!written) { SetLastError( ERROR_INVALID_ACCESS ); - ret = FALSE; + return FALSE; } - return ret; + *written = count; + return TRUE; } diff --git a/include/wine/condrv.h b/include/wine/condrv.h index 3dc6e9714ee..f0f6d2ea585 100644 --- a/include/wine/condrv.h +++ b/include/wine/condrv.h @@ -25,6 +25,7 @@ /* console input ioctls */ #define IOCTL_CONDRV_READ_INPUT CTL_CODE(FILE_DEVICE_CONSOLE, 10, METHOD_BUFFERED, FILE_READ_ACCESS) +#define IOCTL_CONDRV_WRITE_INPUT CTL_CODE(FILE_DEVICE_CONSOLE, 11, METHOD_BUFFERED, FILE_WRITE_PROPERTIES) #define IOCTL_CONDRV_PEEK CTL_CODE(FILE_DEVICE_CONSOLE, 12, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_CONDRV_GET_INPUT_INFO CTL_CODE(FILE_DEVICE_CONSOLE, 13, METHOD_BUFFERED, FILE_READ_PROPERTIES) diff --git a/server/console.c b/server/console.c index 658ce97311c..57234d3b408 100644 --- a/server/console.c +++ b/server/console.c @@ -1537,6 +1537,9 @@ static int console_ioctl( struct fd *fd, ioctl_code_t code, struct async *async return read_console_input( console, async, 1 ); } + case IOCTL_CONDRV_WRITE_INPUT: + return write_console_input( console, get_req_data_size() / sizeof(INPUT_RECORD), get_req_data() ) != -1; + case IOCTL_CONDRV_PEEK: if (get_reply_max_size() % sizeof(INPUT_RECORD)) {