www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - creating a proxy dll

I'm trying to create a proxy dll( a dll forwarding all it's functions to
another dll)
I renamed the dll I want to replace (let's call him foo) to oldfoo.dll
then I created the import library oldfoo.lib and created oldfoo.def with as

LIBRARY         "oldfoo"


and then I created a D file called foo.d with a valid dllmain and then an
extern(c) block with in it the following syntax:

void * internalbar();

void *bar(){asm{naked;jmp internalbar;}}

and when I compile it I get the following error:

C:\Users\maarten\Desktop\workingdir>dmd foo.d oldfoo.def oldfoo.lib
OPTLINK (R) for Win32  Release 8.00.12
Copyright (C) Digital Mars 1989-2010  All rights reserved.
OPTLINK : Warning 148: USE16/USE32 Mismatch : DGROUP
 Error 83: Illegal frame on start address
OPTLINK : Warning 174: 32-bit Segments Inappropriate for 16-bit Segmented

 Error 35: Cannot Reach TARGET from FRAME at Relative 0002BH  from
 Segment _TEXT
 FRAME  = Frame of Group FLAT 0000
 TARGET = External Symbol
7windows7windows6HANDLEbZv 00070H
 FIXUPP Type = 32-bit Conditional JMP
--- errorlevel 2

Can someone point me a bit in the right direction? I've tried this in the
past but then I understood nearly nothing about .def files an .lib files.
Now that I know a bit more I wanted to take up the challenge again.
Oct 21 2011