Giter VIP home page Giter VIP logo

yssource / radare2-bindings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from radareorg/radare2-bindings

0.0 2.0 0.0 5.68 MB

Bindings of the r2 api for Valabind and friends

License: GNU Lesser General Public License v3.0

Makefile 0.63% Shell 0.25% Awk 0.14% C 89.84% C# 1.13% Python 1.16% JavaScript 0.21% Perl 0.06% Go 0.01% Scheme 0.02% Java 0.07% Ruby 0.12% C++ 3.03% Lua 0.87% NewLisp 0.10% PHP 0.02% Vala 2.32% Gosu 0.01%

radare2-bindings's Introduction

radare2 language bindings for r2 api

This repository contains the native bindings generated with Valabind to use the radare2 APIs.

The r2pipe implementations has been moved into a separate repository.

Description

This directory contains the code necessary to use the r2 api from your favourite language.

It supports a large list of programming languages:

  • Python, JavaScript, Java, Vala, Go, Ruby, Perl, Lua, NewLisp, Guile, OCaml

And some other experimental bindings are for:

  • GIR, C++, C#

This package also contains the vdoc/ subdirectory which contains the rules used to generate all interactive html documentation found at:

http://radare.org/vdoc

Dependencies

To build radare2-bindings from repository you need the following programs installed:

  • swig: enables support for python, perl, lua, java and many other
  • vala: if you want to have Vala or Genie bindings
  • valabind: required only in developer mode (not release tarball)

Release tarballs come with all the pregenerated .cxx files, so you have no extra dependencies apart from the language libraries and C++ compiler.

To get install all dependencies do the following steps in order:

  • Install swig and git from repository (ensure you don't have vala installed from package)

    arch$ sudo pacman -S swig git
    deb$ sudo apt install swig git
    
  • Install latest release of Vala from tarball

    http://live.gnome.org/Vala

    ./configure --prefix=/usr
    make
    sudo make install
    
  • Clone vala compiler from git repository:

    $ git clone git://git.gnome.org/vala
    $ cd vala
    $ sh autogen.sh --prefix=/usr
    $ make
    $ sudo make install
    
  • Fetch valabind from the repository:

    $ git clone git://github.com/radare/valabind.git
    $ cd valabind
    $ make
    $ sudo make install PREFIX=/usr
    

To keep bindings up-to-date

When changes are done in libr an ABI break can occur. The bindings will require to be recompiled to work again.

It's recommendable to keep your system always up to date, and upgrade vala and valabind from git/hg.

$ cd vala
$ git pull
$ make
$ sudo make install

$ cd ../valabind
$ git pull
$ make
$ sudo make install PREFIX=/usr

radare2-bindings

If you compile from the repo you need the latest version of valabind and then:

./configure --prefix=/usr

You can select the languages you want to compile with --enable={list-of-langs}

./configure --prefix=/usr --enable=python

Experimental radare2 bindgen

Introduction

This script allows to generate native bindings for these languages directly from radare2 C headers:

More languages are planned, in particular:

  • Ruby - I wanted to use ffi-gen but it needs revival and update to the modern Ruby and Clang.
  • OCaml - needs to be written
  • Lua - maybe LuaAutoC can be used, I don't know.

Usage

genbind.py -o /tmp/r2bindings-output

The tool required radare2 to be installed and takes the include directory from the output of r2 -H

PYTHON

To select the version of python to compile for use the PYTHON_CONFIG environment variable as follows:

$ ./configure --prefix=/usr --enable-devel
$ cd python
$ PYTHON_CONFIG=python2.7-config make
$ su -
# PYTHON_CONFIG=python2.7-config make install

RANDOM NOTES

The valabind integration forces us to do some changes in the r2 API.

These api changes are for:

  • Avoid keywords in function names

    Every language has its own keywords, r2api should try to workaround all those keywords to avoid collisions for bindings.

    Example: use, del, from, continue, etc..

    TODO: we need to review APIs, find better names for functions using those keywords, etc..

  • Review basic data structures

    Linked lists, hash tables, r_db, arrays, ... must be reviewed to fit with vala and swig basics to be able to use them with simple APIs or integrate them with the syntax sugar of the target language.

    Example: foreach (var foo in binls.get_symbols ()) { print ("%s 0x%08"PFMT64x"\n", foo.name, foo.offset); }

  • Unit testing

    Having bindings for python, perl, ruby, .. is good for unit testing because it hardly simplifies the way to test APIs, find bugs, ...

    TODO: write unit testing frameworks for perl, ruby, python, etc..

  • API unification for all languages

    All the previous development points are meant to reduce code in r2, avoid syntax exceptions, simplify api usage, and much moar ;)

SWIG is not complete, there are still so many bugs to fix and so many unimplemented stuff. Here's a list of the most anoying things of it:

  • unsigned char * : not implemented

radare2-bindings's People

Contributors

aweinstock314 avatar condret avatar cr0hn avatar crowell avatar deeso avatar deetch avatar dequis avatar dholm avatar digdugg avatar eddyb avatar fishilico avatar frefreak avatar hackathi avatar hksuki avatar jingtaozf avatar jpenalbae avatar jroimartin avatar lowlyw avatar ls80x avatar maijin avatar makigumo avatar maskray avatar oblique avatar p4n74 avatar radare avatar raulsiles avatar rydnr avatar sushant94 avatar timdiels avatar xvilka avatar

Watchers

 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.