From 810873eb7561e147dff871aa20315e930d1f01bb Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 22 Sep 2020 16:48:04 +0200 Subject: [PATCH] kernel32: Move Beep implementation to conhost. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/kernel32/console.c | 17 +++-------------- include/wine/condrv.h | 1 + programs/conhost/conhost.c | 9 +++++++++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index fc83b2db12a..24f86a9e516 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -23,21 +23,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -/* Reference applications: - * - IDA (interactive disassembler) full version 3.75. Works. - * - LYNX/W32. Works mostly, some keys crash it. - */ - -#include "config.h" -#include "wine/port.h" - #include #include #include #include -#ifdef HAVE_UNISTD_H -# include -#endif #define NONAMELESSUNION #include "ntstatus.h" @@ -84,9 +73,9 @@ HWND WINAPI GetConsoleWindow(void) */ BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur ) { - static const char beep = '\a'; - /* dwFreq and dwDur are ignored by Win95 */ - if (isatty(2)) write( 2, &beep, 1 ); + /* FIXME: we should not require a console to be attached */ + DeviceIoControl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, + IOCTL_CONDRV_BEEP, NULL, 0, NULL, 0, NULL, NULL ); return TRUE; } diff --git a/include/wine/condrv.h b/include/wine/condrv.h index a5633998db0..dd870c2157d 100644 --- a/include/wine/condrv.h +++ b/include/wine/condrv.h @@ -38,6 +38,7 @@ #define IOCTL_CONDRV_GET_TITLE CTL_CODE(FILE_DEVICE_CONSOLE, 16, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_CONDRV_SET_TITLE CTL_CODE(FILE_DEVICE_CONSOLE, 17, METHOD_BUFFERED, FILE_WRITE_ACCESS) #define IOCTL_CONDRV_CTRL_EVENT CTL_CODE(FILE_DEVICE_CONSOLE, 18, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#define IOCTL_CONDRV_BEEP CTL_CODE(FILE_DEVICE_CONSOLE, 19, METHOD_BUFFERED, FILE_ANY_ACCESS) /* console output ioctls */ #define IOCTL_CONDRV_WRITE_CONSOLE CTL_CODE(FILE_DEVICE_CONSOLE, 30, METHOD_BUFFERED, FILE_WRITE_ACCESS) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 82cee8bdf0b..a775e74961c 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -2569,6 +2569,15 @@ static NTSTATUS console_input_ioctl( struct console *console, unsigned int code, if (in_size % sizeof(WCHAR) || *out_size) return STATUS_INVALID_PARAMETER; return set_console_title( console, in_data, in_size ); + case IOCTL_CONDRV_BEEP: + if (in_size || *out_size) return STATUS_INVALID_PARAMETER; + if (console->is_unix) + { + tty_write( console, "\a", 1 ); + tty_sync( console ); + } + return STATUS_SUCCESS; + default: FIXME( "unsupported ioctl %x\n", code ); return STATUS_NOT_SUPPORTED;