ntdll: Move the console handle initialization to the Unix library.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-06-29 10:39:27 +02:00
parent ed566a8723
commit b9f531a0e8
5 changed files with 22 additions and 9 deletions

View File

@ -1286,14 +1286,8 @@ void init_user_process_params( SIZE_T data_size )
RtlFreeUnicodeString( &cmdline );
RtlReleasePath( load_path );
if (isatty(0) || isatty(1) || isatty(2))
params->ConsoleHandle = (HANDLE)2; /* see kernel32/kernel_private.h */
if (!isatty(0))
wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, &params->hStdInput );
if (!isatty(1))
wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params->hStdOutput );
if (!isatty(2))
wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params->hStdError );
unix_funcs->get_initial_console( &params->ConsoleHandle, &params->hStdInput,
&params->hStdOutput, &params->hStdError );
params->wShowWindow = 1; /* SW_SHOWNORMAL */
run_wineboot( &params->Environment );

View File

@ -954,6 +954,21 @@ NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size )
}
/*************************************************************************
* get_initial_console
*
* Return the initial console handles.
*/
void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, HANDLE *std_err )
{
*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)) server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, OBJ_INHERIT, std_in );
if (!isatty(1)) server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_out );
if (!isatty(2)) server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, std_err );
}
/*************************************************************************
* get_initial_directory
*

View File

@ -1491,6 +1491,7 @@ static struct unix_funcs unix_funcs =
ntdll_tan,
get_initial_environment,
get_dynamic_environment,
get_initial_console,
get_initial_directory,
get_unix_codepage,
get_locales,

View File

@ -99,6 +99,7 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T s
extern NTSTATUS CDECL get_initial_environment( WCHAR **wargv[], WCHAR *env, SIZE_T *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_unix_codepage( CPTABLEINFO *table ) DECLSPEC_HIDDEN;
extern void CDECL get_locales( WCHAR *sys, WCHAR *user ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsigned short zero_bits_64, SIZE_T commit_size,

View File

@ -29,7 +29,7 @@ struct msghdr;
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 64
#define NTDLL_UNIXLIB_VERSION 65
struct unix_funcs
{
@ -300,6 +300,8 @@ struct unix_funcs
/* environment functions */
NTSTATUS (CDECL *get_initial_environment)( WCHAR **wargv[], WCHAR *env, SIZE_T *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_directory)( UNICODE_STRING *dir );
void (CDECL *get_unix_codepage)( CPTABLEINFO *table );
void (CDECL *get_locales)( WCHAR *sys, WCHAR *user );