Use VdmRunning to keep the state of the whole VDM, not a VDM task.
Add an event whose signaled state determines the state of the VDM task.
Use FILE_SHARE_READ when opening executables.
svn path=/branches/ntvdm/; revision=63116
/* Open a handle to the executable */
FileHandle = CreateFileA(ExecutablePath,
GENERIC_READ,
/* Open a handle to the executable */
FileHandle = CreateFileA(ExecutablePath,
GENERIC_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
if (Psp == CurrentPsp)
{
CurrentPsp = PspBlock->ParentPsp;
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 */
}
// FIXME: This is probably not the best way to do it
/* Check if this was a nested DOS task */
+ if (CurrentPsp != SYSTEM_PSP)
{
/* Decrement the re-entry count */
CommandInfo.VDMState = VDM_DEC_REENTER_COUNT;
{
/* Decrement the re-entry count */
CommandInfo.VDMState = VDM_DEC_REENTER_COUNT;
{
UNREFERENCED_PARAMETER(Stack);
{
UNREFERENCED_PARAMETER(Stack);
- /* Stop the VDM */
- VdmRunning = FALSE;
+ /* Stop the VDM task */
+ ResetEvent(VdmTaskEvent);
+ EmulatorUnsimulate();
}
VOID WINAPI DosFastConOut(LPWORD Stack)
}
VOID WINAPI DosFastConOut(LPWORD Stack)
- VdmRunning = CpuSimulate = TRUE;
while (VdmRunning && CpuSimulate) ClockUpdate();
CpuCallLevel--;
while (VdmRunning && CpuSimulate) ClockUpdate();
CpuCallLevel--;
static INT VdmMenuPos = -1;
static BOOLEAN ShowPointer = FALSE;
static INT VdmMenuPos = -1;
static BOOLEAN ShowPointer = FALSE;
+HANDLE VdmTaskEvent = NULL;
+
/*
* Those menu helpers were taken from the GUI frontend in winsrv.dll
*/
/*
* Those menu helpers were taken from the GUI frontend in winsrv.dll
*/
}
case CTRL_LAST_CLOSE_EVENT:
{
}
case CTRL_LAST_CLOSE_EVENT:
{
+ if (WaitForSingleObject(VdmTaskEvent, 0) == WAIT_TIMEOUT)
{
/* Exit immediately */
if (CommandThread) TerminateThread(CommandThread, 0);
{
/* Exit immediately */
if (CommandThread) TerminateThread(CommandThread, 0);
+ /* Make sure the task event is signaled */
+ WaitForSingleObject(VdmTaskEvent, INFINITE);
+
/* Wait for an input record */
if (!ReadConsoleInput(ConsoleInput, &InputRecord, 1, &Count))
{
/* Wait for an input record */
if (!ReadConsoleInput(ConsoleInput, &InputRecord, 1, &Count))
{
+ SetEvent(VdmTaskEvent);
EmulatorSimulate();
/* Perform another screen refresh */
EmulatorSimulate();
/* Perform another screen refresh */
DPRINT1("\n\n\nNTVDM - Starting...\n\n\n");
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())
{
/* Initialize the console */
if (!ConsoleInit())
{
+ SetEvent(VdmTaskEvent);
EmulatorSimulate();
/* Perform another screen refresh */
EmulatorSimulate();
/* Perform another screen refresh */
/* FUNCTIONS ******************************************************************/
/* FUNCTIONS ******************************************************************/
+extern HANDLE VdmTaskEvent;
+
VOID DisplayMessage(LPCWSTR Format, ...);
#endif // _NTVDM_H_
VOID DisplayMessage(LPCWSTR Format, ...);
#endif // _NTVDM_H_