ReactOS 0.4.16-dev-2104-gb84fa49
except_x86_64.c
Go to the documentation of this file.
1/*
2 * msvcrt C++ exception handling
3 *
4 * Copyright 2011 Alexandre Julliard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#if defined(__x86_64__) && !defined(__arm64ec__)
22
23#include <stdarg.h>
24#include <fpieee.h>
25#define longjmp ms_longjmp /* avoid prototype mismatch */
26#include <setjmp.h>
27#undef longjmp
28
29#include "ntstatus.h"
30#define WIN32_NO_STATUS
31#include "windef.h"
32#include "winbase.h"
33#include "winternl.h"
34#include "msvcrt.h"
35#include "wine/exception.h"
36#include "excpt.h"
37#include "wine/debug.h"
38
39#include "cppexcept.h"
40
42
43extern void *call_exc_handler( void *handler, ULONG_PTR frame, UINT flags );
44__ASM_GLOBAL_FUNC( call_exc_handler,
45 "subq $0x28,%rsp\n\t"
46 __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t")
47 __ASM_SEH(".seh_stackalloc 0x28\n\t")
48 __ASM_SEH(".seh_endprologue\n\t")
49 "movq %rcx, 0x0(%rsp)\n\t"
50 "movl %r8d, 0x8(%rsp)\n\t"
51 "movq %rdx, 0x10(%rsp)\n\t"
52 "callq *%rcx\n\t"
53 "addq $0x28,%rsp\n\t"
54 __ASM_CFI(".cfi_adjust_cfa_offset -0x28\n\t")
55 "ret" )
56
57
58/*******************************************************************
59 * call_catch_handler
60 */
62{
63 ULONG_PTR frame = rec->ExceptionInformation[1];
64 void *handler = (void *)rec->ExceptionInformation[5];
65
66 TRACE( "calling %p frame %Ix\n", handler, frame );
67 return call_exc_handler( handler, frame, 0x100 );
68}
69
70
71/*******************************************************************
72 * call_unwind_handler
73 */
75{
76 TRACE( "calling %p frame %Ix\n", handler, frame );
77 return call_exc_handler( handler, frame, 0x100 );
78}
79
80
81/*******************************************************************
82 * get_exception_pc
83 */
85{
86 return dispatch->ControlPc;
87}
88
89
90#ifndef __REACTOS__
91/*******************************************************************
92 * longjmp (MSVCRT.@)
93 */
94#ifndef __WINE_PE_BUILD
95void __cdecl longjmp( _JUMP_BUFFER *jmp, int retval )
96{
98
99 if (!retval) retval = 1;
100 if (jmp->Frame)
101 {
103 rec.ExceptionFlags = 0;
104 rec.ExceptionRecord = NULL;
106 rec.NumberParameters = 1;
107 rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
108 RtlUnwind( (void *)jmp->Frame, (void *)jmp->Rip, &rec, IntToPtr(retval) );
109 }
111}
112#endif
113#endif // __REACTOS__
114
115/*******************************************************************
116 * _local_unwind (MSVCRT.@)
117 */
118void __cdecl _local_unwind( void *frame, void *target )
119{
120 RtlUnwind( frame, target, NULL, 0 );
121}
122
123/*********************************************************************
124 * handle_fpieee_flt
125 */
128{
129 FIXME("(%lx %p %p) opcode: %#I64x\n", exception_code, ep, handler,
130 *(ULONG64*)ep->ContextRecord->Rip);
132}
133
134#if _MSVCR_VER>=110 && _MSVCR_VER<=120
135/*********************************************************************
136 * __crtCapturePreviousContext (MSVCR110.@)
137 */
138void __cdecl __crtCapturePreviousContext( CONTEXT *ctx )
139{
141 RUNTIME_FUNCTION *func;
143 ULONG_PTR frame, base;
144 void *data;
145 ULONG i;
146
148 for (i = 0; i < 2; i++)
149 {
150 if (!(func = RtlLookupFunctionEntry( ctx->Rip, &base, &table ))) break;
152 &data, &frame, NULL, NULL, NULL, &handler, 0 )) break;
153 if (!ctx->Rip) break;
154 if (!frame) break;
155 }
156}
157#endif
158
159#endif /* __x86_64__ */
void __cdecl _local_unwind(void *frame, void *target)
Definition: ehandler.c:137
#define RtlUnwind
Definition: longjmp.c:9
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void dispatch(HANDLE hStopEvent)
Definition: dispatch.c:70
#define FIXME(fmt,...)
Definition: precomp.h:53
#define IntToPtr(i)
Definition: basetsd.h:83
#define NULL
Definition: types.h:112
EXCEPTION_ROUTINE * PEXCEPTION_ROUTINE
Definition: compat.h:709
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512
void * call_unwind_handler(void *func, uintptr_t frame, DISPATCHER_CONTEXT *dispatch)
int handle_fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep, int(__cdecl *handler)(_FPIEEE_RECORD *))
void * call_catch_handler(EXCEPTION_RECORD *rec)
ULONG_PTR get_exception_pc(DISPATCHER_CONTEXT *dispatch)
#define __cdecl
Definition: corecrt.h:121
unsigned long __msvcrt_ulong
Definition: corecrt.h:168
_ACRTIMP void __cdecl longjmp(jmp_buf, int)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum func
Definition: glext.h:6028
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define UNW_FLAG_NHANDLER
Definition: gs_support.c:32
#define exception_code
Definition: excpt.h:84
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:91
unsigned __int64 ULONG64
Definition: imports.h:198
#define __ASM_GLOBAL_FUNC(name, code)
Definition: port.h:201
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
#define STATUS_LONGJUMP
Definition: ntstatus.h:297
NTSYSAPI NTSTATUS WINAPI RtlVirtualUnwind2(ULONG, ULONG_PTR, ULONG_PTR, RUNTIME_FUNCTION *, CONTEXT *, BOOLEAN *, void **, ULONG_PTR *, KNONVOLATILE_CONTEXT_POINTERS *, ULONG_PTR *, ULONG_PTR *, PEXCEPTION_ROUTINE *, ULONG)
NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR, ULONG_PTR *, UNWIND_HISTORY_TABLE *)
#define TRACE(s)
Definition: solgame.cpp:4
PCONTEXT ContextRecord
Definition: rtltypes.h:201
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
DWORD ExceptionFlags
Definition: compat.h:209
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
PVOID ExceptionAddress
Definition: compat.h:211
Definition: tools.h:99
#define DWORD_PTR
Definition: treelist.c:76
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
int retval
Definition: wcstombs.cpp:91
#define __ASM_CFI(str)
Definition: asm.h:39
#define __ASM_SEH(str)
Definition: asm.h:45
DECLSPEC_NORETURN void __cdecl __wine_longjmp(__wine_jmp_buf *buf, int retval)