How to obtain the modules list of a running process(for example a game launcher) then loop through the list and get a handle of the modules(dlls) to check if a certain function exists.
Thanks in advance,
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686849(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx
But those are for c++ and I wasn’t able to find some for c# .
To get the list of running processes:
You can then loop through the
processesarray looking for your target process.Then you can call
to get hold of all the modules.
Then you can iterate over that collection and find each module’s filename or handle. Note that the handle, the
HMODULEin Win32 terms, is given by theBaseAddressproperty.Finding out information about the exported functions is a little more difficult. That information is not readily available through the .net classes, and even in raw Win32 it’s tricky because your code is executing out of process. You can’t do anything with the
HMODULEfrom another process.The way to check for existence of a function is to use the dbghelp library to parse the PE data of the actual module file. I couldn’t find any code on the web to do this, so I produced this translation of another Stack Overflow answer of mine. Note that I used a number of declarations from pinvoke.net. I hope this helps!