Giter Site home page Giter Site logo

s3rvac / retdec-cpp Goto Github PK

View Code? Open in Web Editor NEW
9.0 5.0 3.0 217 KB

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

License: MIT License

CMake 12.93% C++ 87.07%
retdec cpp decompiler decompilation disassembler fileinfo

retdec-cpp's Introduction

retdec-cpp

WARNING

The retdec.com decompilation service is to be disabled (see the official announcement). This will render the library and tools in the present repository non-functional. I will keep the repository online in case it is helpful to anyone.

Description

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

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;
    }
}

Status

The library currently provides very basic support of the decompilation, file-analyzing, and test services.

Requirements

To build the library and tools, you need:

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. Let's call the directory retdec.
  • cd retdec
  • mkdir build && cd build
  • cmake ..
  • make && make install

You can pass additional parameters to cmake:

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

You can force a specific version of the required libraries by passing the following parameters to cmake:

  • -DBOOST_ROOT=$BOOST_DIR
  • -DCPPNETLIB_ROOT=$CPPNETLIB_DIR
  • -DOPENSSL_ROOT_DIR=$OPENSSL_DIR
  • -DJsonCpp_ROOT_DIR=$JSONCPP_DIR

The make call supports standard parameters, such as:

  • -j N to build the library in parallel using N processes.
  • 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_DIRS})

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

API Documentation

The API documentation is available here:

You can also generate it by yourself (pass -DRETDEC_DOC=ON to cmake and run make doc).

License

Copyright (c) 2015 Petr Zemek ([email protected]) 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-rust - A library and tools for accessing the service from Rust.
  • retdec-sh - Scripts for accessing the service from shell.

retdec-cpp's People

Contributors

s3rvac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.