0

I've found the Software DLL Export Viewer which can retrieve the name of the exported functions from a dll library file:

enter image description here

I would like to know how I can start trying to mimic the same feature of the function-name retrieval in VB.NET or C# code (I don't need to retrieve the adreesses), for a C++ library.

The C++ dll which I would like to test is MediaInfo

Anyone can guide me?

ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
  • 1
    This seems like what you want to do. http://stackoverflow.com/questions/18249566/c-sharp-get-the-list-of-unmanaged-c-dll-exports – VoidStar Jul 16 '14 at 12:17

1 Answers1

1

The file format of .exe and .dll in modern windows are Portable Executable (most common PE or PE32, there is an 64bits version of the format that change the size of some data and extend others).

Info about the format:
Microsoft PE and COFF Specification
An In-Depth Look into the Win32 Portable Executable File Format, Part 1
An In-Depth Look into the Win32 Portable Executable File Format, Part 2
Peering Inside the PE: A Tour of the Win32 Portable Executable File Format (search for PE File Exports)
corkami Website(with really good info about goodies in binary formats)

In your specific case you are interesting in the exported data directory (which is the data structure that hold the info about the exported functions of the binary (not only dll can have exported functions)). This data structure contains info about the total number of exported functions, the list of the address of the exported functions, the name (if exist) and ordinals of the exported functions, etc...)

If you want to mimic DLL Export Viewer functionality you need to be able to load the PE File (ex: your .dll file and parse necessary data to reach Export Data Directory, like, MZ Header, PE Header, and finally parse Export Data Directory structures).

There is a very good python library named PyFile (that you can use or at least can give you insides and a way to check for problems), there is also PeLib in C++.

The road to take if you want to doit yourself is:
-Load MZ Header (get PE Header offset)
-Load PE Header (get Export Data Directory Offset)
-Load Export Data Directory Structure (get Numbers of Exported Functions and address of the list of exported functions info)
-Loop the list Loading exported functions info (get the address of the name of exported function)
-Read the name.

NetVipeC
  • 4,402
  • 1
  • 17
  • 19
  • Thankyou so much for the help, my knowledges about PE or C++ are very low, so I suppose that in my case is preferible to use a 3rd party library to get the names of the functions of an external lib?, then you can give a see to this url just only to confirm me whether with this .NET lib I could retrieve the names from a C++ lib?: http://hintdesk.com/net-pe-file-format-library/ if not, do you know a PE Library for .NET that could facilite me the task? PS: Sorry for my English – ElektroStudios Jul 16 '14 at 13:40
  • If you only need the name of the functions exported you could use the code in @VoidStar comment (note 32 or 64bits platform), you could also check: [C# header Parser](http://www.bearcanyon.com/dotnet/#AssemblyParser) which parse the header only, but is a start. – NetVipeC Jul 16 '14 at 14:22