From 2ff3b055cee9deab428e1506b95668fd94598331 Mon Sep 17 00:00:00 2001 From: Kamil Hornicek Date: Wed, 6 Oct 2010 16:44:09 +0000 Subject: [PATCH] [CMD] Use the full name we get from SearchForExecutable when building the command line for CreateProcess so we get proper name in argv[0] later. svn path=/trunk/; revision=49020 --- reactos/base/shell/cmd/cmd.c | 16 +++++++++++----- reactos/base/shell/cmd/start.c | 6 +++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index 54ff9b23edc..09f362d73af 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -316,6 +316,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd) TCHAR szWindowTitle[MAX_PATH]; DWORD dwExitCode = 0; TCHAR *FirstEnd; + TCHAR szFullCmdLine [CMDLINE_LENGTH]; TRACE ("Execute: \'%s\' \'%s\'\n", debugstr_aw(First), debugstr_aw(Rest)); @@ -392,11 +393,16 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd) PROCESS_INFORMATION prci; STARTUPINFO stui; - /* build command line for CreateProcess(): first + " " + rest */ - if (*rest) - rest[-1] = _T(' '); + /* build command line for CreateProcess(): FullName + " " + rest */ + _tcscpy(szFullCmdLine, szFullName); - TRACE ("[EXEC: %s]\n", debugstr_aw(Full)); + if (*rest) + { + _tcsncat(szFullCmdLine, _T(" "), CMDLINE_LENGTH - _tcslen(szFullCmdLine)); + _tcsncat(szFullCmdLine, rest, CMDLINE_LENGTH - _tcslen(szFullCmdLine)); + } + + TRACE ("[EXEC: %s]\n", debugstr_aw(szFullCmdLine)); /* fill startup info */ memset (&stui, 0, sizeof (STARTUPINFO)); @@ -409,7 +415,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd) ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT ); if (CreateProcess (szFullName, - Full, + szFullCmdLine, NULL, NULL, TRUE, diff --git a/reactos/base/shell/cmd/start.c b/reactos/base/shell/cmd/start.c index aef28893807..88acf5e3276 100644 --- a/reactos/base/shell/cmd/start.c +++ b/reactos/base/shell/cmd/start.c @@ -246,14 +246,14 @@ INT cmd_start (LPTSTR Rest) else { TRACE ("[EXEC: %s %s]\n", debugstr_aw(szFullName), debugstr_aw(Rest)); - _tcscpy(szFullCmdLine, Rest); + _tcscpy(szFullCmdLine, szFullName); } /* build command line for CreateProcess() */ if (param != NULL) { - _tcscat(szFullCmdLine, _T(" ")); - _tcscat(szFullCmdLine, param); + _tcsncat(szFullCmdLine, _T(" "), CMDLINE_LENGTH - _tcslen(szFullCmdLine)); + _tcsncat(szFullCmdLine, param, CMDLINE_LENGTH - _tcslen(szFullCmdLine)); } /* fill startup info */