Expand description

This library contains utilities to scan the dependencies of Windows executable files and DLLs.

Quick Start

You can use this library to implement ldd for Windows: this repository indeed includes such a binary, called wldd. The following snippet shows how to recursively scan the dependencies of a target executable in a DLL lookup path built using sensible defaults. You can refer to that file for a usage example of more advanced functionalities.

The basic workflow is to first create a LookupQuery, which contains the path to the root executable whose dependencies should be found, a reference to the Windows root partition to use as reference for the scan, and various parameters for performing the scan.

Then the LookupPath can be computed given the query. The path contains a list of entries, which will be probed for a DLL with the name registered in the import table as dependency for the target executable. This search is performed recursively. The path can be freely manipulated after deduction for advanced use cases. It can also be built from a DependencyRunner dwp file, or from a Visual Studio vcxproj or vcxproj.user file.

Once all information is available, the recursive DLL lookup can be performed to obtain a list of interdependent executables. This list represents a directed acyclic graph through the dependency list for each node, and can be visited according to various strategies.

Sanity checks can be run on the list of executables to find missing DLL dependencies or symbols therein.


let exe_path = "path/to/some/executable.exe";
let mut query = dependency_runner::query::LookupQuery::deduce_from_executable_location(exe_path).unwrap();
query.parameters.extract_symbols = true;
let lookup_path = dependency_runner::path::LookupPath::deduce(&query);
let executables = dependency_runner::runner::run(&query, &lookup_path).unwrap();
let sym_check = executables.check(true);

Modules

  • This create contains utility functions used throughout the library, such as error handling and path manipulation.
  • This crate contains the data structures used to hold the results of a dependency scan
  • This is the workhorse of the library: the LookupPath contains the list of possible locations for a dependency, performs the actual lookup and caching of the results and of all filesystem access.
  • Low-level PE file format access through the goblin and pelite libraries
  • Data structures that must be filled with the input and the parameters for the DLL scan
  • Routine to perform a recursive lookup according to the parameters in the user-provided query and the lookup path computed from it (and eventually adjusted by the user)
  • Description of a Windows system useful to compute the lookup path
  • Utilities to parse Visual Studio project files