mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[NTVDM] DosCreateProcess(): Add failure checks when building the OTVDM command-line.
Addendum to commit 0609db55
This commit is contained in:
parent
1bd0e3f9f9
commit
e0a272c95b
1 changed files with 19 additions and 6 deletions
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <strsafe.h>
|
|
||||||
|
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "cpu/cpu.h"
|
#include "cpu/cpu.h"
|
||||||
|
@ -811,12 +810,25 @@ WORD DosCreateProcess(IN LPCSTR ProgramName,
|
||||||
|
|
||||||
STARTUPINFOA si;
|
STARTUPINFOA si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
|
union { DWORD Size; NTSTATUS Status; } Ret;
|
||||||
CHAR ExpName[MAX_PATH];
|
CHAR ExpName[MAX_PATH];
|
||||||
|
|
||||||
ExpandEnvironmentStringsA(AppName, ExpName, ARRAYSIZE(ExpName) - 1);
|
Ret.Size = ExpandEnvironmentStringsA(AppName, ExpName, _countof(ExpName));
|
||||||
StringCbCatA(ExpName, sizeof(ExpName), "\""); // Add double-quote before ProgramName
|
if ((Ret.Size == 0) || (Ret.Size > _countof(ExpName)))
|
||||||
StringCbCatA(ExpName, sizeof(ExpName), ProgramName); // Append Program name
|
{
|
||||||
StringCbCatA(ExpName, sizeof(ExpName), "\""); // Add double-quote after ProgramName
|
/* We failed or buffer too small, fall back to DOS execution */
|
||||||
|
goto RunAsDOS;
|
||||||
|
}
|
||||||
|
Ret.Size--; // Remove NULL-terminator from count
|
||||||
|
|
||||||
|
/* Add double-quotes before and after ProgramName */
|
||||||
|
Ret.Status = RtlStringCchPrintfA(ExpName + Ret.Size, _countof(ExpName) - Ret.Size,
|
||||||
|
"\"%s\"", ProgramName);
|
||||||
|
if (!NT_SUCCESS(Ret.Status))
|
||||||
|
{
|
||||||
|
/* We failed or buffer too small, fall back to DOS execution */
|
||||||
|
goto RunAsDOS;
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMemory(&pi, sizeof(pi));
|
ZeroMemory(&pi, sizeof(pi));
|
||||||
ZeroMemory(&si, sizeof(si));
|
ZeroMemory(&si, sizeof(si));
|
||||||
|
@ -842,7 +854,7 @@ WORD DosCreateProcess(IN LPCSTR ProgramName,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Retrieve the actual path to the "Program Files" directory for displaying the error */
|
/* Retrieve the actual path to the "Program Files" directory for displaying the error */
|
||||||
ExpandEnvironmentStringsA("%ProgramFiles%", ExpName, ARRAYSIZE(ExpName) - 1);
|
ExpandEnvironmentStringsA("%ProgramFiles%", ExpName, _countof(ExpName));
|
||||||
|
|
||||||
DisplayMessage(L"Trying to load '%S'.\n"
|
DisplayMessage(L"Trying to load '%S'.\n"
|
||||||
L"WOW16 applications are not supported internally by NTVDM at the moment.\n"
|
L"WOW16 applications are not supported internally by NTVDM at the moment.\n"
|
||||||
|
@ -852,6 +864,7 @@ WORD DosCreateProcess(IN LPCSTR ProgramName,
|
||||||
}
|
}
|
||||||
// Fall through
|
// Fall through
|
||||||
}
|
}
|
||||||
|
RunAsDOS:
|
||||||
case SCS_DOS_BINARY:
|
case SCS_DOS_BINARY:
|
||||||
{
|
{
|
||||||
/* Load the executable */
|
/* Load the executable */
|
||||||
|
|
Loading…
Reference in a new issue