NtContinue fixed to return failure on invalid params ( not checking for access violat...
[reactos.git] / reactos / ntoskrnl / ps / i386 / continue.c
1 /* $Id: continue.c,v 1.1 2004/07/02 00:47:57 royce Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ps/i386/continue.c
6 * PURPOSE: i386 implementation of NtContinue()
7 * PROGRAMMER: Royce Mitchell III, kjk_hyperion
8 * REVISION HISTORY:
9 * 29/06/04: Created
10 */
11
12 /* INCLUDES ****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <internal/ke.h>
16 #include <internal/ob.h>
17 #include <internal/ps.h>
18 #include <internal/ob.h>
19 #include <internal/pool.h>
20 #include <ntos/minmax.h>
21 #include <internal/ldr.h>
22 #include <rosrtl/string.h>
23
24 #define NDEBUG
25 #include <internal/debug.h>
26
27 #if 1
28 VOID
29 FASTCALL
30 KeRosTrapReturn ( PKTRAP_FRAME TrapFrame, PKTRAP_FRAME PrevTrapFrame );
31
32 VOID STDCALL
33 KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount );
34
35 /*
36 * @implemented
37 */
38 NTSTATUS STDCALL
39 NtContinue (
40 IN PCONTEXT Context,
41 IN BOOLEAN TestAlert)
42 {
43 PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
44 PKTRAP_FRAME PrevTrapFrame = (PKTRAP_FRAME)TrapFrame->Edx;
45
46 DPRINT1("NtContinue: Context: Eip=0x%x, Esp=0x%x\n", Context->Eip, Context->Esp );
47 PULONG Frame = 0;
48 __asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
49 DbgPrint ( "NtContinue(): Ebp=%x, prev/TF=%x/%x\n", Frame, Frame[0], TrapFrame );
50 KeRosDumpStackFrames(NULL,5);
51
52 if ( Context == NULL )
53 {
54 DPRINT1("NtContinue called with NULL Context\n");
55 return STATUS_INVALID_PARAMETER;
56 }
57
58 if ( TrapFrame == NULL )
59 {
60 CPRINT("NtContinue called but TrapFrame was NULL\n");
61 KEBUGCHECK(0);
62 }
63
64 /*
65 * Copy the supplied context over the register information that was saved
66 * on entry to kernel mode, it will then be restored on exit
67 * FIXME: Validate the context
68 */
69 KeContextToTrapFrame ( Context, TrapFrame );
70
71 KeRosTrapReturn ( TrapFrame, PrevTrapFrame );
72
73 return STATUS_SUCCESS; /* this doesn't actually happen b/c KeRosTrapReturn() won't return */
74 }
75 #else
76 NTSTATUS STDCALL
77 NtContinue (
78 IN PCONTEXT Context,
79 IN BOOLEAN TestAlert)
80 {
81 PKTRAP_FRAME TrapFrame = KeGetCurrentThread()->TrapFrame;
82 PULONG Frame = 0;
83 __asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
84 DbgPrint ( "NtContinue(): Ebp=%x, prev/TF=%x/%x\n", Frame, Frame[0], TrapFrame );
85
86 /*
87 * Copy the supplied context over the register information that was saved
88 * on entry to kernel mode, it will then be restored on exit
89 * FIXME: Validate the context
90 */
91 if ( TrapFrame == NULL )
92 {
93 CPRINT("NtContinue called but TrapFrame was NULL\n");
94 KEBUGCHECK(0);
95 }
96 KeContextToTrapFrame ( Context, TrapFrame );
97 return(STATUS_SUCCESS);
98 }
99 #endif