[BASESRV]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 1 Mar 2014 15:13:54 +0000 (15:13 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 1 Mar 2014 15:13:54 +0000 (15:13 +0000)
Implement a function that creates a pair of event handles - BaseSrvCreatePairWaitHandles.
As already explained in the comments of BaseCheckForVDM (in kernel32), the hParent parameter
is actually an event handle (or more precisely, the client event handle), not a process handle.

svn path=/branches/ntvdm/; revision=62367

subsystems/win/basesrv/vdm.c
subsystems/win/basesrv/vdm.h

index a8991c3..63f4425 100644 (file)
@@ -166,6 +166,27 @@ BOOLEAN NTAPI BaseSrvIsVdmAllowed(VOID)
     return VdmAllowed;
 }
 
+NTSTATUS NTAPI BaseSrvCreatePairWaitHandles(PHANDLE ServerEvent, PHANDLE ClientEvent)
+{
+    NTSTATUS Status;
+
+    /* Create the event */
+    Status = NtCreateEvent(ServerEvent, EVENT_ALL_ACCESS, NULL, NotificationEvent, FALSE);
+    if (!NT_SUCCESS(Status)) return Status;
+
+    /* Duplicate the event into the client process */
+    Status = NtDuplicateObject(NtCurrentProcess(),
+                               *ServerEvent,
+                               CsrGetClientThread()->Process->ProcessHandle,
+                               ClientEvent,
+                               0,
+                               0,
+                               DUPLICATE_SAME_ATTRIBUTES | DUPLICATE_SAME_ACCESS);
+
+    if (!NT_SUCCESS(Status)) NtClose(*ServerEvent);
+    return Status;
+}
+
 VOID NTAPI BaseInitializeVDM(VOID)
 {
     /* Initialize the list head */
@@ -276,6 +297,9 @@ CSR_API(BaseSrvCheckVDM)
         DosRecord->ExitCode = 0;
         // TODO: The DOS record structure is incomplete
 
+        Status = BaseSrvCreatePairWaitHandles(&DosRecord->ServerEvent, &DosRecord->ClientEvent);
+        if (!NT_SUCCESS(Status)) goto Cleanup;
+
         /* Add the DOS record */
         InsertHeadList(&ConsoleRecord->DosListHead, &DosRecord->Entry);
 
@@ -423,7 +447,7 @@ CSR_API(BaseSrvGetVDMExitCode)
     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;
+        if (DosRecord->ClientEvent == GetVDMExitCodeRequest->hParent) break;
     }
 
     /* Check if no DOS record was found */
index f12be84..37f34ba 100644 (file)
@@ -32,7 +32,8 @@ typedef struct _VDM_DOS_RECORD
     LIST_ENTRY Entry;
     USHORT State;
     ULONG ExitCode;
-    HANDLE ParentProcess;
+    HANDLE ServerEvent;
+    HANDLE ClientEvent;
     // TODO: Structure incomplete!!!
 } VDM_DOS_RECORD, *PVDM_DOS_RECORD;