/* Open a handle to the executable */
FileHandle = CreateFileA(ExecutablePath,
GENERIC_READ,
- 0,
+ FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
if (Psp == CurrentPsp)
{
CurrentPsp = PspBlock->ParentPsp;
- if (CurrentPsp == SYSTEM_PSP) VdmRunning = FALSE;
+ if (CurrentPsp == SYSTEM_PSP)
+ {
+ ResetEvent(VdmTaskEvent);
+ EmulatorUnsimulate();
+ }
}
// FIXME: This is probably not the best way to do it
/* Check if this was a nested DOS task */
- if (VdmRunning)
+ if (CurrentPsp != SYSTEM_PSP)
{
/* Decrement the re-entry count */
CommandInfo.VDMState = VDM_DEC_REENTER_COUNT;
{
UNREFERENCED_PARAMETER(Stack);
- /* Stop the VDM */
- VdmRunning = FALSE;
+ /* Stop the VDM task */
+ ResetEvent(VdmTaskEvent);
+ EmulatorUnsimulate();
}
VOID WINAPI DosFastConOut(LPWORD Stack)
static INT VdmMenuPos = -1;
static BOOLEAN ShowPointer = FALSE;
+HANDLE VdmTaskEvent = NULL;
+
/*
* Those menu helpers were taken from the GUI frontend in winsrv.dll
*/
}
case CTRL_LAST_CLOSE_EVENT:
{
- if (!VdmRunning)
+ if (WaitForSingleObject(VdmTaskEvent, 0) == WAIT_TIMEOUT)
{
/* Exit immediately */
if (CommandThread) TerminateThread(CommandThread, 0);
+ EmulatorTerminate();
}
else
{
while (VdmRunning)
{
+ /* Make sure the task event is signaled */
+ WaitForSingleObject(VdmTaskEvent, INFINITE);
+
/* Wait for an input record */
if (!ReadConsoleInput(ConsoleInput, &InputRecord, 1, &Count))
{
}
/* Start simulation */
+ SetEvent(VdmTaskEvent);
EmulatorSimulate();
/* Perform another screen refresh */
DPRINT1("\n\n\nNTVDM - Starting...\n\n\n");
+ /* Create the task event */
+ VdmTaskEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ ASSERT(VdmTaskEvent != NULL);
+
/* Initialize the console */
if (!ConsoleInit())
{
}
/* Start simulation */
+ SetEvent(VdmTaskEvent);
EmulatorSimulate();
/* Perform another screen refresh */