• Advertisement
Sign in to follow this  

How to get a list of all exported DLL functions?

This topic is 2896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Quote:
Original post by the_edd
Any good?


The code that was posted in that thread does not work.


#include <winnt.h>
HMODULE lib = LoadLibraryEx("library.dll", NULL, DONT_RESOLVE_DLL_REFERENCES);
assert(((PIMAGE_DOS_HEADER)lib)->e_magic == IMAGE_DOS_SIGNATURE);
PIMAGE_NT_HEADERS header = (BYTE *)lib + ((PIMAGE_DOS_HEADER)lib)->e_lfanew;
assert(header->Signature == IMAGE_NT_SIGNATURE);
assert(header->OptionalHeader.NumberOfRvaAndSizes > 0);
PIMAGE_EXPORT_DIRECTORY exports = (BYTE *)lib + header->
OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
PVOID names = (BYTE *)lib + exports->AddressOfNames;
for (int i = 0; i < exports->NumberOfNames; i++)
printf("Export: %s\n", (BYTE *)lib + ((DWORD *)names)[i]);



I get this debug output:
Quote:

1>.\main.cpp(3454) : error C2440: 'initializing' : cannot convert from 'BYTE *' to 'PIMAGE_NT_HEADERS'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>.\main.cpp(3455) : error C2440: 'initializing' : cannot convert from 'BYTE *' to 'PIMAGE_EXPORT_DIRECTORY'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Share this post


Link to post
Share on other sites
You need to use the imagehelp api to manually parse the dll file.

http://msdn.microsoft.com/en-us/magazine/cc301805.aspx

Share this post


Link to post
Share on other sites
Quote:
Original post by cache_hit
You need to use the imagehelp api to manually parse the dll file.

http://msdn.microsoft.com/en-us/magazine/cc301805.aspx


Thanks, thats what I was looking for!

Share this post


Link to post
Share on other sites
By the way, pay attention to the very bottom of the article where it says "For related articles see ____________" or something like that. The article linked there is possibly even more useful than the one I originally linked. But they're both good reads.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement