[NTVDM] In non-STANDALONE builds, check whether we are started as a VDM and bail out if not.

This commit is contained in:
Hermès Bélusca-Maïto 2021-11-27 01:06:21 +01:00
parent d6d30f9e05
commit b849a696ef
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -20,6 +20,9 @@
#include "dos/dem.h"
/* Extra PSDK/NDK Headers */
#include <ndk/psfuncs.h>
/* VARIABLES ******************************************************************/
NTVDM_SETTINGS GlobalSettings;
@ -473,9 +476,6 @@ PrintMessageAnsi(IN CHAR_PRINT CharPrint,
INT
wmain(INT argc, WCHAR *argv[])
{
NtVdmArgc = argc;
NtVdmArgv = argv;
#ifdef STANDALONE
if (argc < 2)
@ -485,8 +485,27 @@ wmain(INT argc, WCHAR *argv[])
return 0;
}
#else
/* For non-STANDALONE builds, we must be started as a VDM */
NTSTATUS Status;
ULONG VdmPower = 0;
Status = NtQueryInformationProcess(NtCurrentProcess(),
ProcessWx86Information,
&VdmPower,
sizeof(VdmPower),
NULL);
if (!NT_SUCCESS(Status) || (VdmPower == 0))
{
/* Not a VDM, bail out */
return 0;
}
#endif
NtVdmArgc = argc;
NtVdmArgv = argv;
#ifdef ADVANCED_DEBUGGING
{
INT i = 20;