-1

I have a application which is a game launcher. While the application is running I want to loop through the dlls which are loaded in that file and check if a certain function is exported.

How can I do that?

I'm not talking about using net reflector I want to check the exported functions by the dlls loaded in the memory from the game launcher and loop through them to see if a certain function is called.

Jax
  • 977
  • 8
  • 22
  • 40

3 Answers3

1

Jax, look at this StackOverflow question. It should be able to do exactly what you need. To keep things simple, look specifically at the comment that says to use Dumpbin.exe /exports. That will probably be the easiest way to do it. If you absolutely need to do it programmically, look at this Stackoverflow Question instead.

Using the Dumpbin method, you could do something like this:

        // The name of the DLL to output exports from
        const string dllName = @"C:\Windows\System32\Wdi.dll";
        string output = string.Empty;
        var info = new ProcessStartInfo();
        var process = new Process();

        info.CreateNoWindow = true;
        info.RedirectStandardOutput = true;
        info.UseShellExecute = false;
        info.EnvironmentVariables.Remove("Path");
        // DumpBin requires a path to IDE
        info.EnvironmentVariables.Add("Path", Environment.GetEnvironmentVariable("Path") + @";c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\");

        // Your path might be different below.
        info.FileName = @"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\dumpbin.exe";

        info.Arguments = string.Format("/exports \"{0}\"", dllName);

        process.OutputDataReceived += (senderObject, args) => output = output + args.Data;
        process.StartInfo = info;
        process.Start();
        process.BeginOutputReadLine();

        process.WaitForExit();
        // output now contains the output
Community
  • 1
  • 1
Icemanind
  • 47,519
  • 50
  • 171
  • 296
0

Use .net reflection. Here is good sample how to do this:

http://towardsnext.wordpress.com/2008/09/17/listing-types-and-methods-of-assembly-reflection/

Gregor Primar
  • 6,759
  • 2
  • 33
  • 46
0

You might want to look at something like

Using Reflection to load unreferenced assemblies at runtime in C#

Reflection Examples [C#]

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284