Thursday, 15 March 2012

c++ - Win32 API to enumerate dll export functions? -



c++ - Win32 API to enumerate dll export functions? -

i found similar questions no reply looking for. here goes:

for native win32 dll, there win32 api enumerate export function names?

dumpbin /exports pretty much want, that's developer tool, not win32 api.

loadlibraryex dont_resolve_dll_references heavily cautioned against, happens useful particular case – heavy lifting of mapping dll memory (but don't need or want utilize library), makes trivial read header: module handle returned loadlibraryex points right @ it.

#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 = (pimage_nt_headers)((byte *)lib + ((pimage_dos_header)lib)->e_lfanew); assert(header->signature == image_nt_signature); assert(header->optionalheader.numberofrvaandsizes > 0); pimage_export_directory exports = (pimage_export_directory)((byte *)lib + header-> optionalheader.datadirectory[image_directory_entry_export].virtualaddress); assert(exports->addressofnames != 0); byte** names = (byte**)((int)lib + exports->addressofnames); (int = 0; < exports->numberofnames; i++) printf("export: %s\n", (byte *)lib + (int)names[i]);

totally untested, think it's more or less correct. (famous lastly words.)

c++ windows winapi dll

No comments:

Post a Comment