| 1 | ; $Id: exceptutil.asm,v 1.11 2000-09-08 18:07:49 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  _RaiseException@16 | 
|---|
| 15 | extrn   OS2RAISEEXCEPTION : near | 
|---|
| 16 |  | 
|---|
| 17 | _RaiseException@16 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 | add  dword ptr [esp], 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 | 
|---|
| 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 16      ;__stdcall | 
|---|
| 49 | _RaiseException@16 endp | 
|---|
| 50 |  | 
|---|
| 51 | public  _RtlUnwind@16 | 
|---|
| 52 | extrn   OS2RTLUNWIND : near | 
|---|
| 53 |  | 
|---|
| 54 | _RtlUnwind@16 proc near | 
|---|
| 55 | ; fudge return address | 
|---|
| 56 | push eax | 
|---|
| 57 | mov  eax, dword ptr [esp+12] | 
|---|
| 58 | mov  dword ptr [esp+4], eax | 
|---|
| 59 | pop  eax | 
|---|
| 60 |  | 
|---|
| 61 | push dword ptr [esp+4]  ;PWINEXCEPTION_FRAME  pEndFrame | 
|---|
| 62 | push dword ptr [esp+12] ;LPVOID unusedEip | 
|---|
| 63 | push dword ptr [esp+20] ;PWINEXCEPTION_RECORD pRecord | 
|---|
| 64 | push dword ptr [esp+28] ;DWORD  returnEax | 
|---|
| 65 | push dword ptr [esp+16] ;return address | 
|---|
| 66 | push esp | 
|---|
| 67 | add  dword ptr [esp], 20 | 
|---|
| 68 | push ebp | 
|---|
| 69 | pushfd | 
|---|
| 70 | push eax | 
|---|
| 71 | push ebx | 
|---|
| 72 | push ecx | 
|---|
| 73 | push edx | 
|---|
| 74 | push edi | 
|---|
| 75 | push esi | 
|---|
| 76 | xor  eax, eax | 
|---|
| 77 | mov  eax, cs | 
|---|
| 78 | push eax | 
|---|
| 79 | mov  eax, ds | 
|---|
| 80 | push eax | 
|---|
| 81 | mov  eax, es | 
|---|
| 82 | push eax | 
|---|
| 83 | mov  eax, fs | 
|---|
| 84 | push eax | 
|---|
| 85 | mov  eax, gs | 
|---|
| 86 | push eax | 
|---|
| 87 | mov  eax, ss | 
|---|
| 88 | push eax | 
|---|
| 89 | call OS2RTLUNWIND | 
|---|
| 90 |  | 
|---|
| 91 | ret 16      ;__stdcall | 
|---|
| 92 | _RtlUnwind@16 endp | 
|---|
| 93 |  | 
|---|
| 94 |  | 
|---|
| 95 | PUBLIC QueryExceptionChain | 
|---|
| 96 |  | 
|---|
| 97 | QueryExceptionChain proc near | 
|---|
| 98 | mov  eax, fs:[0] | 
|---|
| 99 | ret | 
|---|
| 100 | QueryExceptionChain endp | 
|---|
| 101 |  | 
|---|
| 102 | PUBLIC GetExceptionRecord | 
|---|
| 103 | GetExceptionRecord proc near | 
|---|
| 104 | push ebp | 
|---|
| 105 | mov  ebp, esp | 
|---|
| 106 | push fs | 
|---|
| 107 | push ebx | 
|---|
| 108 |  | 
|---|
| 109 | mov  eax, [ebp+8] | 
|---|
| 110 | mov  fs, eax | 
|---|
| 111 | mov  ebx, [ebp+12] | 
|---|
| 112 | mov  eax, fs:[ebx] | 
|---|
| 113 |  | 
|---|
| 114 | pop  ebx | 
|---|
| 115 | pop  fs | 
|---|
| 116 | pop  ebp | 
|---|
| 117 | ret | 
|---|
| 118 | GetExceptionRecord endp | 
|---|
| 119 |  | 
|---|
| 120 | PUBLIC ChangeTIBStack | 
|---|
| 121 | ChangeTIBStack proc near | 
|---|
| 122 | ;       xor  eax, eax | 
|---|
| 123 | push ebx | 
|---|
| 124 | mov  eax, fs:[4] | 
|---|
| 125 | mov  ebx, fs:[8] | 
|---|
| 126 | add  ebx, 8 | 
|---|
| 127 | mov  fs:[4], ebx | 
|---|
| 128 | mov  fs:[8], eax | 
|---|
| 129 | pop  ebx | 
|---|
| 130 | ret | 
|---|
| 131 | ChangeTIBStack endp | 
|---|
| 132 |  | 
|---|
| 133 | PUBLIC _SetExceptionChain | 
|---|
| 134 |  | 
|---|
| 135 | _SetExceptionChain proc near | 
|---|
| 136 | mov eax, dword ptr [esp+4] | 
|---|
| 137 | mov fs:[0], eax | 
|---|
| 138 | ret | 
|---|
| 139 | _SetExceptionChain endp | 
|---|
| 140 |  | 
|---|
| 141 | PUBLIC getEAX | 
|---|
| 142 | PUBLIC getEBX | 
|---|
| 143 | getEAX  proc near | 
|---|
| 144 | ret | 
|---|
| 145 | getEAX  endp | 
|---|
| 146 |  | 
|---|
| 147 | getEBX  proc near | 
|---|
| 148 | mov  eax, ebx | 
|---|
| 149 | ret | 
|---|
| 150 | getEBX  endp | 
|---|
| 151 |  | 
|---|
| 152 | PUBLIC GetFS | 
|---|
| 153 | GetFS   proc near | 
|---|
| 154 | mov     eax, fs | 
|---|
| 155 | ret | 
|---|
| 156 | GetFS   endp | 
|---|
| 157 |  | 
|---|
| 158 | PUBLIC SetFS | 
|---|
| 159 | SetFS   proc near | 
|---|
| 160 | mov     eax, [esp+4] | 
|---|
| 161 | mov     fs, eax | 
|---|
| 162 | ret | 
|---|
| 163 | SetFS   endp | 
|---|
| 164 |  | 
|---|
| 165 | PUBLIC getCS | 
|---|
| 166 | getCS   proc near | 
|---|
| 167 | mov     eax, cs | 
|---|
| 168 | ret | 
|---|
| 169 | getCS   endp | 
|---|
| 170 |  | 
|---|
| 171 | PUBLIC getDS | 
|---|
| 172 | getDS   proc near | 
|---|
| 173 | mov     eax, ds | 
|---|
| 174 | ret | 
|---|
| 175 | getDS   endp | 
|---|
| 176 |  | 
|---|
| 177 | PUBLIC SetReturnFS | 
|---|
| 178 | SetReturnFS proc near | 
|---|
| 179 | push    fs | 
|---|
| 180 | mov     eax, [esp+8] | 
|---|
| 181 | mov     fs, eax | 
|---|
| 182 | pop     eax | 
|---|
| 183 | ret | 
|---|
| 184 | SetReturnFS endp | 
|---|
| 185 |  | 
|---|
| 186 | PUBLIC getSS | 
|---|
| 187 | getSS   proc near | 
|---|
| 188 | mov     ax, ss | 
|---|
| 189 | ret | 
|---|
| 190 | getSS   endp | 
|---|
| 191 |  | 
|---|
| 192 | PUBLIC getES | 
|---|
| 193 | getES   proc near | 
|---|
| 194 | mov     eax, es | 
|---|
| 195 | ret | 
|---|
| 196 | getES   endp | 
|---|
| 197 |  | 
|---|
| 198 | PUBLIC getGS | 
|---|
| 199 | getGS   proc near | 
|---|
| 200 | mov     eax, gs | 
|---|
| 201 | ret | 
|---|
| 202 | getGS   endp | 
|---|
| 203 |  | 
|---|
| 204 | PUBLIC getESP | 
|---|
| 205 | getESP  proc near | 
|---|
| 206 | mov     eax, esp | 
|---|
| 207 | ret | 
|---|
| 208 | getESP  endp | 
|---|
| 209 |  | 
|---|
| 210 | PUBLIC RestoreOS2FS | 
|---|
| 211 | RestoreOS2FS proc near | 
|---|
| 212 | push    150bh | 
|---|
| 213 | mov     ax, fs | 
|---|
| 214 | pop     fs | 
|---|
| 215 | ret | 
|---|
| 216 | RestoreOS2FS endp | 
|---|
| 217 |  | 
|---|
| 218 | PUBLIC _Mul32x32to64 | 
|---|
| 219 | _Mul32x32to64 proc near | 
|---|
| 220 | push    ebp | 
|---|
| 221 | mov     ebp, esp | 
|---|
| 222 | push    eax | 
|---|
| 223 | push    edx | 
|---|
| 224 | push    edi | 
|---|
| 225 |  | 
|---|
| 226 | mov     edi, [ebp+8]    ;64 bits result | 
|---|
| 227 | mov     eax, [ebp+12]   ;op1 | 
|---|
| 228 | mov     edx, [ebp+16]   ;op2 | 
|---|
| 229 | mul     edx | 
|---|
| 230 | mov     [edi], eax | 
|---|
| 231 | mov     [edi+4], edx | 
|---|
| 232 |  | 
|---|
| 233 | pop     edi | 
|---|
| 234 | pop     edx | 
|---|
| 235 | pop     eax | 
|---|
| 236 | pop     ebp | 
|---|
| 237 | ret | 
|---|
| 238 | _Mul32x32to64 endp | 
|---|
| 239 |  | 
|---|
| 240 | CODE32          ENDS | 
|---|
| 241 |  | 
|---|
| 242 | END | 
|---|