ReactOS 0.4.15-dev-8079-g5db69da
ntvdm.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "bios/bios.h"
#include "cpu/cpu.h"
#include "dos/dem.h"
#include <ndk/psfuncs.h>
#include "./console/console.c"
Include dependency graph for ntvdm.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS NTAPI NtVdmConfigureBios (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
static NTSTATUS NTAPI NtVdmConfigureRom (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
static NTSTATUS NTAPI NtVdmConfigureFloppy (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
static NTSTATUS NTAPI NtVdmConfigureHDD (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
static BOOL LoadGlobalSettings (IN PNTVDM_SETTINGS Settings)
 
static VOID FreeGlobalSettings (IN PNTVDM_SETTINGS Settings)
 
static VOID ConsoleCleanup (VOID)
 
VOID VdmShutdown (BOOLEAN Immediate)
 
VOID DisplayMessage (IN LPCWSTR Format,...)
 
VOID PrintMessageAnsi (IN CHAR_PRINT CharPrint, IN LPCSTR Format,...)
 
INT wmain (INT argc, WCHAR *argv[])
 

Variables

NTVDM_SETTINGS GlobalSettings
 
INT NtVdmArgc
 
WCHAR ** NtVdmArgv
 
WCHAR NtVdmPath [MAX_PATH]
 
ULONG NtVdmPathSize
 
static RTL_QUERY_REGISTRY_TABLE NtVdmConfigurationTable []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file ntvdm.c.

Function Documentation

◆ ConsoleCleanup()

static VOID ConsoleCleanup ( VOID  )
static

Referenced by VdmShutdown().

◆ DisplayMessage()

VOID DisplayMessage ( IN LPCWSTR  Format,
  ... 
)

Definition at line 360 of file ntvdm.c.

361{
362#ifndef WIN2K_COMPLIANT
363 WCHAR StaticBuffer[256];
364 LPWSTR Buffer = StaticBuffer; // Use the static buffer by default.
365#else
366 WCHAR Buffer[2048]; // Large enough. If not, increase it by hand.
367#endif
368 size_t MsgLen;
370
372
373#ifndef WIN2K_COMPLIANT
374 /*
375 * Retrieve the message length and if it is too long, allocate
376 * an auxiliary buffer; otherwise use the static buffer.
377 * The string is built to be NULL-terminated.
378 */
379 MsgLen = _vscwprintf(Format, args);
380 if (MsgLen >= ARRAYSIZE(StaticBuffer))
381 {
382 Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, (MsgLen + 1) * sizeof(WCHAR));
383 if (Buffer == NULL)
384 {
385 /* Allocation failed, use the static buffer and display a suitable error message */
386 Buffer = StaticBuffer;
387 Format = L"DisplayMessage()\nOriginal message is too long and allocating an auxiliary buffer failed.";
388 MsgLen = wcslen(Format);
389 }
390 }
391#else
392 MsgLen = ARRAYSIZE(Buffer) - 1;
393#endif
394
395 RtlZeroMemory(Buffer, (MsgLen + 1) * sizeof(WCHAR));
396 _vsnwprintf(Buffer, MsgLen, Format, args);
397
398 va_end(args);
399
400 /* Display the message */
401 DPRINT1("\n\nNTVDM Subsystem\n%S\n\n", Buffer);
402 MessageBoxW(hConsoleWnd, Buffer, L"NTVDM Subsystem", MB_OK);
403
404#ifndef WIN2K_COMPLIANT
405 /* Free the buffer if needed */
406 if (Buffer != StaticBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
407#endif
408}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define DPRINT1
Definition: precomp.h:8
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest, size_t _Count, const wchar_t *_Format, va_list _Args)
_Check_return_ _CRTIMP int __cdecl _vscwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
#define args
Definition: format.c:66
Definition: match.c:390
HWND hConsoleWnd
Definition: console.c:20
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:790
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ FreeGlobalSettings()

static VOID FreeGlobalSettings ( IN PNTVDM_SETTINGS  Settings)
static

Definition at line 284 of file ntvdm.c.

285{
286 USHORT i;
287
289
290 if (Settings->BiosFileName.Buffer)
291 RtlFreeAnsiString(&Settings->BiosFileName);
292
293 if (Settings->RomFiles.Buffer)
294 RtlFreeAnsiString(&Settings->RomFiles);
295
296 for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i)
297 {
298 if (Settings->FloppyDisks[i].Buffer)
299 RtlFreeUnicodeString(&Settings->FloppyDisks[i]);
300 }
301
302 for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i)
303 {
304 if (Settings->HardDisks[i].Buffer)
305 RtlFreeUnicodeString(&Settings->HardDisks[i]);
306 }
307}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
unsigned short USHORT
Definition: pedump.c:61
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_POWER_POLICY_IDLE_SETTINGS Settings
Definition: wdfdevice.h:2595

Referenced by VdmShutdown().

◆ LoadGlobalSettings()

static BOOL LoadGlobalSettings ( IN PNTVDM_SETTINGS  Settings)
static

Definition at line 254 of file ntvdm.c.

255{
257
259
260 /*
261 * Now we can do:
262 * - CPU core choice
263 * - Video choice
264 * - Sound choice
265 * - Mem?
266 * - ...
267 * - Standalone mode?
268 * - Debug settings
269 */
271 L"NTVDM",
273 Settings,
274 NULL);
275 if (!NT_SUCCESS(Status))
276 {
277 DPRINT1("NTVDM registry settings cannot be fully initialized, using default ones. Status = 0x%08lx\n", Status);
278 }
279
280 return NT_SUCCESS(Status);
281}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
static RTL_QUERY_REGISTRY_TABLE NtVdmConfigurationTable[]
Definition: ntvdm.c:167

Referenced by wmain().

◆ NtVdmConfigureBios()

static NTSTATUS NTAPI NtVdmConfigureBios ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)
static

Definition at line 42 of file ntvdm.c.

48{
50 UNICODE_STRING ValueString;
51
52 /* Check for the type of the value */
53 if (ValueType != REG_SZ)
54 {
55 RtlInitEmptyAnsiString(&Settings->BiosFileName, NULL, 0);
56 return STATUS_SUCCESS;
57 }
58
59 /* Convert the UNICODE string to ANSI and store it */
60 RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
61 ValueString.Length = ValueString.MaximumLength;
62 RtlUnicodeStringToAnsiString(&Settings->BiosFileName, &ValueString, TRUE);
63
64 return STATUS_SUCCESS;
65}
#define TRUE
Definition: types.h:120
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
#define REG_SZ
Definition: layer.c:22
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
struct _NTVDM_SETTINGS * PNTVDM_SETTINGS
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275

◆ NtVdmConfigureFloppy()

static NTSTATUS NTAPI NtVdmConfigureFloppy ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)
static

Definition at line 96 of file ntvdm.c.

102{
105 ULONG DiskNumber = PtrToUlong(EntryContext);
106
107 ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
108
109 /* Check whether the Hard Disk entry was not already configured */
110 if (Settings->FloppyDisks[DiskNumber].Buffer != NULL)
111 {
112 DPRINT1("Floppy Disk %d -- '%wZ' already configured\n", DiskNumber, &Settings->FloppyDisks[DiskNumber]);
113 return STATUS_SUCCESS;
114 }
115
116 /* Check for the type of the value */
117 if (ValueType != REG_SZ)
118 {
119 RtlInitEmptyUnicodeString(&Settings->FloppyDisks[DiskNumber], NULL, 0);
120 return STATUS_SUCCESS;
121 }
122
123 /* Initialize the string */
124 Success = RtlCreateUnicodeString(&Settings->FloppyDisks[DiskNumber], (PCWSTR)ValueData);
126
127 return STATUS_SUCCESS;
128}
unsigned char BOOLEAN
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define PtrToUlong(u)
Definition: config.h:107
@ Success
Definition: eventcreate.c:712
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4207
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59

◆ NtVdmConfigureHDD()

static NTSTATUS NTAPI NtVdmConfigureHDD ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)
static

Definition at line 132 of file ntvdm.c.

138{
141 ULONG DiskNumber = PtrToUlong(EntryContext);
142
143 ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
144
145 /* Check whether the Hard Disk entry was not already configured */
146 if (Settings->HardDisks[DiskNumber].Buffer != NULL)
147 {
148 DPRINT1("Hard Disk %d -- '%wZ' already configured\n", DiskNumber, &Settings->HardDisks[DiskNumber]);
149 return STATUS_SUCCESS;
150 }
151
152 /* Check for the type of the value */
153 if (ValueType != REG_SZ)
154 {
155 RtlInitEmptyUnicodeString(&Settings->HardDisks[DiskNumber], NULL, 0);
156 return STATUS_SUCCESS;
157 }
158
159 /* Initialize the string */
160 Success = RtlCreateUnicodeString(&Settings->HardDisks[DiskNumber], (PCWSTR)ValueData);
162
163 return STATUS_SUCCESS;
164}

◆ NtVdmConfigureRom()

static NTSTATUS NTAPI NtVdmConfigureRom ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)
static

Definition at line 69 of file ntvdm.c.

75{
77 UNICODE_STRING ValueString;
78
79 /* Check for the type of the value */
81 {
82 RtlInitEmptyAnsiString(&Settings->RomFiles, NULL, 0);
83 return STATUS_SUCCESS;
84 }
85
86 /* Convert the UNICODE string to ANSI and store it */
87 RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
88 ValueString.Length = ValueString.MaximumLength;
89 RtlUnicodeStringToAnsiString(&Settings->RomFiles, &ValueString, TRUE);
90
91 return STATUS_SUCCESS;
92}
#define REG_MULTI_SZ
Definition: nt_native.h:1501

◆ PrintMessageAnsi()

VOID PrintMessageAnsi ( IN CHAR_PRINT  CharPrint,
IN LPCSTR  Format,
  ... 
)

Definition at line 416 of file ntvdm.c.

418{
419 static CHAR CurChar = 0;
420 LPSTR str;
421
422#ifndef WIN2K_COMPLIANT
423 CHAR StaticBuffer[256];
424 LPSTR Buffer = StaticBuffer; // Use the static buffer by default.
425#else
426 CHAR Buffer[2048]; // Large enough. If not, increase it by hand.
427#endif
428 size_t MsgLen;
430
432
433#ifndef WIN2K_COMPLIANT
434 /*
435 * Retrieve the message length and if it is too long, allocate
436 * an auxiliary buffer; otherwise use the static buffer.
437 * The string is built to be NULL-terminated.
438 */
439 MsgLen = _vscprintf(Format, args);
440 if (MsgLen >= ARRAYSIZE(StaticBuffer))
441 {
442 Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, (MsgLen + 1) * sizeof(CHAR));
443 if (Buffer == NULL)
444 {
445 /* Allocation failed, use the static buffer and display a suitable error message */
446 Buffer = StaticBuffer;
447 Format = "DisplayMessageAnsi()\nOriginal message is too long and allocating an auxiliary buffer failed.";
448 MsgLen = strlen(Format);
449 }
450 }
451#else
452 MsgLen = ARRAYSIZE(Buffer) - 1;
453#endif
454
455 RtlZeroMemory(Buffer, (MsgLen + 1) * sizeof(CHAR));
456 _vsnprintf(Buffer, MsgLen, Format, args);
457
458 va_end(args);
459
460 /* Display the message */
461 // DPRINT1("\n\nNTVDM DOS32\n%s\n\n", Buffer);
462
463 MsgLen = strlen(Buffer);
464 str = Buffer;
465 while (MsgLen--)
466 {
467 if (*str == '\n' && CurChar != '\r')
468 CharPrint('\r');
469
470 CurChar = *str++;
471 CharPrint(CurChar);
472 }
473
474#ifndef WIN2K_COMPLIANT
475 /* Free the buffer if needed */
476 if (Buffer != StaticBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
477#endif
478}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _CRTIMP int __cdecl _vscprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
const WCHAR * str
#define _vsnprintf
Definition: xmlstorage.h:202
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

Referenced by BiosRomBasic().

◆ VdmShutdown()

VOID VdmShutdown ( BOOLEAN  Immediate)

HACK!! HACK!!

Definition at line 317 of file ntvdm.c.

318{
319 /*
320 * Immediate = TRUE: Immediate shutdown;
321 * FALSE: Delayed shutdown.
322 */
323 static BOOLEAN MustShutdown = FALSE;
324
325 /* If a shutdown is ongoing, just return */
326 if (MustShutdown)
327 {
328 DPRINT1("Shutdown is ongoing...\n");
330 return;
331 }
332
333 /* First notify DOS to see whether we can shut down now */
334 MustShutdown = DosShutdown(Immediate);
335 /*
336 * In case we perform an immediate shutdown, or the DOS says
337 * we can shut down, do it now.
338 */
339 MustShutdown = MustShutdown || Immediate;
340
341 if (MustShutdown)
342 {
344
345 BiosCleanup();
348
350
351 DPRINT1("\n\n\nNTVDM - Exiting...\n\n\n");
352 /* Some VDDs rely on the fact that NTVDM calls ExitProcess on Windows */
353 ExitProcess(0);
354 }
355}
BOOLEAN DosShutdown(BOOLEAN Immediate)
Definition: dem.c:1331
#define FALSE
Definition: types.h:117
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
#define INFINITE
Definition: serial.h:102
VOID EmulatorTerminate(VOID)
Definition: emulator.c:503
VOID EmulatorCleanup(VOID)
Definition: emulator.c:639
static VOID FreeGlobalSettings(IN PNTVDM_SETTINGS Settings)
Definition: ntvdm.c:284
static VOID ConsoleCleanup(VOID)
NTVDM_SETTINGS GlobalSettings
Definition: ntvdm.c:28
VOID BiosCleanup(VOID)
Definition: bios.c:153
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

Referenced by ConsoleCtrlHandler(), MenuEventHandler(), and wmain().

◆ wmain()

INT wmain ( INT  argc,
WCHAR argv[] 
)

Definition at line 481 of file ntvdm.c.

482{
484
485#ifdef STANDALONE
486
487 if (argc < 2)
488 {
489 wprintf(L"\nReactOS Virtual DOS Machine\n\n"
490 L"Usage: NTVDM <executable> [<parameters>]\n");
491 return 0;
492 }
493
494#else
495
496 /* For non-STANDALONE builds, we must be started as a VDM */
498 ULONG VdmPower = 0;
501 &VdmPower,
502 sizeof(VdmPower),
503 NULL);
504 if (!NT_SUCCESS(Status) || (VdmPower == 0))
505 {
506 /* Not a VDM, bail out */
507 return 0;
508 }
509
510#endif
511
512 NtVdmArgc = argc;
513 NtVdmArgv = argv;
514
515#ifdef ADVANCED_DEBUGGING
516 {
517 INT i = 20;
518
519 printf("Waiting for debugger (10 secs)..");
520 while (i--)
521 {
522 printf(".");
523 if (IsDebuggerPresent())
524 {
526 break;
527 }
528 Sleep(500);
529 }
530 printf("Continue\n");
531 }
532#endif
533
534 DPRINT1("\n\n\n"
535 "NTVDM - Starting...\n"
536 "Command Line: '%s'\n"
537 "\n\n",
539
540 /*
541 * Retrieve the full directory of the current running NTVDM instance.
542 * In case of failure, use the default SystemRoot\System32 path.
543 */
545 NtVdmPath[_countof(NtVdmPath) - 1] = UNICODE_NULL; // Ensure NULL-termination (see WinXP bug)
546
549 if (Success)
550 {
551 /* Find the last path separator, remove it as well as the file name */
552 PWCHAR pch = wcsrchr(NtVdmPath, L'\\');
553 if (pch)
554 *pch = UNICODE_NULL;
555 }
556 else
557 {
558 /* We failed, use the default SystemRoot\System32 path */
561 if (!Success)
562 {
563 /* We failed again, try to do it ourselves */
564 NtVdmPathSize = (ULONG)wcslen(SharedUserData->NtSystemRoot) + _countof("\\System32") - 1;
566 if (Success)
567 {
570 L"%s\\System32",
571 SharedUserData->NtSystemRoot));
572 }
573 if (!Success)
574 {
575 wprintf(L"FATAL: Could not retrieve NTVDM path.\n");
576 goto Cleanup;
577 }
578 }
579 }
581
582 /* Load the global VDM settings */
584
585 /* Initialize the console */
586 if (!ConsoleInit())
587 {
588 wprintf(L"FATAL: A problem occurred when trying to initialize the console.\n");
589 goto Cleanup;
590 }
591
592 /* Initialize the emulator */
594 {
595 wprintf(L"FATAL: Failed to initialize the emulator.\n");
596 goto Cleanup;
597 }
598
599 /* Initialize the system BIOS and option ROMs */
602 {
603 wprintf(L"FATAL: Failed to initialize the VDM BIOS.\n");
604 goto Cleanup;
605 }
606
607 /* Let's go! Start simulation */
608 CpuSimulate();
609
610 /* Quit the VDM */
611Cleanup:
613 return 0;
614}
static int argc
Definition: ServiceArgs.c:12
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define wcsrchr
Definition: compat.h:16
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
LPSTR WINAPI GetCommandLineA(VOID)
Definition: proc.c:2003
static const WCHAR Cleanup[]
Definition: register.c:80
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
Definition: emulator.c:510
unsigned int BOOL
Definition: ntddk_ex.h:94
#define printf
Definition: freeldr.h:97
NTSYSAPI void WINAPI DbgBreakPoint(void)
@ ProcessWx86Information
Definition: winternl.h:875
#define pch(ap)
Definition: match.c:418
#define argv
Definition: mplay32.c:18
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define UNICODE_NULL
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
INT NtVdmArgc
Definition: ntvdm.c:31
WCHAR NtVdmPath[MAX_PATH]
Definition: ntvdm.c:35
VOID VdmShutdown(BOOLEAN Immediate)
Definition: ntvdm.c:317
static BOOL LoadGlobalSettings(IN PNTVDM_SETTINGS Settings)
Definition: ntvdm.c:254
ULONG NtVdmPathSize
Definition: ntvdm.c:36
WCHAR ** NtVdmArgv
Definition: ntvdm.c:32
#define SharedUserData
#define _countof(array)
Definition: sndvol32.h:70
ANSI_STRING RomFiles
Definition: ntvdm.h:87
ANSI_STRING BiosFileName
Definition: ntvdm.h:86
BOOLEAN BiosInitialize(IN LPCSTR BiosFileName, IN LPCSTR RomFiles OPTIONAL)
Definition: bios.c:60
static HANDLE ConsoleOutput
Definition: console.c:17
static BOOL ConsoleInit(VOID)
Definition: console.c:446
VOID CpuSimulate(VOID)
Definition: cpu.c:167
int32_t INT
Definition: typedefs.h:58
#define wprintf(...)
Definition: whoami.c:18
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
BOOL WINAPI IsDebuggerPresent(void)
Definition: debugger.c:580

Variable Documentation

◆ GlobalSettings

◆ NtVdmArgc

INT NtVdmArgc

Definition at line 31 of file ntvdm.c.

Referenced by DosStart(), and wmain().

◆ NtVdmArgv

WCHAR** NtVdmArgv

Definition at line 32 of file ntvdm.c.

Referenced by DosStart(), and wmain().

◆ NtVdmConfigurationTable

RTL_QUERY_REGISTRY_TABLE NtVdmConfigurationTable[]
static

Definition at line 167 of file ntvdm.c.

Referenced by LoadGlobalSettings().

◆ NtVdmPath

WCHAR NtVdmPath[MAX_PATH]

Definition at line 35 of file ntvdm.c.

Referenced by CmosInitialize(), and wmain().

◆ NtVdmPathSize

ULONG NtVdmPathSize

Definition at line 36 of file ntvdm.c.

Referenced by wmain().