I have a C dll with exported functions
I can use the command-line tool dumpbin.exe /EXPORTS to extract the list of exported functions, and then use them in my C# code to (successfully) call these functions.
Is there a way to get this exported-functions-list directly from .NET, without having to use an external command-line tool?
Thanks
As far as I know there is no class in the .Net Framework that provides the information you need.
However you can use the platform invocation services (PInvoke) of the .Net platform to use the functions of the Win32 dbghelp.dll DLL. This DLL is part of the Debugging Tools for the Windows platform. The dbghelp DLL provides a function called
SymEnumerateSymbols64
which allows you to enumerate all exported symbols of a dynamic link library. There is also a newer function calledSymEnumSymbols
which also allows to enumerate exported symbols.The code below shows a simple example on how to use the
SymEnumerateSymbols64
function.In order to keep the example simple I did not use the
SymEnumSymbols
function. I've also did the example without using such classes as theSafeHandle
class of the .Net framework. If you need a example for theSymEnumSymbols
function, just let me know.