From 68d8925879820190c4311bcfb0f00471c85c18b4 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 16 Jan 2006 17:05:50 +0000 Subject: [PATCH] Disable correct usage of ESP0 since it seems the V86 code is still not ready to handle that. This should fix the V86 exceptions some people have been having. svn path=/trunk/; revision=20914 --- reactos/ntoskrnl/ke/i386/ctxswitch.S | 8 +++++++- reactos/ntoskrnl/ke/i386/thread.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ke/i386/ctxswitch.S b/reactos/ntoskrnl/ke/i386/ctxswitch.S index 6dac076af42..bb974564034 100644 --- a/reactos/ntoskrnl/ke/i386/ctxswitch.S +++ b/reactos/ntoskrnl/ke/i386/ctxswitch.S @@ -171,7 +171,10 @@ BadThread: NoAdjust: /* Set new ESP0 */ - mov [ebp+KTSS_ESP0], eax + //mov [ebp+KTSS_ESP0], eax + + /* Save it */ + push [ebp+KTSS_ESP0] /* Set TEB pointer */ mov eax, [esi+KTHREAD_TEB] @@ -257,6 +260,9 @@ SameProcess: mov cr0, eax 4: + /* Restore ESP0 */ + pop [ebp+KTSS_ESP0] + /* Restore exception list */ pop [ebx+KPCR_EXCEPTION_LIST] diff --git a/reactos/ntoskrnl/ke/i386/thread.c b/reactos/ntoskrnl/ke/i386/thread.c index 74ac9ff6a3d..117f4319d19 100644 --- a/reactos/ntoskrnl/ke/i386/thread.c +++ b/reactos/ntoskrnl/ke/i386/thread.c @@ -14,6 +14,7 @@ typedef struct _KSHARED_CTXSWITCH_FRAME { + ULONG Esp0; PVOID ExceptionList; PVOID RetEip; } KSHARED_CTXSWITCH_FRAME, *PKSHARED_CTXSWITCH_FRAME; @@ -231,6 +232,9 @@ Ke386InitThreadWithContext(PKTHREAD Thread, /* And set up the Context Switch Frame */ CtxSwitchFrame->RetEip = KiThreadStartup; + CtxSwitchFrame->Esp0 = (ULONG_PTR)Thread->InitialStack - + sizeof(FX_SAVE_AREA) - + 0x10; CtxSwitchFrame->ExceptionList = (PVOID)0xFFFFFFFF; /* Save back the new value of the kernel stack. */