Getting dll function exports (win32)

BlitzMax Forums/BlitzMax Programming/Getting dll function exports (win32)

fredborg(Posted 2007) [#1]
Hi,

How can I find all functions stored in a DLL? I need to call some specific functions, but they may or may not have decorated function names, so getProcAddress won't work in all cases.

In purebasic it is possible to step through the different function names in the DLL (and then doing a string.Find() on the name), how can I do the same in BlitzMax?


Gabriel(Posted 2007) [#2]
How cleanly does it have to be done?

You could call pexports from the command line and then parse the .def file it creates.

pexports mydll.dll >mydll.def


It's not very clean though, because you're going to have a command window popup while you're doing it. I assume you need to programatically grab the function names, right? Like you're letting people write DLL's for a certain purpose and you need your base program to be able to find the names of the functions?


fredborg(Posted 2007) [#3]
Like you're letting people write DLL's for a certain purpose and you need your base program to be able to find the names of the functions?
Yes, exactly. Anything self-contained will do, even simply scanning the .dll file, if someone knows how/where the names are stored. I don't like launching another program to do it.


grable(Posted 2007) [#4]
PE files can have an export section, to get at it you need to decode the PE header and read each section.

Id suggest looking at the source of pexports itself (its a part of mingw so the source is out there).

Btw, there is a good hex editor that can decode PE files and show you all sections, and their structures (if you want to figure this out yourself hehe :)
Tiny Hexer. a good hex editor is invaluable!


H&K(Posted 2007) [#5]
Why not call a small PB program and pass that info to Bmax?


N(Posted 2007) [#6]
http://msdn2.microsoft.com/en-us/library/ms809762.aspx

Take a look at that. You should be able to get an idea of how to read the exported function table, and from that you should be able to search the exported names.