| 1 | ; $Id: exceptutil.asm,v 1.6 2000-03-29 17:17:18 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 | 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 | _RaiseException@16 endp | 
|---|
| 50 |  | 
|---|
| 51 | public  _RtlUnwind@16 | 
|---|
| 52 | extrn   OS2RTLUNWIND : near | 
|---|
| 53 |  | 
|---|
| 54 | _RtlUnwind@16 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 | _RtlUnwind@16 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 getEAX | 
|---|
| 136 | PUBLIC getEBX | 
|---|
| 137 | getEAX  proc near | 
|---|
| 138 | ret | 
|---|
| 139 | getEAX  endp | 
|---|
| 140 |  | 
|---|
| 141 | getEBX  proc near | 
|---|
| 142 | mov  eax, ebx | 
|---|
| 143 | ret | 
|---|
| 144 | getEBX  endp | 
|---|
| 145 |  | 
|---|
| 146 | PUBLIC GetFS | 
|---|
| 147 | GetFS   proc near | 
|---|
| 148 | mov     eax, fs | 
|---|
| 149 | ret | 
|---|
| 150 | GetFS   endp | 
|---|
| 151 |  | 
|---|
| 152 | PUBLIC SetFS | 
|---|
| 153 | SetFS   proc near | 
|---|
| 154 | mov     eax, [esp+4] | 
|---|
| 155 | mov     fs, eax | 
|---|
| 156 | ret | 
|---|
| 157 | SetFS   endp | 
|---|
| 158 |  | 
|---|
| 159 | PUBLIC getCS | 
|---|
| 160 | getCS   proc near | 
|---|
| 161 | mov     eax, cs | 
|---|
| 162 | ret | 
|---|
| 163 | getCS   endp | 
|---|
| 164 |  | 
|---|
| 165 | PUBLIC getDS | 
|---|
| 166 | getDS   proc near | 
|---|
| 167 | mov     eax, ds | 
|---|
| 168 | ret | 
|---|
| 169 | getDS   endp | 
|---|
| 170 |  | 
|---|
| 171 | PUBLIC SetReturnFS | 
|---|
| 172 | SetReturnFS proc near | 
|---|
| 173 | push    fs | 
|---|
| 174 | mov     eax, [esp+8] | 
|---|
| 175 | mov     fs, eax | 
|---|
| 176 | pop     eax | 
|---|
| 177 | ret | 
|---|
| 178 | SetReturnFS endp | 
|---|
| 179 |  | 
|---|
| 180 | PUBLIC getSS | 
|---|
| 181 | getSS   proc near | 
|---|
| 182 | mov     ax, ss | 
|---|
| 183 | ret | 
|---|
| 184 | getSS   endp | 
|---|
| 185 |  | 
|---|
| 186 | PUBLIC getES | 
|---|
| 187 | getES   proc near | 
|---|
| 188 | mov     eax, es | 
|---|
| 189 | ret | 
|---|
| 190 | getES   endp | 
|---|
| 191 |  | 
|---|
| 192 | PUBLIC getGS | 
|---|
| 193 | getGS   proc near | 
|---|
| 194 | mov     eax, gs | 
|---|
| 195 | ret | 
|---|
| 196 | getGS   endp | 
|---|
| 197 |  | 
|---|
| 198 | PUBLIC RestoreOS2FS | 
|---|
| 199 | RestoreOS2FS proc near | 
|---|
| 200 | push    150bh | 
|---|
| 201 | mov     ax, fs | 
|---|
| 202 | pop     fs | 
|---|
| 203 | ret | 
|---|
| 204 | RestoreOS2FS endp | 
|---|
| 205 | CODE32          ENDS | 
|---|
| 206 |  | 
|---|
| 207 | END | 
|---|