views:

1193

answers:

5

I found similar questions but no answer to what I am looking for. So here goes:

For a native Win32 dll, is there a Win32 API to enumerate its export function names?

+4  A: 

I think that the only way is to parse PE header. This article is a good point to start from.

Kirill V. Lyadvinsky
http://msdn.microsoft.com/en-us/magazine/ms809762.aspx is the second part which goes into the export table details.
MSN
+2  A: 

Go over to Microsoft research and grab the Detours Library. One of its examples does exactly what you are asking. The whole library basically makes detouring/rerouting win32 function calls extremely easy. Its pretty cool stuff.

Detours

Edit: Also note that if you just want to look at the export table, you can (at least in visual studios) set your project properties to print out the export/import tables. I can't remember the exact option but should be easy to google.

Edit2:The option is Project Properties->Linker->Debugging->Generate MapFile ->Yes(/MAP)

DeusAduro
A: 

If you're just looking for a way to find out what functions are exported in a DLL, you can use Microsoft's dependency walker (depends.exe). This wont help you if you actually need to discover the exports programmatically, though.

Ferruccio
+5  A: 
ephemient
Worked well enough that my quick port to Python (with ctypes) works fine. Thanks!
Peter Hansen
A: 

If you don't want to go to the trouble of writing your own code and would rather use a DLL that already exists for this purpose, I recommend PE File Format DLL. Comes with source code so that you can modify if you wish. No GPL to worry about.

Also available is a GUI application that shows how to use the DLL.

Stephen Kellett