[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" #include "dos/dem.h"
/* Extra PSDK/NDK Headers */
#include <ndk/psfuncs.h>
/* VARIABLES ******************************************************************/ /* VARIABLES ******************************************************************/
NTVDM_SETTINGS GlobalSettings; NTVDM_SETTINGS GlobalSettings;
@ -473,9 +476,6 @@ PrintMessageAnsi(IN CHAR_PRINT CharPrint,
INT INT
wmain(INT argc, WCHAR *argv[]) wmain(INT argc, WCHAR *argv[])
{ {
NtVdmArgc = argc;
NtVdmArgv = argv;
#ifdef STANDALONE #ifdef STANDALONE
if (argc < 2) if (argc < 2)
@ -485,8 +485,27 @@ wmain(INT argc, WCHAR *argv[])
return 0; 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 #endif
NtVdmArgc = argc;
NtVdmArgv = argv;
#ifdef ADVANCED_DEBUGGING #ifdef ADVANCED_DEBUGGING
{ {
INT i = 20; INT i = 20;