www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - importing DLL

reply BCS <ao pathlink.com> writes:
I have a DLL with no .h no .def and nothing but the DLL. What are my odds 
of linking it in with a D app?
Mar 27 2008
parent reply Neal Alexander <wqeqweuqy hotmail.com> writes:
BCS wrote:
 I have a DLL with no .h no .def and nothing but the DLL. What are my 
 odds of linking it in with a D app?
 
 
implib.exe
Mar 28 2008
parent reply BCS <BCS pathlink.com> writes:
Neal Alexander wrote:
 BCS wrote:
 
 I have a DLL with no .h no .def and nothing but the DLL. What are my 
 odds of linking it in with a D app?
implib.exe
Tried that. It gives me a .lib (that doesn't seem to work but I could be mistaken) but I still don't know what functions are defined. (maybe I should have added "no documentation")
Mar 28 2008
next sibling parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
BCS wrote:
 Neal Alexander wrote:
 BCS wrote:

 I have a DLL with no .h no .def and nothing but the DLL. What are my 
 odds of linking it in with a D app?
implib.exe
Tried that. It gives me a .lib (that doesn't seem to work but I could be mistaken) but I still don't know what functions are defined. (maybe I should have added "no documentation")
If you don't know what functions it defines things get tricky. IIRC you should be able to determine their names somehow, but most DLLs use C-like mangling[1] so there's no sure way to know what parameters they expect or what they return. And even if it's a (non-D[2]) mangling with parameter and type info it's not much better unless you feel like writing e.g. some extern "C" C++ bindings. (Though then at least you know that should work, provided you can demangle them) I do seem to remember "stdcall"[3]-mangled names include the number of bytes of parameters they expect though, so if based on that and the function name you can make an educated guess as to their parameters and return type... [1]: In other words: pretty much no parameter & return type information. [2]: For D mangling, running it through Phobos' std.demangle should produce enough info to declare the right functions. [3]: "extern(Windows)"
Mar 28 2008
prev sibling parent reply Regan Heath <regan netmail.co.nz> writes:
BCS wrote:
 Neal Alexander wrote:
 BCS wrote:

 I have a DLL with no .h no .def and nothing but the DLL. What are my 
 odds of linking it in with a D app?
implib.exe
Tried that. It gives me a .lib (that doesn't seem to work but I could be mistaken) but I still don't know what functions are defined. (maybe I should have added "no documentation")
Do you have a copy of dumpbin: http://support.microsoft.com/kb/177429 Regan
Mar 28 2008
parent reply BCS <ao pathlink.com> writes:
Reply to Regan,

 BCS wrote:
 
 Neal Alexander wrote:
 
 BCS wrote:
 
 I have a DLL with no .h no .def and nothing but the DLL. What are
 my odds of linking it in with a D app?
 
implib.exe
Tried that. It gives me a .lib (that doesn't seem to work but I could be mistaken) but I still don't know what functions are defined. (maybe I should have added "no documentation")
Do you have a copy of dumpbin: http://support.microsoft.com/kb/177429 Regan
I will soon.
Mar 28 2008
parent reply BCS <ao pathlink.com> writes:
Reply to Benjamin,

 Reply to Regan,
 
 BCS wrote:
 
 Neal Alexander wrote:
 
 BCS wrote:
 
 I have a DLL with no .h no .def and nothing but the DLL. What are
 my odds of linking it in with a D app?
 
implib.exe
Tried that. It gives me a .lib (that doesn't seem to work but I could be mistaken) but I still don't know what functions are defined. (maybe I should have added "no documentation")
Do you have a copy of dumpbin: http://support.microsoft.com/kb/177429 Regan
I will soon.
correction, I have it but it's not working (not installed correctly or some such, More fun!)
Mar 28 2008
parent Neal Alexander <wqeqweuqy hotmail.com> writes:
BCS wrote:
 Reply to Benjamin,
 
 Reply to Regan,

 BCS wrote:

 Neal Alexander wrote:

 BCS wrote:

 I have a DLL with no .h no .def and nothing but the DLL. What are
 my odds of linking it in with a D app?
implib.exe
Tried that. It gives me a .lib (that doesn't seem to work but I could be mistaken) but I still don't know what functions are defined. (maybe I should have added "no documentation")
Do you have a copy of dumpbin: http://support.microsoft.com/kb/177429 Regan
I will soon.
correction, I have it but it's not working (not installed correctly or some such, More fun!)
The .lib should work for linking. Use some PE utility to find the exports - StudPE is ok i think. or you can modify this code to dump the export table and generate a D header for your self: http://svn.dsource.org/projects/kong/trunk/kong/examples/import_dump.d
Mar 29 2008