ec156adf928856089e35d51dabf7b9fc6dfb5c7f
[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 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
13 (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
14
15 struct _EXCEPTION_REGISTRATION_RECORD;
16 typedef struct _EXCEPTION_REGISTRATION_RECORD EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
17
18 struct _EXCEPTION_REGISTRATION_RECORD
19 {
20 struct _EXCEPTION_REGISTRATION_RECORD * Prev;
21 PEXCEPTION_HANDLER Handler;
22 };
23
24 #define __TRY _SEH2_TRY
25 #define __EXCEPT(func) _SEH2_EXCEPT(func(_SEH2_GetExceptionInformation()))
26 #define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
27 #define __EXCEPT_ALL _SEH2_EXCEPT(_SEH_EXECUTE_HANDLER)
28 #define __ENDTRY _SEH2_END
29 #define __FINALLY(func) _SEH2_FINALLY { func(!_SEH2_AbnormalTermination()); }
30
31 #ifndef GetExceptionCode
32 #define GetExceptionCode() _SEH2_GetExceptionCode()
33 #endif
34
35 #ifndef GetExceptionInformation
36 #define GetExceptionInformation() _SEH2_GetExceptionInformation()
37 #endif
38
39 #ifndef AbnormalTermination
40 #define AbnormalTermination() _SEH2_AbnormalTermination()
41 #endif
42
43 /* Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD */
44 #define EH_NONCONTINUABLE 0x01
45 #define EH_UNWINDING 0x02
46 #define EH_EXIT_UNWIND 0x04
47 #define EH_STACK_INVALID 0x08
48 #define EH_NESTED_CALL 0x10
49
50 #define EXCEPTION_WINE_STUB 0x80000100
51 #define EXCEPTION_WINE_ASSERTION 0x80000101
52
53 #define EXCEPTION_VM86_INTx 0x80000110
54 #define EXCEPTION_VM86_STI 0x80000111
55 #define EXCEPTION_VM86_PICRETURN 0x80000112
56
57 static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame )
58 {
59 frame->Prev = (struct _EXCEPTION_REGISTRATION_RECORD *)__readfsdword(0);
60 __writefsdword(0, (unsigned long)frame);
61 return frame->Prev;
62 }
63
64 static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTRATION_RECORD *frame )
65 {
66 __writefsdword(0, (unsigned long)frame->Prev);
67 return frame->Prev;
68 }
69
70 extern void __wine_enter_vm86( CONTEXT *context );
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif