Giter Club home page Giter Club logo

restorer's Introduction

restorer

An application that allows you to recover header files for C++ classes and namespaces from dll and pdb files built by Microsoft Visual C++.

The current implementation just meets my requirements and is not a finished product.

  • Tested on Windows only;
  • Only x64 binaries supported.
  • Not all MSVC build options that affect RTTI may be considered, resulting in incomplete or incorrect recovery.

Example

It easy to get current options with help:

$ restorer.exe --help

OVERVIEW: Class header dumper

USAGE: restorer.exe [options] <input object files>

OPTIONS:
--recursive            Collect all binary files recursively
--input-folder=path    Input folder path
--pdb-folder=path      Pdb folder path
--output-folder=path   Output folder path
--help                 Display available options

You can pass a list of dlls or a directory path (for recursive traversal) to the input and get a set of header files at the output, in which all the found characters keep their nesting.

$ ./restorer.exe libA.dll libB.dll

You can find here example folder with example.h header file. After restoration we get something like in example_restored.h.

How it works

  • A lot of information can be obtained from decorated names.
  • It is possible to restore the inheritance hierarchy if the library you are using uses Microsoft Visual C++ RTTI.
  • PDB files can be used to obtain additional information that will increase the amount of information recovered.

We can represent the nesting of classes and namespaces in the form of a tree for each of the modules (exe/dll). Combined tree of all modules gives us a more complete picture, but this requires no collisions. The collected information is displayed in C++ header files, which can even be included in other C++ projects. Unfortunately, RTTI does not keep a list of class fields, so the task is much more complicated. At this point, the class fields need to be restored manually.

Another useful feature of this application is that it tries to restore virtual function tables while maintaining the original order of functions. If you are lucky and enough information is collected, you can get a class/struct definition that can be used to call virtual functions when developing plugins (get pointer in run-time and cast to restored type).

Requirements

  • LLVM
  • DIA (for processing PDB)

Possible improvement directions (TODO)

  • Add a set of options for more flexibility;
  • Full support for PDB processing (structure/class layout info)
  • Restore fields lists for class/struct/union;
  • Add also generation of source files (.cpp) for linkless function calling;
  • Investigate Linux support;
  • Make pre-built packages.

Inspiration and ideas

Thanks for idea to GrandpaGameHacker:

LLVM:

cmu-sei:

restorer's People

Contributors

haltarkon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

restorer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.