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

Last change on this file since 2141 was 2141, checked in by sandervl, 26 years ago

EB's GetThreadContext update

File size: 4.2 KB
Line 
1; $Id: exceptutil.asm,v 1.4 1999-12-19 17:49:38 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
13CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
14 public RaiseExceptionAsm
15 extrn OS2RAISEEXCEPTION : near
16
17RaiseExceptionAsm proc near
18 push dword ptr [esp+4] ;DWORD dwExceptionCode
19 push dword ptr [esp+12] ;DWORD dwExceptionFlags
20 push dword ptr [esp+20] ;DWORD cArguments
21 push dword ptr [esp+28] ;DWORD *lpArguments
22 push dword ptr [esp+16] ;return address
23 push esp
24 sub dword ptr [esp-4], 20
25 push ebp
26 pushfd
27 push eax
28 push ebx
29 push ecx
30 push edx
31 push edi
32 push esi
33 xor eax, eax
34 mov eax, cs ;does 'push cs' push a dword??
35 push eax
36 mov eax, ds
37 push eax
38 mov eax, es
39 push eax
40 mov eax, fs
41 push eax
42 mov eax, gs
43 push eax
44 mov eax, ss
45 push eax
46 call OS2RAISEEXCEPTION
47
48 ret 20 ;__stdcall
49RaiseExceptionAsm endp
50
51 public RtlUnwindAsm
52 extrn OS2RTLUNWIND : near
53
54RtlUnwindAsm proc near
55 push dword ptr [esp+4] ;PWINEXCEPTION_FRAME pEndFrame
56 push dword ptr [esp+12] ;LPVOID unusedEip
57 push dword ptr [esp+20] ;PWINEXCEPTION_RECORD pRecord
58 push dword ptr [esp+28] ;DWORD returnEax
59 push dword ptr [esp+16] ;return address
60 push esp
61 sub dword ptr [esp-4], 20
62 push ebp
63 pushfd
64 push eax
65 push ebx
66 push ecx
67 push edx
68 push edi
69 push esi
70 xor eax, eax
71 mov eax, cs ;does 'push cs' push a dword??
72 push eax
73 mov eax, ds
74 push eax
75 mov eax, es
76 push eax
77 mov eax, fs
78 push eax
79 mov eax, gs
80 push eax
81 mov eax, ss
82 push eax
83 call OS2RTLUNWIND
84
85 ret 20 ;__stdcall
86RtlUnwindAsm endp
87
88
89 PUBLIC QueryExceptionChain
90
91QueryExceptionChain proc near
92 mov eax, fs:[0]
93 ret
94QueryExceptionChain endp
95
96 PUBLIC GetExceptionRecord
97GetExceptionRecord proc near
98 push ebp
99 mov ebp, esp
100 push fs
101 push ebx
102
103 mov eax, [ebp+8]
104 mov fs, eax
105 mov ebx, [ebp+12]
106 mov eax, fs:[ebx]
107
108 pop ebx
109 pop fs
110 pop ebp
111 ret
112GetExceptionRecord endp
113
114 PUBLIC ChangeTIBStack
115ChangeTIBStack proc near
116; xor eax, eax
117 push ebx
118 mov eax, fs:[4]
119 mov ebx, fs:[8]
120 add ebx, 8
121 mov fs:[4], ebx
122 mov fs:[8], eax
123 pop ebx
124 ret
125ChangeTIBStack endp
126
127 PUBLIC _SetExceptionChain
128
129_SetExceptionChain proc near
130 mov eax, dword ptr [esp+4]
131 mov fs:[0], eax
132 ret
133_SetExceptionChain endp
134
135 PUBLIC DisableFPUExceptions
136DisableFPUExceptions proc near
137 push eax
138 push 67Fh
139 fldcw word ptr [esp]
140 pop eax
141 pop eax
142 ret
143DisableFPUExceptions endp
144
145 PUBLIC GetDllEntryPoint
146
147GetDllEntryPoint proc near
148 mov eax, [ebp + 4] ; return address in win32 dll
149 ret
150GetDllEntryPoint endp
151
152 PUBLIC getEAX
153 PUBLIC getEBX
154getEAX proc near
155 ret
156getEAX endp
157
158getEBX proc near
159 mov eax, ebx
160 ret
161getEBX endp
162
163 PUBLIC GetFS
164GetFS proc near
165 mov eax, fs
166 ret
167GetFS endp
168
169 PUBLIC SetFS
170SetFS proc near
171 mov eax, [esp+4]
172 mov fs, eax
173 ret
174SetFS endp
175
176 PUBLIC getCS
177getCS proc near
178 mov eax, cs
179 ret
180getCS endp
181
182 PUBLIC getDS
183getDS proc near
184 mov eax, ds
185 ret
186getDS endp
187
188 PUBLIC SetReturnFS
189SetReturnFS proc near
190 push fs
191 mov eax, [esp+8]
192 mov fs, eax
193 pop eax
194 ret
195SetReturnFS endp
196
197 PUBLIC getSS
198getSS proc near
199 mov ax, ss
200 ret
201getSS endp
202
203 PUBLIC getES
204getES proc near
205 mov eax, es
206 ret
207getES endp
208
209 PUBLIC getGS
210getGS proc near
211 mov eax, gs
212 ret
213getGS endp
214
215 PUBLIC RestoreOS2FS
216RestoreOS2FS proc near
217 push 150bh
218 mov ax, fs
219 pop fs
220 ret
221RestoreOS2FS endp
222CODE32 ENDS
223
224 END
Note: See TracBrowser for help on using the repository browser.