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