Search code examples
pinvokenative-code

How can I use a native DLL from C#?


Given a native DLL, with no documentation or anything, and assuming it is not a COM component, is there any way to extract some sort of interface from that DLL so it can be called from C#?

I know about PInvoke, but that requires me to already know the method names and signatures. I don't have those.

Is it even possible?


Solution

  • You can use a PE reading tool to list the exported functions. For example Dependency Walker will do that for you.

    There's not a right lot you can do with that information though. There's no metadata with a native DLL that tells you how to call those functions, what their signatures are. Or even what the parameters represent.

    Something has gone wrong with this project. A DLL on its own is not enough. You need a header file and some documentation.