3 * Copyright (c) 1996, Onno Hovers (onno@stack.urc.tue.nl)
6 #ifndef __WINE_EXCEPT_H
7 #define __WINE_EXCEPT_H
10 #include "registers.h"
15 #define STATUS_WAIT_0 0x00000000
16 #define STATUS_ABANDONED_WAIT_0 0x00000080
17 #define STATUS_USER_APC 0x000000C0
18 #define STATUS_TIMEOUT 0x00000102
19 #define STATUS_PENDING 0x00000103
20 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
21 #define STATUS_BREAKPOINT 0x80000003
22 #define STATUS_SINGLE_STEP 0x80000004
23 #define STATUS_ACCESS_VIOLATION 0xC0000005
24 #define STATUS_IN_PAGE_ERROR 0xC0000006
25 #define STATUS_NO_MEMORY 0xC0000017
26 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
27 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
28 #define STATUS_INVALID_DISPOSITION 0xC0000026
29 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
30 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
31 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
32 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
33 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
34 #define STATUS_FLOAT_OVERFLOW 0xC0000091
35 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
36 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
37 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
38 #define STATUS_INTEGER_OVERFLOW 0xC0000095
39 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
40 #define STATUS_STACK_OVERFLOW 0xC00000FD
41 #define STATUS_CONTROL_C_EXIT 0xC000013A
43 #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
44 #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
45 #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
46 #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
47 #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
48 #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
49 #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
50 #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
51 #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
52 #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
53 #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
54 #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
55 #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
56 #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
57 #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
58 #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
61 * return values from the actual exception handlers
64 #define ExceptionContinueExecution 0
65 #define ExceptionContinueSearch 1
66 #define ExceptionNestedException 2
67 #define ExceptionCollidedUnwind 3
70 * return values from filters in except() and from UnhandledExceptionFilter
73 #define EXCEPTION_EXECUTE_HANDLER 1
74 #define EXCEPTION_CONTINUE_SEARCH 0
75 #define EXCEPTION_CONTINUE_EXECUTION -1
78 * from OS/2 2.0 exception handling
79 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
82 #define EH_NONCONTINUABLE 0x01
83 #define EH_UNWINDING 0x02
84 #define EH_EXIT_UNWIND 0x04
85 #define EH_STACK_INVALID 0x08
86 #define EH_NESTED_CALL 0x10
88 #define EXCEPTION_CONTINUABLE 0
89 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
92 * The exception record used by Win32 to give additional information
93 * about exception to exception handlers.
96 #define EXCEPTION_MAXIMUM_PARAMETERS 15
98 typedef struct __EXCEPTION_RECORD
101 DWORD ExceptionFlags
;
102 struct __EXCEPTION_RECORD
*ExceptionRecord
;
104 LPVOID ExceptionAddress
;
105 DWORD NumberParameters
;
106 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
109 typedef struct __EXCEPTION_RECORD_MIN
112 DWORD ExceptionFlags
;
113 struct __EXCEPTION_RECORD
*ExceptionRecord
;
115 LPVOID ExceptionAddress
;
116 DWORD NumberParameters
;
117 DWORD ExceptionInformation
[0];
118 } EXCEPTION_RECORD_MIN
;
120 typedef struct __EXCEPTION_RECORD
*PEXCEPTION_RECORD
;
123 * The exception pointers structure passed to exception filters
124 * in except() and the UnhandledExceptionFilter().
127 typedef struct __EXCEPTION_POINTERS
129 PEXCEPTION_RECORD ExceptionRecord
;
130 PCONTEXT ContextRecord
;
131 } EXCEPTION_POINTERS
;
133 typedef struct __EXCEPTION_POINTERS
*PEXCEPTION_POINTERS
;
136 * the function pointer to a exception handler
139 /* forward definition */
140 struct __EXCEPTION_FRAME
;
142 typedef DWORD ( *PEXCEPTION_HANDLER
)( PEXCEPTION_RECORD pexcrec
,
143 struct __EXCEPTION_FRAME
*pestframe
,
148 * function pointer to a UnhandledExceptionFilter();
151 typedef long (*__PTOP_EXCFILTER
)
152 (PEXCEPTION_POINTERS ExceptionInfo
);
154 typedef __PTOP_EXCFILTER PTOP_LEVER_EXCEPTION_FILTER
;
155 typedef __PTOP_EXCFILTER LPTOP_LEVEL_EXCEPTION_FILTER
;
158 * The exception frame, used for registering exception handlers
159 * Win32 cares only about this, but compilers generally emit
160 * larger exception frames for their own use.
163 typedef struct __EXCEPTION_FRAME
165 struct __EXCEPTION_FRAME
*Prev
;
166 PEXCEPTION_HANDLER Handler
;
169 typedef struct __EXCEPTION_FRAME
*PEXCEPTION_FRAME
;
171 extern PEXCEPTION_FRAME TebExceptionFrame
asm("%fs:0");
173 #define EXC_GetFrame() TebExceptionFrame
174 #define EXC_SetFrame(a) (TebExceptionFrame=(a))
177 * Function definitions
180 void EXC_RaiseException(DWORD exccode
, DWORD excflags
,
181 DWORD nargs
, const LPDWORD pargs
,
184 void EXC_RtlUnwind( PEXCEPTION_FRAME pestframe
,
186 PEXCEPTION_RECORD pexcrec
,
190 DWORD
EXC_CallUnhandledExceptionFilter( PEXCEPTION_RECORD precord
,
195 BOOL
RaiseException(DWORD exccode
, DWORD excflags
,
196 DWORD nargs
, const LPDWORD pargs
);
199 * this undocumented function is called when an exception
200 * handler wants all the frames to be unwound. RtlUnwind
201 * calls all exception handlers with the EH_UNWIND or
202 * EH_EXIT_UNWIND flags set in the exception record
204 * This prototype assumes RtlUnwind takes the same
205 * parameters as OS/2 2.0 DosUnwindException
206 * Disassembling RtlUnwind shows this is true, except for
207 * the TargetEIP parameter, which is unused. There is
208 * a fourth parameter, that is used as the eax in the
212 BOOL
RtlUnwind( PEXCEPTION_FRAME pestframe
,
214 PEXCEPTION_RECORD pexcrec
,
217 DWORD
UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers
);
219 #endif /* __WINE_EXCEPT_H */