3 * Copyright (c) 1996, Onno Hovers (onno@stack.urc.tue.nl)
6 #ifndef __WINE_EXCEPT_H
7 #define __WINE_EXCEPT_H
23 #define STATUS_WAIT_0 0x00000000
24 #define STATUS_ABANDONED_WAIT_0 0x00000080
25 #define STATUS_USER_APC 0x000000C0
26 #define STATUS_TIMEOUT 0x00000102
27 #define STATUS_PENDING 0x00000103
28 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
29 #define STATUS_BREAKPOINT 0x80000003
30 #define STATUS_SINGLE_STEP 0x80000004
31 #define STATUS_ACCESS_VIOLATION 0xC0000005
32 #define STATUS_IN_PAGE_ERROR 0xC0000006
33 #define STATUS_NO_MEMORY 0xC0000017
34 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
35 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
36 #define STATUS_INVALID_DISPOSITION 0xC0000026
37 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
38 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
39 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
40 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
41 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
42 #define STATUS_FLOAT_OVERFLOW 0xC0000091
43 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
44 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
45 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
46 #define STATUS_INTEGER_OVERFLOW 0xC0000095
47 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
48 #define STATUS_STACK_OVERFLOW 0xC00000FD
49 #define STATUS_CONTROL_C_EXIT 0xC000013A
51 #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
52 #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
53 #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
54 #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
55 #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
56 #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
57 #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
58 #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
59 #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
60 #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
61 #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
62 #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
63 #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
64 #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
65 #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
66 #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
69 * return values from the actual exception handlers
72 #define ExceptionContinueExecution 0
73 #define ExceptionContinueSearch 1
74 #define ExceptionNestedException 2
75 #define ExceptionCollidedUnwind 3
78 * return values from filters in except() and from UnhandledExceptionFilter
81 #define EXCEPTION_EXECUTE_HANDLER 1
82 #define EXCEPTION_CONTINUE_SEARCH 0
83 #define EXCEPTION_CONTINUE_EXECUTION -1
86 * from OS/2 2.0 exception handling
87 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
90 #define EH_NONCONTINUABLE 0x01
91 #define EH_UNWINDING 0x02
92 #define EH_EXIT_UNWIND 0x04
93 #define EH_STACK_INVALID 0x08
94 #define EH_NESTED_CALL 0x10
96 #define EXCEPTION_CONTINUABLE 0
97 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
104 * The i386 context used by Win32 for almost everything.
107 #define SIZE_OF_80387_REGISTERS 80
109 typedef struct _FLOATING_SAVE_AREA
118 BYTE RegisterArea
[SIZE_OF_80387_REGISTERS
];
120 } FLOATING_SAVE_AREA
;
122 typedef struct __CONTEXT
131 FLOATING_SAVE_AREA FloatSave
;
150 typedef struct __CONTEXT
*PCONTEXT
;
153 * The exception record used by Win32 to give additional information
154 * about exception to exception handlers.
157 #define EXCEPTION_MAXIMUM_PARAMETERS 15
159 typedef struct __EXCEPTION_RECORD
162 DWORD ExceptionFlags
;
163 struct __EXCEPTION_RECORD
*ExceptionRecord
;
165 PVOID ExceptionAddress
;
166 DWORD NumberParameters
;
167 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
170 typedef struct __EXCEPTION_RECORD_MIN
173 DWORD ExceptionFlags
;
174 struct __EXCEPTION_RECORD
*ExceptionRecord
;
176 PVOID ExceptionAddress
;
177 DWORD NumberParameters
;
178 DWORD ExceptionInformation
[0];
179 } EXCEPTION_RECORD_MIN
;
181 typedef struct __EXCEPTION_RECORD
*PEXCEPTION_RECORD
;
184 * The exception pointers structure passed to exception filters
185 * in except() and the UnhandledExceptionFilter().
188 typedef struct __EXCEPTION_POINTERS
190 PEXCEPTION_RECORD ExceptionRecord
;
191 PCONTEXT ContextRecord
;
192 } EXCEPTION_POINTERS
;
194 typedef struct __EXCEPTION_POINTERS
*PEXCEPTION_POINTERS
;
197 * the function pointer to a exception handler
200 /* forward definition */
201 struct __EXCEPTION_FRAME
;
203 typedef DWORD ( *PEXCEPTION_HANDLER
)( PEXCEPTION_RECORD pexcrec
,
204 struct __EXCEPTION_FRAME
*pestframe
,
209 * function pointer to a UnhandledExceptionFilter();
212 typedef long (*__PTOP_EXCFILTER
)
213 (PEXCEPTION_POINTERS ExceptionInfo
);
215 typedef __PTOP_EXCFILTER PTOP_LEVER_EXCEPTION_FILTER
;
216 typedef __PTOP_EXCFILTER LPTOP_LEVEL_EXCEPTION_FILTER
;
219 * The exception frame, used for registering exception handlers
220 * Win32 cares only about this, but compilers generally emit
221 * larger exception frames for their own use.
224 typedef struct __EXCEPTION_FRAME
226 struct __EXCEPTION_FRAME
*Prev
;
227 PEXCEPTION_HANDLER Handler
;
230 typedef struct __EXCEPTION_FRAME
*PEXCEPTION_FRAME
;
232 extern PEXCEPTION_FRAME TebExceptionFrame
asm("%fs:0");
234 #define EXC_GetFrame() TebExceptionFrame
235 #define EXC_SetFrame(a) (TebExceptionFrame=(a))
238 * Function definitions
241 void EXC_RaiseException(DWORD exccode
, DWORD excflags
,
242 DWORD nargs
, const LPDWORD pargs
,
245 void EXC_RtlUnwind( PEXCEPTION_FRAME pestframe
,
247 PEXCEPTION_RECORD pexcrec
,
251 DWORD
EXC_CallUnhandledExceptionFilter( PEXCEPTION_RECORD precord
,
256 BOOL
RaiseException(DWORD exccode
, DWORD excflags
,
257 DWORD nargs
, const LPDWORD pargs
);
260 * this undocumented function is called when an exception
261 * handler wants all the frames to be unwound. RtlUnwind
262 * calls all exception handlers with the EH_UNWIND or
263 * EH_EXIT_UNWIND flags set in the exception record
265 * This prototype assumes RtlUnwind takes the same
266 * parameters as OS/2 2.0 DosUnwindException
267 * Disassembling RtlUnwind shows this is true, except for
268 * the TargetEIP parameter, which is unused. There is
269 * a fourth parameter, that is used as the eax in the
273 BOOL
RtlUnwind( PEXCEPTION_FRAME pestframe
,
275 PEXCEPTION_RECORD pexcrec
,
278 DWORD
UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers
);
280 __PTOP_EXCFILTER
SetUnhandledExceptionFilter(
281 LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
);
283 #endif /* __WINE_EXCEPT_H */