3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: User-mode exception support
6 * FILE: lib/ntdll/rtl/exception.c
7 * PROGRAMERS: David Welch <welch@cwcom.net>
8 * Skywing <skywing@valhallalegends.com>
9 * UPDATES: Skywing, 09/11/2003: Implemented RtlRaiseException and
10 * KiUserRaiseExceptionDispatcher.
13 /* INCLUDES *****************************************************************/
15 #include <ddk/ntddk.h>
23 /* FUNCTIONS ***************************************************************/
26 RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
30 PRTL_BASE_PROCESS_START_ROUTINE RtlBaseProcessStartRoutine = RtlBaseProcessStart;
33 RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
37 KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
40 EXCEPTION_RECORD NestedExceptionRecord;
43 DPRINT("KiUserExceptionDispatcher()\n");
45 if (RtlpDispatchException(ExceptionRecord, Context) != ExceptionContinueExecution)
47 Status = NtContinue(Context, FALSE);
51 Status = NtRaiseException(ExceptionRecord, Context, FALSE);
54 NestedExceptionRecord.ExceptionCode = Status;
55 NestedExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
56 NestedExceptionRecord.ExceptionRecord = ExceptionRecord;
57 NestedExceptionRecord.NumberParameters = Status;
59 RtlRaiseException(&NestedExceptionRecord);
62 /* implemented in except.s */
64 RtlpCaptureContext(PCONTEXT Context);
70 RtlRaiseException(PEXCEPTION_RECORD ExceptionRecord)
75 RtlpCaptureContext(&Context);
77 ExceptionRecord->ExceptionAddress = (PVOID)(*(((PULONG)Context.Ebp)+1));
78 Context.ContextFlags = CONTEXT_FULL;
80 Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
81 RtlRaiseException(ExceptionRecord);
82 RtlRaiseStatus(Status); /* If we get to this point, something is seriously wrong... */
89 KiRaiseUserExceptionDispatcher(VOID)
91 EXCEPTION_RECORD ExceptionRecord;
93 ExceptionRecord.ExceptionCode = ((PTEB)NtCurrentTeb())->ExceptionCode;
94 ExceptionRecord.ExceptionFlags = 0;
95 ExceptionRecord.ExceptionRecord = NULL;
96 ExceptionRecord.NumberParameters = 0;
98 RtlRaiseException(&ExceptionRecord);
102 RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
105 NTSTATUS ExitStatus = STATUS_SUCCESS;
107 ExitStatus = (NTSTATUS) (StartAddress)(Parameter);
109 NtTerminateProcess(NtCurrentProcess(), ExitStatus);