0

Possible Duplicate:
Win32 API to enumerate dll export functions?

I am writing a plugins subsystem and one of the ideas is to iterate through a DLL exported functions. I know there are other ways, just really want to give this one a try.

What I am wondering, is there a way to get a list of functions exported by a DLL in WinAPI?

Thanks in advance!

Community
  • 1
  • 1
strannik
  • 1,595
  • 1
  • 13
  • 22
  • tl;dr from the other question: you can do it, you just have to parse the PE header. But, luckily, that's not that hard. – nneonneo Feb 05 '13 at 13:50
  • Is there a possibility to get to the PE header having HMODULE? – strannik Feb 05 '13 at 13:54
  • @Daniel: Yes, use GetModuleFileName and load the PE header. PS If you want to look at the exported functions of modules a process has loaded in memory, have a look at [this CodeProject article](http://www.codeproject.com/Articles/2082/API-hooking-revealed), specifically the `CHookedFunction::ReplaceInOneModule` function. The code will be mostly the same for just loading the module from disk too. – parrowdice Feb 05 '13 at 14:35
  • 1
    Iterating through exported functions is probably not the way to go. For example, a single DLL may be a plug-in for multiple applications, and it will export different functions for each host. It would be bad if one host reacted to exports intended for the other host. – Raymond Chen Feb 05 '13 at 14:40
  • @RaymondChen I thought the export table was static. Are you saying it can change based on what loads the DLL? – Marc Sherman Feb 05 '13 at 15:06
  • @parrowdice the intend of this is making code piece small and robust. Loading dll header from disk second time does not seem to make sense. Any chance to grab it from memory? – strannik Feb 05 '13 at 15:22
  • @MarcSherman It is static, but you can imaging somebody writing a single DLL that is both an ActiveX control and a Firefox plug-in. That DLL would export both DllGetClassObject and NP_Initialize. It would be bad if Firefox tried to call DllGetClassObject or if IE tried to call NP_Initialize. – Raymond Chen Feb 05 '13 at 15:36
  • @Daniel: Yes, read the second part of my comment. That has the source code (and more) that you're looking for (exported functions in memory). – parrowdice Feb 05 '13 at 15:42

0 Answers0