2 * msvcrt C++ exception handling
4 * Copyright 2011 Alexandre Julliard
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.
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.
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
22 #include "wine/port.h"
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
);
42 struct _DISPATCHER_CONTEXT
;
44 typedef LONG (WINAPI
*PC_LANGUAGE_EXCEPTION_HANDLER
)( EXCEPTION_POINTERS
*ptrs
, ULONG64 frame
);
45 typedef EXCEPTION_DISPOSITION (WINAPI
*PEXCEPTION_ROUTINE
)( EXCEPTION_RECORD
*rec
,
48 struct _DISPATCHER_CONTEXT
*dispatch
);
50 typedef struct _DISPATCHER_CONTEXT
54 PRUNTIME_FUNCTION FunctionEntry
;
55 ULONG64 EstablisherFrame
;
57 PCONTEXT ContextRecord
;
58 PEXCEPTION_ROUTINE LanguageHandler
;
60 PUNWIND_HISTORY_TABLE HistoryTable
;
78 #define TYPE_FLAG_CONST 1
79 #define TYPE_FLAG_VOLATILE 2
80 #define TYPE_FLAG_REFERENCE 8
97 typedef struct __cxx_function_descr
109 } cxx_function_descr
;
111 static inline void* rva_to_ptr(UINT rva
, ULONG64 base
)
113 return rva
? (void*)(base
+rva
) : NULL
;
116 static inline void dump_type(UINT type_rva
, ULONG64 base
)
118 const cxx_type_info
*type
= rva_to_ptr(type_rva
, base
);
120 TRACE("flags %x type %x %s offsets %d,%d,%d size %d copy ctor %x(%p)\n",
121 type
->flags
, type
->type_info
, dbgstr_type_info(rva_to_ptr(type
->type_info
, base
)),
122 type
->offsets
.this_offset
, type
->offsets
.vbase_descr
, type
->offsets
.vbase_offset
,
123 type
->size
, type
->copy_ctor
, rva_to_ptr(type
->copy_ctor
, base
));
126 static void dump_exception_type(const cxx_exception_type
*type
, ULONG64 base
)
128 const cxx_type_info_table
*type_info_table
= rva_to_ptr(type
->type_info_table
, base
);
131 TRACE("flags %x destr %x(%p) handler %x(%p) type info %x(%p)\n",
132 type
->flags
, type
->destructor
, rva_to_ptr(type
->destructor
, base
),
133 type
->custom_handler
, rva_to_ptr(type
->custom_handler
, base
),
134 type
->type_info_table
, type_info_table
);
135 for (i
= 0; i
< type_info_table
->count
; i
++)
138 dump_type(type_info_table
->info
[i
], base
);
142 static void dump_function_descr(const cxx_function_descr
*descr
, ULONG64 image_base
)
144 unwind_info
*unwind_table
= rva_to_ptr(descr
->unwind_table
, image_base
);
145 tryblock_info
*tryblock
= rva_to_ptr(descr
->tryblock
, image_base
);
146 ipmap_info
*ipmap
= rva_to_ptr(descr
->ipmap
, image_base
);
149 TRACE("magic %x\n", descr
->magic
);
150 TRACE("unwind table: %x(%p) %d\n", descr
->unwind_table
, unwind_table
, descr
->unwind_count
);
151 for (i
=0; i
<descr
->unwind_count
; i
++)
153 TRACE(" %d: prev %d func %x(%p)\n", i
, unwind_table
[i
].prev
,
154 unwind_table
[i
].handler
, rva_to_ptr(unwind_table
[i
].handler
, image_base
));
156 TRACE("try table: %x(%p) %d\n", descr
->tryblock
, tryblock
, descr
->tryblock_count
);
157 for (i
=0; i
<descr
->tryblock_count
; i
++)
159 catchblock_info
*catchblock
= rva_to_ptr(tryblock
[i
].catchblock
, image_base
);
161 TRACE(" %d: start %d end %d catchlevel %d catch %x(%p) %d\n", i
,
162 tryblock
[i
].start_level
, tryblock
[i
].end_level
,
163 tryblock
[i
].catch_level
, tryblock
[i
].catchblock
,
164 catchblock
, tryblock
[i
].catchblock_count
);
165 for (j
=0; j
<tryblock
[i
].catchblock_count
; j
++)
167 TRACE(" %d: flags %x offset %d handler %x(%p) frame %x type %x %s\n",
168 j
, catchblock
[j
].flags
, catchblock
[j
].offset
, catchblock
[j
].handler
,
169 rva_to_ptr(catchblock
[j
].handler
, image_base
), catchblock
[j
].frame
,
170 catchblock
[j
].type_info
,
171 dbgstr_type_info(rva_to_ptr(catchblock
[j
].type_info
, image_base
)));
174 TRACE("ipmap: %x(%p) %d\n", descr
->ipmap
, ipmap
, descr
->ipmap_count
);
175 for (i
=0; i
<descr
->ipmap_count
; i
++)
177 TRACE(" %d: ip %x state %d\n", i
, ipmap
[i
].ip
, ipmap
[i
].state
);
179 TRACE("unwind_help %d\n", descr
->unwind_help
);
180 if (descr
->magic
<= CXX_FRAME_MAGIC_VC6
) return;
181 TRACE("expect list: %x\n", descr
->expect_list
);
182 if (descr
->magic
<= CXX_FRAME_MAGIC_VC7
) return;
183 TRACE("flags: %08x\n", descr
->flags
);
186 static inline int ip_to_state(ipmap_info
*ipmap
, UINT count
, int ip
)
188 UINT low
= 0, high
= count
-1, med
;
191 med
= low
+ (high
-low
)/2;
193 if (ipmap
[med
].ip
<= ip
&& ipmap
[med
+1].ip
> ip
)
198 if (ipmap
[med
].ip
< ip
) low
= med
+1;
202 TRACE("%x -> %d\n", ip
, ipmap
[low
].state
);
203 return ipmap
[low
].state
;
206 /* check if the exception type is caught by a given catch block, and return the type that matched */
207 static const cxx_type_info
*find_caught_type(cxx_exception_type
*exc_type
, ULONG64 exc_base
,
208 const type_info
*catch_ti
, UINT catch_flags
)
210 const cxx_type_info_table
*type_info_table
= rva_to_ptr(exc_type
->type_info_table
, exc_base
);
213 for (i
= 0; i
< type_info_table
->count
; i
++)
215 const cxx_type_info
*type
= rva_to_ptr(type_info_table
->info
[i
], exc_base
);
216 const type_info
*ti
= rva_to_ptr(type
->type_info
, exc_base
);
218 if (!catch_ti
) return type
; /* catch(...) matches any type */
221 if (strcmp( catch_ti
->mangled
, ti
->mangled
)) continue;
223 /* type is the same, now check the flags */
224 if ((exc_type
->flags
& TYPE_FLAG_CONST
) &&
225 !(catch_flags
& TYPE_FLAG_CONST
)) continue;
226 if ((exc_type
->flags
& TYPE_FLAG_VOLATILE
) &&
227 !(catch_flags
& TYPE_FLAG_VOLATILE
)) continue;
228 return type
; /* it matched */
233 static inline void copy_exception(void *object
, ULONG64 frame
,
234 DISPATCHER_CONTEXT
*dispatch
,
235 const catchblock_info
*catchblock
,
236 const cxx_type_info
*type
)
238 const type_info
*catch_ti
= rva_to_ptr(catchblock
->type_info
, dispatch
->ImageBase
);
239 void **dest
= rva_to_ptr(catchblock
->offset
, frame
);
241 if (!catch_ti
|| !catch_ti
->mangled
[0]) return;
242 if (!catchblock
->offset
) return;
244 if (catchblock
->flags
& TYPE_FLAG_REFERENCE
)
246 *dest
= get_this_pointer(&type
->offsets
, object
);
248 else if (type
->flags
& CLASS_IS_SIMPLE_TYPE
)
250 memmove(dest
, object
, type
->size
);
251 /* if it is a pointer, adjust it */
252 if (type
->size
== sizeof(void*)) *dest
= get_this_pointer(&type
->offsets
, *dest
);
254 else /* copy the object */
258 if (type
->flags
& CLASS_HAS_VIRTUAL_BASE_CLASS
)
260 void (__cdecl
*copy_ctor
)(void*, void*, int) =
261 rva_to_ptr(type
->copy_ctor
, dispatch
->ImageBase
);
262 copy_ctor(dest
, get_this_pointer(&type
->offsets
, object
), 1);
266 void (__cdecl
*copy_ctor
)(void*, void*) =
267 rva_to_ptr(type
->copy_ctor
, dispatch
->ImageBase
);
268 copy_ctor(dest
, get_this_pointer(&type
->offsets
, object
));
272 memmove(dest
, get_this_pointer(&type
->offsets
,object
), type
->size
);
276 static void cxx_local_unwind(ULONG64 frame
, DISPATCHER_CONTEXT
*dispatch
,
277 const cxx_function_descr
*descr
, int last_level
)
279 const unwind_info
*unwind_table
= rva_to_ptr(descr
->unwind_table
, dispatch
->ImageBase
);
280 void (__cdecl
*handler
)(ULONG64 unk
, ULONG64 rbp
);
281 int *unwind_help
= rva_to_ptr(descr
->unwind_help
, frame
);
284 if (unwind_help
[0] == -2)
286 trylevel
= ip_to_state(rva_to_ptr(descr
->ipmap
, dispatch
->ImageBase
),
287 descr
->ipmap_count
, dispatch
->ControlPc
-dispatch
->ImageBase
);
291 trylevel
= unwind_help
[0];
294 TRACE("current level: %d, last level: %d\n", trylevel
, last_level
);
295 while (trylevel
!= last_level
)
297 if (trylevel
<0 || trylevel
>=descr
->unwind_count
)
299 ERR("invalid trylevel %d\n", trylevel
);
302 handler
= rva_to_ptr(unwind_table
[trylevel
].handler
, dispatch
->ImageBase
);
305 TRACE("handler: %p\n", handler
);
308 trylevel
= unwind_table
[trylevel
].prev
;
310 unwind_help
[0] = last_level
;
313 static inline void* WINAPI
call_catch_block(EXCEPTION_RECORD
*rec
)
315 ULONG64 frame
= rec
->ExceptionInformation
[1];
316 const cxx_function_descr
*descr
= (void*)rec
->ExceptionInformation
[2];
317 EXCEPTION_RECORD
*prev_rec
= (void*)rec
->ExceptionInformation
[4];
318 void* (__cdecl
*handler
)(ULONG64 unk
, ULONG64 rbp
) = (void*)rec
->ExceptionInformation
[5];
319 int *unwind_help
= rva_to_ptr(descr
->unwind_help
, frame
);
320 cxx_frame_info frame_info
;
323 TRACE("calling handler %p\n", handler
);
325 /* FIXME: native does local_unwind here in case of exception rethrow */
326 __CxxRegisterExceptionObject(&prev_rec
, &frame_info
);
327 ret_addr
= handler(0, frame
);
328 __CxxUnregisterExceptionObject(&frame_info
, FALSE
);
334 static inline void find_catch_block(EXCEPTION_RECORD
*rec
, ULONG64 frame
,
335 DISPATCHER_CONTEXT
*dispatch
,
336 const cxx_function_descr
*descr
,
337 cxx_exception_type
*info
)
339 ULONG64 exc_base
= (rec
->NumberParameters
== 4 ? rec
->ExceptionInformation
[3] : 0);
340 int trylevel
= ip_to_state(rva_to_ptr(descr
->ipmap
, dispatch
->ImageBase
),
341 descr
->ipmap_count
, dispatch
->ControlPc
-dispatch
->ImageBase
);
342 EXCEPTION_RECORD catch_record
;
345 ULONG64 orig_frame
= frame
, throw_base
;
346 DWORD throw_func_off
;
350 /* update orig_frame if it's a nested exception */
351 throw_func_off
= RtlLookupFunctionEntry(dispatch
->ControlPc
, &throw_base
, NULL
)->BeginAddress
;
352 throw_func
= rva_to_ptr(throw_func_off
, throw_base
);
353 TRACE("reconstructed handler pointer: %p\n", throw_func
);
354 for (i
=descr
->tryblock_count
; i
>0; i
--)
356 const tryblock_info
*tryblock
= rva_to_ptr(descr
->tryblock
, dispatch
->ImageBase
);
357 tryblock
= &tryblock
[i
-1];
359 if (trylevel
>tryblock
->end_level
&& trylevel
<=tryblock
->catch_level
)
361 for (j
=0; j
<tryblock
->catchblock_count
; j
++)
363 /* TODO: is it possible to have the same handler for multiple catch blocks? */
364 const catchblock_info
*catchblock
= rva_to_ptr(tryblock
->catchblock
, dispatch
->ImageBase
);
365 catchblock
= &catchblock
[j
];
367 if (rva_to_ptr(catchblock
->handler
, dispatch
->ImageBase
) == throw_func
)
369 TRACE("nested exception detected\n");
370 orig_frame
= *(ULONG64
*)rva_to_ptr(catchblock
->frame
, frame
);
371 TRACE("setting orig_frame to %lx\n", orig_frame
);
377 unwind_help
= rva_to_ptr(descr
->unwind_help
, orig_frame
);
378 unwind_help
[0] = trylevel
;
379 TRACE("current trylevel: %d, last catch block: %d\n", trylevel
, unwind_help
[1]);
381 for (i
=0; i
<descr
->tryblock_count
; i
++)
383 const tryblock_info
*tryblock
= rva_to_ptr(descr
->tryblock
, dispatch
->ImageBase
);
384 tryblock
= &tryblock
[i
];
386 if (unwind_help
[1] != -1)
388 if (unwind_help
[1] < tryblock
->start_level
) continue;
389 if (unwind_help
[1] > tryblock
->end_level
) continue;
392 if (trylevel
< tryblock
->start_level
) continue;
393 if (trylevel
> tryblock
->end_level
) continue;
395 /* got a try block */
396 for (j
=0; j
<tryblock
->catchblock_count
; j
++)
398 const catchblock_info
*catchblock
= rva_to_ptr(tryblock
->catchblock
, dispatch
->ImageBase
);
399 catchblock
= &catchblock
[j
];
403 const cxx_type_info
*type
= find_caught_type(info
, exc_base
,
404 rva_to_ptr(catchblock
->type_info
, dispatch
->ImageBase
),
408 TRACE("matched type %p in tryblock %d catchblock %d\n", type
, i
, j
);
410 /* copy the exception to its destination on the stack */
411 copy_exception((void*)rec
->ExceptionInformation
[1],
412 orig_frame
, dispatch
, catchblock
, type
);
416 /* no CXX_EXCEPTION only proceed with a catch(...) block*/
417 if (catchblock
->type_info
)
419 TRACE("found catch(...) block\n");
422 unwind_help
[1] = tryblock
->end_level
+1;
424 /* unwind stack and call catch */
425 memset(&catch_record
, 0, sizeof(catch_record
));
426 catch_record
.ExceptionCode
= STATUS_UNWIND_CONSOLIDATE
;
427 catch_record
.ExceptionFlags
= EXCEPTION_NONCONTINUABLE
;
428 catch_record
.NumberParameters
= 6;
429 catch_record
.ExceptionInformation
[0] = (ULONG_PTR
)call_catch_block
;
430 catch_record
.ExceptionInformation
[1] = orig_frame
;
431 catch_record
.ExceptionInformation
[2] = (ULONG_PTR
)descr
;
432 catch_record
.ExceptionInformation
[3] = tryblock
->start_level
;
433 catch_record
.ExceptionInformation
[4] = (ULONG_PTR
)rec
;
434 catch_record
.ExceptionInformation
[5] =
435 (ULONG_PTR
)rva_to_ptr(catchblock
->handler
, dispatch
->ImageBase
);
436 RtlUnwindEx((void*)orig_frame
, 0, &catch_record
, NULL
, &context
, NULL
);
440 TRACE("no matching catch block found\n");
443 static DWORD
cxx_frame_handler(EXCEPTION_RECORD
*rec
, ULONG64 frame
,
444 CONTEXT
*context
, DISPATCHER_CONTEXT
*dispatch
,
445 const cxx_function_descr
*descr
)
447 cxx_exception_type
*exc_type
;
449 if (descr
->magic
<CXX_FRAME_MAGIC_VC6
|| descr
->magic
>CXX_FRAME_MAGIC_VC8
)
451 FIXME("unhandled frame magic %x\n", descr
->magic
);
452 return ExceptionContinueSearch
;
455 if (rec
->ExceptionFlags
& (EH_UNWINDING
|EH_EXIT_UNWIND
))
457 if (rec
->ExceptionCode
==STATUS_UNWIND_CONSOLIDATE
&& rec
->NumberParameters
==6 &&
458 rec
->ExceptionInformation
[0]==(ULONG_PTR
)call_catch_block
)
460 ULONG64 orig_frame
= rec
->ExceptionInformation
[1];
461 const cxx_function_descr
*descr
= (void*)rec
->ExceptionInformation
[2];
462 int end_level
= rec
->ExceptionInformation
[3];
465 cxx_local_unwind(orig_frame
, dispatch
, descr
, end_level
);
467 /* FIXME: we should only unregister frames registered by call_catch_block here */
468 for (cur
= msvcrt_get_thread_data()->frame_info_head
; cur
; cur
= cur
->next
)
470 if ((ULONG64
)cur
> frame
)
471 __CxxUnregisterExceptionObject((cxx_frame_info
*)cur
, FALSE
);
473 return ExceptionContinueSearch
;
476 cxx_local_unwind(frame
, dispatch
, descr
, -1);
477 return ExceptionContinueSearch
;
479 if (!descr
->tryblock_count
) return ExceptionContinueSearch
;
481 if (rec
->ExceptionCode
== CXX_EXCEPTION
&&
482 rec
->ExceptionInformation
[1] == 0 && rec
->ExceptionInformation
[2] == 0)
484 *rec
= *msvcrt_get_thread_data()->exc_record
;
485 rec
->ExceptionFlags
&= ~EH_UNWINDING
;
487 TRACE("detect rethrow: exception code: %x\n", rec
->ExceptionCode
);
488 if (rec
->ExceptionCode
== CXX_EXCEPTION
)
489 TRACE("re-propage: obj: %lx, type: %lx\n",
490 rec
->ExceptionInformation
[1], rec
->ExceptionInformation
[2]);
494 if (rec
->ExceptionCode
== CXX_EXCEPTION
)
496 exc_type
= (cxx_exception_type
*)rec
->ExceptionInformation
[2];
500 TRACE("handling C++ exception rec %p frame %lx descr %p\n", rec
, frame
, descr
);
501 dump_exception_type(exc_type
, rec
->ExceptionInformation
[3]);
502 dump_function_descr(descr
, dispatch
->ImageBase
);
507 thread_data_t
*data
= msvcrt_get_thread_data();
510 TRACE("handling C exception code %x rec %p frame %lx descr %p\n",
511 rec
->ExceptionCode
, rec
, frame
, descr
);
513 if (data
->se_translator
) {
514 EXCEPTION_POINTERS except_ptrs
;
516 except_ptrs
.ExceptionRecord
= rec
;
517 except_ptrs
.ContextRecord
= context
;
518 data
->se_translator(rec
->ExceptionCode
, &except_ptrs
);
522 find_catch_block(rec
, frame
, dispatch
, descr
, exc_type
);
523 return ExceptionContinueSearch
;
526 /*********************************************************************
527 * __CxxExceptionFilter (MSVCRT.@)
529 int CDECL
__CxxExceptionFilter( PEXCEPTION_POINTERS ptrs
,
530 const type_info
*ti
, int flags
, void **copy
)
532 FIXME( "%p %p %x %p: not implemented\n", ptrs
, ti
, flags
, copy
);
533 return EXCEPTION_CONTINUE_SEARCH
;
536 /*********************************************************************
537 * __CxxFrameHandler (MSVCRT.@)
539 EXCEPTION_DISPOSITION CDECL
__CxxFrameHandler( EXCEPTION_RECORD
*rec
, ULONG64 frame
,
540 CONTEXT
*context
, DISPATCHER_CONTEXT
*dispatch
)
542 TRACE( "%p %lx %p %p\n", rec
, frame
, context
, dispatch
);
543 return cxx_frame_handler( rec
, frame
, context
, dispatch
,
544 rva_to_ptr(*(UINT
*)dispatch
->HandlerData
, dispatch
->ImageBase
) );
548 /*********************************************************************
549 * __CppXcptFilter (MSVCRT.@)
551 int CDECL
__CppXcptFilter(NTSTATUS ex
, PEXCEPTION_POINTERS ptr
)
553 /* only filter c++ exceptions */
554 if (ex
!= CXX_EXCEPTION
) return EXCEPTION_CONTINUE_SEARCH
;
555 return _XcptFilter( ex
, ptr
);
559 /*********************************************************************
560 * __CxxDetectRethrow (MSVCRT.@)
562 BOOL CDECL
__CxxDetectRethrow(PEXCEPTION_POINTERS ptrs
)
564 PEXCEPTION_RECORD rec
;
569 rec
= ptrs
->ExceptionRecord
;
571 if (rec
->ExceptionCode
== CXX_EXCEPTION
&&
572 rec
->NumberParameters
== 4 &&
573 rec
->ExceptionInformation
[0] == CXX_FRAME_MAGIC_VC6
&&
574 rec
->ExceptionInformation
[2])
576 ptrs
->ExceptionRecord
= msvcrt_get_thread_data()->exc_record
;
579 return (msvcrt_get_thread_data()->exc_record
== rec
);
583 /*********************************************************************
584 * __CxxQueryExceptionSize (MSVCRT.@)
586 unsigned int CDECL
__CxxQueryExceptionSize(void)
588 return sizeof(cxx_exception_type
);
592 /*******************************************************************
595 __ASM_GLOBAL_FUNC( MSVCRT__setjmp
,
596 "xorq %rdx,%rdx\n\t" /* frame */
597 "jmp " __ASM_NAME("MSVCRT__setjmpex") );
599 /*******************************************************************
600 * _setjmpex (MSVCRT.@)
602 __ASM_GLOBAL_FUNC( MSVCRT__setjmpex
,
603 "movq %rdx,(%rcx)\n\t" /* jmp_buf->Frame */
604 "movq %rbx,0x8(%rcx)\n\t" /* jmp_buf->Rbx */
605 "leaq 0x8(%rsp),%rax\n\t"
606 "movq %rax,0x10(%rcx)\n\t" /* jmp_buf->Rsp */
607 "movq %rbp,0x18(%rcx)\n\t" /* jmp_buf->Rbp */
608 "movq %rsi,0x20(%rcx)\n\t" /* jmp_buf->Rsi */
609 "movq %rdi,0x28(%rcx)\n\t" /* jmp_buf->Rdi */
610 "movq %r12,0x30(%rcx)\n\t" /* jmp_buf->R12 */
611 "movq %r13,0x38(%rcx)\n\t" /* jmp_buf->R13 */
612 "movq %r14,0x40(%rcx)\n\t" /* jmp_buf->R14 */
613 "movq %r15,0x48(%rcx)\n\t" /* jmp_buf->R15 */
614 "movq (%rsp),%rax\n\t"
615 "movq %rax,0x50(%rcx)\n\t" /* jmp_buf->Rip */
616 "movdqa %xmm6,0x60(%rcx)\n\t" /* jmp_buf->Xmm6 */
617 "movdqa %xmm7,0x70(%rcx)\n\t" /* jmp_buf->Xmm7 */
618 "movdqa %xmm8,0x80(%rcx)\n\t" /* jmp_buf->Xmm8 */
619 "movdqa %xmm9,0x90(%rcx)\n\t" /* jmp_buf->Xmm9 */
620 "movdqa %xmm10,0xa0(%rcx)\n\t" /* jmp_buf->Xmm10 */
621 "movdqa %xmm11,0xb0(%rcx)\n\t" /* jmp_buf->Xmm11 */
622 "movdqa %xmm12,0xc0(%rcx)\n\t" /* jmp_buf->Xmm12 */
623 "movdqa %xmm13,0xd0(%rcx)\n\t" /* jmp_buf->Xmm13 */
624 "movdqa %xmm14,0xe0(%rcx)\n\t" /* jmp_buf->Xmm14 */
625 "movdqa %xmm15,0xf0(%rcx)\n\t" /* jmp_buf->Xmm15 */
630 extern void DECLSPEC_NORETURN CDECL
longjmp_set_regs( struct MSVCRT___JUMP_BUFFER
*jmp
, int retval
);
631 __ASM_GLOBAL_FUNC( longjmp_set_regs
,
632 "movq %rdx,%rax\n\t" /* retval */
633 "movq 0x8(%rcx),%rbx\n\t" /* jmp_buf->Rbx */
634 "movq 0x18(%rcx),%rbp\n\t" /* jmp_buf->Rbp */
635 "movq 0x20(%rcx),%rsi\n\t" /* jmp_buf->Rsi */
636 "movq 0x28(%rcx),%rdi\n\t" /* jmp_buf->Rdi */
637 "movq 0x30(%rcx),%r12\n\t" /* jmp_buf->R12 */
638 "movq 0x38(%rcx),%r13\n\t" /* jmp_buf->R13 */
639 "movq 0x40(%rcx),%r14\n\t" /* jmp_buf->R14 */
640 "movq 0x48(%rcx),%r15\n\t" /* jmp_buf->R15 */
641 "movdqa 0x60(%rcx),%xmm6\n\t" /* jmp_buf->Xmm6 */
642 "movdqa 0x70(%rcx),%xmm7\n\t" /* jmp_buf->Xmm7 */
643 "movdqa 0x80(%rcx),%xmm8\n\t" /* jmp_buf->Xmm8 */
644 "movdqa 0x90(%rcx),%xmm9\n\t" /* jmp_buf->Xmm9 */
645 "movdqa 0xa0(%rcx),%xmm10\n\t" /* jmp_buf->Xmm10 */
646 "movdqa 0xb0(%rcx),%xmm11\n\t" /* jmp_buf->Xmm11 */
647 "movdqa 0xc0(%rcx),%xmm12\n\t" /* jmp_buf->Xmm12 */
648 "movdqa 0xd0(%rcx),%xmm13\n\t" /* jmp_buf->Xmm13 */
649 "movdqa 0xe0(%rcx),%xmm14\n\t" /* jmp_buf->Xmm14 */
650 "movdqa 0xf0(%rcx),%xmm15\n\t" /* jmp_buf->Xmm15 */
651 "movq 0x50(%rcx),%rdx\n\t" /* jmp_buf->Rip */
652 "movq 0x10(%rcx),%rsp\n\t" /* jmp_buf->Rsp */
655 /*******************************************************************
658 void __cdecl
MSVCRT_longjmp( struct MSVCRT___JUMP_BUFFER
*jmp
, int retval
)
660 EXCEPTION_RECORD rec
;
662 if (!retval
) retval
= 1;
665 rec
.ExceptionCode
= STATUS_LONGJUMP
;
666 rec
.ExceptionFlags
= 0;
667 rec
.ExceptionRecord
= NULL
;
668 rec
.ExceptionAddress
= NULL
;
669 rec
.NumberParameters
= 1;
670 rec
.ExceptionInformation
[0] = (DWORD_PTR
)jmp
;
671 RtlUnwind( (void *)jmp
->Frame
, (void *)jmp
->Rip
, &rec
, IntToPtr(retval
) );
673 longjmp_set_regs( jmp
, retval
);
676 /*******************************************************************
677 * _local_unwind (MSVCRT.@)
679 void __cdecl
_local_unwind( void *frame
, void *target
)
681 RtlUnwind( frame
, target
, NULL
, 0 );
684 #endif /* __x86_64__ */