kernelbase: Use ioctl for WriteConsoleInputW implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-07-07 16:07:36 +02:00 committed by Alexandre Julliard
parent d04baa29e2
commit 640773aa9e
3 changed files with 11 additions and 14 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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))
{