2 * Win32 exception assembly functions
4 * Copyright (c) 1996 Onno Hovers, (onno@stack.urc.tue.nl)
9 #ifdef NEED_UNDERSCORE_PREFIX
11 .globl _EXC_CallUnhandledExceptionFilter
12 _EXC_CallUnhandledExceptionFilter:
16 .globl EXC_CallUnhandledExceptionFilter
17 EXC_CallUnhandledExceptionFilter:
19 #endif /* NEED_UNDERSCORE_PREFIX */
22 #ifdef NEED_UNDERSCORE_PREFIX
26 #endif /* NEED_UNDERSCORE_PREFIX */
32 /*******************************************************************
34 * RaiseException (KERNEL32. 418 )
35 * RtlUnwind (KERNEL32. 443 )
37 * we need to save our context before a call to
42 * after these functions we need to restore that context structure as
43 * the actual context so changes made to the context structure in an
44 * exception-handler will be reflected in the context after these
45 * functions return. Fortunately both functions have 4 DWORD params.
46 * we pass the function to be called as a fifth parameter to ContextCall
49 #define CONTEXT_SegSs -4
50 #define CONTEXT_Esp -8
51 #define CONTEXT_EFlags -12
52 #define CONTEXT_SegCs -16
53 #define CONTEXT_Eip -20
54 #define CONTEXT_Ebp -24
55 #define CONTEXT_Eax -28
56 #define CONTEXT_Ecx -32
57 #define CONTEXT_Edx -36
58 #define CONTEXT_Ebx -40
59 #define CONTEXT_Esi -44
60 #define CONTEXT_Edi -48
61 #define CONTEXT_SegDs -52
62 #define CONTEXT_SegEs -56
63 #define CONTEXT_SegFs -60
64 #define CONTEXT_SegGs -64
65 #define FLOAT_Cr0NpxState -68
66 #define FLOAT_RegisterArea -148
67 #define FLOAT_DataSelector -152
68 #define FLOAT_DataOffset -156
69 #define FLOAT_ErrorSelector -160
70 #define FLOAT_ErrorOffset -164
71 #define FLOAT_TagWord -168
72 #define FLOAT_StatusWord -172
73 #define FLOAT_ControlWord -176
74 #define CONTEXT_FloatSave -176
75 #define CONTEXT_Dr7 -180
76 #define CONTEXT_Dr6 -184
77 #define CONTEXT_Dr3 -188
78 #define CONTEXT_Dr2 -192
79 #define CONTEXT_Dr1 -196
80 #define CONTEXT_Dr0 -200
81 #define CONTEXT_ContextFlags -204
83 #define CONTEXTSIZE 204
84 #define CONTEXTFLAGS 0x10007
86 #define ORIG_ESP 16 /** cdecl !!! **/
91 #define PARM_RETURN 12
92 #define PARM_CALLFUNC 8
96 #ifdef NEED_UNDERSCORE_PREFIX
97 .globl _RaiseException
100 push $_EXC_RaiseException
108 #else /* NEED_UNDERSCORE_PREFIX */
109 .globl RaiseException
112 push $EXC_RaiseException
119 #endif /* NEED_UNDERSCORE_PREFIX */
125 subl $CONTEXTSIZE, %esp
126 movl %eax, CONTEXT_Eax(%ebp)
127 leal ORIG_ESP(%ebp), %eax
128 movl %eax, CONTEXT_Esp(%ebp)
129 movl PARM_EFLAGS(%ebp), %eax
130 movl %eax, CONTEXT_EFlags(%ebp)
131 movl PARM_EBP(%ebp), %eax
132 movl %eax, CONTEXT_Ebp(%ebp)
133 movl PARM_RETURN(%ebp), %eax
134 movl %eax, CONTEXT_Eip(%ebp)
135 movl %edi, CONTEXT_Edi(%ebp)
136 movl %esi, CONTEXT_Esi(%ebp)
137 movl %ebx, CONTEXT_Ebx(%ebp)
138 movl %edx, CONTEXT_Edx(%ebp)
139 movl %ecx, CONTEXT_Ecx(%ebp)
142 movl %eax, CONTEXT_SegSs(%ebp)
144 movl %eax, CONTEXT_SegCs(%ebp)
146 movl %eax, CONTEXT_SegGs(%ebp)
148 movl %eax, CONTEXT_SegFs(%ebp)
150 movl %eax, CONTEXT_SegEs(%ebp)
152 movl %eax, CONTEXT_SegDs(%ebp)
153 fsave CONTEXT_FloatSave(%ebp)
154 movl $CONTEXTFLAGS, %eax
155 movl %eax, CONTEXT_ContextFlags(%ebp)
157 leal CONTEXT(%ebp), %eax
159 pushl PARM_ARG4(%ebp)
160 pushl PARM_ARG3(%ebp)
161 pushl PARM_ARG2(%ebp)
162 pushl PARM_ARG1(%ebp)
163 call *PARM_CALLFUNC(%ebp)
166 lds CONTEXT_Esp(%ebp),%edi
167 movl CONTEXT_Eip(%ebp),%eax
169 movl CONTEXT_EFlags(%ebp),%eax
171 movl CONTEXT_Edi(%ebp),%eax
173 movl CONTEXT_SegDs(%ebp),%eax
175 movl CONTEXT_SegEs(%ebp),%eax
177 movl CONTEXT_SegFs(%ebp),%eax
179 movl CONTEXT_SegGs(%ebp),%eax
181 frstor CONTEXT_FloatSave(%ebp)
182 movl CONTEXT_Ecx(%ebp),%ecx
183 movl CONTEXT_Edx(%ebp),%edx
184 movl CONTEXT_Ebx(%ebp),%ebx
185 movl CONTEXT_Esi(%ebp),%esi
186 movl CONTEXT_Eax(%ebp),%eax
187 movl CONTEXT_Ebp(%ebp),%ebp