[BASESRV]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 9 Feb 2014 17:37:35 +0000 (17:37 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sun, 9 Feb 2014 17:37:35 +0000 (17:37 +0000)
Add an (incomplete) definition for VDM console records and VDM DOS records.
Implement BaseSrvIsFirstVDM.
Start implementing BaseSrvCheckVDM.

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

subsystems/win/basesrv/init.c
subsystems/win/basesrv/vdm.c
subsystems/win/basesrv/vdm.h [new file with mode: 0644]

index 49e9485..79d1d46 100644 (file)
@@ -9,6 +9,7 @@
 /* INCLUDES *******************************************************************/
 
 #include "basesrv.h"
+#include "vdm.h"
 
 #include <winreg.h>
 
@@ -591,6 +592,9 @@ CSR_SERVER_DLL_INIT(ServerDllInitialization)
     /* Initialize DOS devices management */
     BaseInitDefineDosDevice();
 
+    /* Initialize VDM support */
+    BaseInitializeVDM();
+
     /* All done */
     return STATUS_SUCCESS;
 }
index 2ac4565..63125e9 100644 (file)
@@ -4,20 +4,90 @@
  * FILE:            subsystems/win/basesrv/vdm.c
  * PURPOSE:         Virtual DOS Machines (VDM) Support
  * PROGRAMMERS:     Hermes Belusca-Maito (hermes.belusca@sfr.fr)
+ *                  Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
  */
 
 /* INCLUDES *******************************************************************/
 
 #include "basesrv.h"
+#include "vdm.h"
 
 #define NDEBUG
 #include <debug.h>
 
+/* GLOBALS ********************************************************************/
+
+BOOLEAN FirstVDM = TRUE;
+LIST_ENTRY VDMConsoleListHead;
+RTL_CRITICAL_SECTION DosCriticalSection;
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS NTAPI BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
+{
+    PLIST_ENTRY i;
+    PVDM_CONSOLE_RECORD CurrentRecord = NULL;
+
+    /* Search for a record that has the same console handle */
+    for (i = VDMConsoleListHead.Flink; i != &VDMConsoleListHead; i = i->Flink)
+    {
+        CurrentRecord = CONTAINING_RECORD(i, VDM_CONSOLE_RECORD, Entry);
+        if (CurrentRecord->ConsoleHandle == ConsoleHandle) break;
+    }
+
+    *Record = CurrentRecord;
+    return CurrentRecord ? STATUS_SUCCESS : STATUS_NOT_FOUND;
+}
+
+VOID NTAPI BaseInitializeVDM(VOID)
+{
+    /* Initialize the list head */
+    InitializeListHead(&VDMConsoleListHead);
+
+    /* Initialize the critical section */
+    RtlInitializeCriticalSection(&DosCriticalSection);
+}
+
 /* PUBLIC SERVER APIS *********************************************************/
 
 CSR_API(BaseSrvCheckVDM)
 {
-    DPRINT1("%s not yet implemented\n", __FUNCTION__);
+    PBASE_CHECK_VDM CheckVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CheckVDMRequest;
+
+    /* Validate the message buffers */
+    if (!CsrValidateMessageBuffer(ApiMessage,
+                                  (PVOID*)&CheckVdmRequest->CmdLine,
+                                  CheckVdmRequest->CmdLen,
+                                  sizeof(*CheckVdmRequest->CmdLine))
+        || !CsrValidateMessageBuffer(ApiMessage,
+                                     (PVOID*)&CheckVdmRequest->AppName,
+                                     CheckVdmRequest->AppLen,
+                                     sizeof(*CheckVdmRequest->AppName))
+        || !CsrValidateMessageBuffer(ApiMessage,
+                                     (PVOID*)&CheckVdmRequest->PifFile,
+                                     CheckVdmRequest->PifLen,
+                                     sizeof(*CheckVdmRequest->PifFile))
+        || !CsrValidateMessageBuffer(ApiMessage,
+                                     (PVOID*)&CheckVdmRequest->CurDirectory,
+                                     CheckVdmRequest->CurDirectoryLen,
+                                     sizeof(*CheckVdmRequest->CurDirectory))
+        || !CsrValidateMessageBuffer(ApiMessage,
+                                     (PVOID*)&CheckVdmRequest->Desktop,
+                                     CheckVdmRequest->DesktopLen,
+                                     sizeof(*CheckVdmRequest->Desktop))
+        || !CsrValidateMessageBuffer(ApiMessage,
+                                     (PVOID*)&CheckVdmRequest->Title,
+                                     CheckVdmRequest->TitleLen,
+                                     sizeof(*CheckVdmRequest->Title))
+        || !CsrValidateMessageBuffer(ApiMessage,
+                                     (PVOID*)&CheckVdmRequest->Reserved,
+                                     CheckVdmRequest->ReservedLen,
+                                     sizeof(*CheckVdmRequest->Reserved)))
+    {
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    // TODO: NOT IMPLEMENTED
     return STATUS_NOT_IMPLEMENTED;
 }
 
@@ -41,8 +111,15 @@ CSR_API(BaseSrvExitVDM)
 
 CSR_API(BaseSrvIsFirstVDM)
 {
-    DPRINT1("%s not yet implemented\n", __FUNCTION__);
-    return STATUS_NOT_IMPLEMENTED;
+    PBASE_IS_FIRST_VDM IsFirstVDMRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.IsFirstVDMRequest;
+
+    /* Return the result */
+    IsFirstVDMRequest->FirstVDM = FirstVDM;
+    
+    /* Clear the first VDM flag */
+    FirstVDM = FALSE;
+
+    return STATUS_SUCCESS;
 }
 
 CSR_API(BaseSrvGetVDMExitCode)
diff --git a/subsystems/win/basesrv/vdm.h b/subsystems/win/basesrv/vdm.h
new file mode 100644 (file)
index 0000000..9147b29
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS Base API Server DLL
+ * FILE:            subsystems/win/basesrv/vdm.h
+ * PURPOSE:         VDM Definitions
+ * PROGRAMMERS:     Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ */
+
+#ifndef __VDM_H__
+#define __VDM_H__
+
+/* DEFINITIONS ****************************************************************/
+
+typedef struct _VDM_CONSOLE_RECORD
+{
+    LIST_ENTRY Entry;
+    HANDLE ConsoleHandle;
+    LIST_ENTRY DosListHead;
+    // TODO: Structure incomplete!!!
+} VDM_CONSOLE_RECORD, *PVDM_CONSOLE_RECORD;
+
+typedef struct _VDM_DOS_RECORD
+{
+    LIST_ENTRY Entry;
+    // TODO: Structure incomplete!!!
+} VDM_DOS_RECORD, *PVDM_DOS_RECORD;
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS NTAPI BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record);
+VOID NTAPI BaseInitializeVDM(VOID);
+
+#endif // __VDM_H__