mirror of
https://github.com/reactos/reactos.git
synced 2024-10-06 17:35:07 +00:00
[NTVDM]
Quit when ntvdm becomes the last process attached to the console. svn path=/branches/ntvdm/; revision=62892
This commit is contained in:
parent
5b74bbc251
commit
a8caf51cd0
|
@ -34,6 +34,7 @@ static HANDLE ConsoleOutput = INVALID_HANDLE_VALUE;
|
||||||
static DWORD OrgConsoleInputMode, OrgConsoleOutputMode;
|
static DWORD OrgConsoleInputMode, OrgConsoleOutputMode;
|
||||||
static CONSOLE_CURSOR_INFO OrgConsoleCursorInfo;
|
static CONSOLE_CURSOR_INFO OrgConsoleCursorInfo;
|
||||||
static CONSOLE_SCREEN_BUFFER_INFO OrgConsoleBufferInfo;
|
static CONSOLE_SCREEN_BUFFER_INFO OrgConsoleBufferInfo;
|
||||||
|
static HANDLE CommandThread = NULL;
|
||||||
|
|
||||||
static HMENU hConsoleMenu = NULL;
|
static HMENU hConsoleMenu = NULL;
|
||||||
static INT VdmMenuPos = -1;
|
static INT VdmMenuPos = -1;
|
||||||
|
@ -196,6 +197,11 @@ BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType)
|
||||||
EmulatorInterrupt(0x23);
|
EmulatorInterrupt(0x23);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CTRL_LAST_CLOSE_EVENT:
|
||||||
|
{
|
||||||
|
if (CommandThread) TerminateThread(CommandThread, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
/* Stop the VDM if the user logs out or closes the console */
|
/* Stop the VDM if the user logs out or closes the console */
|
||||||
|
@ -279,6 +285,9 @@ BOOL ConsoleInit(VOID)
|
||||||
/* Set the handler routine */
|
/* Set the handler routine */
|
||||||
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
|
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
|
||||||
|
|
||||||
|
/* Enable the CTRL_LAST_CLOSE_EVENT */
|
||||||
|
SetLastConsoleEventActive();
|
||||||
|
|
||||||
/* Get the input handle to the real console, and check for success */
|
/* Get the input handle to the real console, and check for success */
|
||||||
ConsoleInput = CreateFileW(L"CONIN$",
|
ConsoleInput = CreateFileW(L"CONIN$",
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
|
@ -368,10 +377,8 @@ VOID ConsoleCleanup(VOID)
|
||||||
if (ConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(ConsoleInput);
|
if (ConsoleInput != INVALID_HANDLE_VALUE) CloseHandle(ConsoleInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
INT wmain(INT argc, WCHAR *argv[])
|
DWORD WINAPI CommandThreadProc(LPVOID Parameter)
|
||||||
{
|
{
|
||||||
#ifndef STANDALONE
|
|
||||||
|
|
||||||
VDM_COMMAND_INFO CommandInfo;
|
VDM_COMMAND_INFO CommandInfo;
|
||||||
CHAR CmdLine[MAX_PATH];
|
CHAR CmdLine[MAX_PATH];
|
||||||
CHAR AppName[MAX_PATH];
|
CHAR AppName[MAX_PATH];
|
||||||
|
@ -379,7 +386,50 @@ INT wmain(INT argc, WCHAR *argv[])
|
||||||
CHAR Desktop[MAX_PATH];
|
CHAR Desktop[MAX_PATH];
|
||||||
CHAR Title[MAX_PATH];
|
CHAR Title[MAX_PATH];
|
||||||
|
|
||||||
#else
|
UNREFERENCED_PARAMETER(Parameter);
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
/* Clear the structure */
|
||||||
|
ZeroMemory(&CommandInfo, sizeof(CommandInfo));
|
||||||
|
|
||||||
|
/* Initialize the structure members */
|
||||||
|
CommandInfo.VDMState = VDM_NOT_LOADED;
|
||||||
|
CommandInfo.CmdLine = CmdLine;
|
||||||
|
CommandInfo.CmdLen = sizeof(CmdLine);
|
||||||
|
CommandInfo.AppName = AppName;
|
||||||
|
CommandInfo.AppLen = sizeof(AppName);
|
||||||
|
CommandInfo.PifFile = PifFile;
|
||||||
|
CommandInfo.PifLen = sizeof(PifFile);
|
||||||
|
CommandInfo.Desktop = Desktop;
|
||||||
|
CommandInfo.DesktopLen = sizeof(Desktop);
|
||||||
|
CommandInfo.Title = Title;
|
||||||
|
CommandInfo.TitleLen = sizeof(Title);
|
||||||
|
|
||||||
|
/* Wait for the next available VDM */
|
||||||
|
if (!GetNextVDMCommand(&CommandInfo)) break;
|
||||||
|
|
||||||
|
/* Start the process from the command line */
|
||||||
|
DPRINT1("Starting '%s'...\n", AppName);
|
||||||
|
if (!DosCreateProcess(AppName, 0))
|
||||||
|
{
|
||||||
|
DisplayMessage(L"Could not start '%S'", AppName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start simulation */
|
||||||
|
EmulatorSimulate();
|
||||||
|
|
||||||
|
/* Perform another screen refresh */
|
||||||
|
VgaRefreshDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT wmain(INT argc, WCHAR *argv[])
|
||||||
|
{
|
||||||
|
#ifdef STANDALONE
|
||||||
|
|
||||||
CHAR CommandLine[DOS_CMDLINE_LENGTH];
|
CHAR CommandLine[DOS_CMDLINE_LENGTH];
|
||||||
|
|
||||||
|
@ -428,42 +478,20 @@ INT wmain(INT argc, WCHAR *argv[])
|
||||||
|
|
||||||
#ifndef STANDALONE
|
#ifndef STANDALONE
|
||||||
|
|
||||||
while (TRUE)
|
/* Create the GetNextVDMCommand thread */
|
||||||
|
CommandThread = CreateThread(NULL, 0, &CommandThreadProc, NULL, 0, NULL);
|
||||||
|
if (CommandThread == NULL)
|
||||||
{
|
{
|
||||||
/* Clear the structure */
|
wprintf(L"FATAL: Failed to create the command processing thread: %d\n", GetLastError());
|
||||||
ZeroMemory(&CommandInfo, sizeof(CommandInfo));
|
goto Cleanup;
|
||||||
|
|
||||||
/* Initialize the structure members */
|
|
||||||
CommandInfo.VDMState = VDM_NOT_LOADED;
|
|
||||||
CommandInfo.CmdLine = CmdLine;
|
|
||||||
CommandInfo.CmdLen = sizeof(CmdLine);
|
|
||||||
CommandInfo.AppName = AppName;
|
|
||||||
CommandInfo.AppLen = sizeof(AppName);
|
|
||||||
CommandInfo.PifFile = PifFile;
|
|
||||||
CommandInfo.PifLen = sizeof(PifFile);
|
|
||||||
CommandInfo.Desktop = Desktop;
|
|
||||||
CommandInfo.DesktopLen = sizeof(Desktop);
|
|
||||||
CommandInfo.Title = Title;
|
|
||||||
CommandInfo.TitleLen = sizeof(Title);
|
|
||||||
|
|
||||||
/* Wait for the next available VDM */
|
|
||||||
if (!GetNextVDMCommand(&CommandInfo)) break;
|
|
||||||
|
|
||||||
/* Start the process from the command line */
|
|
||||||
DPRINT1("Starting '%s'...\n", AppName);
|
|
||||||
if (!DosCreateProcess(AppName, 0))
|
|
||||||
{
|
|
||||||
DisplayMessage(L"Could not start '%S'", AppName);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Start simulation */
|
|
||||||
EmulatorSimulate();
|
|
||||||
|
|
||||||
/* Perform another screen refresh */
|
|
||||||
VgaRefreshDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wait for the command thread to exit */
|
||||||
|
WaitForSingleObject(CommandThread, INFINITE);
|
||||||
|
|
||||||
|
/* Close the thread handle */
|
||||||
|
CloseHandle(CommandThread);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Start the process from the command line */
|
/* Start the process from the command line */
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
DWORD WINAPI SetLastConsoleEventActive(VOID);
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID DisplayMessage(LPCWSTR Format, ...);
|
VOID DisplayMessage(LPCWSTR Format, ...);
|
||||||
|
|
Loading…
Reference in a new issue