Author: aandrejevic Date: Sun Feb 16 00:09:27 2014 New Revision: 62200
URL: http://svn.reactos.org/svn/reactos?rev=62200&view=rev Log: [BASESRV] Move the VDM states and binary types to a public header file. Implement GetNextDosSesId. Continue implementing BaseSrvCheckVDM.
Added: branches/ntvdm/include/reactos/subsys/win/vdm.h (with props) Modified: branches/ntvdm/dll/win32/kernel32/include/vdm.h branches/ntvdm/dll/win32/kernel32/k32.h branches/ntvdm/subsystems/win/basesrv/vdm.c branches/ntvdm/subsystems/win/basesrv/vdm.h
Modified: branches/ntvdm/dll/win32/kernel32/include/vdm.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/dll/win32/kernel32/include... ============================================================================== --- branches/ntvdm/dll/win32/kernel32/include/vdm.h [iso-8859-1] (original) +++ branches/ntvdm/dll/win32/kernel32/include/vdm.h [iso-8859-1] Sun Feb 16 00:09:27 2014 @@ -24,24 +24,6 @@ #define VDM_UNDO_FULL 0x02 #define VDM_UNDO_REUSE 0x04 #define VDM_UNDO_COMPLETED 0x08 - -// -// Binary Types to share with VDM -// -#define BINARY_TYPE_EXE 0x01 -#define BINARY_TYPE_COM 0x02 -#define BINARY_TYPE_PIF 0x03 -#define BINARY_TYPE_DOS 0x10 -#define BINARY_TYPE_SEPARATE_WOW 0x20 -#define BINARY_TYPE_WOW 0x40 -#define BINARY_TYPE_WOW_EX 0x80 - -// -// VDM States -// -#define VDM_NOT_LOADED 0x01 -#define VDM_NOT_READY 0x02 -#define VDM_READY 0x04
/* STRUCTURES *****************************************************************/
Modified: branches/ntvdm/dll/win32/kernel32/k32.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/dll/win32/kernel32/k32.h?r... ============================================================================== --- branches/ntvdm/dll/win32/kernel32/k32.h [iso-8859-1] (original) +++ branches/ntvdm/dll/win32/kernel32/k32.h [iso-8859-1] Sun Feb 16 00:09:27 2014 @@ -46,6 +46,7 @@ #include <win/basemsg.h> #include <win/console.h> #include <win/conmsg.h> +#include <win/vdm.h>
/* DDK Driver Headers */ #include <mountmgr.h>
Added: branches/ntvdm/include/reactos/subsys/win/vdm.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/subsys/win... ============================================================================== --- branches/ntvdm/include/reactos/subsys/win/vdm.h (added) +++ branches/ntvdm/include/reactos/subsys/win/vdm.h [iso-8859-1] Sun Feb 16 00:09:27 2014 @@ -0,0 +1,35 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Base API Server DLL + * FILE: include/reactos/subsys/win/vdm.h + * PURPOSE: Public definitions for the Virtual Dos Machine + * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org> + * Alex Ionescu (alex.ionescu@reactos.org) + */ + +#ifndef _VDM_H +#define _VDM_H + +#pragma once + +// +// Binary Types to share with VDM +// +#define BINARY_TYPE_EXE 0x01 +#define BINARY_TYPE_COM 0x02 +#define BINARY_TYPE_PIF 0x03 +#define BINARY_TYPE_DOS 0x10 +#define BINARY_TYPE_SEPARATE_WOW 0x20 +#define BINARY_TYPE_WOW 0x40 +#define BINARY_TYPE_WOW_EX 0x80 + +// +// VDM States +// +#define VDM_NOT_LOADED 0x01 +#define VDM_NOT_READY 0x02 +#define VDM_READY 0x04 + +#endif // _VDM_H + +/* EOF */
Propchange: branches/ntvdm/include/reactos/subsys/win/vdm.h ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/ntvdm/subsystems/win/basesrv/vdm.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/win/basesrv/vdm... ============================================================================== --- branches/ntvdm/subsystems/win/basesrv/vdm.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/win/basesrv/vdm.c [iso-8859-1] Sun Feb 16 00:09:27 2014 @@ -20,6 +20,7 @@ BOOLEAN FirstVDM = TRUE; LIST_ENTRY VDMConsoleListHead; RTL_CRITICAL_SECTION DosCriticalSection; +RTL_CRITICAL_SECTION WowCriticalSection;
/* FUNCTIONS ******************************************************************/
@@ -39,6 +40,35 @@ return CurrentRecord ? STATUS_SUCCESS : STATUS_NOT_FOUND; }
+ULONG NTAPI GetNextDosSesId(VOID) +{ + ULONG SessionId; + PLIST_ENTRY i; + PVDM_CONSOLE_RECORD CurrentRecord = NULL; + BOOLEAN Found; + + /* Search for an available session ID */ + for (SessionId = 1; SessionId != 0; SessionId++) + { + Found = FALSE; + + /* Check if the ID is already in use */ + for (i = VDMConsoleListHead.Flink; i != &VDMConsoleListHead; i = i->Flink) + { + CurrentRecord = CONTAINING_RECORD(i, VDM_CONSOLE_RECORD, Entry); + if (CurrentRecord->SessionId == SessionId) Found = TRUE; + } + + /* If not, we found one */ + if (!Found) break; + } + + ASSERT(SessionId != 0); + + /* Return the session ID */ + return SessionId; +} + VOID NTAPI BaseInitializeVDM(VOID) { /* Initialize the list head */ @@ -46,13 +76,17 @@
/* Initialize the critical section */ RtlInitializeCriticalSection(&DosCriticalSection); + RtlInitializeCriticalSection(&WowCriticalSection); }
/* PUBLIC SERVER APIS *********************************************************/
CSR_API(BaseSrvCheckVDM) { + NTSTATUS Status; PBASE_CHECK_VDM CheckVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CheckVDMRequest; + PRTL_CRITICAL_SECTION CriticalSection = NULL; + PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
/* Validate the message buffers */ if (!CsrValidateMessageBuffer(ApiMessage, @@ -87,8 +121,59 @@ return STATUS_INVALID_PARAMETER; }
- // TODO: NOT IMPLEMENTED - return STATUS_NOT_IMPLEMENTED; + CriticalSection = (CheckVdmRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW) + ? &DosCriticalSection + : &WowCriticalSection; + + /* Enter the critical section */ + RtlEnterCriticalSection(CriticalSection); + + /* Check if this is a DOS or WOW VDM */ + if (CheckVdmRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW) + { + /* Get the console record */ + Status = BaseSrvGetConsoleRecord(CheckVdmRequest->ConsoleHandle, + &ConsoleRecord); + + if (!NT_SUCCESS(Status)) + { + /* Allocate a new console record */ + ConsoleRecord = (PVDM_CONSOLE_RECORD)RtlAllocateHeap(BaseSrvHeap, + HEAP_ZERO_MEMORY, + sizeof(VDM_CONSOLE_RECORD)); + if (ConsoleRecord == NULL) + { + Status = STATUS_NO_MEMORY; + goto Cleanup; + } + + /* Initialize the console record */ + ConsoleRecord->ConsoleHandle = CheckVdmRequest->ConsoleHandle; + ConsoleRecord->CurrentDirs = NULL; + ConsoleRecord->CurDirsLength = 0; + ConsoleRecord->SessionId = GetNextDosSesId(); + InitializeListHead(&ConsoleRecord->DosListHead); + + /* Add the console record */ + InsertTailList(&VDMConsoleListHead, &ConsoleRecord->Entry); + } + + // TODO: NOT IMPLEMENTED + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; + } + else + { + // TODO: NOT IMPLEMENTED + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; + } + +Cleanup: + /* Leave the critical section */ + RtlLeaveCriticalSection(CriticalSection); + + return Status; }
CSR_API(BaseSrvUpdateVDMEntry)
Modified: branches/ntvdm/subsystems/win/basesrv/vdm.h URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/win/basesrv/vdm... ============================================================================== --- branches/ntvdm/subsystems/win/basesrv/vdm.h [iso-8859-1] (original) +++ branches/ntvdm/subsystems/win/basesrv/vdm.h [iso-8859-1] Sun Feb 16 00:09:27 2014 @@ -9,6 +9,8 @@ #ifndef __VDM_H__ #define __VDM_H__
+#include <win/vdm.h> + /* DEFINITIONS ****************************************************************/
typedef struct _VDM_CONSOLE_RECORD @@ -17,6 +19,7 @@ HANDLE ConsoleHandle; PCHAR CurrentDirs; ULONG CurDirsLength; + ULONG SessionId; LIST_ENTRY DosListHead; // TODO: Structure incomplete!!! } VDM_CONSOLE_RECORD, *PVDM_CONSOLE_RECORD;