Eric Pouech : kernelbase: Provide a pseudo console environment for initial CUI processes not tied to a Unix tty.
Alexandre Julliard
julliard at winehq.org
Tue Apr 12 15:35:17 CDT 2022
Module: wine
Branch: master
Commit: eff83cd4e00e8ccd4daad05bdd6d76e77664ddd1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=eff83cd4e00e8ccd4daad05bdd6d76e77664ddd1
Author: Eric Pouech <eric.pouech at gmail.com>
Date: Mon Apr 11 15:05:09 2022 +0200
kernelbase: Provide a pseudo console environment for initial CUI processes not tied to a Unix tty.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52771
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52761
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52743
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/console.c | 18 ++++++++++++++----
dlls/ntdll/unix/env.c | 2 ++
include/wine/condrv.h | 1 +
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c
index 046eee6147c..590198cf7bf 100644
--- a/dlls/kernelbase/console.c
+++ b/dlls/kernelbase/console.c
@@ -86,6 +86,12 @@ static BOOL console_ioctl( HANDLE handle, DWORD code, void *in_buff, DWORD in_co
IO_STATUS_BLOCK io;
NTSTATUS status;
+ if (handle == CONSOLE_HANDLE_SHELL_NO_WINDOW)
+ {
+ WARN("Incorrect access to Shell-no-window console (ioctl=%lx)\n", code);
+ SetLastError( ERROR_INVALID_ACCESS );
+ return FALSE;
+ }
status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, code, in_buff, in_count,
out_buff, out_count );
switch( status )
@@ -621,10 +627,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
{
RtlEnterCriticalSection( &console_section );
- NtClose( console_connection );
- console_connection = NULL;
+ if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != CONSOLE_HANDLE_SHELL_NO_WINDOW)
+ {
+ NtClose( console_connection );
+ console_connection = NULL;
- NtClose( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle );
+ NtClose( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle );
+ }
RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
if (console_flags & CONSOLE_INPUT_HANDLE) NtClose( GetStdHandle( STD_INPUT_HANDLE ));
@@ -2303,5 +2312,6 @@ void init_console( void )
if (RtlImageNtHeader( mod )->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
alloc_console( no_window );
}
- else if (params->ConsoleHandle) create_console_connection( params->ConsoleHandle );
+ else if (params->ConsoleHandle && params->ConsoleHandle != CONSOLE_HANDLE_SHELL_NO_WINDOW)
+ create_console_connection( params->ConsoleHandle );
}
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index 89297472a34..3976e5b4365 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -1354,6 +1354,8 @@ static void get_initial_console( RTL_USER_PROCESS_PARAMETERS *params )
params->hStdOutput = (HANDLE)((UINT_PTR)params->hStdOutput | 1);
output_fd = 1;
}
+ if (!params->ConsoleHandle && main_image_info.SubSystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI)
+ params->ConsoleHandle = CONSOLE_HANDLE_SHELL_NO_WINDOW;
if (output_fd != -1)
{
diff --git a/include/wine/condrv.h b/include/wine/condrv.h
index 2d763d0b821..3355d7177b0 100644
--- a/include/wine/condrv.h
+++ b/include/wine/condrv.h
@@ -191,5 +191,6 @@ struct condrv_ctrl_event
#define CONSOLE_HANDLE_ALLOC LongToHandle(-1)
#define CONSOLE_HANDLE_ALLOC_NO_WINDOW LongToHandle(-2)
#define CONSOLE_HANDLE_SHELL LongToHandle(-3)
+#define CONSOLE_HANDLE_SHELL_NO_WINDOW LongToHandle(-4)
#endif /* _INC_CONDRV */
More information about the wine-cvs
mailing list