source: trunk/src/kernel32/exceptutil.asm@ 9304

Last change on this file since 9304 was 8401, checked in by sandervl, 23 years ago

hard disk access updates & fixes

File size: 7.4 KB
Line 
1; $Id: exceptutil.asm,v 1.19 2002-05-10 14:55:11 sandervl Exp $
2
3;/*
4; * Project Odin Software License can be found in LICENSE.TXT
5; * Win32 Exception handling + misc functions for OS/2
6; *
7; * Copyright 1998 Sander van Leeuwen
8; *
9; */
10.386p
11 NAME except
12
13DATA32 segment dword use32 public 'DATA'
14DATA32 ends
15CONST32_RO segment dword use32 public 'CONST'
16CONST32_RO ends
17BSS32 segment dword use32 public 'BSS'
18BSS32 ends
19DGROUP group BSS32, DATA32
20 assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
21
22DATA32 segment dword use32 public 'DATA'
23
24CONST32_RO segment
25 align 04h
26@CBE8 db "KERNEL32: Calling handle"
27db "r at %p code=%lx flags=%"
28db "lx",0ah,0h
29@CBE9 db "KERNEL32: Handler return"
30db "ed %lx",0ah,0h
31CONST32_RO ends
32DATA32 ends
33
34CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
35 public _RaiseException@16
36 extrn OS2RAISEEXCEPTION : near
37
38_RaiseException@16 proc near
39 push dword ptr [esp+4] ;DWORD dwExceptionCode
40 push dword ptr [esp+12] ;DWORD dwExceptionFlags
41 push dword ptr [esp+20] ;DWORD cArguments
42 push dword ptr [esp+28] ;DWORD *lpArguments
43 push dword ptr [esp+16] ;return address
44 push esp
45 add dword ptr [esp], 20
46 push ebp
47 pushfd
48 push eax
49 push ebx
50 push ecx
51 push edx
52 push edi
53 push esi
54 xor eax, eax
55 mov eax, cs
56 push eax
57 mov eax, ds
58 push eax
59 mov eax, es
60 push eax
61 mov eax, fs
62 push eax
63 mov eax, gs
64 push eax
65 mov eax, ss
66 push eax
67 call OS2RAISEEXCEPTION
68
69 ret 16 ;__stdcall
70_RaiseException@16 endp
71
72 public _RtlUnwind@16
73 extrn OS2RTLUNWIND : near
74
75_RtlUnwind@16 proc near
76 push dword ptr [esp+4] ;PWINEXCEPTION_FRAME pEndFrame
77 push dword ptr [esp+12] ;LPVOID unusedEip
78 push dword ptr [esp+20] ;PWINEXCEPTION_RECORD pRecord
79 push dword ptr [esp+28] ;DWORD returnEax
80 push dword ptr [esp+16] ;return address
81 push esp
82 add dword ptr [esp], 20
83 push ebp
84 pushfd
85 push eax
86 push ebx
87 push ecx
88 push edx
89 push edi
90 push esi
91 xor eax, eax
92 mov eax, cs
93 push eax
94 mov eax, ds
95 push eax
96 mov eax, es
97 push eax
98 mov eax, fs
99 push eax
100 mov eax, gs
101 push eax
102 mov eax, ss
103 push eax
104 call OS2RTLUNWIND
105
106 ret 16 ;__stdcall
107_RtlUnwind@16 endp
108
109
110 PUBLIC QueryExceptionChain
111
112QueryExceptionChain proc near
113 mov eax, fs:[0]
114 ret
115QueryExceptionChain endp
116
117 PUBLIC GetExceptionRecord
118GetExceptionRecord proc near
119 push ebp
120 mov ebp, esp
121 push fs
122 push ebx
123
124 mov eax, [ebp+8]
125 mov fs, eax
126 mov ebx, [ebp+12]
127 mov eax, fs:[ebx]
128
129 pop ebx
130 pop fs
131 pop ebp
132 ret
133GetExceptionRecord endp
134
135 PUBLIC ChangeTIBStack
136ChangeTIBStack proc near
137; xor eax, eax
138 push ebx
139 mov eax, fs:[4]
140 mov ebx, fs:[8]
141 add ebx, 8
142 mov fs:[4], ebx
143 mov fs:[8], eax
144 pop ebx
145 ret
146ChangeTIBStack endp
147
148 PUBLIC _SetExceptionChain
149
150_SetExceptionChain proc near
151 mov eax, dword ptr [esp+4]
152 mov fs:[0], eax
153 ret
154_SetExceptionChain endp
155
156
157 PUBLIC _AsmCallThreadHandler
158_AsmCallThreadHandler proc near
159 push ebp
160 mov ebp, esp
161
162 push dword ptr [ebp+12]
163 mov eax, dword ptr [ebp+8]
164 call eax
165
166 mov esp, ebp
167 pop ebp
168 ret
169_AsmCallThreadHandler endp
170
171 PUBLIC _CallEntryPoint
172_CallEntryPoint proc near
173 push ebp
174 mov ebp, esp
175
176 mov eax, esp
177 sub eax, 16
178 and eax, 0FFFFFFF0h
179 add eax, 4
180 mov esp, eax
181
182 push dword ptr [ebp+12]
183 mov eax, dword ptr [ebp+8]
184 call eax
185
186 mov esp, ebp
187 pop ebp
188 ret
189_CallEntryPoint endp
190
191
192; 281 static DWORD EXC_CallHandler( WINEXCEPTION_RECORD *record, WINEXCEPTION_FRAME *frame,
193 EXTRN WriteLog:PROC
194 EXTRN _GetThreadTEB@0:PROC
195IFDEF DEBUG
196 EXTRN DbgEnabledKERNEL32:DWORD
197ENDIF
198
199EXC_push_frame__FP19_WINEXCEPTION_FRAME proc
200 push ebp
201 mov ebp,esp
202 sub esp,04h
203 mov [ebp+08h],eax; frame
204
205; 132 TEB *teb = GetThreadTEB();
206 call _GetThreadTEB@0
207 mov [ebp-04h],eax; teb
208
209; 133 frame->Prev = (PWINEXCEPTION_FRAME)teb->except;
210 mov ecx,[ebp-04h]; teb
211 mov ecx,[ecx]
212 mov eax,[ebp+08h]; frame
213 mov [eax],ecx
214
215; 134 teb->except = frame;
216 mov eax,[ebp-04h]; teb
217 mov ecx,[ebp+08h]; frame
218 mov [eax],ecx
219
220; 135 return frame->Prev;
221 mov eax,[ebp+08h]; frame
222 mov eax,[eax]
223 leave
224 ret
225EXC_push_frame__FP19_WINEXCEPTION_FRAME endp
226
227; 138 static inline WINEXCEPTION_FRAME * EXC_pop_frame( WINEXCEPTION_FRAME *frame )
228 align 04h
229
230EXC_pop_frame__FP19_WINEXCEPTION_FRAME proc
231 push ebp
232 mov ebp,esp
233 sub esp,04h
234 mov [ebp+08h],eax; frame
235
236; 141 TEB *teb = GetThreadTEB();
237 call _GetThreadTEB@0
238 mov [ebp-04h],eax; teb
239
240; 142 teb->except = frame->Prev;
241 mov ecx,[ebp+08h]; frame
242 mov ecx,[ecx]
243 mov eax,[ebp-04h]; teb
244 mov [eax],ecx
245
246; 143 return frame->Prev;
247 mov eax,[ebp+08h]; frame
248 mov eax,[eax]
249 leave
250 ret
251EXC_pop_frame__FP19_WINEXCEPTION_FRAME endp
252
253 align 04h
254 PUBLIC EXC_CallHandler__FP20_WINEXCEPTION_RECORDP19_WINEXCEPTION_FRAMEP10WINCONTEXTPP19_WINEXCEPTION_FRAMEPFP20_WINEXCEPTION_RECORDP19_WINEXCEPTION_FRAMEP10WINCONTEXTPv_UlT5
255
256EXC_CallHandler__FP20_WINEXCEPTION_RECORDP19_WINEXCEPTION_FRAMEP10WINCONTEXTPP19_WINEXCEPTION_FRAMEPFP20_WINEXCEPTION_RECORDP19_WINEXCEPTION_FRAMEP10WINCONTEXTPv_UlT5 proc
257 push ebp
258 mov ebp,esp
259 sub esp,010h
260 sub esp,04h
261 mov [ebp+08h],eax; record
262 mov [ebp+0ch],edx; frame
263 mov [ebp+010h],ecx; context
264
265; 296 newframe.frame.Handler = nested_handler;
266 mov eax,[ebp+01ch]; nested_handler
267 mov [ebp-08h],eax; newframe
268
269; 297 newframe.prevFrame = frame;
270 mov eax,[ebp+0ch]; frame
271 mov [ebp-04h],eax; newframe
272
273; 298 EXC_push_frame( &newframe.frame );
274 lea eax,[ebp-0ch]; newframe
275 call EXC_push_frame__FP19_WINEXCEPTION_FRAME
276
277; 299 dprintf(("KERNEL32: Calling handler at %p code=%lx flags=%lx\n",
278IFDEF DEBUG
279 cmp word ptr DbgEnabledKERNEL32+020h,01h
280 jne @BLBL20
281 mov eax,[ebp+08h]; record
282 push dword ptr [eax+04h]
283 mov eax,[ebp+08h]; record
284 push dword ptr [eax]
285 push dword ptr [ebp+018h]; handler
286 push offset FLAT:@CBE8
287 call WriteLog
288 add esp,010h
289ENDIF
290
291; 300 handler, record->ExceptionCode, record->ExceptionFlags));
292@BLBL20:
293
294; 301 ret = handler( record, frame, context, dispatcher );
295 push dword ptr [ebp+014h]; dispatcher
296 push dword ptr [ebp+010h]; context
297 push dword ptr [ebp+0ch]; frame
298 push dword ptr [ebp+08h]; record
299 call dword ptr [ebp+018h]; handler
300 mov [ebp-010h],eax; ret
301
302IFDEF DEBUG
303; 302 dprintf(("KERNEL32: Handler returned %lx\n", ret));
304 cmp word ptr DbgEnabledKERNEL32+020h,01h
305 jne @BLBL21
306 push dword ptr [ebp-010h]; ret
307 push offset FLAT:@CBE9
308 call WriteLog
309 add esp,08h
310@BLBL21:
311ENDIF
312
313; 303 EXC_pop_frame( &newframe.frame );
314 lea eax,[ebp-0ch]; newframe
315 call EXC_pop_frame__FP19_WINEXCEPTION_FRAME
316
317; 304 return ret;
318 mov eax,[ebp-010h]; ret
319 add esp,04h
320 leave
321 ret
322EXC_CallHandler__FP20_WINEXCEPTION_RECORDP19_WINEXCEPTION_FRAMEP10WINCONTEXTPP19_WINEXCEPTION_FRAMEPFP20_WINEXCEPTION_RECORDP19_WINEXCEPTION_FRAMEP10WINCONTEXTPv_UlT5 endp
323
324CODE32 ENDS
325
326 END
Note: See TracBrowser for help on using the repository browser.