Sign in to follow this  
SteveDeFacto

How to get a list of all exported DLL functions?

Recommended Posts

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this