From: Eric Pouech epouech@codeweavers.com
Unix consoles (created from initial process) are inherited by child processes for various reasons, like keeping std handles bound to that unix console. This differs from Windows as the default for a GUI is not to have console attached.
If a GUI programs asks for a console, it will succeed on Windows but fail under Wine as the Unix console is still present.
So, allow AllocConsole() to succeed when called from a GUI program and tied to a Unix console. (don't do it for CUI as they are already attached to a console).
This fixes Scrap Mechanic when run with '-dev' option. (based on suggestion from Zhiyi Zhang)
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/kernelbase/console.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 831e358c692..787d87b937b 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -476,6 +476,15 @@ error: */ BOOL WINAPI AllocConsole(void) { + RTL_USER_PROCESS_PARAMETERS *params = RtlGetCurrentPeb()->ProcessParameters; + + /* allow gui applications to create a genuine console over a unix one */ + if (RtlImageNtHeader( GetModuleHandleW( NULL ) )->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI && + (params->ConsoleHandle == CONSOLE_HANDLE_SHELL_NO_WINDOW || + console_ioctl( params->ConsoleHandle, IOCTL_CONDRV_IS_UNIX, NULL, 0, NULL, 0, NULL ))) + { + FreeConsole(); + } return alloc_console( FALSE ); }