[NTVDM] Add otya128's WineVDM integration code into ReactOS (#4113)
authorDoug Lyons <douglyons@douglyons.com>
Tue, 23 Nov 2021 22:50:05 +0000 (16:50 -0600)
committerGitHub <noreply@github.com>
Tue, 23 Nov 2021 22:50:05 +0000 (23:50 +0100)
This is an interim solution until a more integrated solution with NTVDM is developed.
CORE-17852

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

index 7f356b0..4924676 100644 (file)
@@ -796,10 +796,49 @@ WORD DosCreateProcess(IN LPCSTR ProgramName,
         /* Those are handled by NTVDM */
         case SCS_WOW_BINARY:
         {
-            DisplayMessage(L"Trying to load '%S'.\n"
-                           L"WOW16 applications are not supported internally by NTVDM at the moment.\n"
-                           L"Press 'OK' to continue.",
-                           ProgramName);
+            static const PCSTR AppName = "\"%ProgramFiles%\\otvdm\\otvdmw.exe\" ";
+
+            STARTUPINFOA si;
+            PROCESS_INFORMATION pi;
+            CHAR ExpName[MAX_PATH];
+
+            ExpandEnvironmentStringsA(AppName, ExpName, ARRAYSIZE(ExpName) - 1);
+            strcat(ExpName, "\"");         // Add double-quote before ProgramName
+            strcat(ExpName, ProgramName);  // Append Program name
+            strcat(ExpName, "\"");         // Add double-quote after ProgramName
+
+            ZeroMemory(&pi, sizeof(pi));
+            ZeroMemory(&si, sizeof(si));
+            si.cb = sizeof(si);
+
+            /* Create the process */
+            if (CreateProcessA(NULL,    // No Application Name
+                               ExpName, // Just our Command Line
+                               NULL,    // Cannot inherit Process Handle
+                               NULL,    // Cannot inherit Thread Handle
+                               FALSE,   // No handle inheritance
+                               0,       // No extra creation flags
+                               NULL,    // No environment block
+                               NULL,    // No starting directory 
+                               &si,
+                               &pi))
+            {
+                /* Close the handles */
+                CloseHandle(pi.hThread);
+                CloseHandle(pi.hProcess);
+                break;
+            }
+            else
+            {
+                /* Retrieve the actual path to the "Program Files" directory for displaying the error */
+                ExpandEnvironmentStringsA("%ProgramFiles%", ExpName, ARRAYSIZE(ExpName) - 1);
+
+                DisplayMessage(L"Trying to load '%S'.\n"
+                               L"WOW16 applications are not supported internally by NTVDM at the moment.\n"
+                               L"Consider installing WineVDM from the ReactOS Applications Manager in\n'%S'.\n\n"
+                               L"Click on OK to continue.",
+                               ProgramName, ExpName);
+            }
             // Fall through
         }
         case SCS_DOS_BINARY: