[NTVDM]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 10 Aug 2013 20:50:37 +0000 (20:50 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 10 Aug 2013 20:50:37 +0000 (20:50 +0000)
- 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
subsystems/ntvdm/ntvdm.c

index 90fc79c..86d5e3d 100644 (file)
@@ -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;
     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;
     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);
 
     /* 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 */
     /* 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++;
            && ((Parameters[ParamCount] = strtok(NULL, " \t")) != NULL))
     {
         ParamCount++;
index fae599f..bbb44d4 100644 (file)
@@ -77,7 +77,7 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType)
 INT wmain(INT argc, WCHAR *argv[])
 {
     INT i;
 INT wmain(INT argc, WCHAR *argv[])
 {
     INT i;
-    CHAR CommandLine[128];
+    CHAR CommandLine[MAX_PATH];
     DWORD CurrentTickCount;
     DWORD LastTickCount = GetTickCount();
     DWORD Cycles = 0;
     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 */
     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)
     {
 #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
     {
     }
     else
     {