Automated library compilation and PDB annotation with CMake and IDA Pro
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmake
modules
.gitignore
LICENSE
README.md
TODO
bindifflib.py
bindifflib_exporter.py
compilers.yml
ida_plugin.py
libs.yml
requirements.txt
settings.yml

README.md

Disclaimer

This repository contains code that is rather a solid POC than an professionally developed piece of software. The author does not take any responsibilities if using this code damages your system.

The author intends to re-write the whole code but he probably won't do this until he feels pressured enough to start doing it. Thus, the code is just made public so that it does not get lost over time and maybe someone finds this useful and uses it.

bindifflib

In general, the whole code is more or less a wrapper around CMake which allows to compile a list of libraries (defined in libs.yml) with a set of different compilers (currently only Visual Studio compilers on a Windows host system). Nevertheless, one can also specify build scripts which are executed as batch files.

After compiling, this framework also takes all DLLs which have a corresponding PDB along and puts them into IDA Pro to generate IDB files for which (mostly) all functions have their names correctly set in the database (based on the PDB files generated by Visual Studio).

libs.yml

The libs.yml contains the configuration for all the libraries that shoulb be built using bindifflib. For an example on how to use the file, please refer to the preconfigured libs.yml shipped with bindifflib. Basically, the file contains a list of libraries which can have several settings. Libraries are configured like this:

libs:
    <libid>:
        <list of configuration values>
    <libid2>:
        <another list of configuration values>

The possible configuration values can be:

  • name: (short) name of library, can be used to group several different libraries under one single name; does not have to be unique
  • url: url template for the package download which must have {version} at least one time somewhere inside, e.g. https://ftp.pcre.org/pub/pcre/pcre2-{version}.tar.gz (single occurrence) or http://www.bzip.org/{version}/bzip2-{version}.tar.gz (multiple occurrences). Cannot be used together with urls! The following protocols can be handled:
    • http(s)
    • ftp
  • urls: a list of urls that point to source archives for the library. bindifflib tries to get the library version from the url using the regex /\/<name of library>[-_](.*)\.<filetype>$/. Cannot be used together with url!
  • versions: a list of versions of the given library to be downloaded and built, the values from here will be put into the URL template as version.
  • filetype: type of downloaded file, can be one of:
    • tar.gz
    • zip
  • cmakeflags: list of custom cmake flags to change the default behaviour of the CMakeLists.txt of the library; e.g.:
cmakeflags:
    - PCRE2_BUILD_TESTS=OFF
    - BUILD_SHARED_LIBS=ON
  • extracts_to_subfolder: specifies whether the archive of the library unpacks plain files or unpacks into a subfolder; can be true or false
  • dependencies: list of dependencies of the library - caution: the dependencies need to be part of the list of libraries! this is just something like a "reference" within the list
    • all: dependencies for all versions
    • <version>: one may want to specify a certain version of a dependency for a certain version of the library (e.g. because of API changes etc) or just add an additional dependency. This can be done using something like the following - the values from all are overwritten if the name of the library matches:
dependencies:
    all:
        bzip2: "1.0.6"
        zlib: "1.2.11"
    <version>:
        bzip2: "1.0.4"
  • customcmake: allows to specify a custom CMake file to build the library; may be of use if the one of the library has a bug or if the library does not provide one at all. The custom CMake file has to be placed in the cmake subfolder and the config value is the full path within the directory. The customcmake allows for providing different CMake files for different targets. Works similar to the targets of dependencies. The file will be copied over to source_dir/CMakeLists.txt and will overwrite any existing CMakeLists.txt without asking or warning.
customcmake:
    "10.22": pcre2/pcre2-10.22.cmake
  • custombuild: a list of commands that need to be used to compile the library; the commands will be put into a temporary batch file in the exact same order as they are written in the config file
  • 64bit: can be true or false; allows for disabling the 64bit build of the library

compilers.yml

<id>:
    generator: <generator name>
    short: <short name>
    vcvarsall: <full path to vcvarsall.bat

This snippet can be placed several times in compilers.yml. Each library of libs.yml will be built with each of the provided compilers.

  • id: compiler id, only internal use; must be unique
  • generator: CMake generator for the compiler, e.g. Visual Studio 10 2010
  • short: short name of the compiler, e.g. msvc10; will be appended to directory names etc
  • vcvarsall: contains the full path to the vcvarsall.bat script of the compiler, e.g. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat