Reactos
at listview 148 lines 4.5 kB view raw
1#ifndef __WINE_WINE_EXCEPTION_H 2#define __WINE_WINE_EXCEPTION_H 3 4#include <setjmp.h> 5#include <intrin.h> 6#include <excpt.h> 7 8#ifdef __cplusplus 9extern "C" { 10#endif 11 12/* Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD */ 13#define EH_NONCONTINUABLE 0x01 14#define EH_UNWINDING 0x02 15#define EH_EXIT_UNWIND 0x04 16#define EH_STACK_INVALID 0x08 17#define EH_NESTED_CALL 0x10 18#define EH_TARGET_UNWIND 0x20 19#define EH_COLLIDED_UNWIND 0x40 20 21#define EXCEPTION_WINE_STUB 0x80000100 22#define EXCEPTION_WINE_ASSERTION 0x80000101 23 24#define EXCEPTION_VM86_INTx 0x80000110 25#define EXCEPTION_VM86_STI 0x80000111 26#define EXCEPTION_VM86_PICRETURN 0x80000112 27 28#ifndef _RTLTYPES_H 29#ifndef __WINE_WINNT_EXCEPTION_REGISTRATION_RECORD 30#define __WINE_WINNT_EXCEPTION_REGISTRATION_RECORD 31struct _EXCEPTION_REGISTRATION_RECORD; 32 33typedef 34DWORD 35(*PEXCEPTION_HANDLER)( 36 struct _EXCEPTION_RECORD*, 37 struct _EXCEPTION_REGISTRATION_RECORD *, 38 struct _CONTEXT*, 39 struct _EXCEPTION_REGISTRATION_RECORD**); 40 41typedef struct _EXCEPTION_REGISTRATION_RECORD EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD; 42 43struct _EXCEPTION_REGISTRATION_RECORD 44{ 45 struct _EXCEPTION_REGISTRATION_RECORD * Prev; 46 PEXCEPTION_HANDLER Handler; 47}; 48#endif // __WINE_WINNT_EXCEPTION_REGISTRATION_RECORD 49#else 50typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD 51{ 52 PVOID Prev; 53 PEXCEPTION_ROUTINE Handler; 54} WINE_EXCEPTION_REGISTRATION_RECORD, *PWINE_EXCEPTION_REGISTRATION_RECORD; 55 56#define _EXCEPTION_REGISTRATION_RECORD _WINE_EXCEPTION_REGISTRATION_RECORD 57#define EXCEPTION_REGISTRATION_RECORD WINE_EXCEPTION_REGISTRATION_RECORD 58#define PEXCEPTION_REGISTRATION_RECORD PWINE_EXCEPTION_REGISTRATION_RECORD 59#endif 60 61#define __TRY _SEH2_TRY { 62#define __EXCEPT(func) } _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation())) { 63#define __EXCEPT_CTX(func, ctx) } _SEH2_EXCEPT((func)(GetExceptionInformation(), ctx)) { 64#define __EXCEPT_PAGE_FAULT } _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION) { 65#define __EXCEPT_ALL } _SEH2_EXCEPT(1) { 66#define __ENDTRY } _SEH2_END 67#define __FINALLY(func) } _SEH2_FINALLY { func(!_SEH2_AbnormalTermination()); } { 68#define __FINALLY_CTX(func, ctx) } _SEH2_FINALLY { func(!_SEH2_AbnormalTermination(), ctx); }; _SEH2_END 69 70#ifndef GetExceptionCode 71#define GetExceptionCode() _SEH2_GetExceptionCode() 72#endif 73 74#ifndef GetExceptionInformation 75#define GetExceptionInformation() _SEH2_GetExceptionInformation() 76#endif 77 78#ifndef AbnormalTermination 79#define AbnormalTermination() _SEH2_AbnormalTermination() 80#endif 81 82#if defined(__MINGW32__) || defined(__CYGWIN__) 83#define sigjmp_buf jmp_buf 84#define sigsetjmp(buf,sigs) setjmp(buf) 85#define siglongjmp(buf,val) longjmp(buf,val) 86#endif 87 88#ifdef _MSC_VER 89#pragma warning(push) 90#pragma warning(disable:4733) 91#endif 92 93#ifndef __wine_jmp_buf // Conflict with CRT hack 94#ifdef __i386__ 95typedef struct { int reg[16]; } __wine_jmp_buf; 96#elif defined(__x86_64__) 97typedef struct { DECLSPEC_ALIGN(16) struct { unsigned __int64 Part[2]; } reg[16]; } __wine_jmp_buf; 98#elif defined(__arm__) 99typedef struct { int reg[28]; } __wine_jmp_buf; 100#elif defined(__aarch64__) 101typedef struct { __int64 reg[24]; } __wine_jmp_buf; 102#else 103typedef struct { int reg; } __wine_jmp_buf; 104#endif 105#endif 106 107DECLSPEC_NORETURN extern void __cdecl __wine_longjmp( __wine_jmp_buf *buf, int retval ); 108DECLSPEC_NORETURN extern void __cdecl __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record, 109 void (*target)(void) ); 110 111static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame ) 112{ 113#ifdef __i386__ 114 frame->Prev = (struct _EXCEPTION_REGISTRATION_RECORD *)__readfsdword(0); 115 __writefsdword(0, (unsigned long)frame); 116 return frame->Prev; 117#else 118 NT_TIB *teb = (NT_TIB *)NtCurrentTeb(); 119 frame->Prev = teb->ExceptionList; 120 teb->ExceptionList = (PVOID)frame; 121 return frame->Prev; 122#endif 123} 124 125static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTRATION_RECORD *frame ) 126{ 127#ifdef __i386__ 128 __writefsdword(0, (unsigned long)frame->Prev); 129 return frame->Prev; 130#else 131 NT_TIB *teb = (NT_TIB *)NtCurrentTeb(); 132 frame->Prev = teb->ExceptionList; 133 teb->ExceptionList = (PVOID)frame; 134 return frame->Prev; 135#endif 136} 137 138#ifdef _MSC_VER 139#pragma warning(pop) 140#endif 141 142extern void __wine_enter_vm86( CONTEXT *context ); 143 144#ifdef __cplusplus 145} 146#endif 147 148#endif