From 7328873681ce88bec3234e80450174c17b562352 Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sat, 21 Sep 2013 00:41:41 +0000 Subject: [PATCH] [SOFT386] Implement external stack modification. [NTVDM] Implement EmulatorSetStack for NEW_EMULATOR. svn path=/branches/ntvdm/; revision=60257 --- include/reactos/libs/soft386/soft386.h | 4 ++++ lib/soft386/soft386.c | 16 ++++++++++++++++ subsystems/ntvdm/emulator.c | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/reactos/libs/soft386/soft386.h b/include/reactos/libs/soft386/soft386.h index 50e23a22670..f3412ea34d8 100644 --- a/include/reactos/libs/soft386/soft386.h +++ b/include/reactos/libs/soft386/soft386.h @@ -341,6 +341,10 @@ VOID NTAPI Soft386ExecuteAt(PSOFT386_STATE State, USHORT Segment, ULONG Offset); +VOID +NTAPI +Soft386SetStack(PSOFT386_STATE State, USHORT Segment, ULONG Offset); + #endif // _SOFT386_H_ /* EOF */ diff --git a/lib/soft386/soft386.c b/lib/soft386/soft386.c index 76c5f58f7dc..08cba1ab942 100644 --- a/lib/soft386/soft386.c +++ b/lib/soft386/soft386.c @@ -270,4 +270,20 @@ Soft386ExecuteAt(PSOFT386_STATE State, USHORT Segment, ULONG Offset) State->InstPtr.Long = Offset; } +VOID +NTAPI +Soft386SetStack(PSOFT386_STATE State, USHORT Segment, ULONG Offset) +{ + /* Load the new SS */ + if (!Soft386LoadSegment(State, SOFT386_REG_SS, Segment)) + { + /* An exception occurred, let the handler execute instead */ + return; + } + + /* Set the new SP */ + State->GeneralRegs[SOFT386_REG_ESP].Long = Offset; +} + + /* EOF */ diff --git a/subsystems/ntvdm/emulator.c b/subsystems/ntvdm/emulator.c index c41d1c646ac..6fba6da5c1c 100644 --- a/subsystems/ntvdm/emulator.c +++ b/subsystems/ntvdm/emulator.c @@ -429,7 +429,7 @@ VOID EmulatorSetStack(WORD Segment, DWORD Offset) /* Call the softx86 API */ softx86_set_stack_ptr(&EmulatorContext, Segment, Offset); #else - // TODO: NOT IMPLEMENTED + Soft386SetStack(&EmulatorContext, Segment, Offset); #endif }