Author: sir_richard Date: Tue Jan 19 09:26:25 2010 New Revision: 45143
URL: http://svn.reactos.org/svn/reactos?rev=45143&view=rev Log: [NTOS]: Implement the special NtRaiseException in C as well, just like we did for NtContinue.
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/ke/i386/trap.s trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/k... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Tue Jan 19 09:26:25 2010 @@ -934,6 +934,16 @@
NTSTATUS NTAPI +KiRaiseException( + IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT Context, + IN PKEXCEPTION_FRAME ExceptionFrame, + IN PKTRAP_FRAME TrapFrame, + IN BOOLEAN SearchFrames +); + +NTSTATUS +NTAPI KiContinue( IN PCONTEXT Context, IN PKEXCEPTION_FRAME ExceptionFrame,
Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?rev... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Tue Jan 19 09:26:25 2010 @@ -476,49 +476,11 @@
.func NtRaiseException@12 _NtRaiseException@12: - - /* NOTE: We -must- be called by Zw* to have the right frame! */ - /* Push the stack frame */ - push ebp - - /* Get the current thread and restore its trap frame */ - mov ebx, PCR[KPCR_CURRENT_THREAD] - mov edx, [ebp+KTRAP_FRAME_EDX] - mov [ebx+KTHREAD_TRAP_FRAME], edx - - /* Set up stack frame */ - mov ebp, esp - - /* Get the Trap Frame in EBX */ - mov ebx, [ebp+0] - - /* Get the exception list and restore */ - mov eax, [ebx+KTRAP_FRAME_EXCEPTION_LIST] - mov PCR[KPCR_EXCEPTION_LIST], eax - - /* Get the parameters */ - mov edx, [ebp+16] /* Search frames */ - mov ecx, [ebp+12] /* Context */ - mov eax, [ebp+8] /* Exception Record */ - - /* Raise the exception */ - push edx - push ebx - push 0 - push ecx - push eax - call _KiRaiseException@20 - - /* Restore trap frame in EBP */ - pop ebp - mov esp, ebp - - /* Check the result */ - or eax, eax - jz _KiServiceExit2 - - /* Restore debug registers too */ - jmp _KiServiceExit + /* Call C code */ + mov ecx, [esp+4] + mov edx, [esp+8] + or edx, [esp+12] + jmp @NtRaiseExceptionHandler@8 .endfunc
.func NtContinue@8
Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.c... ============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Tue Jan 19 09:26:25 2010 @@ -1693,6 +1693,46 @@
VOID FASTCALL +NtRaiseExceptionHandler(IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT Context) +{ + BOOLEAN FirstChance; + NTSTATUS Status; + PKTHREAD Thread; + PKTRAP_FRAME TrapFrame; + + /* Fixup parameters */ + FirstChance = (ULONG_PTR)Context & 1; + Context = (PVOID)((ULONG_PTR)Context & ~1); + + /* Get trap frame and link previous one*/ + Thread = KeGetCurrentThread(); + TrapFrame = Thread->TrapFrame; + Thread->TrapFrame = (PKTRAP_FRAME)TrapFrame->Edx; + + /* Set exception list */ + KeGetPcr()->Tib.ExceptionList = TrapFrame->ExceptionList; + + /* Raise the exception */ + Status = KiRaiseException(ExceptionRecord, + Context, + NULL, + TrapFrame, + FirstChance); + if (NT_SUCCESS(Status)) + { + /* It was handled, so exit restoring all state */ + KiServiceExit2(TrapFrame); + } + else + { + /* Exit with error */ + KiServiceExit(TrapFrame, Status); + } +} + +VOID +FASTCALL NtContinueHandler(IN PCONTEXT Context, IN BOOLEAN TestAlert) {