ReactOS 0.4.15-dev-7196-g0fe0b40
except.c
Go to the documentation of this file.
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
16VOID
19{
22
23 /* Capture the current context */
25
26 /* Fix up Context.Rip for the caller */
28
29 /* Fix up Context.Rsp for the caller */
31
32 /* Save the exception address */
33 ExceptionRecord->ExceptionAddress = (PVOID)Context.Rip;
34
35 /* Check if user mode debugger is active */
37 {
38 /* Raise an exception immediately */
39 Status = ZwRaiseException(ExceptionRecord, &Context, TRUE);
40 }
41 else
42 {
43 /* Dispatch the exception and check if we should continue */
44 if (!RtlDispatchException(ExceptionRecord, &Context))
45 {
46 /* Raise the exception */
47 Status = ZwRaiseException(ExceptionRecord, &Context, FALSE);
48 }
49 else
50 {
51 /* Continue, go back to previous context */
53 }
54 }
55
56 /* If we returned, raise a status */
58}
59
60/*
61* @unimplemented
62*/
66{
68 return NULL;
69}
70
74 _In_opt_ PVOID TargetFrame,
75 _In_opt_ PVOID TargetIp,
76 _In_ PEXCEPTION_RECORD ExceptionRecord,
79 _In_opt_ struct _UNWIND_HISTORY_TABLE *HistoryTable,
81
82/*
83 * @unimplemented
84 */
88 _In_ PEXCEPTION_RECORD ExceptionRecord,
90{
92
93 /* Perform vectored exception handling for user mode */
95 {
96 /* Exception handled, now call vectored continue handlers */
98
99 /* Continue execution */
100 return TRUE;
101 }
102
103 /* Call the internal unwind routine */
104 Handled = RtlpUnwindInternal(NULL, // TargetFrame
105 NULL, // TargetIp
106 ExceptionRecord,
107 0, // ReturnValue
109 NULL, // HistoryTable
111
112 /* In user mode, call any registered vectored continue handlers */
114
115 return Handled;
116}
unsigned char BOOLEAN
UINT32 void void ** ReturnValue
Definition: acevents.h:216
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI RtlpCheckForActiveDebugger(VOID)
Definition: libsupp.c:25
Status
Definition: gdiplustypes.h:25
#define _ReturnAddress()
Definition: intrin_arm.h:35
#define _AddressOfReturnAddress()
Definition: intrin_ppc.h:40
if(dx< 0)
Definition: linetemp.h:194
unsigned __int64 ULONG64
Definition: imports.h:198
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
NTSYSAPI NTSTATUS NTAPI ZwContinue(_In_ PCONTEXT Context, _In_ BOOLEAN TestAlert)
NTSYSAPI NTSTATUS NTAPI ZwRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context, _In_ BOOLEAN SearchFrames)
NTSYSAPI BOOLEAN NTAPI RtlDispatchException(_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
Definition: except.c:87
DECLSPEC_NORETURN NTSYSAPI VOID NTAPI RtlRaiseStatus(_In_ NTSTATUS Status)
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
NTSYSAPI VOID NTAPI RtlRaiseException(_In_ PEXCEPTION_RECORD ExceptionRecord)
_IRQL_requires_same_ _In_ PVOID _Inout_ struct _CONTEXT * ContextRecord
Definition: ntbasedef.h:654
VOID NTAPI RtlCallVectoredContinueHandlers(_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
Definition: libsupp.c:822
BOOLEAN NTAPI RtlCallVectoredExceptionHandlers(_In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PCONTEXT Context)
Definition: libsupp.c:813
#define STATUS_INVALID_DISPOSITION
Definition: ntstatus.h:275
@ UNW_FLAG_EHANDLER
Definition: rsym64.h:108
PVOID NTAPI RtlpGetExceptionAddress(VOID)
Definition: except.c:65
BOOLEAN NTAPI RtlpUnwindInternal(_In_opt_ PVOID TargetFrame, _In_opt_ PVOID TargetIp, _In_ PEXCEPTION_RECORD ExceptionRecord, _In_ PVOID ReturnValue, _In_ PCONTEXT ContextRecord, _In_opt_ struct _UNWIND_HISTORY_TABLE *HistoryTable, _In_ ULONG Flags)
Definition: unwind.c:666
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ BOOLEAN Handled
Definition: ketypes.h:349