Skip to content

A C++ library and tools providing easy access to the retdec.com decompilation service through their REST API.

License

Notifications You must be signed in to change notification settings

pokey909/retdec-cpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retdec-cpp

A C++ library and tools providing easy access to the retdec.com decompilation service through their public REST API.

Development Status

The library is in an early stage of development.

Usage Example

The following example creates a decompiler, starts a decompilation of the given binary file, and prints the decompiled C code to the standard output.

#include <iostream>
#include <retdec/retdec.h>

using namespace retdec;

int main(int argc, char **argv) {
    if (argc != 3) {
        std::cerr << "usage: " << argv[0] << " API-KEY FILE\n";
        return 1;
    }

    try {
        Decompiler decompiler(
            Settings()
                .apiKey(argv[1])
        );
        auto decompilation = decompiler.runDecompilation(
            DecompilationArguments()
                .mode("bin")
                .inputFile(File::fromFilesystem(argv[2]))
        );
        decompilation->waitUntilFinished();
        std::cout << decompilation->getOutputHll();
        return 0;
    } catch (const Error &ex) {
        std::cerr << "error: " << ex.what() << "\n";
        return 1;
    }
}

Requirements

The Boost and OpenSSL libraries have to be installed on your system. Other libraries are automatically downloaded and built if they are not present on your system.

Build and Installation

  • Clone the repository or download the sources into a directory. Lets call the directory retdec.
  • cd retdec
  • mkdir build && cd build
  • cmake ..
  • make && make install

You can pass additional parameters to cmake:

  • -DRETDEC_DOC=1 to build with API documentation (requires Doxygen, disabled by default).
  • -DRETDEC_TESTS=1 to build with unit tests (disabled by default).
  • -DRETDEC_TOOLS=1 to build with tools (disabled by default).
  • -DRETDEC_COVERAGE=1 to build with code coverage support (requires LCOV, disabled by default).
  • -DCMAKE_BUILD_TYPE=debug to build with debugging information, which is useful during the development. By default, the library is built in the release mode.
  • -DCMAKE_INSTALL_PREFIX:PATH=/usr to set a custom installation path.

The make call supports standard parameters, such as:

  • -j N to build the library by using N processors.
  • VERBOSE=1 to show verbose output when building the library.

Use

If you use CMake, you can incorporate the library into your project in the following way.

set(retdec_DIR "/path/to/installed/retdec/lib/cmake")
find_package(retdec)
include_directories(SYSTEM ${retdec_INCLUDE_DIR})

add_executable(your_app your_app.cpp)
target_link_libraries(your_app retdec)

API Documentation

The API documentation is available here.

License

Copyright (c) 2015 Petr Zemek (s3rvac@gmail.com) and contributors.

Distributed under the MIT license. See the LICENSE file for more details.

Access from Other Languages

If you want to access the retdec.com decompilation service from other languages, check out the following projects:

  • retdec-python - A library and tools for accessing the service from Python.
  • retdec-sh - Scripts for accessing the service from shell.

About

A C++ library and tools providing easy access to the retdec.com decompilation service through their REST API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 85.1%
  • CMake 14.9%