xref: /reactos/sdk/lib/rtl/amd64/except.c (revision d6eebaa4)
1 /*
2  * PROJECT:     ReactOS Run-Time Library
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     User-mode exception support for AMD64
5  * COPYRIGHT:   Copyright 2018-2021 Timo Kreuzer <timo.kreuzer@reactos.org>
6  */
7 
8 /* INCLUDES *****************************************************************/
9 
10 #include <rtl.h>
11 #define NDEBUG
12 #include <debug.h>
13 
14 /* PUBLIC FUNCTIONS **********************************************************/
15 
16 /*
17 * @unimplemented
18 */
19 PVOID
20 NTAPI
21 RtlpGetExceptionAddress(VOID)
22 {
23     UNIMPLEMENTED;
24     return NULL;
25 }
26 
27 BOOLEAN
28 NTAPI
29 RtlpUnwindInternal(
30     _In_opt_ PVOID TargetFrame,
31     _In_opt_ PVOID TargetIp,
32     _In_ PEXCEPTION_RECORD ExceptionRecord,
33     _In_ PVOID ReturnValue,
34     _In_ PCONTEXT ContextRecord,
35     _In_opt_ struct _UNWIND_HISTORY_TABLE *HistoryTable,
36     _In_ ULONG Flags);
37 
38 /*
39  * @unimplemented
40  */
41 BOOLEAN
42 NTAPI
43 RtlDispatchException(
44     _In_ PEXCEPTION_RECORD ExceptionRecord,
45     _In_ PCONTEXT ContextRecord)
46 {
47     BOOLEAN Handled;
48 
49     /* Perform vectored exception handling for user mode */
50     if (RtlCallVectoredExceptionHandlers(ExceptionRecord, ContextRecord))
51     {
52         /* Exception handled, now call vectored continue handlers */
53         RtlCallVectoredContinueHandlers(ExceptionRecord, ContextRecord);
54 
55         /* Continue execution */
56         return TRUE;
57     }
58 
59     /* Call the internal unwind routine */
60     Handled = RtlpUnwindInternal(NULL, // TargetFrame
61                                  NULL, // TargetIp
62                                  ExceptionRecord,
63                                  0, // ReturnValue
64                                  ContextRecord,
65                                  NULL, // HistoryTable
66                                  UNW_FLAG_EHANDLER);
67 
68     /* In user mode, call any registered vectored continue handlers */
69     RtlCallVectoredContinueHandlers(ExceptionRecord, ContextRecord);
70 
71     return Handled;
72 }
73