NtContinue fixed to return failure on invalid params ( not checking for access violations yet ), but not clobber EAX on success. This patch was made possiblel by the collaborative efforts of myself, kjk_hyperion, Art Yerkes, and Skywing.

svn path=/trunk/; revision=9964
This commit is contained in:
Royce Mitchell III 2004-07-02 00:47:57 +00:00
parent 8467d37d7d
commit 837baf14b4
4 changed files with 157 additions and 66 deletions

View file

@ -51,7 +51,10 @@ OBJECTS_RTL_I386 := \
rtl/i386/exception.o \ rtl/i386/exception.o \
rtl/i386/seh.o rtl/i386/seh.o
OBJECTS_PS_I386 := \
ps/i386/continue.o
RTL_EXCLUDE_FILTER := RTL_EXCLUDE_FILTER :=
OBJECTS_ARCH = $(OBJECTS_BOOT) $(OBJECTS_EX_I386) $(OBJECTS_KE_I386) $(OBJECTS_MM_I386) \ OBJECTS_ARCH = $(OBJECTS_BOOT) $(OBJECTS_EX_I386) $(OBJECTS_KE_I386) $(OBJECTS_MM_I386) \
$(OBJECTS_RTL_I386) $(OBJECTS_RTL_I386) $(OBJECTS_PS_I386)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: syscall.S,v 1.15 2004/07/01 01:52:37 royce Exp $ /* $Id: syscall.S,v 1.16 2004/07/02 00:47:57 royce Exp $
* *
* FILE: ntoskrnl/hal/x86/syscall.s * FILE: ntoskrnl/hal/x86/syscall.s
* PURPOSE: 2E trap handler * PURPOSE: 2E trap handler
@ -94,6 +94,7 @@ L3:
pushl $0 /* XXX: TempCS */ pushl $0 /* XXX: TempCS */
pushl $0 /* XXX: DebugPointer */ pushl $0 /* XXX: DebugPointer */
pushl $0 /* XXX: DebugArgMark */ pushl $0 /* XXX: DebugArgMark */
#ifdef DBG #ifdef DBG
/* Trick gdb 6 into backtracing over the system call */ /* Trick gdb 6 into backtracing over the system call */
movl 4(%ebp), %ebx movl 4(%ebp), %ebx
@ -260,6 +261,17 @@ KeReturnFromSystemCall:
movl %ebx, KTHREAD_TRAP_FRAME(%esi) movl %ebx, KTHREAD_TRAP_FRAME(%esi)
KiRosTrapReturn: KiRosTrapReturn:
#if 0
mov KTRAP_FRAME_RESERVED1(%ebp), %ax
cmp %ax, SSIDX_NTCONTINUE
jnz KeNoEpilogPrint
movl KTRAP_FRAME_ESP(%ebp), %ecx
movl KTRAP_FRAME_EBP(%ebp), %edx
call @KeRosPrintEspEbp@8
KeNoEpilogPrint:
#endif
/* Skip debug information and unsaved registers */ /* Skip debug information and unsaved registers */
addl $0x30, %esp addl $0x30, %esp
popl %gs popl %gs
@ -291,6 +303,11 @@ KiRosTrapReturn:
*/ */
.globl @KeRosTrapReturn@8 .globl @KeRosTrapReturn@8
@KeRosTrapReturn@8: @KeRosTrapReturn@8:
/* point %esp to the trap frame to restore */
movl %ecx, %esp
movl %esp, %ebp
/* Call the post system call hook and deliver any pending APCs */ /* Call the post system call hook and deliver any pending APCs */
pushl %esp pushl %esp
call _KiAfterSystemCallHook call _KiAfterSystemCallHook
@ -302,6 +319,4 @@ KiRosTrapReturn:
/* Restore the old trap frame pointer */ /* Restore the old trap frame pointer */
movl %edx, KTHREAD_TRAP_FRAME(%esi) movl %edx, KTHREAD_TRAP_FRAME(%esi)
/* point %esp to the trap frame to restore */
movl %ecx, %esp
jmp KiRosTrapReturn; jmp KiRosTrapReturn;

View file

@ -0,0 +1,99 @@
/* $Id: continue.c,v 1.1 2004/07/02 00:47:57 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/i386/continue.c
* PURPOSE: i386 implementation of NtContinue()
* PROGRAMMER: Royce Mitchell III, kjk_hyperion
* REVISION HISTORY:
* 29/06/04: Created
*/
/* INCLUDES ****************************************************************/
#include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/ob.h>
#include <internal/ps.h>
#include <internal/ob.h>
#include <internal/pool.h>
#include <ntos/minmax.h>
#include <internal/ldr.h>
#include <rosrtl/string.h>
#define NDEBUG
#include <internal/debug.h>
#if 1
VOID
FASTCALL
KeRosTrapReturn ( PKTRAP_FRAME TrapFrame, PKTRAP_FRAME PrevTrapFrame );
VOID STDCALL
KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount );
/*
* @implemented
*/
NTSTATUS STDCALL
NtContinue (
IN PCONTEXT Context,
IN BOOLEAN TestAlert)
{
PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
PKTRAP_FRAME PrevTrapFrame = (PKTRAP_FRAME)TrapFrame->Edx;
DPRINT1("NtContinue: Context: Eip=0x%x, Esp=0x%x\n", Context->Eip, Context->Esp );
PULONG Frame = 0;
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
DbgPrint ( "NtContinue(): Ebp=%x, prev/TF=%x/%x\n", Frame, Frame[0], TrapFrame );
KeRosDumpStackFrames(NULL,5);
if ( Context == NULL )
{
DPRINT1("NtContinue called with NULL Context\n");
return STATUS_INVALID_PARAMETER;
}
if ( TrapFrame == NULL )
{
CPRINT("NtContinue called but TrapFrame was NULL\n");
KEBUGCHECK(0);
}
/*
* Copy the supplied context over the register information that was saved
* on entry to kernel mode, it will then be restored on exit
* FIXME: Validate the context
*/
KeContextToTrapFrame ( Context, TrapFrame );
KeRosTrapReturn ( TrapFrame, PrevTrapFrame );
return STATUS_SUCCESS; /* this doesn't actually happen b/c KeRosTrapReturn() won't return */
}
#else
NTSTATUS STDCALL
NtContinue (
IN PCONTEXT Context,
IN BOOLEAN TestAlert)
{
PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
PULONG Frame = 0;
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
DbgPrint ( "NtContinue(): Ebp=%x, prev/TF=%x/%x\n", Frame, Frame[0], TrapFrame );
/*
* Copy the supplied context over the register information that was saved
* on entry to kernel mode, it will then be restored on exit
* FIXME: Validate the context
*/
if ( TrapFrame == NULL )
{
CPRINT("NtContinue called but TrapFrame was NULL\n");
KEBUGCHECK(0);
}
KeContextToTrapFrame ( Context, TrapFrame );
return(STATUS_SUCCESS);
}
#endif

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.125 2004/07/01 02:40:23 hyperion Exp $ /* $Id: thread.c,v 1.126 2004/07/02 00:47:57 royce Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -721,32 +721,6 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
return(Status); return(Status);
} }
NTSTATUS STDCALL
NtContinue(IN PCONTEXT Context,
IN BOOLEAN TestAlert)
{
PKTRAP_FRAME TrapFrame;
/*
* Copy the supplied context over the register information that was saved
* on entry to kernel mode, it will then be restored on exit
* FIXME: Validate the context
*/
TrapFrame = KeGetCurrentThread()->TrapFrame;
if (TrapFrame == NULL)
{
CPRINT("NtContinue called but TrapFrame was NULL\n");
KEBUGCHECK(0);
}
KeContextToTrapFrame(Context, TrapFrame);
if(TestAlert)
KiTestAlert();
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL NTSTATUS STDCALL
NtYieldExecution(VOID) NtYieldExecution(VOID)
{ {