[NTVDM][KERNEL32]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Fri, 2 May 2014 22:23:34 +0000 (22:23 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Fri, 2 May 2014 22:23:34 +0000 (22:23 +0000)
Send the specified task ID to CSRSS in GetNextVDMCommand.
In ntvdm, parse the command line parameters to find the session ID, and pass it in
every call to GetNextVDMCommand.

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

dll/win32/kernel32/client/vdm.c
subsystems/ntvdm/dos/dos32krnl/dos.c
subsystems/ntvdm/ntvdm.c
subsystems/ntvdm/ntvdm.h

index 63027dc..c37a3cf 100644 (file)
@@ -1149,6 +1149,7 @@ GetNextVDMCommand(PVDM_COMMAND_INFO CommandData)
             ZeroMemory(GetNextVdmCommand, sizeof(*GetNextVdmCommand));
 
             /* Setup the input parameters */
+            GetNextVdmCommand->iTask = CommandData->TaskId;
             GetNextVdmCommand->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
             GetNextVdmCommand->CmdLen = CommandData->CmdLen;
             GetNextVdmCommand->AppLen = CommandData->AppLen;
index f145447..f1f9fff 100644 (file)
@@ -1336,6 +1336,7 @@ WORD DosCreateProcess(DOS_EXEC_TYPE LoadType,
             ZeroMemory(&CommandInfo, sizeof(CommandInfo));
 
             /* Initialize the structure members */
+            CommandInfo.TaskId = SessionId;
             CommandInfo.VDMState = VDM_FLAG_NESTED_TASK | VDM_FLAG_DONT_WAIT;
             CommandInfo.CmdLine = CmdLine;
             CommandInfo.CmdLen = sizeof(CmdLine);
@@ -1455,6 +1456,7 @@ Done:
     if (CurrentPsp != SYSTEM_PSP)
     {
         /* Decrement the re-entry count */
+        CommandInfo.TaskId = SessionId;
         CommandInfo.VDMState = VDM_DEC_REENTER_COUNT;
         GetNextVDMCommand(&CommandInfo);
 
@@ -1462,6 +1464,7 @@ Done:
         ZeroMemory(&CommandInfo, sizeof(CommandInfo));
 
         /* Update the VDM state of the task */
+        CommandInfo.TaskId = SessionId;
         CommandInfo.VDMState = VDM_FLAG_DONT_WAIT;
         GetNextVDMCommand(&CommandInfo);
     }
index 5078c6e..3576bf4 100644 (file)
@@ -39,6 +39,7 @@ static HMENU hConsoleMenu  = NULL;
 static INT   VdmMenuPos    = -1;
 static BOOLEAN ShowPointer = FALSE;
 
+ULONG SessionId = 0;
 HANDLE VdmTaskEvent = NULL;
 
 /*
@@ -382,6 +383,7 @@ DWORD WINAPI CommandThreadProc(LPVOID Parameter)
         ZeroMemory(&CommandInfo, sizeof(CommandInfo));
 
         /* Initialize the structure members */
+        CommandInfo.TaskId = SessionId;
         CommandInfo.VDMState = VDM_FLAG_DOS;
         CommandInfo.CmdLine = CmdLine;
         CommandInfo.CmdLen = sizeof(CmdLine);
@@ -455,6 +457,20 @@ INT wmain(INT argc, WCHAR *argv[])
         return 0;
     }
 
+#else
+    INT i;
+    WCHAR *endptr;
+
+    /* Parse the command line arguments */
+    for (i = 1; i < argc; i++)
+    {
+        if (wcsncmp(argv[i], L"-i", 2) == 0)
+        {
+            /* This is the session ID */
+            SessionId = wcstoul(argv[i] + 2, &endptr, 10);
+        }
+    }
+
 #endif
 
     DPRINT1("\n\n\nNTVDM - Starting...\n\n\n");
index 2404dd4..3555ce4 100644 (file)
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <conio.h>
+#include <wchar.h>
 
 #define WIN32_NO_STATUS
 #include <windef.h>
@@ -33,6 +34,7 @@ DWORD WINAPI SetLastConsoleEventActive(VOID);
 
 /* FUNCTIONS ******************************************************************/
 
+extern ULONG SessionId;
 extern HANDLE VdmTaskEvent;
 
 VOID DisplayMessage(LPCWSTR Format, ...);