ReactOS  0.4.13-dev-1165-gd2976ca
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 "./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
 
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 353 of file ntvdm.c.

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

◆ FreeGlobalSettings()

static VOID FreeGlobalSettings ( IN PNTVDM_SETTINGS  Settings)
static

Definition at line 277 of file ntvdm.c.

278 {
279  USHORT i;
280 
281  ASSERT(Settings);
282 
283  if (Settings->BiosFileName.Buffer)
284  RtlFreeAnsiString(&Settings->BiosFileName);
285 
286  if (Settings->RomFiles.Buffer)
287  RtlFreeAnsiString(&Settings->RomFiles);
288 
289  for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i)
290  {
291  if (Settings->FloppyDisks[i].Buffer)
292  RtlFreeUnicodeString(&Settings->FloppyDisks[i]);
293  }
294 
295  for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i)
296  {
297  if (Settings->HardDisks[i].Buffer)
298  RtlFreeUnicodeString(&Settings->HardDisks[i]);
299  }
300 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
SETTINGS Settings
Definition: charmap.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned short USHORT
Definition: pedump.c:61

Referenced by VdmShutdown().

◆ LoadGlobalSettings()

static BOOL LoadGlobalSettings ( IN PNTVDM_SETTINGS  Settings)
static

Definition at line 247 of file ntvdm.c.

248 {
250 
251  ASSERT(Settings);
252 
253  /*
254  * Now we can do:
255  * - CPU core choice
256  * - Video choice
257  * - Sound choice
258  * - Mem?
259  * - ...
260  * - Standalone mode?
261  * - Debug settings
262  */
264  L"NTVDM",
266  Settings,
267  NULL);
268  if (!NT_SUCCESS(Status))
269  {
270  DPRINT1("NTVDM registry settings cannot be fully initialized, using default ones. Status = 0x%08lx\n", Status);
271  }
272 
273  return NT_SUCCESS(Status);
274 }
LONG NTSTATUS
Definition: precomp.h:26
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
SETTINGS Settings
Definition: charmap.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
static RTL_QUERY_REGISTRY_TABLE NtVdmConfigurationTable[]
Definition: ntvdm.c:160
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8

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 35 of file ntvdm.c.

41 {
43  UNICODE_STRING ValueString;
44 
45  /* Check for the type of the value */
46  if (ValueType != REG_SZ)
47  {
48  RtlInitEmptyAnsiString(&Settings->BiosFileName, NULL, 0);
49  return STATUS_SUCCESS;
50  }
51 
52  /* Convert the UNICODE string to ANSI and store it */
53  RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
54  ValueString.Length = ValueString.MaximumLength;
55  RtlUnicodeStringToAnsiString(&Settings->BiosFileName, &ValueString, TRUE);
56 
57  return STATUS_SUCCESS;
58 }
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4016
uint16_t * PWCHAR
Definition: typedefs.h:54
struct _NTVDM_SETTINGS * PNTVDM_SETTINGS
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
SETTINGS Settings
Definition: charmap.c:26
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define REG_SZ
Definition: layer.c:22

◆ 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 89 of file ntvdm.c.

95 {
98  ULONG DiskNumber = PtrToUlong(EntryContext);
99 
100  ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
101 
102  /* Check whether the Hard Disk entry was not already configured */
103  if (Settings->FloppyDisks[DiskNumber].Buffer != NULL)
104  {
105  DPRINT1("Floppy Disk %d -- '%wZ' already configured\n", DiskNumber, &Settings->FloppyDisks[DiskNumber]);
106  return STATUS_SUCCESS;
107  }
108 
109  /* Check for the type of the value */
110  if (ValueType != REG_SZ)
111  {
112  RtlInitEmptyUnicodeString(&Settings->FloppyDisks[DiskNumber], NULL, 0);
113  return STATUS_SUCCESS;
114  }
115 
116  /* Initialize the string */
117  Success = RtlCreateUnicodeString(&Settings->FloppyDisks[DiskNumber], (PCWSTR)ValueData);
118  ASSERT(Success);
119 
120  return STATUS_SUCCESS;
121 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4016
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
struct _NTVDM_SETTINGS * PNTVDM_SETTINGS
unsigned char BOOLEAN
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4004
smooth NULL
Definition: ftsmooth.c:416
#define PtrToUlong(u)
Definition: config.h:107
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
SETTINGS Settings
Definition: charmap.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define REG_SZ
Definition: layer.c:22

◆ 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 125 of file ntvdm.c.

131 {
134  ULONG DiskNumber = PtrToUlong(EntryContext);
135 
136  ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
137 
138  /* Check whether the Hard Disk entry was not already configured */
139  if (Settings->HardDisks[DiskNumber].Buffer != NULL)
140  {
141  DPRINT1("Hard Disk %d -- '%wZ' already configured\n", DiskNumber, &Settings->HardDisks[DiskNumber]);
142  return STATUS_SUCCESS;
143  }
144 
145  /* Check for the type of the value */
146  if (ValueType != REG_SZ)
147  {
148  RtlInitEmptyUnicodeString(&Settings->HardDisks[DiskNumber], NULL, 0);
149  return STATUS_SUCCESS;
150  }
151 
152  /* Initialize the string */
153  Success = RtlCreateUnicodeString(&Settings->HardDisks[DiskNumber], (PCWSTR)ValueData);
154  ASSERT(Success);
155 
156  return STATUS_SUCCESS;
157 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4016
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
struct _NTVDM_SETTINGS * PNTVDM_SETTINGS
unsigned char BOOLEAN
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4004
smooth NULL
Definition: ftsmooth.c:416
#define PtrToUlong(u)
Definition: config.h:107
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
SETTINGS Settings
Definition: charmap.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define REG_SZ
Definition: layer.c:22

◆ 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 62 of file ntvdm.c.

68 {
70  UNICODE_STRING ValueString;
71 
72  /* Check for the type of the value */
73  if (ValueType != REG_MULTI_SZ)
74  {
75  RtlInitEmptyAnsiString(&Settings->RomFiles, NULL, 0);
76  return STATUS_SUCCESS;
77  }
78 
79  /* Convert the UNICODE string to ANSI and store it */
80  RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
81  ValueString.Length = ValueString.MaximumLength;
82  RtlUnicodeStringToAnsiString(&Settings->RomFiles, &ValueString, TRUE);
83 
84  return STATUS_SUCCESS;
85 }
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4016
uint16_t * PWCHAR
Definition: typedefs.h:54
#define REG_MULTI_SZ
Definition: nt_native.h:1501
struct _NTVDM_SETTINGS * PNTVDM_SETTINGS
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
SETTINGS Settings
Definition: charmap.c:26
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ PrintMessageAnsi()

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

Definition at line 409 of file ntvdm.c.

411 {
412  static CHAR CurChar = 0;
413  LPSTR str;
414 
415 #ifndef WIN2K_COMPLIANT
416  CHAR StaticBuffer[256];
417  LPSTR Buffer = StaticBuffer; // Use the static buffer by default.
418 #else
419  CHAR Buffer[2048]; // Large enough. If not, increase it by hand.
420 #endif
421  size_t MsgLen;
422  va_list args;
423 
424  va_start(args, Format);
425 
426 #ifndef WIN2K_COMPLIANT
427  /*
428  * Retrieve the message length and if it is too long, allocate
429  * an auxiliary buffer; otherwise use the static buffer.
430  * The string is built to be NULL-terminated.
431  */
432  MsgLen = _vscprintf(Format, args);
433  if (MsgLen >= ARRAYSIZE(StaticBuffer))
434  {
435  Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, (MsgLen + 1) * sizeof(CHAR));
436  if (Buffer == NULL)
437  {
438  /* Allocation failed, use the static buffer and display a suitable error message */
439  Buffer = StaticBuffer;
440  Format = "DisplayMessageAnsi()\nOriginal message is too long and allocating an auxiliary buffer failed.";
441  MsgLen = strlen(Format);
442  }
443  }
444 #else
445  MsgLen = ARRAYSIZE(Buffer) - 1;
446 #endif
447 
448  RtlZeroMemory(Buffer, (MsgLen + 1) * sizeof(CHAR));
449  _vsnprintf(Buffer, MsgLen, Format, args);
450 
451  va_end(args);
452 
453  /* Display the message */
454  // DPRINT1("\n\nNTVDM DOS32\n%s\n\n", Buffer);
455 
456  MsgLen = strlen(Buffer);
457  str = Buffer;
458  while (MsgLen--)
459  {
460  if (*str == '\n' && CurChar != '\r')
461  CharPrint('\r');
462 
463  CurChar = *str++;
464  CharPrint(CurChar);
465  }
466 
467 #ifndef WIN2K_COMPLIANT
468  /* Free the buffer if needed */
469  if (Buffer != StaticBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
470 #endif
471 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
char * LPSTR
Definition: xmlstorage.h:182
Definition: match.c:390
#define va_end(ap)
Definition: acmsvcex.h:90
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
static TCHAR CurChar
Definition: parser.c:52
_Check_return_ _CRTIMP int __cdecl _vscprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define _vsnprintf
Definition: xmlstorage.h:202
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define args
Definition: format.c:66

Referenced by BiosRomBasic().

◆ VdmShutdown()

VOID VdmShutdown ( BOOLEAN  Immediate)

HACK!! HACK!!

Definition at line 310 of file ntvdm.c.

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

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

◆ wmain()

INT wmain ( INT  argc,
WCHAR argv[] 
)

Definition at line 474 of file ntvdm.c.

475 {
476  NtVdmArgc = argc;
477  NtVdmArgv = argv;
478 
479 #ifdef STANDALONE
480 
481  if (argc < 2)
482  {
483  wprintf(L"\nReactOS Virtual DOS Machine\n\n"
484  L"Usage: NTVDM <executable> [<parameters>]\n");
485  return 0;
486  }
487 
488 #endif
489 
490 #ifdef ADVANCED_DEBUGGING
491  {
492  INT i = 20;
493 
494  printf("Waiting for debugger (10 secs)..");
495  while (i--)
496  {
497  printf(".");
498  if (IsDebuggerPresent())
499  {
500  DbgBreakPoint();
501  break;
502  }
503  Sleep(500);
504  }
505  printf("Continue\n");
506  }
507 #endif
508 
509  /* Load the global VDM settings */
511 
512  DPRINT1("\n\n\nNTVDM - Starting...\n\n\n");
513 
514  /* Initialize the console */
515  if (!ConsoleInit())
516  {
517  wprintf(L"FATAL: A problem occurred when trying to initialize the console\n");
518  goto Cleanup;
519  }
520 
521  /* Initialize the emulator */
523  {
524  wprintf(L"FATAL: Failed to initialize the emulator\n");
525  goto Cleanup;
526  }
527 
528  /* Initialize the system BIOS and option ROMs */
531  {
532  wprintf(L"FATAL: Failed to initialize the VDM BIOS.\n");
533  goto Cleanup;
534  }
535 
536  /* Let's go! Start simulation */
537  CpuSimulate();
538 
539  /* Quit the VDM */
540 Cleanup:
541  VdmShutdown(TRUE);
542  return 0;
543 }
BOOL WINAPI IsDebuggerPresent(VOID)
Definition: debugger.c:615
static int argc
Definition: ServiceArgs.c:12
INT NtVdmArgc
Definition: ntvdm.c:28
#define TRUE
Definition: types.h:120
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
BOOLEAN ConsoleInit(void)
Definition: hardware.c:946
#define wprintf(...)
Definition: whoami.c:18
#define argv
Definition: mplay32.c:18
void DbgBreakPoint()
Definition: mach.c:551
int32_t INT
Definition: typedefs.h:56
ANSI_STRING RomFiles
Definition: ntvdm.h:77
VOID CpuSimulate(VOID)
Definition: cpu.c:167
static BOOL LoadGlobalSettings(IN PNTVDM_SETTINGS Settings)
Definition: ntvdm.c:247
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
WCHAR ** NtVdmArgv
Definition: ntvdm.c:29
VOID VdmShutdown(BOOLEAN Immediate)
Definition: ntvdm.c:310
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
Definition: emulator.c:510
static const WCHAR L[]
Definition: oid.c:1250
ANSI_STRING BiosFileName
Definition: ntvdm.h:76
static const WCHAR Cleanup[]
Definition: register.c:80
#define DPRINT1
Definition: precomp.h:8
static HANDLE ConsoleOutput
Definition: console.c:17
BOOLEAN BiosInitialize(IN LPCSTR BiosFileName, IN LPCSTR RomFiles OPTIONAL)
Definition: bios.c:60
NTVDM_SETTINGS GlobalSettings
Definition: ntvdm.c:25
#define printf
Definition: config.h:203

Variable Documentation

◆ GlobalSettings

◆ NtVdmArgc

INT NtVdmArgc

Definition at line 28 of file ntvdm.c.

Referenced by DosStart(), and wmain().

◆ NtVdmArgv

WCHAR** NtVdmArgv

Definition at line 29 of file ntvdm.c.

Referenced by DosStart(), and wmain().

◆ NtVdmConfigurationTable

RTL_QUERY_REGISTRY_TABLE NtVdmConfigurationTable[]
static

Definition at line 160 of file ntvdm.c.

Referenced by LoadGlobalSettings().