Module: wine Branch: master Commit: fda954dfd4f1a0d07ca151324b9eaedc1f09964d URL: https://gitlab.winehq.org/wine/wine/-/commit/fda954dfd4f1a0d07ca151324b9eaed...
Author: Eric Pouech eric.pouech@gmail.com Date: Wed Dec 21 10:48:28 2022 +0100
conhost.exe: Handle ctrl-pause/break key strokes.
Note: this patch should be extended by adding insertion of the CTRL_BREAK_EVENT into processes' crtl handler (as it's done for CTRL_C_EVENT).
Signed-off-by: Eric Pouech eric.pouech@gmail.com
---
programs/conhost/conhost.c | 31 +++++++++++++++++++++++++++---- server/console.c | 8 +++++--- 2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 800e8bab822..0bc6abe657c 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -1463,6 +1463,29 @@ static NTSTATUS read_console( struct console *console, unsigned int ioctl, size_ return process_console_input( console ); }
+static BOOL map_to_ctrlevent( struct console *console, const INPUT_RECORD *record, + unsigned int* event) +{ + if (record->EventType == KEY_EVENT) + { + if (record->Event.KeyEvent.uChar.UnicodeChar == 'C' - 64 && + !(record->Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) + { + *event = CTRL_C_EVENT; + return TRUE; + } + /* we want to get ctrl-pause/break, but it's already translated by user32 into VK_CANCEL */ + if (record->Event.KeyEvent.uChar.UnicodeChar == 0 && + record->Event.KeyEvent.wVirtualKeyCode == VK_CANCEL && + record->Event.KeyEvent.dwControlKeyState == LEFT_CTRL_PRESSED) + { + *event = CTRL_BREAK_EVENT; + return TRUE; + } + } + return FALSE; +} + /* add input events to a console input queue */ NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *records, unsigned int count, BOOL flush ) @@ -1485,9 +1508,9 @@ NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *recor unsigned int i = 0; while (i < count) { - if (records[i].EventType == KEY_EVENT && - records[i].Event.KeyEvent.uChar.UnicodeChar == 'C' - 64 && - !(records[i].Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) + unsigned int event; + + if (map_to_ctrlevent(console, &records[i], &event)) { if (i != count - 1) memcpy( &console->records[console->record_count + i], @@ -1499,7 +1522,7 @@ NTSTATUS write_console_input( struct console *console, const INPUT_RECORD *recor struct condrv_ctrl_event ctrl_event; IO_STATUS_BLOCK io;
- ctrl_event.event = CTRL_C_EVENT; + ctrl_event.event = event; ctrl_event.group_id = 0; NtDeviceIoControlFile( console->server, NULL, NULL, NULL, &io, IOCTL_CONDRV_CTRL_EVENT, &ctrl_event, sizeof(ctrl_event), NULL, 0 ); diff --git a/server/console.c b/server/console.c index 5f3f50d006f..34f8d09408f 100644 --- a/server/console.c +++ b/server/console.c @@ -694,14 +694,16 @@ static void propagate_console_signal( struct console *console, set_error( STATUS_INVALID_PARAMETER ); return; } - /* FIXME: should support the other events (like CTRL_BREAK) */ - if (sig != CTRL_C_EVENT) + switch (sig) { + case CTRL_C_EVENT: csi.signal = SIGINT; break; + case CTRL_BREAK_EVENT: csi.signal = SIGQUIT; break; + default: + /* FIXME: should support the other events */ set_error( STATUS_NOT_IMPLEMENTED ); return; } csi.console = console; - csi.signal = SIGINT; csi.group = group_id;
enum_processes(propagate_console_signal_cb, &csi);