|
|
Microsoft OS/2 SDK 2.0 05-30-1990
;Thunk Compiler Version 13.25 Jan 10 1990 11:56:04 ;File Compiled Fri Apr 13 14:00:54 1990 ;Command Line: thunk -y thunks.mif thunks.asm ; Static Name Aliases ; TITLE $thunks.asm .386 ;Error codes taken out of error.h ERROR_NOMEMORY EQU 8 ERROR_INVALIDPARAM EQU 87 PUBLIC DEBUG32OUTPUT CODE32 SEGMENT DWORD USE32 PUBLIC 'CODE' EXTRN DOS32ALLOCMEM:NEAR EXTRN DOS32FREEMEM:NEAR EXTRN THK32ALIASMEM:NEAR EXTRN THK32FREEALIAS:NEAR EXTRN THK32ALLOCBLOCK:NEAR EXTRN THK32FREEBLOCK:NEAR EXTRN THK32HANDLEBOUNDARY:NEAR EXTRN THK32HANDLESTRING:NEAR EXTRN THK32DEALLOC:NEAR EXTRN THK32ALLOCVARLEN:NEAR CODE32 ENDS DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' DATA32 ENDS EXTRN DEBUGOUTPUT:FAR CODE16 SEGMENT WORD USE16 PUBLIC 'CODE' CODE16 ENDS ;Create a dummy label to trick MASM into correct fixups CODE16 SEGMENT T_DEBUGOUTPUT LABEL FAR CODE16 ENDS CODE32 SEGMENT ASSUME CS:FLAT,DS:FLAT,ES:FLAT DEBUG32OUTPUT PROC push ebp mov ebp,esp cld ;Assume direction flag clear xor eax,eax push eax ; temp storage for return value push esi push edi push eax ; temp storage push eax ;Error flag for cleanup push eax ; temp storage for Stack Allocation Flags push eax ; temp storage for BMP Flags push eax ; temp storage for Alias Flags push eax ; temp storage for ptr param #1 ;* Compare stack selector against FLAT:R3DSB ;* If the selector is not equal, then don't bump stack. mov ax,ss cmp ax,seg FLAT:DATA32 ; standard 32 bit stack? jne short L1 ; if not, skip bumping code ;* Bump the stack down if too near 64K boundary. mov eax,esp cmp ax,1024 jae short L1 xor ax,ax mov esp,eax ; bump the stack down ;Insure that 1 DWORD exists on stack push eax L1: ; ****> BEGIN Pointer/Structure Section mov esi,[ebp+8] ;fpchText base address ;Pointer fpchText --> pchText or esi,esi jz L2 mov [ebp-36],esi ;Handle String Parameters push -32 ;Alias flag offset push 1 ;Flag Mask pop edx call THK32HANDLESTRING jc ERR_DEBUG32OUTPUT ;jmp if too long mov [ebp-36],edi L2: ; ****> END Pointer/Structure Section ;* Create new call frame, using 16-bit semantics. push es push ebx push ebp ; save ebp mov eax,esp ; save current esp push ss push eax mov dx,ss ; get cpl bits to use as dpl bits and dx,3 ; mask off rest of register or dl,4 ;Force LDT bit on ;From Name: fpchText Type: string mov eax,DWORD PTR [ebp-36] or eax,eax jz short L3 ;NULL pointer ror eax,16 ; CRMA on structure pointer shl ax,3 or al,dl rol eax,16 L3: push eax ;* Convert SS:ESP to 16-bit SS:SP. mov eax,esp ; use CRMA on ESP ror eax,16 shl ax,3 or al,dl rol eax,16 push eax ; push new stack pointer lss sp,DWORD PTR [esp] ; ss:sp = 16-bit ptr ;* Jump to 16-bit segment to issue call (so that 16-bit API can RETF). jmp FAR PTR T_DEBUGOUTPUT INVP_DEBUG32OUTPUT: push 87 pop eax mov BYTE PTR [ebp-20],1 ;Set flag jmp short L4 NOMEM_DEBUG32OUTPUT: push 8 pop eax ERR_DEBUG32OUTPUT: mov BYTE PTR [ebp-20],1 ;Set flag jmp short L4 R_DEBUGOUTPUT: ; label defining return jmp location ;* Restore 32-bit SS:ESP - it is on top of stack. movzx esp,sp ; make sure that esp is correct lss esp,[esp] pop ebp pop ebx pop es ;Convert Return Code ;SHORT --> LONG movsx eax,ax L4: ;Functions contain pointers, save return code mov [ebp-4],eax ;Save return code ; ****> BEGIN Pointer/Structure Unpack Section ;Undo Pointer fpchText --> pchText mov esi,[ebp-36] ;fpchText temp address or esi,esi jz L5 mov edi,[ebp+8] ;fpchText original address ;Types are identical and no imbedded pointers exist ;This means that we treated the pointer as a buffer ;If temp address == original address then no work required cmp esi,edi je L5 ;Handle String Parameters ;Strings are never copied out push -32 ;Alloc Flag Offset mov edx,1 call THK32DEALLOC L5: ;No action required ; ****> END Pointer/Structure Unpack Section ;* 32-bit return code. lea esp,[ebp-12] pop edi pop esi pop eax ;Pop saved return code leave ret ; Remove parameters DEBUG32OUTPUT endp CODE32 ENDS ;* 16-bit code to make API call. CODE16 SEGMENT ASSUME CS:CODE16 .errnz ($ - T_DEBUGOUTPUT) call FAR PTR DEBUGOUTPUT ; call 16-bit version jmp FAR PTR FLAT:R_DEBUGOUTPUT ; jump back CODE16 ENDS CODE32 SEGMENT ASSUME CS:FLAT,DS:FLAT,SS:FLAT THK32COPYBLOCK: ; Copy ECX bytes from ESI to EDI mov eax,3 and eax,ecx shr ecx,2 rep movsd mov ecx,eax rep movsb ret CODE32 ENDS END
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.