From d0176d9ee8d12a84d7c6a7d37fecdb2a023c20f1 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sun, 9 Feb 2014 22:26:13 +0000 Subject: [PATCH] [BASESRV] Implement BaseSrvGetVDMCurDirs. The current directory information is stored in the console record, and it applies to all DOS records within it. svn path=/branches/ntvdm/; revision=62086 --- subsystems/win/basesrv/vdm.c | 41 +++++++++++++++++++++++++++++++++--- subsystems/win/basesrv/vdm.h | 2 ++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/subsystems/win/basesrv/vdm.c b/subsystems/win/basesrv/vdm.c index 63125e93e54..cc8d6ded65f 100644 --- a/subsystems/win/basesrv/vdm.c +++ b/subsystems/win/basesrv/vdm.c @@ -115,7 +115,7 @@ CSR_API(BaseSrvIsFirstVDM) /* Return the result */ IsFirstVDMRequest->FirstVDM = FirstVDM; - + /* Clear the first VDM flag */ FirstVDM = FALSE; @@ -142,8 +142,43 @@ CSR_API(BaseSrvSetVDMCurDirs) CSR_API(BaseSrvGetVDMCurDirs) { - DPRINT1("%s not yet implemented\n", __FUNCTION__); - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest; + PVDM_CONSOLE_RECORD ConsoleRecord; + + /* Validate the output buffer */ + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs, + VDMCurrentDirsRequest->cchCurDirs, + sizeof(*VDMCurrentDirsRequest->lpszzCurDirs))) + { + return STATUS_INVALID_PARAMETER; + } + + /* Enter the critical section */ + RtlEnterCriticalSection(&DosCriticalSection); + + /* Find the console record */ + Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord); + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* Check if the buffer is large enough */ + if (VDMCurrentDirsRequest->cchCurDirs < ConsoleRecord->CurDirsLength) + { + Status = STATUS_BUFFER_TOO_SMALL; + goto Cleanup; + } + + /* Copy the data */ + RtlMoveMemory(VDMCurrentDirsRequest->lpszzCurDirs, + ConsoleRecord->CurrentDirs, + ConsoleRecord->CurDirsLength); + +Cleanup: + /* Leave the critical section */ + RtlLeaveCriticalSection(&DosCriticalSection); + + return Status; } CSR_API(BaseSrvBatNotification) diff --git a/subsystems/win/basesrv/vdm.h b/subsystems/win/basesrv/vdm.h index 9147b29a62d..1b844b6aca8 100644 --- a/subsystems/win/basesrv/vdm.h +++ b/subsystems/win/basesrv/vdm.h @@ -15,6 +15,8 @@ typedef struct _VDM_CONSOLE_RECORD { LIST_ENTRY Entry; HANDLE ConsoleHandle; + PCHAR CurrentDirs; + ULONG CurDirsLength; LIST_ENTRY DosListHead; // TODO: Structure incomplete!!! } VDM_CONSOLE_RECORD, *PVDM_CONSOLE_RECORD; -- 2.17.1