1 | ; $Id: exceptutil.asm,v 1.2 1999-08-29 14:56:02 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 |
|
---|
13 | CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
|
---|
14 | public RaiseExceptionAsm
|
---|
15 | extrn OS2RAISEEXCEPTION : near
|
---|
16 |
|
---|
17 | RaiseExceptionAsm 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
|
---|
49 | RaiseExceptionAsm endp
|
---|
50 |
|
---|
51 | public RtlUnwindAsm
|
---|
52 | extrn OS2RTLUNWIND : near
|
---|
53 |
|
---|
54 | RtlUnwindAsm 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
|
---|
86 | RtlUnwindAsm endp
|
---|
87 |
|
---|
88 |
|
---|
89 | PUBLIC QueryExceptionChain
|
---|
90 |
|
---|
91 | QueryExceptionChain proc near
|
---|
92 | mov eax, fs:[0]
|
---|
93 | ret
|
---|
94 | QueryExceptionChain endp
|
---|
95 |
|
---|
96 | PUBLIC GetExceptionRecord
|
---|
97 | GetExceptionRecord 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
|
---|
112 | GetExceptionRecord endp
|
---|
113 |
|
---|
114 | PUBLIC ChangeTIBStack
|
---|
115 | ChangeTIBStack 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
|
---|
125 | ChangeTIBStack 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
|
---|
136 | DisableFPUExceptions proc near
|
---|
137 | push eax
|
---|
138 | push 67Fh
|
---|
139 | fldcw word ptr [esp]
|
---|
140 | pop eax
|
---|
141 | pop eax
|
---|
142 | ret
|
---|
143 | DisableFPUExceptions endp
|
---|
144 |
|
---|
145 | PUBLIC GetDllEntryPoint
|
---|
146 |
|
---|
147 | GetDllEntryPoint proc near
|
---|
148 | mov eax, [ebp + 4] ; return address in win32 dll
|
---|
149 | ret
|
---|
150 | GetDllEntryPoint endp
|
---|
151 |
|
---|
152 | PUBLIC getEAX
|
---|
153 | PUBLIC getEBX
|
---|
154 | getEAX proc near
|
---|
155 | ret
|
---|
156 | getEAX endp
|
---|
157 |
|
---|
158 | getEBX proc near
|
---|
159 | mov eax, ebx
|
---|
160 | ret
|
---|
161 | getEBX endp
|
---|
162 |
|
---|
163 | PUBLIC GetFS
|
---|
164 | GetFS proc near
|
---|
165 | mov eax, fs
|
---|
166 | ret
|
---|
167 | GetFS endp
|
---|
168 |
|
---|
169 | PUBLIC SetFS
|
---|
170 | SetFS proc near
|
---|
171 | mov eax, [esp+4]
|
---|
172 | mov fs, eax
|
---|
173 | ret
|
---|
174 | SetFS endp
|
---|
175 |
|
---|
176 | PUBLIC SetReturnFS
|
---|
177 | SetReturnFS proc near
|
---|
178 | push fs
|
---|
179 | mov eax, [esp+8]
|
---|
180 | mov fs, eax
|
---|
181 | pop eax
|
---|
182 | ret
|
---|
183 | SetReturnFS endp
|
---|
184 |
|
---|
185 | PUBLIC getSS
|
---|
186 | getSS proc near
|
---|
187 | mov ax, ss
|
---|
188 | ret
|
---|
189 | getSS endp
|
---|
190 |
|
---|
191 | PUBLIC RestoreOS2FS
|
---|
192 | RestoreOS2FS proc near
|
---|
193 | push 150bh
|
---|
194 | mov ax, fs
|
---|
195 | pop fs
|
---|
196 | ret
|
---|
197 | RestoreOS2FS endp
|
---|
198 | CODE32 ENDS
|
---|
199 |
|
---|
200 | END
|
---|