2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
5 * PURPOSE: Virtual DOS Machine
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
11 BOOLEAN VdmRunning
= TRUE
;
12 LPVOID BaseAddress
= NULL
;
13 LPCWSTR ExceptionName
[] =
20 L
"Bound Range Exceeded",
25 VOID
DisplayMessage(LPCWSTR Format
, ...)
30 va_start(Parameters
, Format
);
31 _vsnwprintf(Buffer
, 256, Format
, Parameters
);
32 MessageBox(NULL
, Buffer
, L
"NTVDM Subsystem", MB_OK
);
36 BOOL WINAPI
ConsoleCtrlHandler(DWORD ControlType
)
41 case CTRL_BREAK_EVENT
:
43 /* Perform interrupt 0x23 */
44 EmulatorInterrupt(0x23);
48 /* Stop the VDM if the user logs out or closes the console */
55 INT
wmain(INT argc
, WCHAR
*argv
[])
58 BOOLEAN PrintUsage
= TRUE
;
59 CHAR CommandLine
[128];
61 /* Set the handler routine */
62 SetConsoleCtrlHandler(ConsoleCtrlHandler
, TRUE
);
64 /* Parse the command line arguments */
65 for (i
= 1; i
< argc
; i
++)
67 if (argv
[i
][0] != L
'-' && argv
[i
][0] != L
'/') continue;
74 if (argv
[i
+1] != NULL
)
76 /* The DOS command line must be ASCII */
77 WideCharToMultiByte(CP_ACP
, 0, argv
[i
+1], -1, CommandLine
, 128, NULL
, NULL
);
79 /* This is the only mandatory parameter */
86 wprintf(L
"Unknown option: %s", argv
[i
]);
93 wprintf(L
"ReactOS Virtual DOS Machine\n\n");
94 wprintf(L
"Usage: NTVDM /F <PROGRAM>\n");
98 if (!EmulatorInitialize()) return 1;
100 /* Initialize the system BIOS */
101 if (!BiosInitialize())
103 wprintf(L
"FATAL: Failed to initialize the VDM BIOS.\n");
107 /* Initialize the VDM DOS kernel */
108 if (!DosInitialize())
110 wprintf(L
"FATAL: Failed to initialize the VDM DOS kernel.\n");
114 /* Start the process from the command line */
115 if (!DosCreateProcess(CommandLine
, 0))
117 DisplayMessage(L
"Could not start program: %S", CommandLine
);
122 while (VdmRunning
) EmulatorStep();