Process DLL DLLs

I would like to add registration to our unit tests, which write the DLLs that they use and where they are loaded from.

I can get the information that I need from Sysinternals ListDLL, but I will need to start it while the test process is running, and I will finish the race conditions: for example, ListDLL can start too early and skip the DLL loaded halfway through the test run; or ListDLL may start too late after the test process completes.

Similarly, I can get the necessary information from the output windows and Visual Studio debugging modules, but I would like to automate this on our build server.

Is there any command line tool that can run an arbitrary EXE, track the DLLs it uses, and write information to a file?

+4
source share
3 answers

You can write your own tool that will use the debugging features. This tool should

  • Start a new paused process.
  • Bind the created process as a debugger
  • Debug process events, as I recall, you need LOAD_DLL_DEBUG_EVENT

http://msdn.microsoft.com/en-us/library/windows/desktop/ms679302(v=vs.85).aspx

+2
source

The good news: It's not too hard to write it yourself using Detours. Pick up the LoadLibraryA / W functions and write the DLL names to a file (using GetModuleFileName for the value returned by the actual LoadLibrary). Also hook on CreateProcess so that you can register DLLs loaded by child processes.

The bad news: I would like to publish the source code that I used, but it is an internal tool that I cannot share with.

Edit: I'm not sure if this tool bypass hooks is completely reliable, as during my testing it missed several dlls. Here is an alternative tool using the debugger API: https://github.com/timrobinson/logdlls

+1
source

Please note that SysInternals (now MSFT: http://technet.microsoft.com/en-US/sysinternals ) has excellent tools for tracking all kinds of events that occur when the application loads: Process Monitor. You will need to filter out anything that is not related to the application you are considering. Alternatively, you can set the filter Operation = "Upload Image".

I tried the tool Tim Robinson, but it seems that it will only track the DLL associated with Windows, so it is not useful to me in my case.

0
source

All Articles