Author: aandrejevic
Date: Sun Mar 2 02:50:40 2014
New Revision: 62374
URL:
http://svn.reactos.org/svn/reactos?rev=62374&view=rev
Log:
[BASESRV]
Move the GET_NEXT_VDM_COMMAND_DATA structure to a global header, and
rename it to VDM_COMMAND_INFO.
Implement BaseSrvCopyCommand, which moves the BASE_CHECK_VDM structure data
into a new VDM_COMMAND_INFO structure.
Implement BaseSrvFreeVDMInfo which frees a VDM_COMMAND_INFO structure and
everything in it.
Modified:
branches/ntvdm/dll/win32/kernel32/client/vdm.c
branches/ntvdm/dll/win32/kernel32/include/vdm.h
branches/ntvdm/include/reactos/subsys/win/vdm.h
branches/ntvdm/subsystems/win/basesrv/vdm.c
branches/ntvdm/subsystems/win/basesrv/vdm.h
Modified: branches/ntvdm/dll/win32/kernel32/client/vdm.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/dll/win32/kernel32/client…
==============================================================================
--- branches/ntvdm/dll/win32/kernel32/client/vdm.c [iso-8859-1] (original)
+++ branches/ntvdm/dll/win32/kernel32/client/vdm.c [iso-8859-1] Sun Mar 2 02:50:40 2014
@@ -1130,7 +1130,7 @@
*/
DWORD
WINAPI
-GetNextVDMCommand(PGET_NEXT_VDM_COMMAND_DATA CommandData)
+GetNextVDMCommand(PVDM_COMMAND_INFO CommandData)
{
STUB;
return 0;
Modified: branches/ntvdm/dll/win32/kernel32/include/vdm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/dll/win32/kernel32/includ…
==============================================================================
--- branches/ntvdm/dll/win32/kernel32/include/vdm.h [iso-8859-1] (original)
+++ branches/ntvdm/dll/win32/kernel32/include/vdm.h [iso-8859-1] Sun Mar 2 02:50:40 2014
@@ -24,39 +24,6 @@
#define VDM_UNDO_FULL 0x02
#define VDM_UNDO_REUSE 0x04
#define VDM_UNDO_COMPLETED 0x08
-
-/* STRUCTURES *****************************************************************/
-
-typedef struct _GET_NEXT_VDM_COMMAND_DATA
-{
- ULONG iTask;
- ULONG dwUnused;
- ULONG dwExitCode;
- ULONG dwCodePage;
- HANDLE hStdIn;
- HANDLE hStdOut;
- HANDLE hStdErr;
- LPSTR lpCmdLine;
- LPSTR lpAppName;
- LPSTR lpPifFile;
- LPSTR lpCurDirectory;
- LPSTR lpEnv;
- ULONG dwEnvLen;
- STARTUPINFOA StartupInfo;
- LPSTR lpDesktop;
- ULONG dwDesktopLen;
- LPSTR lpTitle;
- ULONG dwTitleLen;
- LPVOID lpReserved;
- ULONG dwReservedLen;
- USHORT wCmdLen;
- USHORT wAppLen;
- USHORT wPifLen;
- USHORT wCurDirectoryLen;
- USHORT wVDMState;
- USHORT wCurrentDrive;
- BOOLEAN fComingFromBat;
-} GET_NEXT_VDM_COMMAND_DATA, *PGET_NEXT_VDM_COMMAND_DATA;
/* FUNCTION PROTOTYPES ********************************************************/
Modified: branches/ntvdm/include/reactos/subsys/win/vdm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/include/reactos/subsys/wi…
==============================================================================
--- branches/ntvdm/include/reactos/subsys/win/vdm.h [iso-8859-1] (original)
+++ branches/ntvdm/include/reactos/subsys/win/vdm.h [iso-8859-1] Sun Mar 2 02:50:40 2014
@@ -30,6 +30,37 @@
#define VDM_NOT_READY 0x02
#define VDM_READY 0x04
+typedef struct
+{
+ ULONG TaskId;
+ ULONG Unused;
+ ULONG ExitCode;
+ ULONG CodePage;
+ HANDLE StdIn;
+ HANDLE StdOut;
+ HANDLE StdErr;
+ LPSTR CmdLine;
+ LPSTR AppName;
+ LPSTR PifFile;
+ LPSTR CurDirectory;
+ LPSTR Env;
+ ULONG EnvLen;
+ STARTUPINFOA StartupInfo;
+ LPSTR Desktop;
+ ULONG DesktopLen;
+ LPSTR Title;
+ ULONG TitleLen;
+ LPVOID Reserved;
+ ULONG ReservedLen;
+ USHORT CmdLen;
+ USHORT AppLen;
+ USHORT PifLen;
+ USHORT CurDirectoryLen;
+ USHORT VDMState;
+ USHORT CurrentDrive;
+ BOOLEAN ComingFromBat;
+} VDM_COMMAND_INFO, *PVDM_COMMAND_INFO;
+
#endif // _VDM_H
/* EOF */
Modified: branches/ntvdm/subsystems/win/basesrv/vdm.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/win/basesrv/vd…
==============================================================================
--- branches/ntvdm/subsystems/win/basesrv/vdm.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/win/basesrv/vdm.c [iso-8859-1] Sun Mar 2 02:50:40 2014
@@ -185,6 +185,166 @@
if (!NT_SUCCESS(Status)) NtClose(*ServerEvent);
return Status;
+}
+
+VOID BaseSrvFreeVDMInfo(PVDM_COMMAND_INFO CommandInfo)
+{
+ /* Free the allocated structure members */
+ if (CommandInfo->CmdLine != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->CmdLine);
+ if (CommandInfo->AppName != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->AppName);
+ if (CommandInfo->PifFile != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->PifFile);
+ if (CommandInfo->CurDirectory != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->CurDirectory);
+ if (CommandInfo->Env != NULL) RtlFreeHeap(BaseSrvHeap, 0, CommandInfo->Env);
+ if (CommandInfo->Desktop != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->Desktop);
+ if (CommandInfo->Title != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->Title);
+ if (CommandInfo->Reserved != NULL) RtlFreeHeap(BaseSrvHeap, 0,
CommandInfo->Reserved);
+
+ /* Free the structure itself */
+ RtlFreeHeap(BaseSrvHeap, 0, CommandInfo);
+}
+
+BOOLEAN NTAPI BaseSrvCopyCommand(PBASE_CHECK_VDM CheckVdmRequest, PVDM_DOS_RECORD
DosRecord)
+{
+ BOOLEAN Success = FALSE;
+ PVDM_COMMAND_INFO CommandInfo = NULL;
+
+ /* Allocate the command information structure */
+ CommandInfo = (PVDM_COMMAND_INFO)RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ sizeof(VDM_COMMAND_INFO));
+ if (CommandInfo == NULL) return FALSE;
+
+ /* Fill the structure */
+ CommandInfo->TaskId = CheckVdmRequest->iTask;
+ CommandInfo->ExitCode = DosRecord->ExitCode;
+ CommandInfo->CodePage = CheckVdmRequest->CodePage;
+ CommandInfo->StdIn = CheckVdmRequest->StdIn;
+ CommandInfo->StdOut = CheckVdmRequest->StdOut;
+ CommandInfo->StdErr = CheckVdmRequest->StdErr;
+
+ /* Allocate memory for the command line */
+ CommandInfo->CmdLine = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->CmdLen);
+ if (CommandInfo->CmdLine == NULL) goto Cleanup;
+
+ /* Copy the command line */
+ RtlMoveMemory(CommandInfo->CmdLine, CheckVdmRequest->CmdLine,
CheckVdmRequest->CmdLen);
+
+ /* Allocate memory for the application name */
+ CommandInfo->AppName = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->AppLen);
+ if (CommandInfo->AppName == NULL) goto Cleanup;
+
+ /* Copy the application name */
+ RtlMoveMemory(CommandInfo->AppName, CheckVdmRequest->AppName,
CheckVdmRequest->AppLen);
+
+ /* Allocate memory for the PIF file name */
+ if (CheckVdmRequest->PifLen != 0)
+ {
+ CommandInfo->PifFile = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->PifLen);
+ if (CommandInfo->PifFile == NULL) goto Cleanup;
+
+ /* Copy the PIF file name */
+ RtlMoveMemory(CommandInfo->PifFile, CheckVdmRequest->PifFile,
CheckVdmRequest->PifLen);
+ }
+ else CommandInfo->PifFile = NULL;
+
+ /* Allocate memory for the current directory */
+ if (CheckVdmRequest->CurDirectoryLen != 0)
+ {
+ CommandInfo->CurDirectory = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+
CheckVdmRequest->CurDirectoryLen);
+ if (CommandInfo->CurDirectory == NULL) goto Cleanup;
+
+ /* Copy the current directory */
+ RtlMoveMemory(CommandInfo->CurDirectory,
+ CheckVdmRequest->CurDirectory,
+ CheckVdmRequest->CurDirectoryLen);
+ }
+ else CommandInfo->CurDirectory = NULL;
+
+ /* Allocate memory for the environment block */
+ CommandInfo->Env = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->EnvLen);
+ if (CommandInfo->Env == NULL) goto Cleanup;
+
+ /* Copy the environment block */
+ RtlMoveMemory(CommandInfo->Env, CheckVdmRequest->Env,
CheckVdmRequest->EnvLen);
+
+ CommandInfo->EnvLen = CheckVdmRequest->EnvLen;
+ RtlMoveMemory(&CommandInfo->StartupInfo,
+ CheckVdmRequest->StartupInfo,
+ sizeof(STARTUPINFOA));
+
+ /* Allocate memory for the desktop */
+ if (CheckVdmRequest->DesktopLen != 0)
+ {
+ CommandInfo->Desktop = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->DesktopLen);
+ if (CommandInfo->Desktop == NULL) goto Cleanup;
+
+ /* Copy the desktop name */
+ RtlMoveMemory(CommandInfo->Desktop, CheckVdmRequest->Desktop,
CheckVdmRequest->DesktopLen);
+ }
+ else CommandInfo->Desktop = NULL;
+
+ CommandInfo->DesktopLen = CheckVdmRequest->DesktopLen;
+
+ /* Allocate memory for the title */
+ if (CheckVdmRequest->TitleLen != 0)
+ {
+ CommandInfo->Title = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->TitleLen);
+ if (CommandInfo->Title == NULL) goto Cleanup;
+
+ /* Copy the title */
+ RtlMoveMemory(CommandInfo->Title, CheckVdmRequest->Title,
CheckVdmRequest->TitleLen);
+ }
+ else CommandInfo->Title = NULL;
+
+ CommandInfo->TitleLen = CheckVdmRequest->TitleLen;
+
+ /* Allocate memory for the reserved field */
+ if (CheckVdmRequest->ReservedLen != 0)
+ {
+ CommandInfo->Reserved = RtlAllocateHeap(BaseSrvHeap,
+ HEAP_ZERO_MEMORY,
+ CheckVdmRequest->ReservedLen);
+ if (CommandInfo->Reserved == NULL) goto Cleanup;
+
+ /* Copy the reserved field */
+ RtlMoveMemory(CommandInfo->Reserved,
+ CheckVdmRequest->Reserved,
+ CheckVdmRequest->ReservedLen);
+ }
+ else CommandInfo->Reserved = NULL;
+
+ CommandInfo->ReservedLen = CheckVdmRequest->ReservedLen;
+
+ CommandInfo->CmdLen = CheckVdmRequest->CmdLen;
+ CommandInfo->AppLen = CheckVdmRequest->AppLen;
+ CommandInfo->PifLen = CheckVdmRequest->PifLen;
+ CommandInfo->CurDirectoryLen = CheckVdmRequest->CurDirectoryLen;
+ CommandInfo->VDMState = DosRecord->State;
+ // TODO: Set CommandInfo->CurrentDrive
+ // TODO: Set CommandInfo->ComingFromBat
+
+ /* Set the DOS record's command structure */
+ DosRecord->CommandInfo = CommandInfo;
+
+Cleanup:
+ /* If it wasn't successful, free the memory */
+ if (!Success) BaseSrvFreeVDMInfo(CommandInfo);
+
+ return Success;
}
VOID NTAPI BaseInitializeVDM(VOID)
@@ -300,6 +460,14 @@
Status = BaseSrvCreatePairWaitHandles(&DosRecord->ServerEvent,
&DosRecord->ClientEvent);
if (!NT_SUCCESS(Status)) goto Cleanup;
+ /* Translate the input structure into a VDM command structure and set it in the
DOS record */
+ if (!BaseSrvCopyCommand(CheckVdmRequest, DosRecord))
+ {
+ /* The only possibility is that an allocation failure occurred */
+ Status = STATUS_NO_MEMORY;
+ goto Cleanup;
+ }
+
/* Add the DOS record */
InsertHeadList(&ConsoleRecord->DosListHead, &DosRecord->Entry);
Modified: branches/ntvdm/subsystems/win/basesrv/vdm.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/win/basesrv/vd…
==============================================================================
--- branches/ntvdm/subsystems/win/basesrv/vdm.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/win/basesrv/vdm.h [iso-8859-1] Sun Mar 2 02:50:40 2014
@@ -34,6 +34,7 @@
ULONG ExitCode;
HANDLE ServerEvent;
HANDLE ClientEvent;
+ PVDM_COMMAND_INFO CommandInfo;
// TODO: Structure incomplete!!!
} VDM_DOS_RECORD, *PVDM_DOS_RECORD;