Author: aandrejevic
Date: Thu Apr 23 15:19:48 2015
New Revision: 67369
URL:
http://svn.reactos.org/svn/reactos?rev=67369&view=rev
Log:
[NTVDM]
Store the return address in INT 22h as a far pointer.
The amount of memory stored in the Env variable is EnvSize, not sizeof(Env)
since Env is a pointer.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Thu Apr 23
15:19:48 2015
@@ -694,7 +694,11 @@
return &DosSystemFileTable[HandleTable[DosHandle]];
}
-VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD
Environment)
+VOID DosInitializePsp(WORD PspSegment,
+ LPCSTR CommandLine,
+ WORD ProgramSize,
+ WORD Environment,
+ DWORD ReturnAddress)
{
PDOS_PSP PspBlock = SEGMENT_TO_PSP(PspSegment);
LPDWORD IntVecTable = (LPDWORD)((ULONG_PTR)BaseAddress);
@@ -709,7 +713,7 @@
PspBlock->LastParagraph = PspSegment + ProgramSize - 1;
/* Save the interrupt vectors */
- PspBlock->TerminateAddress = IntVecTable[0x22];
+ PspBlock->TerminateAddress = ReturnAddress;
PspBlock->BreakAddress = IntVecTable[0x23];
PspBlock->CriticalAddress = IntVecTable[0x24];
@@ -744,6 +748,7 @@
IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
IN LPCSTR Environment OPTIONAL,
+ IN DWORD ReturnAddress OPTIONAL,
OUT PDWORD StackLocation OPTIONAL,
OUT PDWORD EntryPoint OPTIONAL)
{
@@ -865,7 +870,8 @@
DosInitializePsp(Segment,
CommandLine,
(WORD)ExeSize,
- EnvBlock);
+ EnvBlock,
+ ReturnAddress);
/* The process owns its own memory */
DosChangeMemoryOwner(Segment, Segment);
@@ -943,7 +949,8 @@
DosInitializePsp(Segment,
CommandLine,
MaxAllocSize,
- EnvBlock);
+ EnvBlock,
+ ReturnAddress);
if (LoadType == DOS_LOAD_AND_EXECUTE)
{
@@ -993,11 +1000,13 @@
IN LPCSTR Environment OPTIONAL)
{
DWORD Result;
+ LPDWORD IntVecTable = (LPDWORD)((ULONG_PTR)BaseAddress);
Result = DosLoadExecutable(DOS_LOAD_AND_EXECUTE,
ExecutablePath,
CommandLine,
Environment,
+ IntVecTable[0x20], // Use INT 20h
NULL,
NULL);
@@ -1028,7 +1037,8 @@
#ifndef STANDALONE
WORD DosCreateProcess(DOS_EXEC_TYPE LoadType,
LPCSTR ProgramName,
- PDOS_EXEC_PARAM_BLOCK Parameters)
+ PDOS_EXEC_PARAM_BLOCK Parameters,
+ DWORD ReturnAddress)
{
DWORD Result;
DWORD BinaryType;
@@ -1097,7 +1107,7 @@
CommandInfo.Title = Title;
CommandInfo.TitleLen = sizeof(Title);
CommandInfo.Env = Env;
- CommandInfo.EnvLen = sizeof(Env);
+ CommandInfo.EnvLen = EnvSize;
Command:
/* Get the VDM command information */
@@ -1123,6 +1133,7 @@
AppName,
CmdLine,
Env,
+ ReturnAddress,
&Parameters->StackLocation,
&Parameters->EntryPoint);
if (Result == ERROR_SUCCESS)
@@ -2486,7 +2497,8 @@
DOS_EXEC_TYPE LoadType = (DOS_EXEC_TYPE)getAL();
LPSTR ProgramName = SEG_OFF_TO_PTR(getDS(), getDX());
PDOS_EXEC_PARAM_BLOCK ParamBlock = SEG_OFF_TO_PTR(getES(), getBX());
- WORD ErrorCode = DosCreateProcess(LoadType, ProgramName, ParamBlock);
+ DWORD ReturnAddress = MAKELONG(Stack[STACK_IP], Stack[STACK_CS]);
+ WORD ErrorCode = DosCreateProcess(LoadType, ProgramName, ParamBlock,
ReturnAddress);
if (ErrorCode == ERROR_SUCCESS)
{
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] Thu Apr 23
15:19:48 2015
@@ -238,19 +238,27 @@
LPDWORD NewOffset);
BOOL DosFlushFileBuffers(WORD FileHandle);
-VOID DosInitializePsp(WORD PspSegment, LPCSTR CommandLine, WORD ProgramSize, WORD
Environment);
+VOID DosInitializePsp(
+ WORD PspSegment,
+ LPCSTR CommandLine,
+ WORD ProgramSize,
+ WORD Environment,
+ DWORD ReturnAddress
+);
DWORD DosLoadExecutable(
IN DOS_EXEC_TYPE LoadType,
IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
IN LPCSTR Environment OPTIONAL,
+ IN DWORD ReturnAddress OPTIONAL,
OUT PDWORD StackLocation OPTIONAL,
OUT PDWORD EntryPoint OPTIONAL
);
WORD DosCreateProcess(
DOS_EXEC_TYPE LoadType,
LPCSTR ProgramName,
- PDOS_EXEC_PARAM_BLOCK Parameters
+ PDOS_EXEC_PARAM_BLOCK Parameters,
+ DWORD ReturnAddress
);
DWORD DosStartProcess(
IN LPCSTR ExecutablePath,