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.
28 typedef EXCEPTION_DISPOSITION CDECL (*PEXCEPTION_HANDLER)(
29 struct _EXCEPTION_RECORD* ExceptionRecord,
30 struct _EXCEPTION_REGISTRATION* ExceptionRegistration,
32 PVOID DispatcherContext);
35 #define EXCEPTION_MAXIMUM_PARAMETERS (15)
37 typedef struct _EXCEPTION_RECORD {
40 struct _EXCEPTION_RECORD *ExceptionRecord;
41 PVOID ExceptionAddress;
42 DWORD NumberParameters;
43 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
44 } EXCEPTION_RECORD, *PEXCEPTION_RECORD, *LPEXCEPTION_RECORD;
47 #ifndef _GNU_H_WINDOWS32_DEFINES
49 #define EXCEPTION_NONCONTINUABLE 0x01
50 #endif /* __NTOSKRNL__ */
51 #endif /* _GNU_H_WINDOWS32_DEFINES */
52 #define EXCEPTION_UNWINDING 0x02
53 #define EXCEPTION_EXIT_UNWIND 0x04
54 #define EXCEPTION_STACK_INVALID 0x08
55 #define EXCEPTION_NESTED_CALL 0x10
58 typedef struct _EXCEPTION_POINTERS {
59 PEXCEPTION_RECORD ExceptionRecord;
60 PCONTEXT ContextRecord;
61 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS, *LPEXCEPTION_POINTERS;
64 typedef struct _EXCEPTION_REGISTRATION
66 struct _EXCEPTION_REGISTRATION* prev;
67 PEXCEPTION_HANDLER handler;
68 } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
70 typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
71 typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
75 * A macro which installs the supplied exception handler.
76 * Push the pointer to the new handler onto the stack,
77 * then push the pointer to the old registration structure (at fs:0)
78 * onto the stack, then put a pointer to the new registration
79 * structure (i.e. the current stack pointer) at fs:0.
81 #define __try1(pHandler) \
82 __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
86 * A macro which (dispite its name) *removes* an installed
87 * exception handler. Should be used only in conjunction with the above
88 * install routine __try1.
89 * Move the pointer to the old reg. struct (at the current stack
90 * position) to fs:0, replacing the pointer we installed above,
91 * then add 8 to the stack pointer to get rid of the space we
92 * used when we pushed on our new reg. struct above. Notice that
93 * the stack must be in the exact state at this point that it was
94 * after we did _try1 or this will smash things.
97 __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
103 // Runtime DLL structures
105 #ifndef _GNU_H_WINDOWS32_DEFINES
107 #define EXCEPTION_EXECUTE_HANDLER 1
108 #define EXCEPTION_CONTINUE_SEARCH 0
109 #define EXCEPTION_CONTINUE_EXECUTION -1
110 #endif /* __NTOSKRNL__ */
111 #endif /* _GNU_H_WINDOWS32_DEFINES */
113 // Functions of the following prototype return one of the above constants
114 typedef DWORD CDECL (*PSCOPE_EXCEPTION_FILTER)(VOID);
115 typedef VOID CDECL (*PSCOPE_EXCEPTION_HANDLER)(VOID);
117 typedef struct _SCOPETABLE_ENTRY
119 DWORD PreviousTryLevel;
120 PSCOPE_EXCEPTION_FILTER FilterRoutine;
121 PSCOPE_EXCEPTION_HANDLER HandlerRoutine;
122 } SCOPETABLE_ENTRY, *PSCOPETABLE_ENTRY;
125 Other structures preceeding this structure:
126 ULONG_PTR StandardESPInFrame;
127 LPEXCEPTION_POINTERS ExceptionPointers;
129 typedef struct _RTL_EXCEPTION_REGISTRATION_I386
131 EXCEPTION_REGISTRATION OS;
132 PSCOPETABLE_ENTRY ScopeTable;
134 /* Value of EBP before the EXCEPTION_REGISTRATION was created */
136 } RTL_EXCEPTION_REGISTRATION_I386, *PRTL_EXCEPTION_REGISTRATION_I386;
138 #define TRYLEVEL_NONE -1
140 typedef RTL_EXCEPTION_REGISTRATION_I386 RTL_EXCEPTION_REGISTRATION;
141 typedef PRTL_EXCEPTION_REGISTRATION_I386 PRTL_EXCEPTION_REGISTRATION;
145 #endif /* __INCLUDE_EXCEPT_H */