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 #define EXCEPTION_NONCONTINUABLE 0x01
61 #endif /* __NTOSKRNL__ */
62 #endif /* _GNU_H_WINDOWS32_DEFINES */
63 #define EXCEPTION_UNWINDING 0x02
64 #define EXCEPTION_EXIT_UNWIND 0x04
65 #define EXCEPTION_STACK_INVALID 0x08
66 #define EXCEPTION_NESTED_CALL 0x10
69 typedef struct _EXCEPTION_REGISTRATION
71 struct _EXCEPTION_REGISTRATION
* prev
;
72 PEXCEPTION_HANDLER handler
;
73 } EXCEPTION_REGISTRATION
, *PEXCEPTION_REGISTRATION
;
75 typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD
;
76 typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD
;
80 * A macro which installs the supplied exception handler.
81 * Push the pointer to the new handler onto the stack,
82 * then push the pointer to the old registration structure (at fs:0)
83 * onto the stack, then put a pointer to the new registration
84 * structure (i.e. the current stack pointer) at fs:0.
86 #define __try1(pHandler) \
87 __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
91 * A macro which (dispite its name) *removes* an installed
92 * exception handler. Should be used only in conjunction with the above
93 * install routine __try1.
94 * Move the pointer to the old reg. struct (at the current stack
95 * position) to fs:0, replacing the pointer we installed above,
96 * then add 8 to the stack pointer to get rid of the space we
97 * used when we pushed on our new reg. struct above. Notice that
98 * the stack must be in the exact state at this point that it was
99 * after we did _try1 or this will smash things.
102 __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
108 // Runtime DLL structures
110 #ifndef _GNU_H_WINDOWS32_DEFINES
112 #define EXCEPTION_EXECUTE_HANDLER 1
113 #define EXCEPTION_CONTINUE_SEARCH 0
114 #define EXCEPTION_CONTINUE_EXECUTION -1
115 #endif /* __NTOSKRNL__ */
116 #endif /* _GNU_H_WINDOWS32_DEFINES */
118 // Functions of the following prototype return one of the above constants
120 typedef DWORD
CDECL (*PSCOPE_EXCEPTION_FILTER
)(VOID
);
121 typedef VOID
CDECL (*PSCOPE_EXCEPTION_HANDLER
)(VOID
);
123 typedef DWORD (CDECL
*PSCOPE_EXCEPTION_FILTER
)(VOID
);
124 typedef VOID (CDECL
*PSCOPE_EXCEPTION_HANDLER
)(VOID
);
127 typedef struct _SCOPETABLE_ENTRY
129 DWORD PreviousTryLevel
;
130 PSCOPE_EXCEPTION_FILTER FilterRoutine
;
131 PSCOPE_EXCEPTION_HANDLER HandlerRoutine
;
132 } SCOPETABLE_ENTRY
, *PSCOPETABLE_ENTRY
;
135 Other structures preceeding this structure:
136 ULONG_PTR StandardESPInFrame;
137 LPEXCEPTION_POINTERS ExceptionPointers;
139 typedef struct _RTL_EXCEPTION_REGISTRATION_I386
141 EXCEPTION_REGISTRATION OS
;
142 PSCOPETABLE_ENTRY ScopeTable
;
144 /* Value of EBP before the EXCEPTION_REGISTRATION was created */
146 } RTL_EXCEPTION_REGISTRATION_I386
, *PRTL_EXCEPTION_REGISTRATION_I386
;
148 #define TRYLEVEL_NONE -1
150 typedef RTL_EXCEPTION_REGISTRATION_I386 RTL_EXCEPTION_REGISTRATION
;
151 typedef PRTL_EXCEPTION_REGISTRATION_I386 PRTL_EXCEPTION_REGISTRATION
;
157 #define EXCEPTION_MAXIMUM_PARAMETERS (15)
159 typedef struct _EXCEPTION_POINTERS
{
160 PEXCEPTION_RECORD ExceptionRecord
;
161 PCONTEXT ContextRecord
;
162 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
, *LPEXCEPTION_POINTERS
;
164 #endif /* !__USE_W32API */
166 #endif /* __INCLUDE_EXCEPT_H */