How to get a list of all exported DLL functions?
I'm trying to get a list of all exported functions from my DLL but I can't seem to find a command that does this?
Not even on MSDN
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 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
Quote:Original post by the_edd
Fix it then. Show a little initiative.
I don't understand what it's trying to do...
Are you seeking a way to get the list programmatically or do you just want to have a list? If you just want the list, check out this free utility: Dependency Walker.
You need to use the imagehelp api to manually parse the dll file.
http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement