2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: include/ntos/except.h
5 * PURPOSE: Exception handling structures
6 * PROGRAMMER: Casper S. Hornstrup <chorns@users.sourceforge.net>
9 #ifndef __INCLUDE_EXCEPT_H
10 #define __INCLUDE_EXCEPT_H
13 ExceptionContinueExecution = 0,
14 ExceptionContinueSearch,
15 ExceptionNestedException,
16 ExceptionCollidedUnwind,
17 ExceptionDismiss /* ??? */
18 } EXCEPTION_DISPOSITION;
21 struct _EXCEPTION_RECORD;
22 struct _EXCEPTION_REGISTRATION;
25 * The type of function that is expected as an exception handler to be
26 * installed with _try1.
29 typedef EXCEPTION_DISPOSITION (CDECL *PEXCEPTION_HANDLER)(
30 struct _EXCEPTION_RECORD* ExceptionRecord,
31 struct _EXCEPTION_REGISTRATION* ExceptionRegistration,
33 PVOID DispatcherContext);
35 typedef EXCEPTION_DISPOSITION (CDECL *PEXCEPTION_HANDLER)(
36 struct _EXCEPTION_RECORD* ExceptionRecord,
37 struct _EXCEPTION_REGISTRATION* ExceptionRegistration,
39 PVOID DispatcherContext);
44 #define EXCEPTION_MAXIMUM_PARAMETERS (15)
46 typedef struct _EXCEPTION_RECORD {
49 struct _EXCEPTION_RECORD *ExceptionRecord;
50 PVOID ExceptionAddress;
51 DWORD NumberParameters;
52 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
53 } EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD;
55 #endif /* !__USE_W32API */
58 #ifndef _GNU_H_WINDOWS32_DEFINES
60 #ifndef EXCEPTION_NONCONTINUABLE
61 #define EXCEPTION_NONCONTINUABLE 0x01
63 #endif /* __NTOSKRNL__ */
64 #endif /* _GNU_H_WINDOWS32_DEFINES */
65 #define EXCEPTION_UNWINDING 0x02
66 #define EXCEPTION_EXIT_UNWIND 0x04
67 #define EXCEPTION_STACK_INVALID 0x08
68 #define EXCEPTION_NESTED_CALL 0x10
71 typedef struct _EXCEPTION_REGISTRATION
73 struct _EXCEPTION_REGISTRATION* prev;
74 PEXCEPTION_HANDLER handler;
75 } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
77 typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
78 typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
82 * A macro which installs the supplied exception handler.
83 * Push the pointer to the new handler onto the stack,
84 * then push the pointer to the old registration structure (at fs:0)
85 * onto the stack, then put a pointer to the new registration
86 * structure (i.e. the current stack pointer) at fs:0.
88 #define __try1(pHandler) \
89 __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
93 * A macro which (dispite its name) *removes* an installed
94 * exception handler. Should be used only in conjunction with the above
95 * install routine __try1.
96 * Move the pointer to the old reg. struct (at the current stack
97 * position) to fs:0, replacing the pointer we installed above,
98 * then add 8 to the stack pointer to get rid of the space we
99 * used when we pushed on our new reg. struct above. Notice that
100 * the stack must be in the exact state at this point that it was
101 * after we did _try1 or this will smash things.
104 __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
110 /* Runtime DLL structures */
112 #ifndef _GNU_H_WINDOWS32_DEFINES
114 #define EXCEPTION_EXECUTE_HANDLER 1
115 #define EXCEPTION_CONTINUE_SEARCH 0
116 /* #define EXCEPTION_CONTINUE_EXECUTION -1 */
117 #endif /* __NTOSKRNL__ */
118 #endif /* _GNU_H_WINDOWS32_DEFINES */
120 /* Functions of the following prototype return one of the above constants */
122 typedef DWORD CDECL (*PSCOPE_EXCEPTION_FILTER)(VOID);
123 typedef VOID CDECL (*PSCOPE_EXCEPTION_HANDLER)(VOID);
125 typedef DWORD (CDECL *PSCOPE_EXCEPTION_FILTER)(VOID);
126 typedef VOID (CDECL *PSCOPE_EXCEPTION_HANDLER)(VOID);
129 typedef struct _SCOPETABLE_ENTRY
131 DWORD PreviousTryLevel;
132 PSCOPE_EXCEPTION_FILTER FilterRoutine;
133 PSCOPE_EXCEPTION_HANDLER HandlerRoutine;
134 } SCOPETABLE_ENTRY, *PSCOPETABLE_ENTRY;
137 Other structures preceeding this structure:
138 ULONG_PTR StandardESPInFrame;
139 LPEXCEPTION_POINTERS ExceptionPointers;
141 typedef struct _RTL_EXCEPTION_REGISTRATION_I386
143 EXCEPTION_REGISTRATION OS;
144 PSCOPETABLE_ENTRY ScopeTable;
146 /* Value of EBP before the EXCEPTION_REGISTRATION was created */
148 } RTL_EXCEPTION_REGISTRATION_I386, *PRTL_EXCEPTION_REGISTRATION_I386;
150 #define TRYLEVEL_NONE -1
152 typedef RTL_EXCEPTION_REGISTRATION_I386 RTL_EXCEPTION_REGISTRATION;
153 typedef PRTL_EXCEPTION_REGISTRATION_I386 PRTL_EXCEPTION_REGISTRATION;
159 #define EXCEPTION_MAXIMUM_PARAMETERS (15)
161 typedef struct _EXCEPTION_POINTERS {
162 PEXCEPTION_RECORD ExceptionRecord;
163 PCONTEXT ContextRecord;
164 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS, *LPEXCEPTION_POINTERS;
166 #endif /* !__USE_W32API */
168 #endif /* __INCLUDE_EXCEPT_H */