From e9fde4873de6bf96a84595cc8797103d55b2763f Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sat, 30 May 2015 02:23:44 +0000 Subject: [PATCH] [NTVDM][BASESRV] - When a DOS application is started by a process that has no console, the ConsoleHandle in the VDM_CONSOLE_RECORD is initially NULL. Fix that by making an initial VDM_GET_FIRST_COMMAND call in NTVDM and setting the ConsoleHandle to the handle of NTVDM's console in BaseSrvGetNextVDMCommand. - Fix a bug in BaseSrvGetVDMExitCode (VDM_READY means the task has exited). svn path=/trunk/; revision=67961 --- reactos/subsystems/mvdm/ntvdm/dos/dem.c | 8 ++++++++ reactos/subsystems/win/basesrv/vdm.c | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dem.c b/reactos/subsystems/mvdm/ntvdm/dos/dem.c index 4ea219420b9..f4608ea1eea 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dem.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dem.c @@ -217,6 +217,14 @@ CommandThreadProc(LPVOID Parameter) UNREFERENCED_PARAMETER(Parameter); ASSERT(Env); + /* Clear the structure */ + RtlZeroMemory(&CommandInfo, sizeof(CommandInfo)); + + /* Get the initial information */ + CommandInfo.TaskId = SessionId; + CommandInfo.VDMState = VDM_GET_FIRST_COMMAND | VDM_FLAG_DOS; + GetNextVDMCommand(&CommandInfo); + do { /* Clear the structure */ diff --git a/reactos/subsystems/win/basesrv/vdm.c b/reactos/subsystems/win/basesrv/vdm.c index 44e63d6b2d3..2493120fdf8 100644 --- a/reactos/subsystems/win/basesrv/vdm.c +++ b/reactos/subsystems/win/basesrv/vdm.c @@ -976,6 +976,13 @@ CSR_API(BaseSrvGetNextVDMCommand) goto Cleanup; } + /* Check if the console handle hasn't been set yet */ + if (ConsoleRecord->ConsoleHandle == NULL) + { + /* Set it now */ + ConsoleRecord->ConsoleHandle = GetNextVdmCommandRequest->ConsoleHandle; + } + /* Fill the command information */ Status = BaseSrvFillCommandInfo(DosRecord->CommandInfo, GetNextVdmCommandRequest); goto Cleanup; @@ -1204,7 +1211,7 @@ CSR_API(BaseSrvGetVDMExitCode) } /* Check if this task is still running */ - if (DosRecord->State == VDM_READY) + if (DosRecord->State != VDM_READY) { GetVDMExitCodeRequest->ExitCode = STATUS_PENDING; goto Cleanup; -- 2.17.1