- 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
This commit is contained in:
Hermès Bélusca-Maïto 2013-08-10 20:50:37 +00:00
parent b34e5646dd
commit 2288b2c576
2 changed files with 8 additions and 6 deletions

View file

@ -874,8 +874,8 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock)
BOOLEAN Success = FALSE, AllocatedEnvBlock = FALSE; BOOLEAN Success = FALSE, AllocatedEnvBlock = FALSE;
HANDLE FileHandle = INVALID_HANDLE_VALUE, FileMapping = NULL; HANDLE FileHandle = INVALID_HANDLE_VALUE, FileMapping = NULL;
LPBYTE Address = NULL; LPBYTE Address = NULL;
LPSTR ProgramFilePath, Parameters[128]; LPSTR ProgramFilePath, Parameters[256];
CHAR CommandLineCopy[128]; CHAR CommandLineCopy[MAX_PATH];
INT ParamCount = 0; INT ParamCount = 0;
WORD Segment = 0; WORD Segment = 0;
WORD MaxAllocSize; WORD MaxAllocSize;
@ -891,11 +891,13 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock)
/* Save a copy of the command line */ /* Save a copy of the command line */
strcpy(CommandLineCopy, CommandLine); strcpy(CommandLineCopy, CommandLine);
// FIXME: Improve parsing (especially: "some_path\with spaces\program.exe" options)
/* Get the file name of the executable */ /* Get the file name of the executable */
ProgramFilePath = strtok(CommandLineCopy, " \t"); ProgramFilePath = strtok(CommandLineCopy, " \t");
/* Load the parameters in the local array */ /* Load the parameters in the local array */
while ((ParamCount < 256) while ((ParamCount < sizeof(Parameters)/sizeof(Parameters[0]))
&& ((Parameters[ParamCount] = strtok(NULL, " \t")) != NULL)) && ((Parameters[ParamCount] = strtok(NULL, " \t")) != NULL))
{ {
ParamCount++; ParamCount++;

View file

@ -77,7 +77,7 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType)
INT wmain(INT argc, WCHAR *argv[]) INT wmain(INT argc, WCHAR *argv[])
{ {
INT i; INT i;
CHAR CommandLine[128]; CHAR CommandLine[MAX_PATH];
DWORD CurrentTickCount; DWORD CurrentTickCount;
DWORD LastTickCount = GetTickCount(); DWORD LastTickCount = GetTickCount();
DWORD Cycles = 0; DWORD Cycles = 0;
@ -94,11 +94,11 @@ INT wmain(INT argc, WCHAR *argv[])
UNREFERENCED_PARAMETER(argv); UNREFERENCED_PARAMETER(argv);
/* The DOS command line must be ASCII */ /* 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 #else
if (argc == 2 && argv[1] != NULL) 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 else
{ {