From 2288b2c576ca5f6a9d58cdf314dc5355383e7bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 10 Aug 2013 20:50:37 +0000 Subject: [PATCH] [NTVDM] - Use up to 256 parameters for programs (as suggested by the parsing while loop), but don't hardcode this values in many other places. - The passed command line to ntvdm should be as long as MAX_PATH. svn path=/branches/ntvdm/; revision=59691 --- subsystems/ntvdm/dos.c | 8 +++++--- subsystems/ntvdm/ntvdm.c | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/subsystems/ntvdm/dos.c b/subsystems/ntvdm/dos.c index 90fc79c80cb..86d5e3d0c2a 100644 --- a/subsystems/ntvdm/dos.c +++ b/subsystems/ntvdm/dos.c @@ -874,8 +874,8 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) BOOLEAN Success = FALSE, AllocatedEnvBlock = FALSE; HANDLE FileHandle = INVALID_HANDLE_VALUE, FileMapping = NULL; LPBYTE Address = NULL; - LPSTR ProgramFilePath, Parameters[128]; - CHAR CommandLineCopy[128]; + LPSTR ProgramFilePath, Parameters[256]; + CHAR CommandLineCopy[MAX_PATH]; INT ParamCount = 0; WORD Segment = 0; WORD MaxAllocSize; @@ -891,11 +891,13 @@ 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"); /* Load the parameters in the local array */ - while ((ParamCount < 256) + while ((ParamCount < sizeof(Parameters)/sizeof(Parameters[0])) && ((Parameters[ParamCount] = strtok(NULL, " \t")) != NULL)) { ParamCount++; diff --git a/subsystems/ntvdm/ntvdm.c b/subsystems/ntvdm/ntvdm.c index fae599f961f..bbb44d4bd4f 100644 --- a/subsystems/ntvdm/ntvdm.c +++ b/subsystems/ntvdm/ntvdm.c @@ -77,7 +77,7 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType) INT wmain(INT argc, WCHAR *argv[]) { INT i; - CHAR CommandLine[128]; + CHAR CommandLine[MAX_PATH]; DWORD CurrentTickCount; DWORD LastTickCount = GetTickCount(); DWORD Cycles = 0; @@ -94,11 +94,11 @@ INT wmain(INT argc, WCHAR *argv[]) UNREFERENCED_PARAMETER(argv); /* The DOS command line must be ASCII */ - WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, 128, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, GetCommandLine(), -1, CommandLine, sizeof(CommandLine), NULL, NULL); #else if (argc == 2 && argv[1] != NULL) { - WideCharToMultiByte(CP_ACP, 0, argv[1], -1, CommandLine, 128, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, argv[1], -1, CommandLine, sizeof(CommandLine), NULL, NULL); } else {