From: Aleksandar Andrejevic Date: Sat, 1 Mar 2014 15:13:54 +0000 (+0000) Subject: [BASESRV] X-Git-Tag: backups/0.3.17@66124~1365^2~51 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=d01148ac9b99397dfdffd28407270deb5cbc936d;hp=f488f7003ea2f49ba4691410ca95c0b0efd21633 [BASESRV] 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 --- diff --git a/subsystems/win/basesrv/vdm.c b/subsystems/win/basesrv/vdm.c index a8991c31e4f..63f4425ece0 100644 --- a/subsystems/win/basesrv/vdm.c +++ b/subsystems/win/basesrv/vdm.c @@ -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 */ diff --git a/subsystems/win/basesrv/vdm.h b/subsystems/win/basesrv/vdm.h index f12be8458ea..37f34baf251 100644 --- a/subsystems/win/basesrv/vdm.h +++ b/subsystems/win/basesrv/vdm.h @@ -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;