How to Find All the Functions Exposed by a Dll

Is there a way to find all the functions exposed by a dll

It takes a bit of work, but you can do this programmaticly using the DbgHelp library from Microsoft.

Debugging Applications for Microsoft .Net and Microsoft Windows, by John Robbins is an excellent (if a little older) book which contains use details and full source. And, you can pick it up on Amazon for the cheap!

Is there any native DLL export functions viewer?

you can use Dependency Walker to view the function name.
you can see the function's parameters only if it's decorated.
read the following from the FAQ:

How do I view the parameter and return types of a function?
For most functions, this information is simply not present in the module. The Windows' module file format only provides a single text string to identify each function. There is no structured way to list the number of parameters, the parameter types, or the return type. However, some languages do something called function "decoration" or "mangling", which is the process of encoding information into the text string. For example, a function like int Foo(int, int) encoded with simple decoration might be exported as _Foo@8. The 8 refers to the number of bytes used by the parameters. If C++ decoration is used, the function would be exported as ?Foo@@YGHHH@Z, which can be directly decoded back to the function's original prototype: int Foo(int, int). Dependency Walker supports C++ undecoration by using the Undecorate C++ Functions Command.

How to identify what calls are made to a DLL?

What you want to make a is a proxy DLL. You replace the original DLL with yours and rename the original, then you LoadLibrary() the original renamed DLL. For functions you don't want to log or modify, you just pass through to the real DLL function. Otherwise you modify the arguments and then pass it through.

There are many tools which can help you generate a proxy DLL

  • https://github.com/maluramichael/dll-proxy-generator
  • https://github.com/zeroKilo/ProxyDllMaker
  • https://github.com/kevinalmansa/DLL_Wrapper

How to expose functions of a DLL correctly?

You can use a factory method and an interface:

For example:

//your classes: internal
internal class TestBase // Base class that I dont want to expose
{

}

//note: added interface
//note2: this class is not exposed
internal class TestFunctions : TestBase, IYourTestClass // The class that I want to expose
{

}

//an interface to communicate with the outside world:
public interface IYourTestClass
{
//bool Test(); some functions and properties
}

//and a public factory method (this is the most simple version)
public static class TestClassesFactory
{
public static IYourTestClass GetTestClass()
{
return new TestFunctions();
}
}

So in your caller's application now both classes aren't exposed. Instead you can use the factory to request a new one:

public void Main()
{
IYourTestClass jeuh = TestClassesFactory.GetTestClass();
}


Related Topics



Leave a reply



Submit