www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - creating a proxy dll

--0016e6d77d7f996bf704afd3c029
Content-Type: text/plain; charset=ISO-8859-1

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
syntax

"
LIBRARY         "oldfoo"

IMPORTS
internalbar=oldfoo.bar
...
"

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.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 148: USE16/USE32 Mismatch : DGROUP
C:\D\dmd2\windows\bin\..\lib\SNN.lib(dllstart)
 Error 83: Illegal frame on start address
OPTLINK : Warning 174: 32-bit Segments Inappropriate for 16-bit Segmented
output

foo.obj(foo)
 Error 35: Cannot Reach TARGET from FRAME at Relative 0002BH  from
 Segment _TEXT
 FRAME  = Frame of Group FLAT 0000
 TARGET = External Symbol
_D4core3sys7windows3dll18dll_process_detachFT4core3sys
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.

--0016e6d77d7f996bf704afd3c029
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I'm trying to create a proxy dll( a dll forwarding all it's functio=
ns to another dll)<div>I renamed the dll I want to replace (let&#39;s call =
him foo) to oldfoo.dll</div><div>then I created the import library oldfoo.l=
ib and created oldfoo.def with as syntax</div>
<div><br></div><div>&quot;</div><div><div>LIBRARY =A0 =A0 =A0 =A0 &quot;old=
foo&quot;</div><div><br></div><div>IMPORTS</div><div>internalbar=3Doldfoo.b=
ar</div></div><div>...</div><div>&quot;</div><div><br></div><div>and then I=
 created a D file called foo.d with a valid dllmain and then an extern(c) b=
lock with in it the following syntax:</div>
<div><br></div><div>&quot;</div><div>void * internalbar();</div><div>...</d=
iv><div><br></div><div>//////////////////////////////////</div><div>void *b=
ar(){asm{naked;jmp internalbar;}}</div><div>...</div><div>&quot;</div><div>
<br></div><div>and when I compile it I get the following error:</div><div><=
br></div><div>&quot;</div><div><div>C:\Users\maarten\Desktop\workingdir&gt;=
dmd foo.d oldfoo.def oldfoo.lib</div><div>OPTLINK (R) for Win32 =A0Release =
8.00.12</div>
<div>Copyright (C) Digital Mars 1989-2010 =A0All rights reserved.</div><div=
<a href=3D"http://www.digitalmars.com/ctg/optlink.html">http://www.digital=

Mismatch : DGROUP</div> <div>C:\D\dmd2\windows\bin\..\lib\SNN.lib(dllstart)</div><div>=A0Error 83: = Illegal frame on start address</div><div>OPTLINK : Warning 174: 32-bit Segm= ents Inappropriate for 16-bit Segmented output</div><div><br></div><div>foo= .obj(foo)</div> <div>=A0Error 35: Cannot Reach TARGET from FRAME at Relative 0002BH =A0from= </div><div>=A0Segment _TEXT</div><div>=A0FRAME =A0=3D Frame of Group FLAT 0= 000</div><div>=A0TARGET =3D External Symbol _D4core3sys7windows3dll18dll_pr= ocess_detachFT4core3sys</div> <div>7windows7windows6HANDLEbZv 00070H</div><div>=A0FIXUPP Type =3D 32-bit = Conditional JMP</div><div>--- errorlevel 2</div><div>&quot;</div></div><div=
<br></div><div>Can someone point me a bit in the right direction? I&#39;ve=

es an .lib files. Now that I know a bit more I wanted to take up the challe= nge again.</div> --0016e6d77d7f996bf704afd3c029--
Oct 21 2011