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