Here is an attempt to make a DLL with forwarded functions. fwdfunctions.dll exports two functions forwarded to Console.dll

fwdfuncs.inc :

Cls     PROTO           ; forwarded to Console.ClearScreen
ConOut  PROTO :DWORD    ; forwarded to Console.StdOut
szUpper PROTO :DWORD


fwdfuncs.def :

LIBRARY fwdfuncs
EXPORTS

szUpper
ConOut=Console.StdOut
Cls=Console.ClearScreen


Forwarding functions to another DLL is easy, create dummy procedure declarations with the original function names.

fwdfuncs.asm :


.code

LibMain    PROC instance:DWORD,reason:DWORD,unused:DWORD

    mov eax,1
    ret

LibMain    ENDP

.
.
.

ClearScreen PROC                ; forwarded to Console.ClearScreen
ClearScreen ENDP

StdOut      PROC lpszText:DWORD ; forwarded to Console.StdOut
StdOut      ENDP

END LibMain


A demo project calling forwarded functions :


.386
.model flat,stdcall
option casemap:none

include    \masm32\include\windows.inc
include    \masm32\include\kernel32.inc
include    fwdfuncs.inc

includelib \masm32\lib\kernel32.lib
includelib fwdfuncs.lib

.data
message    db 'Hello from the forwarded function',0
function    db 'ConOut',13,10,0

.code

start:

    invoke  Cls                    ; forwarded to Console.ClearScreen
    invoke  szUpper,ADDR message
    mov    BYTE PTR ,32
    invoke  ConOut,ADDR message    ; forwarded to Console.StdOut
    invoke  ExitProcess,0       

END start
Attachments:
Posted on 2006-10-02 08:17:23 by Vortex