Author: aandrejevic
Date: Tue Feb 18 02:15:33 2014
New Revision: 62237

URL: http://svn.reactos.org/svn/reactos?rev=62237&view=rev
Log:
[BASESRV]
Implement BaseSrvGetVDMExitCode.


Modified:
    branches/ntvdm/subsystems/win/basesrv/vdm.c
    branches/ntvdm/subsystems/win/basesrv/vdm.h

Modified: branches/ntvdm/subsystems/win/basesrv/vdm.c
URL: 
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/win/basesrv/vdm.c?rev=62237&r1=62236&r2=62237&view=diff
==============================================================================
--- branches/ntvdm/subsystems/win/basesrv/vdm.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/win/basesrv/vdm.c [iso-8859-1] Tue Feb 18 
02:15:33 2014
@@ -209,8 +209,52 @@
 
 CSR_API(BaseSrvGetVDMExitCode)
 {
-    DPRINT1("%s not yet implemented\n", __FUNCTION__);
-    return STATUS_NOT_IMPLEMENTED;
+    NTSTATUS Status;
+    PBASE_GET_VDM_EXIT_CODE GetVDMExitCodeRequest = 
&((PBASE_API_MESSAGE)ApiMessage)->Data.GetVDMExitCodeRequest;
+    PLIST_ENTRY i = NULL;
+    PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
+    PVDM_DOS_RECORD DosRecord = NULL;
+
+    /* Enter the critical section */
+    RtlEnterCriticalSection(&DosCriticalSection);
+
+    /* Get the console record */
+    Status = BaseSrvGetConsoleRecord(GetVDMExitCodeRequest->ConsoleHandle, 
&ConsoleRecord);
+    if (!NT_SUCCESS(Status)) goto Cleanup;
+
+    /* Search for a DOS record that has the same parent process handle */
+    for (i = ConsoleRecord->DosListHead.Flink; i != 
&ConsoleRecord->DosListHead; i = i->Flink)
+    {
+        DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
+        if (DosRecord->ParentProcess == GetVDMExitCodeRequest->hParent) break;
+    }
+
+    /* Check if no DOS record was found */
+    if (i == &ConsoleRecord->DosListHead)
+    {
+        Status = STATUS_NOT_FOUND;
+        goto Cleanup;
+    }
+
+    /* Check if this task is still running */
+    if (DosRecord->State == VDM_READY)
+    {
+        GetVDMExitCodeRequest->ExitCode = STATUS_PENDING;
+        goto Cleanup;
+    }
+
+    /* Return the exit code */
+    GetVDMExitCodeRequest->ExitCode = DosRecord->ExitCode;
+
+    /* Since this is a zombie task record, remove it */
+    RemoveEntryList(&DosRecord->Entry);
+    RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
+
+Cleanup:
+    /* Leave the critical section */
+    RtlLeaveCriticalSection(&DosCriticalSection);
+
+    return Status;
 }
 
 CSR_API(BaseSrvSetReenterCount)

Modified: branches/ntvdm/subsystems/win/basesrv/vdm.h
URL: 
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/win/basesrv/vdm.h?rev=62237&r1=62236&r2=62237&view=diff
==============================================================================
--- branches/ntvdm/subsystems/win/basesrv/vdm.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/win/basesrv/vdm.h [iso-8859-1] Tue Feb 18 
02:15:33 2014
@@ -27,6 +27,9 @@
 typedef struct _VDM_DOS_RECORD
 {
     LIST_ENTRY Entry;
+    USHORT State;
+    ULONG ExitCode;
+    HANDLE ParentProcess;
     // TODO: Structure incomplete!!!
 } VDM_DOS_RECORD, *PVDM_DOS_RECORD;
 


Reply via email to