1 | ; $Id: except.asm,v 1.3 1999-06-10 20:47:58 phaller 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 | ASSUME CS:FLAT ,DS:FLAT,SS:FLAT
|
---|
15 | public RaiseExceptionAsm
|
---|
16 | extrn OS2RAISEEXCEPTION : near
|
---|
17 |
|
---|
18 | RaiseExceptionAsm proc near
|
---|
19 | push dword ptr [esp+4] ;DWORD dwExceptionCode
|
---|
20 | push dword ptr [esp+12] ;DWORD dwExceptionFlags
|
---|
21 | push dword ptr [esp+20] ;DWORD cArguments
|
---|
22 | push dword ptr [esp+28] ;DWORD *lpArguments
|
---|
23 | push dword ptr [esp+16] ;return address
|
---|
24 | push esp
|
---|
25 | sub dword ptr [esp-4], 20
|
---|
26 | push ebp
|
---|
27 | pushfd
|
---|
28 | push eax
|
---|
29 | push ebx
|
---|
30 | push ecx
|
---|
31 | push edx
|
---|
32 | push edi
|
---|
33 | push esi
|
---|
34 | xor eax, eax
|
---|
35 | mov eax, cs ;does 'push cs' push a dword??
|
---|
36 | push eax
|
---|
37 | mov eax, ds
|
---|
38 | push eax
|
---|
39 | mov eax, es
|
---|
40 | push eax
|
---|
41 | mov eax, fs
|
---|
42 | push eax
|
---|
43 | mov eax, gs
|
---|
44 | push eax
|
---|
45 | mov eax, ss
|
---|
46 | push eax
|
---|
47 | call OS2RAISEEXCEPTION
|
---|
48 |
|
---|
49 | ret 20 ;__stdcall
|
---|
50 | RaiseExceptionAsm endp
|
---|
51 |
|
---|
52 | public RtlUnwindAsm
|
---|
53 | extrn OS2RTLUNWIND : near
|
---|
54 |
|
---|
55 | RtlUnwindAsm proc near
|
---|
56 | push dword ptr [esp+4] ;PWINEXCEPTION_FRAME pEndFrame
|
---|
57 | push dword ptr [esp+12] ;LPVOID unusedEip
|
---|
58 | push dword ptr [esp+20] ;PWINEXCEPTION_RECORD pRecord
|
---|
59 | push dword ptr [esp+28] ;DWORD returnEax
|
---|
60 | push dword ptr [esp+16] ;return address
|
---|
61 | push esp
|
---|
62 | sub dword ptr [esp-4], 20
|
---|
63 | push ebp
|
---|
64 | pushfd
|
---|
65 | push eax
|
---|
66 | push ebx
|
---|
67 | push ecx
|
---|
68 | push edx
|
---|
69 | push edi
|
---|
70 | push esi
|
---|
71 | xor eax, eax
|
---|
72 | mov eax, cs ;does 'push cs' push a dword??
|
---|
73 | push eax
|
---|
74 | mov eax, ds
|
---|
75 | push eax
|
---|
76 | mov eax, es
|
---|
77 | push eax
|
---|
78 | mov eax, fs
|
---|
79 | push eax
|
---|
80 | mov eax, gs
|
---|
81 | push eax
|
---|
82 | mov eax, ss
|
---|
83 | push eax
|
---|
84 | call OS2RTLUNWIND
|
---|
85 |
|
---|
86 | ret 20 ;__stdcall
|
---|
87 | RtlUnwindAsm endp
|
---|
88 |
|
---|
89 |
|
---|
90 | PUBLIC QueryExceptionChain
|
---|
91 |
|
---|
92 | QueryExceptionChain proc near
|
---|
93 | mov eax, fs:[0]
|
---|
94 | ret
|
---|
95 | QueryExceptionChain endp
|
---|
96 |
|
---|
97 | PUBLIC GetExceptionRecord
|
---|
98 | GetExceptionRecord proc near
|
---|
99 | push ebp
|
---|
100 | mov ebp, esp
|
---|
101 | push fs
|
---|
102 | push ebx
|
---|
103 |
|
---|
104 | mov eax, [ebp+8]
|
---|
105 | mov fs, eax
|
---|
106 | mov ebx, [ebp+12]
|
---|
107 | mov eax, fs:[ebx]
|
---|
108 |
|
---|
109 | pop ebx
|
---|
110 | pop fs
|
---|
111 | pop ebp
|
---|
112 | ret
|
---|
113 | GetExceptionRecord endp
|
---|
114 |
|
---|
115 | PUBLIC ChangeTIBStack
|
---|
116 | ChangeTIBStack proc near
|
---|
117 | ; xor eax, eax
|
---|
118 | push ebx
|
---|
119 | mov eax, fs:[4]
|
---|
120 | mov ebx, fs:[8]
|
---|
121 | add ebx, 8
|
---|
122 | mov fs:[4], ebx
|
---|
123 | mov fs:[8], eax
|
---|
124 | pop ebx
|
---|
125 | ret
|
---|
126 | ChangeTIBStack endp
|
---|
127 |
|
---|
128 | PUBLIC _SetExceptionChain
|
---|
129 |
|
---|
130 | _SetExceptionChain proc near
|
---|
131 | mov eax, dword ptr [esp+4]
|
---|
132 | mov fs:[0], eax
|
---|
133 | ret
|
---|
134 | _SetExceptionChain endp
|
---|
135 |
|
---|
136 | PUBLIC DisableFPUExceptions
|
---|
137 | DisableFPUExceptions proc near
|
---|
138 | push eax
|
---|
139 | push 67Fh
|
---|
140 | fldcw word ptr [esp]
|
---|
141 | pop eax
|
---|
142 | pop eax
|
---|
143 | ret
|
---|
144 | DisableFPUExceptions endp
|
---|
145 |
|
---|
146 | PUBLIC GetDllEntryPoint
|
---|
147 |
|
---|
148 | GetDllEntryPoint proc near
|
---|
149 | mov eax, [ebp + 4] ; return address in win32 dll
|
---|
150 | ret
|
---|
151 | GetDllEntryPoint endp
|
---|
152 |
|
---|
153 | PUBLIC getEAX
|
---|
154 | PUBLIC getEBX
|
---|
155 | getEAX proc near
|
---|
156 | ret
|
---|
157 | getEAX endp
|
---|
158 |
|
---|
159 | getEBX proc near
|
---|
160 | mov eax, ebx
|
---|
161 | ret
|
---|
162 | getEBX endp
|
---|
163 |
|
---|
164 | PUBLIC GetFS
|
---|
165 | GetFS proc near
|
---|
166 | mov eax, fs
|
---|
167 | ret
|
---|
168 | GetFS endp
|
---|
169 |
|
---|
170 | PUBLIC SetFS
|
---|
171 | SetFS proc near
|
---|
172 | mov eax, [esp+4]
|
---|
173 | mov fs, eax
|
---|
174 | ret
|
---|
175 | SetFS endp
|
---|
176 |
|
---|
177 | CODE32 ENDS
|
---|
178 |
|
---|
179 | END
|
---|