2 * msvcrt C++ exception handling
4 * Copyright 2011 Alexandre Julliard
5 * Copyright 2013 André Hentschel
6 * Copyright 2017 Martin Storsjo
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
31 #define WIN32_NO_STATUS
36 #include "wine/exception.h"
38 #include "wine/debug.h"
40 #include "cppexcept.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(seh
);
45 /*********************************************************************
46 * __CxxExceptionFilter (MSVCRT.@)
48 int CDECL
__CxxExceptionFilter( PEXCEPTION_POINTERS ptrs
,
49 const type_info
*ti
, int flags
, void **copy
)
51 FIXME( "%p %p %x %p: not implemented\n", ptrs
, ti
, flags
, copy
);
52 return EXCEPTION_CONTINUE_SEARCH
;
55 /*********************************************************************
56 * __CxxFrameHandler (MSVCRT.@)
58 EXCEPTION_DISPOSITION CDECL
__CxxFrameHandler(EXCEPTION_RECORD
*rec
, DWORD frame
, CONTEXT
*context
,
59 DISPATCHER_CONTEXT
*dispatch
)
61 FIXME("%p %x %p %p: not implemented\n", rec
, frame
, context
, dispatch
);
62 return ExceptionContinueSearch
;
66 /*********************************************************************
67 * __CppXcptFilter (MSVCRT.@)
69 int CDECL
__CppXcptFilter(NTSTATUS ex
, PEXCEPTION_POINTERS ptr
)
71 /* only filter c++ exceptions */
72 if (ex
!= CXX_EXCEPTION
) return EXCEPTION_CONTINUE_SEARCH
;
73 return _XcptFilter(ex
, ptr
);
77 /*********************************************************************
78 * __CxxDetectRethrow (MSVCRT.@)
80 BOOL CDECL
__CxxDetectRethrow(PEXCEPTION_POINTERS ptrs
)
82 PEXCEPTION_RECORD rec
;
87 rec
= ptrs
->ExceptionRecord
;
89 if (rec
->ExceptionCode
== CXX_EXCEPTION
&&
90 rec
->NumberParameters
== 3 &&
91 rec
->ExceptionInformation
[0] == CXX_FRAME_MAGIC_VC6
&&
92 rec
->ExceptionInformation
[2])
94 ptrs
->ExceptionRecord
= msvcrt_get_thread_data()->exc_record
;
97 return (msvcrt_get_thread_data()->exc_record
== rec
);
101 /*********************************************************************
102 * __CxxQueryExceptionSize (MSVCRT.@)
104 unsigned int CDECL
__CxxQueryExceptionSize(void)
106 return sizeof(cxx_exception_type
);
110 /*******************************************************************
113 __ASM_GLOBAL_FUNC(MSVCRT__setjmp
,
114 "mov x1, #0\n\t" /* frame */
115 "b " __ASM_NAME("__wine_setjmpex"));
117 /*******************************************************************
120 void __cdecl
MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER
*jmp
, int retval
)
122 EXCEPTION_RECORD rec
;
124 if (!retval
) retval
= 1;
127 rec
.ExceptionCode
= STATUS_LONGJUMP
;
128 rec
.ExceptionFlags
= 0;
129 rec
.ExceptionRecord
= NULL
;
130 rec
.ExceptionAddress
= NULL
;
131 rec
.NumberParameters
= 1;
132 rec
.ExceptionInformation
[0] = (DWORD_PTR
)jmp
;
133 RtlUnwind((void *)jmp
->Frame
, (void *)jmp
->Lr
, &rec
, IntToPtr(retval
));
135 __wine_longjmp( (__wine_jmp_buf
*)jmp
, retval
);
138 /*********************************************************************
139 * _fpieee_flt (MSVCRT.@)
141 int __cdecl
_fpieee_flt(ULONG exception_code
, EXCEPTION_POINTERS
*ep
,
142 int (__cdecl
*handler
)(_FPIEEE_RECORD
*))
144 FIXME("(%x %p %p)\n", exception_code
, ep
, handler
);
145 return EXCEPTION_CONTINUE_SEARCH
;
148 #endif /* __aarch64__ */