mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[BASESRV]
Move the VDM states and binary types to a public header file. Implement GetNextDosSesId. Continue implementing BaseSrvCheckVDM. svn path=/branches/ntvdm/; revision=62200
This commit is contained in:
parent
522f29b775
commit
c64a03a80f
5 changed files with 126 additions and 20 deletions
|
@ -25,24 +25,6 @@ typedef enum _VDM_ENTRY_CODE
|
|||
#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 *****************************************************************/
|
||||
|
||||
typedef struct _GET_NEXT_VDM_COMMAND_DATA
|
||||
|
|
|
@ -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>
|
||||
|
|
35
include/reactos/subsys/win/vdm.h
Normal file
35
include/reactos/subsys/win/vdm.h
Normal file
|
@ -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 */
|
|
@ -20,6 +20,7 @@
|
|||
BOOLEAN FirstVDM = TRUE;
|
||||
LIST_ENTRY VDMConsoleListHead;
|
||||
RTL_CRITICAL_SECTION DosCriticalSection;
|
||||
RTL_CRITICAL_SECTION WowCriticalSection;
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
|
@ -39,6 +40,35 @@ NTSTATUS NTAPI BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD
|
|||
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 @@ VOID NTAPI BaseInitializeVDM(VOID)
|
|||
|
||||
/* 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 @@ CSR_API(BaseSrvCheckVDM)
|
|||
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)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef __VDM_H__
|
||||
#define __VDM_H__
|
||||
|
||||
#include <win/vdm.h>
|
||||
|
||||
/* DEFINITIONS ****************************************************************/
|
||||
|
||||
typedef struct _VDM_CONSOLE_RECORD
|
||||
|
@ -17,6 +19,7 @@ typedef struct _VDM_CONSOLE_RECORD
|
|||
HANDLE ConsoleHandle;
|
||||
PCHAR CurrentDirs;
|
||||
ULONG CurDirsLength;
|
||||
ULONG SessionId;
|
||||
LIST_ENTRY DosListHead;
|
||||
// TODO: Structure incomplete!!!
|
||||
} VDM_CONSOLE_RECORD, *PVDM_CONSOLE_RECORD;
|
||||
|
|
Loading…
Reference in a new issue