2 * msvcrt C++ exception handling
4 * Copyright 2011 Alexandre Julliard
5 * Copyright 2013 André Hentschel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #define WIN32_NO_STATUS
34 #include "wine/exception.h"
36 #include "wine/debug.h"
38 #include "cppexcept.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(seh
);
43 /*********************************************************************
44 * __CxxExceptionFilter (MSVCRT.@)
46 int CDECL
__CxxExceptionFilter( PEXCEPTION_POINTERS ptrs
,
47 const type_info
*ti
, int flags
, void **copy
)
49 FIXME( "%p %p %x %p: not implemented\n", ptrs
, ti
, flags
, copy
);
50 return EXCEPTION_CONTINUE_SEARCH
;
53 /*********************************************************************
54 * __CxxFrameHandler (MSVCRT.@)
56 EXCEPTION_DISPOSITION CDECL
__CxxFrameHandler(EXCEPTION_RECORD
*rec
, DWORD frame
, CONTEXT
*context
,
57 DISPATCHER_CONTEXT
*dispatch
)
59 FIXME("%p %x %p %p: not implemented\n", rec
, frame
, context
, dispatch
);
60 return ExceptionContinueSearch
;
64 /*********************************************************************
65 * __CppXcptFilter (MSVCRT.@)
67 int CDECL
__CppXcptFilter(NTSTATUS ex
, PEXCEPTION_POINTERS ptr
)
69 /* only filter c++ exceptions */
70 if (ex
!= CXX_EXCEPTION
) return EXCEPTION_CONTINUE_SEARCH
;
71 return _XcptFilter(ex
, ptr
);
75 /*********************************************************************
76 * __CxxDetectRethrow (MSVCRT.@)
78 BOOL CDECL
__CxxDetectRethrow(PEXCEPTION_POINTERS ptrs
)
80 PEXCEPTION_RECORD rec
;
85 rec
= ptrs
->ExceptionRecord
;
87 if (rec
->ExceptionCode
== CXX_EXCEPTION
&&
88 rec
->NumberParameters
== 3 &&
89 rec
->ExceptionInformation
[0] == CXX_FRAME_MAGIC_VC6
&&
90 rec
->ExceptionInformation
[2])
92 ptrs
->ExceptionRecord
= msvcrt_get_thread_data()->exc_record
;
95 return (msvcrt_get_thread_data()->exc_record
== rec
);
99 /*********************************************************************
100 * __CxxQueryExceptionSize (MSVCRT.@)
102 unsigned int CDECL
__CxxQueryExceptionSize(void)
104 return sizeof(cxx_exception_type
);
108 /*******************************************************************
111 __ASM_GLOBAL_FUNC(MSVCRT__setjmp
,
112 "mov r1, #0\n\t" /* frame */
113 "b " __ASM_NAME("__wine_setjmpex"));
115 /*******************************************************************
118 void __cdecl
MSVCRT_longjmp(_JUMP_BUFFER
*jmp
, int retval
)
120 EXCEPTION_RECORD rec
;
122 if (!retval
) retval
= 1;
125 rec
.ExceptionCode
= STATUS_LONGJUMP
;
126 rec
.ExceptionFlags
= 0;
127 rec
.ExceptionRecord
= NULL
;
128 rec
.ExceptionAddress
= NULL
;
129 rec
.NumberParameters
= 1;
130 rec
.ExceptionInformation
[0] = (DWORD_PTR
)jmp
;
131 RtlUnwind((void *)jmp
->Frame
, (void *)jmp
->Pc
, &rec
, IntToPtr(retval
));
133 __wine_longjmp( (__wine_jmp_buf
*)jmp
, retval
);
136 /*********************************************************************
137 * _fpieee_flt (MSVCRT.@)
139 int __cdecl
_fpieee_flt(__msvcrt_ulong exception_code
, EXCEPTION_POINTERS
*ep
,
140 int (__cdecl
*handler
)(_FPIEEE_RECORD
*))
142 FIXME("(%lx %p %p)\n", exception_code
, ep
, handler
);
143 return EXCEPTION_CONTINUE_SEARCH
;