+ return Result;
+}
+
+WORD DosCreateProcess(DOS_EXEC_TYPE LoadType,
+ LPCSTR ProgramName,
+ PDOS_EXEC_PARAM_BLOCK Parameters)
+{
+ DWORD Result;
+ DWORD BinaryType;
+ LPVOID Environment = NULL;
+ VDM_COMMAND_INFO CommandInfo;
+ CHAR CmdLine[MAX_PATH];
+ CHAR AppName[MAX_PATH];
+ CHAR PifFile[MAX_PATH];
+ CHAR Desktop[MAX_PATH];
+ CHAR Title[MAX_PATH];
+ CHAR Env[MAX_PATH];
+ STARTUPINFOA StartupInfo;
+ PROCESS_INFORMATION ProcessInfo;
+
+ /* Get the binary type */
+ if (!GetBinaryTypeA(ProgramName, &BinaryType)) return GetLastError();
+
+ /* Did the caller specify an environment segment? */
+ if (Parameters->Environment)
+ {
+ /* Yes, use it instead of the parent one */
+ Environment = SEG_OFF_TO_PTR(Parameters->Environment, 0);
+ }
+
+ /* Set up the startup info structure */
+ ZeroMemory(&StartupInfo, sizeof(STARTUPINFOA));
+ StartupInfo.cb = sizeof(STARTUPINFOA);
+
+ /* Create the process */
+ if (!CreateProcessA(ProgramName,
+ FAR_POINTER(Parameters->CommandLine),
+ NULL,
+ NULL,
+ FALSE,
+ 0,
+ Environment,
+ NULL,
+ &StartupInfo,
+ &ProcessInfo))
+ {
+ return GetLastError();
+ }
+
+ /* Check the type of the program */
+ switch (BinaryType)
+ {
+ /* These are handled by NTVDM */
+ case SCS_DOS_BINARY:
+ case SCS_WOW_BINARY:
+ {
+ /* Clear the structure */
+ ZeroMemory(&CommandInfo, sizeof(CommandInfo));
+
+ /* Initialize the structure members */
+ CommandInfo.VDMState = VDM_FLAG_NESTED_TASK | VDM_FLAG_DONT_WAIT;
+ CommandInfo.CmdLine = CmdLine;
+ CommandInfo.CmdLen = sizeof(CmdLine);
+ CommandInfo.AppName = AppName;
+ CommandInfo.AppLen = sizeof(AppName);
+ CommandInfo.PifFile = PifFile;
+ CommandInfo.PifLen = sizeof(PifFile);
+ CommandInfo.Desktop = Desktop;
+ CommandInfo.DesktopLen = sizeof(Desktop);
+ CommandInfo.Title = Title;
+ CommandInfo.TitleLen = sizeof(Title);
+ CommandInfo.Env = Env;
+ CommandInfo.EnvLen = sizeof(Env);
+
+ /* Get the VDM command information */
+ if (!GetNextVDMCommand(&CommandInfo))
+ {
+ /* Shouldn't happen */
+ ASSERT(FALSE);
+ }
+
+ /* Increment the re-entry count */
+ CommandInfo.VDMState = VDM_INC_REENTER_COUNT;
+ GetNextVDMCommand(&CommandInfo);
+
+ /* Load the executable */
+ Result= DosLoadExecutable(LoadType,
+ AppName,
+ CmdLine,
+ Env,
+ &Parameters->StackLocation,
+ &Parameters->EntryPoint);
+ if (Result != ERROR_SUCCESS)
+ {
+ DisplayMessage(L"Could not load '%S'. Error: %u", AppName, Result);
+ break;
+ }
+
+ break;
+ }
+
+ /* Not handled by NTVDM */
+ default:
+ {
+ /* Wait for the process to finish executing */
+ WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
+ }
+ }
+
+ /* Close the handles */
+ CloseHandle(ProcessInfo.hProcess);
+ CloseHandle(ProcessInfo.hThread);
+
+ return ERROR_SUCCESS;