diff --git a/dll/win32/kernel32/client/vdm.c b/dll/win32/kernel32/client/vdm.c index c37a3cf3589..07f65a3101c 100644 --- a/dll/win32/kernel32/client/vdm.c +++ b/dll/win32/kernel32/client/vdm.c @@ -401,8 +401,17 @@ BaseCheckVDM(IN ULONG BinaryType, CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepCheckVDM), sizeof(BASE_CHECK_VDM)); - /* Write back the task ID */ - *iTask = CheckVdm->iTask; + /* Check if there is no console */ + if (CheckVdm->ConsoleHandle == NULL) + { + /* Write back the task ID */ + *iTask = CheckVdm->iTask; + } + else + { + /* Otherwise, iTask should be zero */ + *iTask = 0; + } Cleanup: diff --git a/subsystems/ntvdm/ntvdm.c b/subsystems/ntvdm/ntvdm.c index 3576bf4182c..813a8858f0a 100644 --- a/subsystems/ntvdm/ntvdm.c +++ b/subsystems/ntvdm/ntvdm.c @@ -377,7 +377,7 @@ DWORD WINAPI CommandThreadProc(LPVOID Parameter) UNREFERENCED_PARAMETER(Parameter); - while (AcceptCommands) + do { /* Clear the structure */ ZeroMemory(&CommandInfo, sizeof(CommandInfo)); @@ -431,6 +431,7 @@ DWORD WINAPI CommandThreadProc(LPVOID Parameter) First = FALSE; } + while (AcceptCommands); return 0; } @@ -468,6 +469,9 @@ INT wmain(INT argc, WCHAR *argv[]) { /* This is the session ID */ SessionId = wcstoul(argv[i] + 2, &endptr, 10); + + /* The VDM hasn't been started from a console, so quit when the task is done */ + AcceptCommands = FALSE; } }