From cf559336a12b2fc4c4d9f5a8108f553d700235c3 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Tue, 12 Nov 2013 01:56:18 +0000 Subject: [PATCH] [NTVDM] The command line in the PSP consists only of the parameters, the program name is omitted. svn path=/branches/ntvdm/; revision=60959 --- subsystems/ntvdm/dos.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/subsystems/ntvdm/dos.c b/subsystems/ntvdm/dos.c index 523c31b38e3..0a9de21a1f5 100644 --- a/subsystems/ntvdm/dos.c +++ b/subsystems/ntvdm/dos.c @@ -1025,6 +1025,7 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) LPBYTE Address = NULL; LPSTR ProgramFilePath, Parameters[256]; CHAR CommandLineCopy[DOS_CMDLINE_LENGTH]; + CHAR ParamString[DOS_CMDLINE_LENGTH]; INT ParamCount = 0; WORD Segment = 0; WORD MaxAllocSize; @@ -1040,8 +1041,6 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) /* Save a copy of the command line */ strcpy(CommandLineCopy, CommandLine); - // FIXME: Improve parsing (especially: "some_path\with spaces\program.exe" options) - /* Get the file name of the executable */ ProgramFilePath = strtok(CommandLineCopy, " \t"); @@ -1052,6 +1051,15 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) ParamCount++; } + ZeroMemory(ParamString, sizeof(ParamString)); + + /* Store the parameters in a string */ + for (i = 0; i < ParamCount; i++) + { + strncat(ParamString, Parameters[i], DOS_CMDLINE_LENGTH - strlen(ParamString) - 1); + strncat(ParamString, " ", DOS_CMDLINE_LENGTH - strlen(ParamString) - 1); + } + /* Open a handle to the executable */ FileHandle = CreateFileA(ProgramFilePath, GENERIC_READ, @@ -1124,7 +1132,7 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) /* Initialize the PSP */ DosInitializePsp(Segment, - CommandLine, + ParamString, (WORD)ExeSize, EnvBlock); @@ -1193,7 +1201,7 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) /* Initialize the PSP */ DosInitializePsp(Segment, - CommandLine, + ParamString, MaxAllocSize, EnvBlock); -- 2.17.1