| 1 | ; $Id: innidmdllthunks.asm 717 2003-09-23 23:42:11Z bird $ | 
|---|
| 2 | ; | 
|---|
| 3 | ; 16-bit thunkers. | 
|---|
| 4 | ; | 
|---|
| 5 | ; Copyright (c) 2003 InnoTek Systemberatung GmbH | 
|---|
| 6 | ; Author: knut st. osmundsen <bird-srcspam@anduin.net> | 
|---|
| 7 | ; | 
|---|
| 8 | ; | 
|---|
| 9 | ; This program is free software; you can redistribute it and/or modify | 
|---|
| 10 | ; it under the terms of the GNU General Public License as published by | 
|---|
| 11 | ; the Free Software Foundation; either version 2 of the License, or | 
|---|
| 12 | ; (at your option) any later version. | 
|---|
| 13 | ; | 
|---|
| 14 | ; This program is distributed in the hope that it will be useful, | 
|---|
| 15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 17 | ; GNU General Public License for more details. | 
|---|
| 18 | ; | 
|---|
| 19 | ; You should have received a copy of the GNU General Public License | 
|---|
| 20 | ; along with This program; if not, write to the Free Software | 
|---|
| 21 | ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|---|
| 22 | ; | 
|---|
| 23 | ; | 
|---|
| 24 |  | 
|---|
| 25 | .386 | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | extrn InitDemangleID32:near | 
|---|
| 29 | extrn DemangleID32:near | 
|---|
| 30 |  | 
|---|
| 31 | CODE16 segment dword use16 public 'CODE' | 
|---|
| 32 | CODE16 ends | 
|---|
| 33 | CODE32 segment para use32 public 'CODE' | 
|---|
| 34 | CODE32 ends | 
|---|
| 35 | DATA32 segment para use32 public 'DATA' | 
|---|
| 36 | DATA32 ends | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 | CODE16 segment | 
|---|
| 40 | ASSUME ss:NOTHING, ds:NOTHING, es:NOTHING, cs:CODE16 | 
|---|
| 41 |  | 
|---|
| 42 | ;; | 
|---|
| 43 | ; Init stuff. | 
|---|
| 44 | ; @cproto   unsigned short pascal far INITDEMANGLEID(char far * psInitParms); | 
|---|
| 45 | INITDEMANGLEID proc far | 
|---|
| 46 | push    ebp | 
|---|
| 47 | movsx   ebp, sp | 
|---|
| 48 |  | 
|---|
| 49 | jmp far ptr FLAT:INITDEMANGLEID_32bit | 
|---|
| 50 | ASSUME ss:nothing | 
|---|
| 51 | CODE16 ends | 
|---|
| 52 | CODE32 segment | 
|---|
| 53 | INITDEMANGLEID_32bit:: | 
|---|
| 54 | ; | 
|---|
| 55 | ; Thunk stack to 32bits! | 
|---|
| 56 | ; | 
|---|
| 57 | ; prepare switch back. | 
|---|
| 58 | mov     edx, esp | 
|---|
| 59 | push    ss | 
|---|
| 60 | push    edx | 
|---|
| 61 | ; the switch. | 
|---|
| 62 | xor     eax, eax | 
|---|
| 63 | mov     eax, ss | 
|---|
| 64 | shl     eax, 13 | 
|---|
| 65 | mov     ax, sp | 
|---|
| 66 | mov     edx, seg FLAT:DATA32 | 
|---|
| 67 | push    edx | 
|---|
| 68 | push    eax | 
|---|
| 69 | lss     esp, ss:[esp] | 
|---|
| 70 | ASSUME ss:FLAT | 
|---|
| 71 |  | 
|---|
| 72 | ; DS / ES | 
|---|
| 73 | push    ds | 
|---|
| 74 | push    es | 
|---|
| 75 | mov     ds, edx | 
|---|
| 76 | mov     es, edx | 
|---|
| 77 |  | 
|---|
| 78 | ; ebp high | 
|---|
| 79 | mov     edx, esp | 
|---|
| 80 | mov     dx, bp | 
|---|
| 81 | mov     ebp, edx | 
|---|
| 82 |  | 
|---|
| 83 | ; | 
|---|
| 84 | ; Thunk parameters and call the 32bit version. | 
|---|
| 85 | ; | 
|---|
| 86 | mov     eax, [ebp + 08h]            ; psInitParms | 
|---|
| 87 | mov     edx, eax | 
|---|
| 88 | shr     eax, 3 | 
|---|
| 89 | mov     ax, dx | 
|---|
| 90 | push    eax | 
|---|
| 91 | call    InitDemangleID32 | 
|---|
| 92 | add     esp, 04h | 
|---|
| 93 |  | 
|---|
| 94 | ; ES / DS | 
|---|
| 95 | pop     es | 
|---|
| 96 | pop     ds | 
|---|
| 97 |  | 
|---|
| 98 | ; | 
|---|
| 99 | ; Switch the stack back to 16 bit. | 
|---|
| 100 | ; | 
|---|
| 101 | movzx   ebp, bp | 
|---|
| 102 | lss     esp, ss:[esp] | 
|---|
| 103 | ASSUME ss:NOTHING | 
|---|
| 104 |  | 
|---|
| 105 | jmp     far ptr CODE16:INITDEMANGLEID_16bit | 
|---|
| 106 | CODE32 ends | 
|---|
| 107 | CODE16 segment | 
|---|
| 108 | INITDEMANGLEID_16bit:: | 
|---|
| 109 |  | 
|---|
| 110 | mov     sp, bp | 
|---|
| 111 | pop     ebp | 
|---|
| 112 | ret 04h | 
|---|
| 113 | INITDEMANGLEID endp | 
|---|
| 114 |  | 
|---|
| 115 | ;; | 
|---|
| 116 | ; Demangle symbol. | 
|---|
| 117 | ;unsigned short pascal far DEMANGLEID(char far * psMangledName, char far * pszPrototype, unsigned long BufferLen); | 
|---|
| 118 | DEMANGLEID proc far | 
|---|
| 119 | push    ebp | 
|---|
| 120 | movsx   ebp, sp | 
|---|
| 121 |  | 
|---|
| 122 | jmp far ptr FLAT:DEMANGLEID_32bit | 
|---|
| 123 | ASSUME ss:nothing | 
|---|
| 124 | CODE16 ends | 
|---|
| 125 | CODE32 segment | 
|---|
| 126 | DEMANGLEID_32bit:: | 
|---|
| 127 | ; | 
|---|
| 128 | ; Thunk stack to 32bits! | 
|---|
| 129 | ; | 
|---|
| 130 | ; prepare switch back. | 
|---|
| 131 | mov     edx, esp | 
|---|
| 132 | push    ss | 
|---|
| 133 | push    edx | 
|---|
| 134 | ; the switch. | 
|---|
| 135 | xor     eax, eax | 
|---|
| 136 | mov     eax, ss | 
|---|
| 137 | shl     eax, 13 | 
|---|
| 138 | mov     ax, sp | 
|---|
| 139 | mov     edx, seg FLAT:DATA32 | 
|---|
| 140 | push    edx | 
|---|
| 141 | push    eax | 
|---|
| 142 | lss     esp, ss:[esp] | 
|---|
| 143 | ASSUME ss:FLAT | 
|---|
| 144 |  | 
|---|
| 145 | ; DS / ES | 
|---|
| 146 | push    ds | 
|---|
| 147 | push    es | 
|---|
| 148 | mov     ds, edx | 
|---|
| 149 | mov     es, edx | 
|---|
| 150 |  | 
|---|
| 151 | ; ebp high | 
|---|
| 152 | mov     edx, esp | 
|---|
| 153 | mov     dx, bp | 
|---|
| 154 | mov     ebp, edx | 
|---|
| 155 |  | 
|---|
| 156 |  | 
|---|
| 157 | ; | 
|---|
| 158 | ; Thunk parameters and call the 32bit version. | 
|---|
| 159 | ; | 
|---|
| 160 | mov     eax, [ebp + 8]              ; BufferLen | 
|---|
| 161 | push    eax | 
|---|
| 162 |  | 
|---|
| 163 | mov     eax, [ebp + 0ch]            ; pszPrototype | 
|---|
| 164 | mov     edx, eax | 
|---|
| 165 | shr     eax, 3 | 
|---|
| 166 | mov     ax, dx | 
|---|
| 167 | push    eax | 
|---|
| 168 |  | 
|---|
| 169 | mov     eax, [ebp + 10h]            ; psMangledName | 
|---|
| 170 | mov     edx, eax | 
|---|
| 171 | shr     eax, 3 | 
|---|
| 172 | mov     ax, dx | 
|---|
| 173 | push    eax | 
|---|
| 174 | call    DemangleID32 | 
|---|
| 175 | add     esp, 0ch | 
|---|
| 176 |  | 
|---|
| 177 | ; ES / DS | 
|---|
| 178 | pop     es | 
|---|
| 179 | pop     ds | 
|---|
| 180 |  | 
|---|
| 181 | ; | 
|---|
| 182 | ; Switch the stack back to 16 bit. | 
|---|
| 183 | ; | 
|---|
| 184 | movzx   ebp, bp | 
|---|
| 185 | lss     esp, ss:[esp] | 
|---|
| 186 | ASSUME ss:NOTHING | 
|---|
| 187 |  | 
|---|
| 188 | jmp     far ptr CODE16:DEMANGLEID_16bit | 
|---|
| 189 | CODE32 ends | 
|---|
| 190 | CODE16 segment | 
|---|
| 191 | DEMANGLEID_16bit:: | 
|---|
| 192 |  | 
|---|
| 193 | mov     sp, bp | 
|---|
| 194 | pop     ebp | 
|---|
| 195 | ret 0ch | 
|---|
| 196 | DEMANGLEID endp | 
|---|
| 197 |  | 
|---|
| 198 | CODE16 ends | 
|---|
| 199 |  | 
|---|
| 200 | end | 
|---|