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