[PATCH v2 0/1] MR1668: wineconsole: Let the created console's title be the command's name.
The title was set to 'wineconsole.exe' instead of the name of the created process. conhost.exe loads its per application configuration from the console's title. Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> -- v2: wineconsole: Set launched process name as created console title. https://gitlab.winehq.org/wine/wine/-/merge_requests/1668
From: Eric Pouech <eric.pouech(a)gmail.com> wineconsole was setting created console's title to '????\wineconsole.exe'. This was preventing conhost to load its configuration according to first running command path. Signed-off-by: Eric Pouech <eric.pouech(a)gmail.com> --- programs/wineconsole/wineconsole.c | 38 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 1924bf791e6..aeeee11aa86 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -41,36 +41,38 @@ int WINAPI wWinMain( HINSTANCE inst, HINSTANCE prev, WCHAR *cmdline, INT show ) static WCHAR default_cmd[] = L"cmd"; - FreeConsole(); /* make sure we're not connected to inherited console */ - if (!AllocConsole()) - { - ERR( "failed to allocate console: %lu\n", GetLastError() ); - return 1; - } - if (!*cmd) cmd = default_cmd; - startup.dwFlags = STARTF_USESTDHANDLES; - startup.hStdInput = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, 0, 0 ); - startup.hStdOutput = CreateFileW( L"CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, 0, 0 ); - startup.hStdError = startup.hStdOutput; - - if (!CreateProcessW( NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info )) + if (!CreateProcessW( NULL, cmd, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startup, &info )) { + HANDLE hStdInput, hStdOutput; WCHAR format[256], *buf; INPUT_RECORD ir; DWORD len; + exit_code = GetLastError(); - WARN( "CreateProcess failed: %lu\n", exit_code ); + WARN( "CreateProcess '%ls' failed: %lu\n", cmd, exit_code ); + + /* create a new console to display error messages in it */ + FreeConsole(); /* make sure we're not connected to any console */ + if (!AllocConsole()) + { + ERR( "failed to allocate console: %lu\n", GetLastError() ); + return 1; + } + + hStdInput = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, 0, 0 ); + hStdOutput = CreateFileW( L"CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, NULL, + OPEN_EXISTING, 0, 0 ); + LoadStringW( GetModuleHandleW( NULL ), IDS_CMD_LAUNCH_FAILED, format, ARRAY_SIZE(format) ); len = wcslen( format ) + wcslen( cmd ); if ((buf = malloc( len * sizeof(WCHAR) ))) { swprintf( buf, len, format, cmd ); - WriteConsoleW( startup.hStdOutput, buf, wcslen(buf), &len, NULL); - while (ReadConsoleInputW( startup.hStdInput, &ir, 1, &len ) && ir.EventType == MOUSE_EVENT); + WriteConsoleW( hStdOutput, buf, wcslen(buf), &len, NULL); + while (ReadConsoleInputW( hStdInput, &ir, 1, &len ) && ir.EventType == MOUSE_EVENT); } return exit_code; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1668
Of course the patch does what the description reads. Agreed that it does a bit more than that :wink: Pushing a V2 that keeps the current behavior in place (in terms of wineconsole's exit code and failure error messages display). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1668#note_18584
participants (2)
-
Eric Pouech -
eric pouech (@epo)