update for HEAD-2003050101
[reactos.git] / lib / ntdll / rtl / exception.c
1 /* $Id$
2  *
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  * PROGRAMER:         David Welch <welch@cwcom.net>
8  */
9
10 /* INCLUDES *****************************************************************/
11
12 #include <ddk/ntddk.h>
13 #include <windows.h>
14 #include <string.h>
15
16 #define NDEBUG
17 #include <debug.h>
18
19 /* FUNCTIONS ***************************************************************/
20
21 VOID STDCALL
22 RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
23   PVOID Parameter);
24
25 __declspec(dllexport)
26 PRTL_BASE_PROCESS_START_ROUTINE RtlBaseProcessStartRoutine = RtlBaseProcessStart;
27
28 ULONG
29 RtlpDispatchException(IN PEXCEPTION_RECORD  ExceptionRecord,
30         IN PCONTEXT  Context);
31
32 VOID STDCALL
33 KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
34                           PCONTEXT Context)
35 {
36   EXCEPTION_RECORD NestedExceptionRecord;
37   NTSTATUS Status;
38
39   DPRINT("KiUserExceptionDispatcher()\n");
40
41   if (RtlpDispatchException(ExceptionRecord, Context) != ExceptionContinueExecution)
42     {
43       Status = NtContinue(Context, FALSE);
44     }
45   else
46     {
47       Status = NtRaiseException(ExceptionRecord, Context, FALSE);
48     }
49
50   NestedExceptionRecord.ExceptionCode = Status;
51   NestedExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
52   NestedExceptionRecord.ExceptionRecord = ExceptionRecord;
53   NestedExceptionRecord.NumberParameters = Status;
54
55   RtlRaiseException(&NestedExceptionRecord);
56 }
57
58 VOID STDCALL
59 RtlRaiseException(PEXCEPTION_RECORD ExceptionRecord)
60 {
61   DPRINT("RtlRaiseException()\n");
62 }
63
64 VOID STDCALL
65 RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
66   PVOID Parameter)
67 {
68   NTSTATUS ExitStatus = STATUS_SUCCESS;
69
70   ExitStatus = (NTSTATUS) (StartAddress)(Parameter);
71
72   NtTerminateProcess(NtCurrentProcess(), ExitStatus);
73  }
74
75 /* EOF */