winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2020
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
703 discussions
Start a n
N
ew thread
Jacek Caban : kernelbase: Use conhost to handle Unix consoles.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: 54e117018cd4cc58c258da92686bfad13946bde2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=54e117018cd4cc58c258da92…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:07:29 2020 +0200 kernelbase: Use conhost to handle Unix consoles. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/console.c | 60 ++++++++++++++++++++++++++++++++++++++++++----- dlls/ntdll/unix/env.c | 29 ++++++++++++++++++----- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 2289d7ea5f..0d105199fc 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -1656,11 +1656,18 @@ static HANDLE create_pseudo_console( COORD size, HANDLE input, HANDLE output, HA si.StartupInfo.hStdError = output; si.StartupInfo.dwFlags = STARTF_USESTDHANDLES; swprintf( conhost_path, ARRAY_SIZE(conhost_path), L"%s\\conhost.exe", system_dir ); - swprintf( cmd, ARRAY_SIZE(cmd), - L"\"%s\" --headless %s--width %u --height %u --signal 0x%x --server 0x%x", - conhost_path, (flags & PSEUDOCONSOLE_INHERIT_CURSOR) ? L"--inheritcursor " : L"", - size.X, size.Y, signal, server ); - + if (signal) + { + swprintf( cmd, ARRAY_SIZE(cmd), + L"\"%s\" --headless %s--width %u --height %u --signal 0x%x --server 0x%x", + conhost_path, (flags & PSEUDOCONSOLE_INHERIT_CURSOR) ? L"--inheritcursor " : L"", + size.X, size.Y, signal, server ); + } + else + { + swprintf( cmd, ARRAY_SIZE(cmd), L"\"%s\" --unix --width %u --height %u --server 0x%x", + conhost_path, size.X, size.Y, server ); + } Wow64DisableWow64FsRedirection( &redir ); res = CreateProcessW( conhost_path, cmd, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si.StartupInfo, &pi ); @@ -1745,11 +1752,52 @@ HRESULT WINAPI ResizePseudoConsole( HPCON handle, COORD size ) return E_NOTIMPL; } +static BOOL is_tty_handle( HANDLE handle ) +{ + return ((UINT_PTR)handle & 3) == 1; +} + void init_console( void ) { RTL_USER_PROCESS_PARAMETERS *params = RtlGetCurrentPeb()->ProcessParameters; - if (params->ConsoleHandle == CONSOLE_HANDLE_ALLOC) + if (params->ConsoleHandle == CONSOLE_HANDLE_SHELL) + { + HANDLE tty_in = NULL, tty_out = NULL, process = NULL; + COORD size; + + if (is_tty_handle( params->hStdInput )) + { + tty_in = params->hStdInput; + params->hStdInput = NULL; + } + if (is_tty_handle( params->hStdOutput )) + { + tty_out = params->hStdOutput; + params->hStdOutput = NULL; + } + if (is_tty_handle( params->hStdError )) + { + if (tty_out) CloseHandle( params->hStdError ); + else tty_out = params->hStdError; + params->hStdError = NULL; + } + + size.X = params->dwXCountChars; + size.Y = params->dwYCountChars; + TRACE( "creating unix console (size %u %u)\n", size.X, size.Y ); + params->ConsoleHandle = create_pseudo_console( size, tty_in, tty_out, NULL, 0, &process ); + CloseHandle( process ); + CloseHandle( tty_in ); + CloseHandle( tty_out ); + + if (params->ConsoleHandle && create_console_connection( params->ConsoleHandle )) + { + init_console_std_handles( FALSE ); + console_flags = 0; + } + } + else if (params->ConsoleHandle == CONSOLE_HANDLE_ALLOC) { HMODULE mod = GetModuleHandleW( NULL ); params->ConsoleHandle = NULL; diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index f4d9ef15fc..876dcf0192 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1156,12 +1156,29 @@ NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size ) void CDECL get_initial_console( RTL_USER_PROCESS_PARAMETERS *params ) { int output_fd = -1; - if (isatty(0) || isatty(1) || isatty(2)) params->ConsoleHandle = CONSOLE_HANDLE_SHELL; - if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput ); - if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError ); - else output_fd = 2; - if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput ); - else output_fd = 1; + + wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput ); + wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput ); + wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError ); + + /* mark tty handles for kernelbase, see init_console */ + if (params->hStdInput && isatty(0)) + { + params->ConsoleHandle = CONSOLE_HANDLE_SHELL; + params->hStdInput = (HANDLE)((UINT_PTR)params->hStdInput | 1); + } + if (params->hStdError && isatty(2)) + { + params->ConsoleHandle = CONSOLE_HANDLE_SHELL; + params->hStdError = (HANDLE)((UINT_PTR)params->hStdError | 1); + output_fd = 2; + } + if (params->hStdOutput && isatty(1)) + { + params->ConsoleHandle = CONSOLE_HANDLE_SHELL; + params->hStdOutput = (HANDLE)((UINT_PTR)params->hStdOutput | 1); + output_fd = 1; + } if (output_fd != -1) {
1
0
0
0
Jacek Caban : ntdll: Fill console size in get_initial_console.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: 0957f9302ca40bd85e092ed335d3fd10ab9bf4da URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0957f9302ca40bd85e092ed3…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:07:15 2020 +0200 ntdll: Fill console size in get_initial_console. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/env.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 1684f5dcc9..f4d9ef15fc 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -32,6 +32,7 @@ #include <fcntl.h> #include <stdarg.h> #include <sys/types.h> +#include <sys/ioctl.h> #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif @@ -1154,10 +1155,23 @@ NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size ) */ void CDECL get_initial_console( RTL_USER_PROCESS_PARAMETERS *params ) { + int output_fd = -1; if (isatty(0) || isatty(1) || isatty(2)) params->ConsoleHandle = CONSOLE_HANDLE_SHELL; if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput ); - if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput ); if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError ); + else output_fd = 2; + if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput ); + else output_fd = 1; + + if (output_fd != -1) + { + struct winsize size; + if (!ioctl( output_fd, TIOCGWINSZ, &size )) + { + params->dwXCountChars = size.ws_col; + params->dwYCountChars = size.ws_row; + } + } }
1
0
0
0
Jacek Caban : ntdll: Pass RTL_USER_PROCESS_PARAMETERS to get_initial_console.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: 6bcc1b9225efe028319bbc64ce6b42a03e4d7ec7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6bcc1b9225efe028319bbc64…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:07:00 2020 +0200 ntdll: Pass RTL_USER_PROCESS_PARAMETERS to get_initial_console. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/env.c | 3 +-- dlls/ntdll/unix/env.c | 12 ++++++------ dlls/ntdll/unix/unix_private.h | 2 +- dlls/ntdll/unixlib.h | 5 ++--- include/wine/condrv.h | 1 + 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c index 933792317d..bf3fedcac6 100644 --- a/dlls/ntdll/env.c +++ b/dlls/ntdll/env.c @@ -1254,8 +1254,7 @@ void init_user_process_params(void) RtlFreeUnicodeString( &cmdline ); RtlReleasePath( load_path ); - unix_funcs->get_initial_console( ¶ms->ConsoleHandle, ¶ms->hStdInput, - ¶ms->hStdOutput, ¶ms->hStdError ); + unix_funcs->get_initial_console( params ); params->wShowWindow = 1; /* SW_SHOWNORMAL */ run_wineboot( ¶ms->Environment ); diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 350fe6e8e0..1684f5dcc9 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -55,6 +55,7 @@ #include "winternl.h" #include "winbase.h" #include "winnls.h" +#include "wine/condrv.h" #include "wine/debug.h" #include "unix_private.h" @@ -1151,13 +1152,12 @@ NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size ) * * Return the initial console handles. */ -void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, HANDLE *std_err ) +void CDECL get_initial_console( RTL_USER_PROCESS_PARAMETERS *params ) { - *handle = *std_in = *std_out = *std_err = 0; - if (isatty(0) || isatty(1) || isatty(2)) *handle = (HANDLE)2; /* see kernel32/kernel_private.h */ - if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, std_in ); - if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_out ); - if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_err ); + if (isatty(0) || isatty(1) || isatty(2)) params->ConsoleHandle = CONSOLE_HANDLE_SHELL; + if (!isatty(0)) wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdInput ); + if (!isatty(1)) wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdOutput ); + if (!isatty(2)) wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, ¶ms->hStdError ); } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 39edee09a0..37c1e2ac01 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -107,7 +107,7 @@ extern NTSTATUS CDECL get_initial_environment( WCHAR **wargv[], WCHAR *env, SIZE extern NTSTATUS CDECL get_startup_info( startup_info_t *info, SIZE_T *total_size, SIZE_T *info_size ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size ) DECLSPEC_HIDDEN; extern void CDECL get_initial_directory( UNICODE_STRING *dir ) DECLSPEC_HIDDEN; -extern void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, HANDLE *std_err ) DECLSPEC_HIDDEN; +extern void CDECL get_initial_console( RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN; extern USHORT * CDECL get_unix_codepage_data(void) DECLSPEC_HIDDEN; extern void CDECL get_locales( WCHAR *sys, WCHAR *user ) DECLSPEC_HIDDEN; extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index f5c57dde4d..7ed3148e4c 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -27,7 +27,7 @@ struct _DISPATCHER_CONTEXT; /* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 105 +#define NTDLL_UNIXLIB_VERSION 106 struct unix_funcs { @@ -72,8 +72,7 @@ struct unix_funcs NTSTATUS (CDECL *get_initial_environment)( WCHAR **wargv[], WCHAR *env, SIZE_T *size ); NTSTATUS (CDECL *get_startup_info)( startup_info_t *info, SIZE_T *total_size, SIZE_T *info_size ); NTSTATUS (CDECL *get_dynamic_environment)( WCHAR *env, SIZE_T *size ); - void (CDECL *get_initial_console)( HANDLE *handle, HANDLE *std_in, - HANDLE *std_out, HANDLE *std_err ); + void (CDECL *get_initial_console)( RTL_USER_PROCESS_PARAMETERS *params ); void (CDECL *get_initial_directory)( UNICODE_STRING *dir ); USHORT * (CDECL *get_unix_codepage_data)(void); void (CDECL *get_locales)( WCHAR *sys, WCHAR *user ); diff --git a/include/wine/condrv.h b/include/wine/condrv.h index b82531280b..a5633998db 100644 --- a/include/wine/condrv.h +++ b/include/wine/condrv.h @@ -244,5 +244,6 @@ struct condrv_ctrl_event /* Wine specific values for console inheritance (params->ConsoleHandle) */ #define CONSOLE_HANDLE_ALLOC ((HANDLE)1) +#define CONSOLE_HANDLE_SHELL ((HANDLE)2) #endif /* _INC_CONDRV */
1
0
0
0
Jacek Caban : kernelbase: Move force override logic to init_console_std_handles callers.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: ef57a8df8b53fcacf769a28bb9f4e77317ce7167 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ef57a8df8b53fcacf769a28b…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:06:50 2020 +0200 kernelbase: Move force override logic to init_console_std_handles callers. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/console.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 8c39cde30a..2289d7ea5f 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -224,20 +224,18 @@ static BOOL create_console_connection( HANDLE root ) return set_ntstatus( status ); } -static BOOL init_console_std_handles(void) +static BOOL init_console_std_handles( BOOL override_all ) { HANDLE std_out = NULL, std_err = NULL, handle; OBJECT_ATTRIBUTES attr = {sizeof(attr)}; IO_STATUS_BLOCK iosb; UNICODE_STRING name; - STARTUPINFOW si; NTSTATUS status; - GetStartupInfoW( &si ); attr.ObjectName = &name; attr.Attributes = OBJ_INHERIT; - if (!(si.dwFlags & STARTF_USESTDHANDLES) || !GetStdHandle( STD_INPUT_HANDLE )) + if (override_all || !GetStdHandle( STD_INPUT_HANDLE )) { /* FIXME: Use unbound console handle */ RtlInitUnicodeString( &name, L"\\Device\\ConDrv\\CurrentIn" ); @@ -250,7 +248,7 @@ static BOOL init_console_std_handles(void) SetStdHandle( STD_INPUT_HANDLE, console_handle_map( handle )); } - if (si.dwFlags & STARTF_USESTDHANDLES) + if (!override_all) { std_out = GetStdHandle( STD_OUTPUT_HANDLE ); std_err = GetStdHandle( STD_ERROR_HANDLE ); @@ -306,7 +304,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid ) if (ret) { RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = create_console_reference( console_connection ); - ret = RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle && init_console_std_handles(); + if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle) + { + STARTUPINFOW si; + GetStartupInfoW( &si ); + init_console_std_handles( !(si.dwFlags & STARTF_USESTDHANDLES) ); + } + else ret = FALSE; } if (!ret) FreeConsole(); @@ -379,7 +383,7 @@ BOOL WINAPI AllocConsole(void) CloseHandle( pi.hProcess ); } CloseHandle( event ); - if (!ret || !init_console_std_handles()) goto error; + if (!ret || !init_console_std_handles( !(app_si.dwFlags & STARTF_USESTDHANDLES) )) goto error; console = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 0, NULL, OPEN_EXISTING, 0, 0 ); if (console == INVALID_HANDLE_VALUE) goto error; RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = console;
1
0
0
0
Jacek Caban : conhost: Use IOCTL_CONDRV_SETUP_INPUT to initialize input in Unix mode.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: c47f64bd3e5ca6e10096dc9b39d3df2cc9be95a0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c47f64bd3e5ca6e10096dc9b…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:06:37 2020 +0200 conhost: Use IOCTL_CONDRV_SETUP_INPUT to initialize input in Unix mode. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/conhost/conhost.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 0de55af14c..c637b16379 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -1625,6 +1625,14 @@ static DWORD WINAPI tty_input( void *param ) BOOL signaled; NTSTATUS status; + if (console->is_unix) + { + unsigned int h = condrv_handle( console->tty_input ); + status = NtDeviceIoControlFile( console->server, NULL, NULL, NULL, &io, IOCTL_CONDRV_SETUP_INPUT, + &h, sizeof(h), NULL, 0 ); + if (status) ERR( "input setup failed: %#x\n", status ); + } + event = CreateEventW( NULL, TRUE, FALSE, NULL ); for (;;) @@ -1682,6 +1690,13 @@ static DWORD WINAPI tty_input( void *param ) EnterCriticalSection( &console_section ); if (console->read_ioctl) read_complete( console, status, NULL, 0, FALSE ); + if (console->is_unix) + { + unsigned int h = 0; + status = NtDeviceIoControlFile( console->server, NULL, NULL, NULL, &io, IOCTL_CONDRV_SETUP_INPUT, + &h, sizeof(h), NULL, 0 ); + if (status) ERR( "input restore failed: %#x\n", status ); + } CloseHandle( console->input_thread ); console->input_thread = NULL; LeaveCriticalSection( &console_section );
1
0
0
0
Jacek Caban : server: Introduce IOCTL_CONDRV_SETUP_INPUT ioctl.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: 52f6a56a1aa450c893e19a0e63a90c60626d3dcf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=52f6a56a1aa450c893e19a0e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:06:26 2020 +0200 server: Introduce IOCTL_CONDRV_SETUP_INPUT ioctl. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- include/wine/condrv.h | 5 ++++- server/console.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ server/trace.c | 1 + 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/include/wine/condrv.h b/include/wine/condrv.h index e5ba9c7444..b82531280b 100644 --- a/include/wine/condrv.h +++ b/include/wine/condrv.h @@ -50,7 +50,10 @@ #define IOCTL_CONDRV_SCROLL CTL_CODE(FILE_DEVICE_CONSOLE, 37, METHOD_BUFFERED, FILE_WRITE_ACCESS) /* console connection ioctls */ -#define IOCTL_CONDRV_BIND_PID CTL_CODE(FILE_DEVICE_CONSOLE, 51, METHOD_BUFFERED, FILE_READ_PROPERTIES) +#define IOCTL_CONDRV_BIND_PID CTL_CODE(FILE_DEVICE_CONSOLE, 51, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/* console server ioctls */ +#define IOCTL_CONDRV_SETUP_INPUT CTL_CODE(FILE_DEVICE_CONSOLE, 60, METHOD_BUFFERED, FILE_ANY_ACCESS) /* console renderer ioctls */ #define IOCTL_CONDRV_GET_RENDERER_EVENTS CTL_CODE(FILE_DEVICE_CONSOLE, 70, METHOD_BUFFERED, FILE_READ_ACCESS) diff --git a/server/console.c b/server/console.c index a946abacbb..2a5d7733fe 100644 --- a/server/console.c +++ b/server/console.c @@ -28,6 +28,8 @@ #include <stdio.h> #include <unistd.h> #include <signal.h> +#include <sys/ioctl.h> +#include <termios.h> #include "ntstatus.h" #define WIN32_NO_STATUS @@ -198,6 +200,8 @@ struct console_server struct list queue; /* ioctl queue */ struct list read_queue; /* blocking read queue */ int busy; /* flag if server processing an ioctl */ + int term_fd; /* UNIX terminal fd */ + struct termios termios; /* original termios */ }; static void console_server_dump( struct object *obj, int verbose ); @@ -665,6 +669,13 @@ static void disconnect_console_server( struct console_server *server ) console_host_ioctl_terminate( call, STATUS_CANCELLED ); } + if (server->term_fd != -1) + { + tcsetattr( server->term_fd, TCSANOW, &server->termios ); + close( server->term_fd ); + server->term_fd = -1; + } + if (server->console) { assert( server->console->server == server ); @@ -1772,6 +1783,7 @@ static struct object *create_console_server( void ) if (!(server = alloc_object( &console_server_ops ))) return NULL; server->console = NULL; server->busy = 0; + server->term_fd = -1; list_init( &server->queue ); list_init( &server->read_queue ); server->fd = alloc_pseudo_fd( &console_server_fd_ops, &server->obj, FILE_SYNCHRONOUS_IO_NONALERT ); @@ -2337,6 +2349,53 @@ static int console_server_ioctl( struct fd *fd, ioctl_code_t code, struct async return !get_error(); } + case IOCTL_CONDRV_SETUP_INPUT: + { + struct termios term; + obj_handle_t handle; + struct file *file; + int unix_fd; + + if (get_req_data_size() != sizeof(unsigned int) || get_reply_max_size()) + { + set_error( STATUS_INVALID_PARAMETER ); + return 0; + } + if (server->term_fd != -1) + { + tcsetattr( server->term_fd, TCSANOW, &server->termios ); + close( server->term_fd ); + server->term_fd = -1; + } + handle = *(unsigned int *)get_req_data(); + if (!handle) return 1; + if (!(file = get_file_obj( current->process, handle, FILE_READ_DATA ))) + { + return 0; + } + unix_fd = get_file_unix_fd( file ); + release_object( file ); + + if (tcgetattr( unix_fd, &server->termios )) + { + file_set_error(); + return 0; + } + term = server->termios; + term.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN); + term.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + term.c_cflag &= ~(CSIZE | PARENB); + term.c_cflag |= CS8; + term.c_cc[VMIN] = 1; + term.c_cc[VTIME] = 0; + if (tcsetattr( unix_fd, TCSANOW, &term ) || (server->term_fd = dup( unix_fd )) == -1) + { + file_set_error(); + return 0; + } + return 1; + } + default: set_error( STATUS_INVALID_HANDLE ); return 0; diff --git a/server/trace.c b/server/trace.c index 91e3208c49..707a952357 100644 --- a/server/trace.c +++ b/server/trace.c @@ -129,6 +129,7 @@ static void dump_ioctl_code( const char *prefix, const ioctl_code_t *code ) CASE(IOCTL_CONDRV_READ_OUTPUT); CASE(IOCTL_CONDRV_SET_MODE); CASE(IOCTL_CONDRV_SET_OUTPUT_INFO); + CASE(IOCTL_CONDRV_SETUP_INPUT); CASE(IOCTL_CONDRV_WRITE_CONSOLE); CASE(IOCTL_CONDRV_WRITE_INPUT); CASE(IOCTL_CONDRV_WRITE_OUTPUT);
1
0
0
0
Jacek Caban : conhost: Delay creating input thread in Unix mode.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: 158471d676e799d3d23a356b442ecc4afd2ade57 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=158471d676e799d3d23a356b…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:06:11 2020 +0200 conhost: Delay creating input thread in Unix mode. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/conhost/conhost.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 3f7b5fb914..0de55af14c 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -99,6 +99,7 @@ struct console unsigned int input_cp; /* console input codepage */ unsigned int output_cp; /* console output codepage */ unsigned int win; /* window handle if backend supports it */ + HANDLE input_thread; /* input thread handle */ HANDLE tty_input; /* handle to tty input stream */ HANDLE tty_output; /* handle to tty output stream */ char tty_buffer[4096]; /* tty output buffer */ @@ -1681,11 +1682,20 @@ static DWORD WINAPI tty_input( void *param ) EnterCriticalSection( &console_section ); if (console->read_ioctl) read_complete( console, status, NULL, 0, FALSE ); + CloseHandle( console->input_thread ); + console->input_thread = NULL; LeaveCriticalSection( &console_section ); return 0; } +static BOOL ensure_tty_input_thread( struct console *console ) +{ + if (!console->input_thread) + console->input_thread = CreateThread( NULL, 0, tty_input, console, 0, NULL ); + return console->input_thread != NULL; +} + static NTSTATUS screen_buffer_activate( struct screen_buffer *screen_buffer ) { RECT update_rect; @@ -2424,6 +2434,7 @@ static NTSTATUS console_input_ioctl( struct console *console, unsigned int code, case IOCTL_CONDRV_READ_CONSOLE: if (in_size || *out_size % sizeof(WCHAR)) return STATUS_INVALID_PARAMETER; + ensure_tty_input_thread( console ); return read_console( console, *out_size ); case IOCTL_CONDRV_READ_INPUT: @@ -2431,6 +2442,7 @@ static NTSTATUS console_input_ioctl( struct console *console, unsigned int code, unsigned int blocking; NTSTATUS status; if (in_size && in_size != sizeof(blocking)) return STATUS_INVALID_PARAMETER; + ensure_tty_input_thread( console ); blocking = in_size && *(unsigned int *)in_data; if (blocking && !console->record_count && *out_size) { @@ -2683,7 +2695,7 @@ static int main_loop( struct console *console, HANDLE signal ) int __cdecl wmain(int argc, WCHAR *argv[]) { int headless = 0, i, width = 0, height = 0; - HANDLE signal = NULL, input_thread; + HANDLE signal = NULL; WCHAR *end; static struct console console; @@ -2764,10 +2776,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) console.tty_input = GetStdHandle( STD_INPUT_HANDLE ); console.tty_output = GetStdHandle( STD_OUTPUT_HANDLE ); init_tty_output( &console ); - - if (!(input_thread = CreateThread( NULL, 0, tty_input, &console, 0, NULL ))) - return 1; - CloseHandle( input_thread ); + if (!console.is_unix && !ensure_tty_input_thread( &console )) return 1; } return main_loop( &console, signal );
1
0
0
0
Jacek Caban : conhost: Force using relative cursor positioning in update_read_output.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: fc408f3d4376722dbe173495be10ef2ce34874d1 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fc408f3d4376722dbe173495…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:06:03 2020 +0200 conhost: Force using relative cursor positioning in update_read_output. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/conhost/conhost.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 97855e5e32..3f7b5fb914 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -309,6 +309,27 @@ static void set_tty_cursor( struct console *console, unsigned int x, unsigned in tty_write( console, buf, strlen(buf) ); } +static void set_tty_cursor_relative( struct console *console, unsigned int x, unsigned int y ) +{ + if (y < console->tty_cursor_y) + { + char buf[64]; + sprintf( buf, "\x1b[%uA", console->tty_cursor_y - y ); + tty_write( console, buf, strlen(buf) ); + console->tty_cursor_y = y; + } + else + { + while (console->tty_cursor_y < y) + { + console->tty_cursor_x = 0; + console->tty_cursor_y++; + tty_write( console, "\r\n", 2 ); + } + } + set_tty_cursor( console, x, y ); +} + static void set_tty_attr( struct console *console, unsigned int attr ) { char buf[8]; @@ -1216,7 +1237,16 @@ static void update_read_output( struct console *console ) } } - update_output( screen_buffer, &update_rect ); + /* always try to use relative cursor positions in UNIX mode so that it works even if cursor + * position is out of sync */ + if (update_rect.left <= update_rect.right && update_rect.top <= update_rect.bottom) + { + if (console->is_unix) + set_tty_cursor_relative( screen_buffer->console, update_rect.left, update_rect.top ); + update_output( screen_buffer, &update_rect ); + } + if (console->is_unix) + set_tty_cursor_relative( screen_buffer->console, screen_buffer->cursor_x, screen_buffer->cursor_y ); tty_sync( screen_buffer->console ); }
1
0
0
0
Jacek Caban : conhost: Use CP_UNIXCP in Unix mode.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: aecf53d0f745a65c15e0f1abbaf27af0d7c0a486 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=aecf53d0f745a65c15e0f1ab…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:05:51 2020 +0200 conhost: Use CP_UNIXCP in Unix mode. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/conhost/conhost.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 5df6848ba5..97855e5e32 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -233,6 +233,11 @@ static BOOL is_active( struct screen_buffer *screen_buffer ) return screen_buffer == screen_buffer->console->active; } +static unsigned int get_tty_cp( struct console *console ) +{ + return console->is_unix ? CP_UNIXCP : CP_UTF8; +} + static void tty_flush( struct console *console ) { if (!console->tty_output || !console->tty_buffer_count) return; @@ -406,7 +411,8 @@ static void update_output( struct screen_buffer *screen_buffer, RECT *rect ) break; } - size = WideCharToMultiByte( CP_UTF8, 0, &ch->ch, 1, buf, sizeof(buf), NULL, NULL ); + size = WideCharToMultiByte( get_tty_cp( screen_buffer->console ), 0, + &ch->ch, 1, buf, sizeof(buf), NULL, NULL ); tty_write( screen_buffer->console, buf, size ); screen_buffer->console->tty_cursor_x++; } @@ -1604,7 +1610,7 @@ static DWORD WINAPI tty_input( void *param ) signaled = console->record_count != 0; /* FIXME: Handle partial char read */ - count = MultiByteToWideChar(CP_UTF8, 0, read_buf, io.Information, buf, ARRAY_SIZE(buf)); + count = MultiByteToWideChar( get_tty_cp( console ), 0, read_buf, io.Information, buf, ARRAY_SIZE(buf) ); TRACE( "%s\n", debugstr_wn(buf, count) ); @@ -2288,9 +2294,9 @@ static NTSTATUS set_console_title( struct console *console, const WCHAR *in_titl char *vt; tty_write( console, "\x1b]0;", 4 ); - len = WideCharToMultiByte( CP_UTF8, 0, console->title, size / sizeof(WCHAR), NULL, 0, NULL, NULL); + len = WideCharToMultiByte( get_tty_cp( console ), 0, console->title, size / sizeof(WCHAR), NULL, 0, NULL, NULL); if ((vt = tty_alloc_buffer( console, len ))) - WideCharToMultiByte( CP_UTF8, 0, console->title, size / sizeof(WCHAR), vt, len, NULL, NULL ); + WideCharToMultiByte( get_tty_cp( console ), 0, console->title, size / sizeof(WCHAR), vt, len, NULL, NULL ); tty_write( console, "\x07", 1 ); tty_sync( console ); }
1
0
0
0
Jacek Caban : conhost: Introduce Unix mode.
by Alexandre Julliard
21 Sep '20
21 Sep '20
Module: wine Branch: master Commit: ef5af87f6cc951b29800bcaf97bc1d9c86283b4a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ef5af87f6cc951b29800bcaf…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 21 17:05:41 2020 +0200 conhost: Introduce Unix mode. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/conhost/conhost.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 1d48194206..5df6848ba5 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -79,6 +79,7 @@ struct console HANDLE server; /* console server handle */ unsigned int mode; /* input mode */ struct screen_buffer *active; /* active screen buffer */ + int is_unix; /* UNIX terminal mode */ INPUT_RECORD *records; /* input records */ unsigned int record_count; /* number of input records */ unsigned int record_size; /* size of input records buffer */ @@ -356,10 +357,14 @@ static void tty_sync( struct console *console ) static void init_tty_output( struct console *console ) { - /* initialize tty output, but don't flush */ - tty_write( console, "\x1b[2J", 4 ); /* clear screen */ - set_tty_attr( console, console->active->attr ); - tty_write( console, "\x1b[H", 3 ); /* move cursor to (0,0) */ + if (!console->is_unix) + { + /* initialize tty output, but don't flush */ + tty_write( console, "\x1b[2J", 4 ); /* clear screen */ + set_tty_attr( console, console->active->attr ); + tty_write( console, "\x1b[H", 3 ); /* move cursor to (0,0) */ + } + else console->tty_attr = empty_char_info.attr; console->tty_cursor_visible = TRUE; } @@ -2641,7 +2646,7 @@ static int main_loop( struct console *console, HANDLE signal ) int __cdecl wmain(int argc, WCHAR *argv[]) { - int headless = 0, i, width = 80, height = 150; + int headless = 0, i, width = 0, height = 0; HANDLE signal = NULL, input_thread; WCHAR *end; @@ -2664,18 +2669,24 @@ int __cdecl wmain(int argc, WCHAR *argv[]) headless = 1; continue; } + if (!wcscmp( argv[i], L"--unix")) + { + console.is_unix = 1; + headless = 1; + continue; + } if (!wcscmp( argv[i], L"--width" )) { if (++i == argc) return 1; width = wcstol( argv[i], &end, 0 ); - if (!width || width > 0xffff || *end) return 1; + if ((!width && !console.is_unix) || width > 0xffff || *end) return 1; continue; } if (!wcscmp( argv[i], L"--height" )) { if (++i == argc) return 1; height = wcstol( argv[i], &end, 0 ); - if (!height || height > 0xffff || *end) return 1; + if ((!height && !console.is_unix) || height > 0xffff || *end) return 1; continue; } if (!wcscmp( argv[i], L"--signal" )) @@ -2708,6 +2719,9 @@ int __cdecl wmain(int argc, WCHAR *argv[]) return 1; } + if (!width) width = 80; + if (!height) height = 150; + if (!(console.active = create_screen_buffer( &console, 1, width, height ))) return 1; if (headless) {
1
0
0
0
← Newer
1
...
24
25
26
27
28
29
30
...
71
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200