af390505e7138d8b39e4db78abc8d6b462886a08
[reactos.git] / reactos / include / reactos / wine / exception.h
1 #ifndef __WINE_WINE_EXCEPTION_H
2 #define __WINE_WINE_EXCEPTION_H
3
4 #include <intrin.h>
5 #include <pseh/pseh2.h>
6 #include <pseh/excpt.h>
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 struct _EXCEPTION_REGISTRATION_RECORD;
13 typedef struct _EXCEPTION_REGISTRATION_RECORD EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
14
15 struct _EXCEPTION_REGISTRATION_RECORD
16 {
17 struct _EXCEPTION_REGISTRATION_RECORD * Prev;
18 PEXCEPTION_HANDLER Handler;
19 };
20
21 #define __TRY _SEH2_TRY
22 #define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation()))
23 #define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
24 #define __EXCEPT_ALL _SEH2_EXCEPT(_SEH_EXECUTE_HANDLER)
25 #define __ENDTRY _SEH2_END
26 #define __FINALLY(func) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination()); }
27
28 #ifndef GetExceptionCode
29 #define GetExceptionCode() _SEH2_GetExceptionCode()
30 #endif
31
32 #ifndef GetExceptionInformation
33 #define GetExceptionInformation() _SEH2_GetExceptionInformation()
34 #endif
35
36 #ifndef AbnormalTermination
37 #define AbnormalTermination() _SEH2_AbnormalTermination()
38 #endif
39
40 #define EXCEPTION_WINE_STUB 0x80000100
41 #define EXCEPTION_WINE_ASSERTION 0x80000101
42
43 #define EXCEPTION_VM86_INTx 0x80000110
44 #define EXCEPTION_VM86_STI 0x80000111
45 #define EXCEPTION_VM86_PICRETURN 0x80000112
46
47 static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame )
48 {
49 frame->Prev = (struct _EXCEPTION_REGISTRATION_RECORD *)__readfsdword(0);
50 __writefsdword(0, (unsigned long)frame);
51 return frame->Prev;
52 }
53
54 static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTRATION_RECORD *frame )
55 {
56 __writefsdword(0, (unsigned long)frame->Prev);
57 return frame->Prev;
58 }
59
60 extern void __wine_enter_vm86( CONTEXT *context );
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif