[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Wed, 6 May 2015 21:56:15 +0000 (21:56 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Wed, 6 May 2015 21:56:15 +0000 (21:56 +0000)
Try to find the shortened full path in DosLoadExecutable, and use that whenever
possible.

svn path=/trunk/; revision=67580

reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.c

index b9c7d49..46f644d 100644 (file)
@@ -255,6 +255,8 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
     WORD LoadSegment;
     WORD MaxAllocSize;
     DWORD i, FileSize;
+    CHAR FullPath[MAX_PATH];
+    CHAR ShortFullPath[MAX_PATH];
 
     /* Buffer for command line conversion: 1 byte for size; 127 bytes for contents */
     CHAR CmdLineBuffer[1 + DOS_CMDLINE_LENGTH];
@@ -265,6 +267,17 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
             Parameters,
             ReturnAddress);
 
+    /* Try to get the full path to the executable */
+    if (GetFullPathNameA(ExecutablePath, sizeof(FullPath), FullPath, NULL))
+    {
+        /* Try to shorten the full path */
+        if (GetShortPathNameA(FullPath, ShortFullPath, sizeof(ShortFullPath)))
+        {
+            /* Use the shortened full path from now on */
+            ExecutablePath = ShortFullPath;
+        }
+    }
+
     /* Open a handle to the executable */
     FileHandle = CreateFileA(ExecutablePath,
                              GENERIC_READ,