Commit 68b4ffeb authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernelbase: Return key state in ReadConsoleW with control.

parent ef8d44e5
...@@ -2031,7 +2031,7 @@ BOOL WINAPI ReadConsoleW( HANDLE handle, void *buffer, DWORD length, DWORD *coun ...@@ -2031,7 +2031,7 @@ BOOL WINAPI ReadConsoleW( HANDLE handle, void *buffer, DWORD length, DWORD *coun
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return FALSE; return FALSE;
} }
if (!(tmp = HeapAlloc( GetProcessHeap(), 0, sizeof(DWORD) + crc->nInitialChars * sizeof(WCHAR) ))) if (!(tmp = HeapAlloc( GetProcessHeap(), 0, sizeof(DWORD) + length * sizeof(WCHAR) )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
...@@ -2041,9 +2041,13 @@ BOOL WINAPI ReadConsoleW( HANDLE handle, void *buffer, DWORD length, DWORD *coun ...@@ -2041,9 +2041,13 @@ BOOL WINAPI ReadConsoleW( HANDLE handle, void *buffer, DWORD length, DWORD *coun
memcpy( tmp + sizeof(DWORD), buffer, crc->nInitialChars * sizeof(WCHAR) ); memcpy( tmp + sizeof(DWORD), buffer, crc->nInitialChars * sizeof(WCHAR) );
ret = console_ioctl( handle, IOCTL_CONDRV_READ_CONSOLE_CONTROL, ret = console_ioctl( handle, IOCTL_CONDRV_READ_CONSOLE_CONTROL,
tmp, sizeof(DWORD) + crc->nInitialChars * sizeof(WCHAR), tmp, sizeof(DWORD) + crc->nInitialChars * sizeof(WCHAR),
buffer, length * sizeof(WCHAR), tmp, sizeof(DWORD) + length * sizeof(WCHAR), count );
count ); if (ret)
crc->dwConsoleKeyState = 0; {
memcpy( &crc->dwConsoleKeyState, tmp, sizeof(DWORD) );
*count -= sizeof(DWORD);
memcpy( buffer, tmp + sizeof(DWORD), *count );
}
HeapFree( GetProcessHeap(), 0, tmp ); HeapFree( GetProcessHeap(), 0, tmp );
} }
else else
......
...@@ -457,6 +457,8 @@ static NTSTATUS read_complete( struct console *console, NTSTATUS status, const v ...@@ -457,6 +457,8 @@ static NTSTATUS read_complete( struct console *console, NTSTATUS status, const v
req->signal = signal; req->signal = signal;
req->read = 1; req->read = 1;
req->status = status; req->status = status;
if (console->read_ioctl == IOCTL_CONDRV_READ_CONSOLE_CONTROL)
wine_server_add_data( req, &console->key_state, sizeof(console->key_state) );
wine_server_add_data( req, buf, size ); wine_server_add_data( req, buf, size );
status = wine_server_call( req ); status = wine_server_call( req );
} }
...@@ -1250,6 +1252,7 @@ static NTSTATUS process_console_input( struct console *console ) ...@@ -1250,6 +1252,7 @@ static NTSTATUS process_console_input( struct console *console )
struct edit_line *ctx = &console->edit_line; struct edit_line *ctx = &console->edit_line;
unsigned int i; unsigned int i;
WCHAR ctrl_value = FIRST_NON_CONTROL_CHAR; WCHAR ctrl_value = FIRST_NON_CONTROL_CHAR;
unsigned int ctrl_keyvalue = 0;
switch (console->read_ioctl) switch (console->read_ioctl)
{ {
...@@ -1297,6 +1300,7 @@ static NTSTATUS process_console_input( struct console *console ) ...@@ -1297,6 +1300,7 @@ static NTSTATUS process_console_input( struct console *console )
if (ctx->ctrl_mask & (1u << ir.Event.KeyEvent.uChar.UnicodeChar)) if (ctx->ctrl_mask & (1u << ir.Event.KeyEvent.uChar.UnicodeChar))
{ {
ctrl_value = ir.Event.KeyEvent.uChar.UnicodeChar; ctrl_value = ir.Event.KeyEvent.uChar.UnicodeChar;
ctrl_keyvalue = ir.Event.KeyEvent.dwControlKeyState;
ctx->status = STATUS_SUCCESS; ctx->status = STATUS_SUCCESS;
TRACE("Found ctrl char in mask: ^%lc %x\n", ir.Event.KeyEvent.uChar.UnicodeChar + '@', ctx->ctrl_mask); TRACE("Found ctrl char in mask: ^%lc %x\n", ir.Event.KeyEvent.uChar.UnicodeChar + '@', ctx->ctrl_mask);
continue; continue;
...@@ -1363,6 +1367,7 @@ static NTSTATUS process_console_input( struct console *console ) ...@@ -1363,6 +1367,7 @@ static NTSTATUS process_console_input( struct console *console )
if (ctrl_value < FIRST_NON_CONTROL_CHAR) if (ctrl_value < FIRST_NON_CONTROL_CHAR)
{ {
edit_line_insert( console, &ctrl_value, 1 ); edit_line_insert( console, &ctrl_value, 1 );
console->key_state = ctrl_keyvalue;
} }
else else
{ {
...@@ -1404,6 +1409,7 @@ static NTSTATUS read_console( struct console *console, unsigned int ioctl, size_ ...@@ -1404,6 +1409,7 @@ static NTSTATUS read_console( struct console *console, unsigned int ioctl, size_
} }
console->read_ioctl = ioctl; console->read_ioctl = ioctl;
console->key_state = 0;
if (!out_size || console->read_buffer_count) if (!out_size || console->read_buffer_count)
{ {
read_from_buffer( console, out_size ); read_from_buffer( console, out_size );
...@@ -2562,10 +2568,10 @@ static NTSTATUS console_input_ioctl( struct console *console, unsigned int code, ...@@ -2562,10 +2568,10 @@ static NTSTATUS console_input_ioctl( struct console *console, unsigned int code,
case IOCTL_CONDRV_READ_CONSOLE_CONTROL: case IOCTL_CONDRV_READ_CONSOLE_CONTROL:
if ((in_size < sizeof(DWORD)) || ((in_size - sizeof(DWORD)) % sizeof(WCHAR)) || if ((in_size < sizeof(DWORD)) || ((in_size - sizeof(DWORD)) % sizeof(WCHAR)) ||
(*out_size % sizeof(WCHAR))) (*out_size < sizeof(DWORD)) || ((*out_size - sizeof(DWORD)) % sizeof(WCHAR)))
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
ensure_tty_input_thread( console ); ensure_tty_input_thread( console );
status = read_console( console, code, *out_size, status = read_console( console, code, *out_size - sizeof(DWORD),
(const WCHAR*)((const char*)in_data + sizeof(DWORD)), (const WCHAR*)((const char*)in_data + sizeof(DWORD)),
(in_size - sizeof(DWORD)) / sizeof(WCHAR), (in_size - sizeof(DWORD)) / sizeof(WCHAR),
*(DWORD*)in_data ); *(DWORD*)in_data );
......
...@@ -88,6 +88,7 @@ struct console ...@@ -88,6 +88,7 @@ struct console
unsigned int read_ioctl; /* current read ioctl */ unsigned int read_ioctl; /* current read ioctl */
size_t pending_read; /* size of pending read buffer */ size_t pending_read; /* size of pending read buffer */
struct edit_line edit_line; /* edit line context */ struct edit_line edit_line; /* edit line context */
unsigned int key_state;
struct console_window *window; struct console_window *window;
WCHAR *title; /* console title */ WCHAR *title; /* console title */
struct history_line **history; /* lines history */ struct history_line **history; /* lines history */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment