|
|
1.1 ! root 1: ;Thunk Compiler Version 13.25 Jan 10 1990 11:56:04 ! 2: ;File Compiled Fri Apr 13 14:00:54 1990 ! 3: ! 4: ;Command Line: thunk -y thunks.mif thunks.asm ! 5: ! 6: ; Static Name Aliases ! 7: ; ! 8: ! 9: TITLE $thunks.asm ! 10: ! 11: .386 ! 12: ! 13: ;Error codes taken out of error.h ! 14: ! 15: ERROR_NOMEMORY EQU 8 ! 16: ! 17: ERROR_INVALIDPARAM EQU 87 ! 18: ! 19: PUBLIC DEBUG32OUTPUT ! 20: ! 21: CODE32 SEGMENT DWORD USE32 PUBLIC 'CODE' ! 22: ! 23: ! 24: EXTRN DOS32ALLOCMEM:NEAR ! 25: ! 26: EXTRN DOS32FREEMEM:NEAR ! 27: ! 28: EXTRN THK32ALIASMEM:NEAR ! 29: ! 30: EXTRN THK32FREEALIAS:NEAR ! 31: ! 32: EXTRN THK32ALLOCBLOCK:NEAR ! 33: ! 34: EXTRN THK32FREEBLOCK:NEAR ! 35: ! 36: EXTRN THK32HANDLEBOUNDARY:NEAR ! 37: ! 38: EXTRN THK32HANDLESTRING:NEAR ! 39: ! 40: EXTRN THK32DEALLOC:NEAR ! 41: ! 42: EXTRN THK32ALLOCVARLEN:NEAR ! 43: ! 44: CODE32 ENDS ! 45: DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' ! 46: ! 47: DATA32 ENDS ! 48: EXTRN DEBUGOUTPUT:FAR ! 49: CODE16 SEGMENT WORD USE16 PUBLIC 'CODE' ! 50: ! 51: ! 52: CODE16 ENDS ! 53: ! 54: ;Create a dummy label to trick MASM into correct fixups ! 55: ! 56: CODE16 SEGMENT ! 57: ! 58: T_DEBUGOUTPUT LABEL FAR ! 59: ! 60: CODE16 ENDS ! 61: ! 62: ! 63: CODE32 SEGMENT ! 64: ASSUME CS:FLAT,DS:FLAT,ES:FLAT ! 65: DEBUG32OUTPUT PROC ! 66: ! 67: push ebp ! 68: mov ebp,esp ! 69: ! 70: ! 71: cld ;Assume direction flag clear ! 72: xor eax,eax ! 73: push eax ; temp storage for return value ! 74: push esi ! 75: push edi ! 76: push eax ; temp storage ! 77: push eax ;Error flag for cleanup ! 78: push eax ; temp storage for Stack Allocation Flags ! 79: push eax ; temp storage for BMP Flags ! 80: push eax ; temp storage for Alias Flags ! 81: push eax ; temp storage for ptr param #1 ! 82: ;* Compare stack selector against FLAT:R3DSB ! 83: ;* If the selector is not equal, then don't bump stack. ! 84: ! 85: mov ax,ss ! 86: cmp ax,seg FLAT:DATA32 ; standard 32 bit stack? ! 87: jne short L1 ; if not, skip bumping code ! 88: ! 89: ;* Bump the stack down if too near 64K boundary. ! 90: ! 91: mov eax,esp ! 92: cmp ax,1024 ! 93: jae short L1 ! 94: xor ax,ax ! 95: mov esp,eax ; bump the stack down ! 96: ! 97: ! 98: ;Insure that 1 DWORD exists on stack ! 99: push eax ! 100: L1: ! 101: ! 102: ! 103: ; ****> BEGIN Pointer/Structure Section ! 104: ! 105: ! 106: ! 107: mov esi,[ebp+8] ;fpchText base address ! 108: ! 109: ;Pointer fpchText --> pchText ! 110: or esi,esi ! 111: jz L2 ! 112: ! 113: mov [ebp-36],esi ! 114: ;Handle String Parameters ! 115: ! 116: push -32 ;Alias flag offset ! 117: push 1 ;Flag Mask ! 118: pop edx ! 119: call THK32HANDLESTRING ! 120: jc ERR_DEBUG32OUTPUT ;jmp if too long ! 121: mov [ebp-36],edi ! 122: ! 123: L2: ! 124: ! 125: ; ****> END Pointer/Structure Section ! 126: ! 127: ;* Create new call frame, using 16-bit semantics. ! 128: ! 129: push es ! 130: push ebx ! 131: push ebp ; save ebp ! 132: mov eax,esp ; save current esp ! 133: push ss ! 134: push eax ! 135: ! 136: ! 137: mov dx,ss ; get cpl bits to use as dpl bits ! 138: and dx,3 ; mask off rest of register ! 139: ! 140: or dl,4 ;Force LDT bit on ! 141: ! 142: ! 143: ;From Name: fpchText Type: string ! 144: mov eax,DWORD PTR [ebp-36] ! 145: or eax,eax ! 146: jz short L3 ;NULL pointer ! 147: ! 148: ror eax,16 ; CRMA on structure pointer ! 149: shl ax,3 ! 150: or al,dl ! 151: rol eax,16 ! 152: L3: push eax ! 153: ! 154: ! 155: ;* Convert SS:ESP to 16-bit SS:SP. ! 156: ! 157: mov eax,esp ; use CRMA on ESP ! 158: ror eax,16 ! 159: shl ax,3 ! 160: or al,dl ! 161: rol eax,16 ! 162: ! 163: push eax ; push new stack pointer ! 164: lss sp,DWORD PTR [esp] ; ss:sp = 16-bit ptr ! 165: ! 166: ;* Jump to 16-bit segment to issue call (so that 16-bit API can RETF). ! 167: ! 168: jmp FAR PTR T_DEBUGOUTPUT ! 169: ! 170: ! 171: INVP_DEBUG32OUTPUT: ! 172: push 87 ! 173: pop eax ! 174: mov BYTE PTR [ebp-20],1 ;Set flag ! 175: jmp short L4 ! 176: ! 177: NOMEM_DEBUG32OUTPUT: ! 178: push 8 ! 179: pop eax ! 180: ! 181: ERR_DEBUG32OUTPUT: ! 182: mov BYTE PTR [ebp-20],1 ;Set flag ! 183: jmp short L4 ! 184: R_DEBUGOUTPUT: ; label defining return jmp location ! 185: ! 186: ! 187: ;* Restore 32-bit SS:ESP - it is on top of stack. ! 188: ! 189: movzx esp,sp ; make sure that esp is correct ! 190: lss esp,[esp] ! 191: pop ebp ! 192: pop ebx ! 193: pop es ! 194: ! 195: ! 196: ! 197: ;Convert Return Code ! 198: ;SHORT --> LONG ! 199: movsx eax,ax ! 200: L4: ! 201: ;Functions contain pointers, save return code ! 202: mov [ebp-4],eax ;Save return code ! 203: ! 204: ; ****> BEGIN Pointer/Structure Unpack Section ! 205: ! 206: ! 207: ;Undo Pointer fpchText --> pchText ! 208: ! 209: ! 210: mov esi,[ebp-36] ;fpchText temp address ! 211: or esi,esi ! 212: jz L5 ! 213: ! 214: ! 215: ! 216: mov edi,[ebp+8] ;fpchText original address ! 217: ;Types are identical and no imbedded pointers exist ! 218: ;This means that we treated the pointer as a buffer ! 219: ;If temp address == original address then no work required ! 220: cmp esi,edi ! 221: je L5 ! 222: ;Handle String Parameters ! 223: ;Strings are never copied out ! 224: push -32 ;Alloc Flag Offset ! 225: mov edx,1 ! 226: ! 227: call THK32DEALLOC ! 228: ! 229: ! 230: L5: ;No action required ! 231: ! 232: ; ****> END Pointer/Structure Unpack Section ! 233: ! 234: ;* 32-bit return code. ! 235: ! 236: lea esp,[ebp-12] ! 237: pop edi ! 238: pop esi ! 239: pop eax ;Pop saved return code ! 240: leave ! 241: ret ; Remove parameters ! 242: ! 243: DEBUG32OUTPUT endp ! 244: ! 245: CODE32 ENDS ! 246: ! 247: ;* 16-bit code to make API call. ! 248: ! 249: CODE16 SEGMENT ! 250: ! 251: ASSUME CS:CODE16 ! 252: .errnz ($ - T_DEBUGOUTPUT) ! 253: ! 254: call FAR PTR DEBUGOUTPUT ; call 16-bit version ! 255: jmp FAR PTR FLAT:R_DEBUGOUTPUT ; jump back ! 256: ! 257: CODE16 ENDS ! 258: ! 259: ! 260: ! 261: CODE32 SEGMENT ! 262: ! 263: ! 264: ASSUME CS:FLAT,DS:FLAT,SS:FLAT ! 265: ! 266: THK32COPYBLOCK: ! 267: ! 268: ; Copy ECX bytes from ESI to EDI ! 269: mov eax,3 ! 270: and eax,ecx ! 271: shr ecx,2 ! 272: rep movsd ! 273: mov ecx,eax ! 274: rep movsb ! 275: ! 276: ret ! 277: ! 278: CODE32 ENDS ! 279: ! 280: END
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.