Code Monkey home page Code Monkey logo

radare2-bindings's Introduction

radare2 API bindings

  • pip install r2libr Python r2libr bindings 🚀
  • Vala / Swig CI vala swig ci🚀

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

If you are looking for the r2pipe bindings, check this repository.

Description

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

Supported target languages:

  • Python
  • JavaScript
  • Java
    • jna Pure Java for FFI
    • java JNI native bindings
  • Go
  • Ruby
  • Perl
  • Lua
  • Vala
  • Rust
    • genbind.py -o /tmp/r2bindings-output -l rust
  • 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.

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.

Using r2pm

Fortunely, all those dependencies can be installed with r2pm:

r2pm -cgi vala swig valabind

Source build

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

  • Install vala and swig from your distro
arch$ sudo pacman -S swig valac
deb$ sudo apt install -y swig valac
mac$ brew install swig valac

Or install

  • Install latest release of Vala from tarball or git
  • Fetch valabind from the repository:
$ git clone https://github.com/radare/valabind
$ cd valabind
$ 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
make

r2libr (python)

r2libr are the most complete python bindings generated from source with all libr dynamic libraries bundled in a wheel.

You may have a try without the need to install radare2:

pip3 install --upgrade r2libr

For details, see r2libr.

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 It is possible also specify the particular languages, for example:

genbind.py -o /tmp/r2bindings-output -l go rust python

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=python3.2-config make
$ su -
# PYTHON_CONFIG=python3.2-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

aronsky avatar aweinstock314 avatar c0d3d avatar ckanibal avatar condret avatar cr0hn avatar crowell avatar deeso avatar dholm avatar eddyb avatar fishilico avatar frefreak avatar guedou avatar hackathi avatar jingtaozf avatar jpenalbae avatar jroimartin avatar kingmahmud avatar maijin avatar maskray avatar p4n74 avatar radare avatar raulsiles avatar rlaemmert avatar rydnr avatar sushant94 avatar timdiels avatar trufae avatar wtdcode avatar xvilka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

radare2-bindings's Issues

dotnet-r2pipe on Windows just hangs

dotnet-r2pipe on Mono 3.12 using radare2 0.9.9-git aka radare-0.9.8-813.g37cfb20 commit 7161 works fine and as expected.

The same code under Windows however doesn't run. radare2 0.9.9-git aka jenkins-radare2-w32-4239 commit 7779 just hangs and uses somewhere between 10 and 20% CPU constantly.

Tested with both master dotnet-r2pipe and my reworked fork. Same behavior.

build python bindings with error

r_core_wrap.cxx:7227:62: error: too few arguments to function ‘RList* r_core_asm_strsearch(RCore*, const char*, long long unsigned int, long long unsigned int, int, int)’

Do not build other bindings if some specified with --enable

E.g. to build ocaml bindings - we need to run

./configure --enable=ocaml
make
make install

But it also compiles unspecified ducktape:

 - node-ffi: no
 - ctypes: yes
 - ocaml: SWIG is buggy. Please set in ocamldec.swg the following line:
#define caml_array_length swig_caml_array_length
test_wrap.cxx:855:59: error: 'mlsize_t caml_array_length__(caml_value_t)' was declared 'extern' and later 'static' [-fpermissive]
     SWIGSTATIC mlsize_t caml_array_length( CAML_VALUE arr );
                                                           ^
<command-line>:0:19: error: previous declaration of 'mlsize_t caml_array_length__(caml_value_t)' [-fpermissive]
/usr/lib64/ocaml/caml/mlvalues.h:252:21: note: in expansion of macro 'caml_array_length'
 CAMLextern mlsize_t caml_array_length (value);   /* size in items */
                     ^
no
 - cxx: yes (g++)
 - valac: yes
Supported langs:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for working directories... current
using prefix '/tmp/r2'
checking for c compiler... gcc
checking for c++ compiler... g++
checking for valabind... /tmp/valabind/bin/valabind
checking for swig... /usr/bin/swig
checking for g-ir-compiler... /usr/bin/g-ir-compiler
checking pkg-config flags for r_core... yes
creating ./config.mk
cleaning temporally files... done

Final report:
 - PREFIX = /tmp/r2
 - HAVE_SWIG = 1
 - HAVE_VALABIND = 1
 - HAVE_GIRCOMPILER = 1
+ NOSUDO=1
+ DESTDIR=/tmp/r2
+ PREFIX=/tmp/r2
+ PKG_CONFIG_PATH=/tmp/r2/lib/pkgconfig
+ PATH=/tmp/valabind/bin:/var/lib/jenkins/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/cross/bin
+ PYTHON_INSTALL_DIR=/tmp/r2
+ make
make -C libr/lang/p
make[1]: Entering directory `/var/lib/jenkins/workspace/radare2-bindings-ocaml/libr/lang/p'
gcc -I/tmp/r2/include/libr  -Wall -DPREFIX=\"/tmp/r2\" -I. -Iduk   -c -o duktape.o duktape.c
In file included from duktape.c:6:0:
duk_bi_date.c: In function ‘duk__parse_string_strptime’:
duk_bi_date.c:328:2: warning: implicit declaration of function ‘strptime’ [-Wimplicit-function-declaration]
duk_bi_date.c:328:46: warning: comparison between pointer and integer [enabled by default]
gcc -std=c99 -I/tmp/r2/include/libr  -Wall -DPREFIX=\"/tmp/r2\" -I. -Iduk -fPIC -L/tmp/r2/lib  -lr_core -lr_util -shared \
    -o lang_duktape.so duktape.c
In file included from duktape.c:6:0:
duk_bi_date.c: In function ‘duk__get_local_tzoffset’:
duk_bi_date.c:226:2: warning: implicit declaration of function ‘gmtime_r’ [-Wimplicit-function-declaration]
duk_bi_date.c: In function ‘duk__parse_string_strptime’:
duk_bi_date.c:328:2: warning: implicit declaration of function ‘strptime’ [-Wimplicit-function-declaration]
duk_bi_date.c:328:46: warning: comparison between pointer and integer [enabled by default]
LANG  lang_duktape.so

from http://ci.rada.re/view/Bindings/job/radare2-bindings-ocaml/1/console

automatically find perl archlib

Only Perl 5.10 is supported right now since /usr/lib/perl/5.10/CORE is set in the Makefile. The quick fix is to ask perl itself where to find archlib:

-       -${CC} ${CFLAGS} -I/usr/lib/perl/5.10/CORE/ \
+       -${CC} ${CFLAGS} -I$(shell perl -MConfig -e 'print $$Config{archlib}')/CORE/ \

corrupted double-linked list or segfault when using get_bbs

When I use this little script I have an corrupted double-linked list.
If I replace /bin/true by /bin/ls I have a segfault.

#!/usr/bin/env python                                                                                                                 

from r2 import r_core

rc = r_core.RCore()

rc.file_open("/bin/true", 0, 0)

rc.bin_load("", 0)

rc.anal_all()

rc.anal.get_fcns()[0].get_bbs()

`ad` should show if the address is pointed by a register

use anal->reg

    R_ANAL_DATA_TYPE_REGISTER = 10

in theory this command should be used to analyze the conetns of the memory. not the offsets of it. so this feature must identify numeric values that are referenced by any register.

Getting strings from an "unknown" binary file

Hi,

I am currently trying to use the Java version of the API to get all of the strings from a binary file. However, it seems that radare does not know automatically what file type the file is, so it doesn't return anything when I load the file up into an RBin object and try to use the get_strings() method. This also makes sense because when I try to analyze the file with rabin2 via command line to get the strings it gives me the warning:

WARN: Use '-e bin.rawstr=true' or 'rabin2 -zz' to find strings on unknown file types

So then when I try again with the -zz flag, it finds all of the strings.

I was wondering if there is a way to find all of the strings in an unknown file type from the API? I have already tried using RCore but I believe that passing commands via RCore is only for commands from within Radare and not other commands like rabin2?

If anyone has any ideas that would be great!

Thanks,
-4leaf

radare2-1.0.0 release

  • Fix Python Ctypes binding
  • Fix Node.JS bindings (requires changes to the valabind - nodejs ffi interface)

`axtj` is broken in Python

Radare2 is not outputting JSON, but things like:

[{u'type': u'C', u'from': 4269326, u'opcode': u'call section..init'}]

Notice the u prefix; meaning that it's unicode.

pkg-config does not find r_core when prefix is not the default /usr

When radare2 is not installed in the default /usr (e.g. ~/radare) then pkg-config does not find cflags for r_core, r_util, etc.

A simple work-around for cflags is to define PKG_CONFIG_PATH=${RADARE}/lib/pkgconfig where $RADARE points to the radare2 installation directory. Maybe configure should have a flag --with-radare=DIR and then define PKG_CONFIG_PATH accordingly in all Makefiles.

This same issue makes building of language bindings in libr/lang/p fail since LDFLAGS lacks the path to radare2 lib directory. Once, pkg-config can find r_core, it can be easily solved replacing:

-LDFLAGS_LIB=-lr_core -lr_util -shared
+LDFLAGS_LIB=$(shell pkg-config --libs-only-L r_core) -lr_core -lr_util -shared

Ocaml bindings are broken

  • ocaml: SWIG is buggy. Please set in ocamldec.swg the following line:
    #define caml_array_length swig_caml_array_length
    test_wrap.cxx:855:54: error: declaration of C function 'int caml_array_length__(caml_value_t)' conflicts with
    In file included from /usr/lib64/ocaml/caml/alloc.h:22:0,
    from test_wrap.cxx:741:
    /usr/lib64/ocaml/caml/mlvalues.h:250:21: error: previous declaration 'mlsize_t caml_array_length__(caml_value_t)' here
    no

Cannot normally install nodejs bindings

I try to use Nodejs bindings and have a problems with install. Make is normally finished but I see one error:

node-ffi # make
...
NOTICE >class Radare.RMagic
NOTICE >ns SDB
NOTICE >class SDB.Sdb
<stdin>: In function ‘main’:
<stdin>:30:15209: error: ‘R_ANAL_REFLINE_TYPE_STYLE’ undeclared (first use in this function)
<stdin>:30:15209: note: each undeclared identifier is reported only once for each function it appears in
<stdin>:30:17547: error: ‘R_DBG_REASON_NEW_PID’ undeclared (first use in this function)
<stdin>:30:17568: error: ‘R_DBG_REASON_NEW_TID’ undeclared (first use in this function)
<stdin>:30:17589: error: ‘R_DBG_REASON_NEW_LIB’ undeclared (first use in this function)
<stdin>:30:17610: error: ‘R_DBG_REASON_EXIT_PID’ undeclared (first use in this function)
<stdin>:30:17632: error: ‘R_DBG_REASON_EXIT_TID’ undeclared (first use in this function)
<stdin>:30:17654: error: ‘R_DBG_REASON_EXIT_LIB’ undeclared (first use in this function)
<stdin>:30:17676: error: ‘R_DBG_REASON_TRAP’ undeclared (first use in this function)
<stdin>:30:17694: error: ‘R_DBG_REASON_ILL’ undeclared (first use in this function)
<stdin>:30:17711: error: ‘R_DBG_REASON_SIGNAL’ undeclared (first use in this function)
<stdin>:30:17731: error: ‘R_DBG_REASON_FPU’ undeclared (first use in this function)
<stdin>:30:17748: error: ‘R_DBG_REASON_BP’ undeclared (first use in this function)
<stdin>:30:17764: error: ‘R_DBG_REASON_UNKNOWN’ undeclared (first use in this function)
ERROR gcc exited with status 256
... r_core.so
Build r_bin -lr_bin -lr_util -lr_db -lr_io 
valabind-cc node-ffi r_bin -NRadare -NSDB -x --vapidir=../vapi ../vapi/r_bin -I/usr/include/libr -lr_bin -lr_util -lr_db -lr_io
valabind --node-ffi -I /usr/include/libr -x -N SDB -N Radare --vapidir ../vapi -o r_bin.js -m r_bin ../vapi/r_bin
NOTICE Symbol defined VALABIND_NODEJS
NOTICE Adding dependency package glib-2.0
NOTICE Adding dependency package gobject-2.0
NOTICE Adding dependency package ../vapi/r_bin
NOTICE Adding dependency package r_util
NOTICE Adding dependency package r_io
NOTICE >ns Radare
...

After I try to start examples and see errors again: not load ffi & ref modules. And cannot npm install it from node-ffi folder: npm log https://dl.dropboxusercontent.com/u/10688770/npm-debug.log

But I could copy this modules from other folder and r_asm.js found it:
r2_core_binding

Fix the RAnalCond structure

$ python2 -c "from r2 import r_core"
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/r2/r_core.py", line 339, in
class RAnalCond(Structure): #19
File "/usr/lib/python2.7/site-packages/r2/r_core.py", line 342, in RAnalCond
('arg', RAnalValue * 2),
NameError: name 'RAnalValue' is not defined

NodeJS snippets that *should* work

There are some code constructions that can result in failed attempts, when the code looks good.

  • openSync() with 1 parameter
var r2pipe = require ('r2pipe');
r2pipe.openSync(function(r2) {
   console.log(r2.cmd('?e hello world'));
});
// TypeError: First argument must be file descriptor
  • openSync() with no parameters
var r2pipe = require ('r2pipe');
var r2 = r2pipe.openSync();
console.log(r2.cmd('?e hello world'));
// TypeError: First argument must be file descriptor
  • open() with 1 parameter
var r2pipe = require ('r2pipe');
r2pipe.open(function(r2) {
   r2.cmd('?e hello world', console.log);
});
// TypeError: First argument must be file descriptor
  • open() with no parameters
var r2pipe = require ('r2pipe');
var r2 = r2pipe.open(); // XXX if no parameters we should connect in sync but continue async
r2.cmd('?e hello world', console.log);
// TypeError: First argument must be file descriptor

c-bindings segfault with getenv

$ r2  /bin/ls
 -- radare2 is like windows 7 but even better.
[0x004049d0]> #!c
c> printf("%s\n", getenv("USER"));
suse
c> printf("%s\n", getenv("R2_COLOR"));
Segmentation fault
$ r2 -v
radare2 0.10.2-git 10727 @ linux-little-x86-64 git.0.10.1-270-g659b83f
commit: 659b83fb433e9bc104086dde08eefbcd3626e85e build: 2016-03-28

ImportError: No module named r_util

root@ubuntu:~/radare2/radare2-bindings/python# python test-r2rc.py
Traceback (most recent call last):
File "test-r2rc.py", line 6, in
from r_util import *
ImportError: No module named r_util

Why is this a problem?

Inconsistent Results when Using Bindings vs Radare2

I'm not sure if this is the appropriate place for this issue, however I'm getting inconsistent results when using the Ruby r2pipe gem vs Radare2.

For reference, the binary that I'm looking at is MD5: 5896d840a314e8bc86ceadb5a6450cf8

When using Radare2, I'm able to see the full list of functions, below is a snippet

:~> radare2 -A  5896d840a314e8bc86ceadb5a6450cf8
 -- Your project name should contain an uppercase letter, 8 vowels, some numbers, and the first 5 numbers of your private bitcoin key.
[0x0040508e]> afl~?
152
[0x0040508e]> afl
0x0040508e  235  6  entry0
0x00404740  82  4  fcn.00404740
0x00401500  83  1  sub.KERNEL32.dll_GetTempPathA_500
0x00404a86  19  1  fcn.00404a86
0x00404a66  32  3  fcn.00404a66
..... snipped .....

When using the Ruby API, the following information is returned

:~> irb
irb(main):001:0> require 'r2pipe'
=> true
irb(main):002:0> r2p = R2Pipe.new("5896d840a314e8bc86ceadb5a6450cf8")
=> #<R2Pipe:0x00000000e022c0 @file="5896d840a314e8bc86ceadb5a6450cf8", @read=#<File:/dev/pts/2>, @write=#<File:/dev/pts/2>, @pid=6861>
irb(main):003:0> r2p.cmd('aa')
=> ""
irb(main):004:0> r2p.cmd('afl~?')
=> "1\r\n"
irb(main):005:0> r2p.cmd('afl')
=> "0x0040508e  235  6  entry0\r\n"

Is there a reason that r2pipe is only seeing 1 function listed versus the 152 recognized by Radare2?

Thank you for your time.

pip package bokken

minishwoods tools/binaryninja-python ‹crowell_r2_integration› » pip install r2pipe
Downloading/unpacking r2pipe
  Downloading r2pipe-0.6.1.tar.gz
  Running setup.py (path:/tmp/pip-build-QGFUWR/r2pipe/setup.py) egg_info for package r2pipe
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-QGFUWR/r2pipe/setup.py", line 4, in <module>
        with open('README.rst') as readme_file:
    IOError: [Errno 2] No such file or directory: 'README.rst'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip-build-QGFUWR/r2pipe/setup.py", line 4, in <module>

    with open('README.rst') as readme_file:

IOError: [Errno 2] No such file or directory: 'README.rst'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-QGFUWR/r2pipe
Storing debug log for failure in /home/jeff/.pip/pip.log

we need to package README.rst apparently?

radare grabs CTRL-C while loading binary and dont return it

A simple script like the one below will grab CTRL-C in the bin_load() call so that script dont get the interrupt.

from r2 import r_core
rc = r_core.RCore()
rc.file_open("/bin/ls", 0, 0)
rc.bin_load("/bin/ls", 0)
raw_input()

Try control-c when waiting for user input to verify

Go bindings are broken

I am unable to get the Go-language bindings working with r2. I don't think this is due to an issue with r2 being in a state of flux, rather I think it has something to do with the binding generation themselves. I fixed as many Go binding bugs as I could (see other PRs), but I'm woefully uneducated in SWIG.

Details:

$ cd radare2-bindings/go
$ # remove Makefile line 5 (`include ../rules.mk`), as described in #26, or we don't get anywhere
$ make r_bin.so
  ...   # output looks fine
$ make rbintest
. ./goenv.sh ; \
    ${GOC} -I . test-r_bin.go ; \
    ${GOL} -L . test-r_bin.${GO_N} ; \
    LD_LIBRARY_PATH=. ./${GO_N}.out /bin/ls
./6.out: symbol lookup error: ./6.out: undefined symbol: _wrap_RListIter_get_next
make: *** [rbintest] Error 127

Other supporting details:

$ nm 6.out | grep _wrap_RListIter_get_next                                
  00000000004506f0 T r_bin._swig_wrap_RListIter_get_next
  00000000005ef2b0 d x_wrap_RListIter_get_next
$ nm r_bin.a | grep _wrap_RListIter_get_next     
  nm: __.GOSYMDEF: File format not recognized
  nm: __.PKGDEF: File format not recognized
  nm: r_bin.6: File format not recognized
  nm: r_bin_gc.6: File format not recognized
$ grep _wrap_RListIter_get_next r_bin_wrap.cxx                            
  void _wrap_RListIter_get_next(void *swig_v) { RListIter *arg1 = (RListIter *) 0 ;     RListIter *result = 0 ; struct swigargs {

I think the fix would be small, but requires insight into r2 and SWIG (which I don't have yet). If you could dedicate a little time to fixing the the issue, I'd really appreciate it. Otherwise, if you could point me towards the appropriate resources to learn to do it myself, that would be a great help.

TypeError: RCore_gdiff expected 2 arguments, got 3

root@ubuntu:~/radare2/radare2-bindings/python# python test-ragdiff2.py /bin/sh /bin/sh
Traceback (most recent call last):
File "test-ragdiff2.py", line 241, in
main()
File "test-ragdiff2.py", line 236, in main
rd.diff()
File "test-ragdiff2.py", line 208, in diff
self.c.gdiff(self.c2, True)
TypeError: RCore_gdiff expected 2 arguments, got 3

Error searching lua pkgconfig in archlinux

Makefile on libr/lang/p uses this code to look for the .pc files for lua

LUAPKG=$(shell pkg-config --list-all|awk '/lua-/{print $$1;}')

in arch linux pc filenames don't have the '-'.

Error building Python bindings

Hi,

I tried to build the Python bindings but I'm having problems:

$ ./configure --enable=python
(...stripped...)
$ make
make -C libr/lang/p
make[1]: *** No hay ninguna regla para construir el objetivo «lang_tcc.so», necesario para «all».  Alto.
make: *** [all] Error 2

Any idea?

Global r2pipe options

We need some extra options for r2pipe:

  • path to r2 binary (actually is 'radare2' in $PATH)
  • extra commandline options for spawn/launch

Simple building process

Improve building system to be able run ./configure with --select-python, --select-ruby, etc, then make, then make install. Now it is completely independent codebase, so can be simplified in this way. Also, it is possible to define languages to be built at once, and you'll get both bindings and lang_* plugin for chosen language.

Makefile:156: recipe for target 'install-python' failed

-> Extracting radare2-bindings-0.9.8.tar.xz with bsdtar
==> Removing existing $pkgdir/ directory...
==> Starting build()...
==> Using valabind 0.9.0
==> Using swig 3.0.5
Checking valabind languages support...

  • python: yes
  • perl: yes
  • ruby: yes
  • lua: yes
  • go: SWIG -go: -intgosize option required but not specified
    no
  • java: test_wrap.c:135:17: fatal error: jni.h: No such file or directory
    #include <jni.h>
    ^
    compilation terminated.
    no
  • guile: yes
  • php5: test_wrap.c:706:18: fatal error: zend.h: No such file or directory
    #include "zend.h"
    ^
    compilation terminated.
    no
  • node-ffi: no
  • ctypes: yes
  • ocaml: SWIG is buggy. Please set in ocamldec.swg the following line:
    #define caml_array_length swig_caml_array_length
    /usr/bin/valabind-cc: line 106: ocamlc: command not found
    test_wrap.cxx:741:24: fatal error: caml/alloc.h: No such file or directory
    #include <caml/alloc.h>
    ^
    compilation terminated.
    no
  • cxx: yes (g++)
  • valac: yes
    Supported langs:
  • python
    checking build system type... i686-unknown-linux-gnu
    checking host system type... i686-unknown-linux-gnu
    checking target system type... i686-unknown-linux-gnu
    checking for working directories... current
    using prefix '/usr'
    checking for c compiler... gcc
    checking for c++ compiler... g++
    checking for valabind... /usr/bin/valabind
    checking for swig... /usr/bin/swig
    checking for g-ir-compiler... no
    checking pkg-config flags for r_core... yes
    creating ./config.mk
    cleaning temporally files... done

...

==> Entering fakeroot environment...
==> Starting package()...
make -C libr/lang/p install
make[1]: Entering directory '/tmp/yaourt-tmp-user/aur-r2-bindings/src/radare2-bindings-0.9.8/libr/lang/p'
mkdir -p /tmp/yaourt-tmp-user/aur-r2-bindings/pkg/r2-bindings//usr/lib/radare2/0.9.9-git/
[ -n "ls *.so" ] && cp -f _.so /tmp/yaourt-tmp-user/aur-r2-bindings/pkg/r2-bindings//usr/lib/radare2/0.9.9-git/ || true
make[1]: Leaving directory '/tmp/yaourt-tmp-user/aur-r2-bindings/src/radare2-bindings-0.9.8/libr/lang/p'
test -f python/r_core.so
Makefile:156: recipe for target 'install-python' failed
make: *
* [install-python] Error 1
==> ERROR: A failure occurred in package().
Aborting...
==> ERROR: Makepkg was unable to build r2-bindings.
==> Restart building r2-bindings ? [y/N]
==> ------------------------------------

Write C++ R2pipe API

For rlang and local-pipe. Not sure about json, http/tcp if we should use an async lib, etc.

Objects from Java Bindings do not all work

I compiled the Java Bindings on Ubuntu 13.10 and some objects (RAsm, RFSFile, RAsmOp, RAnal, RMeta) give me a java.lang.UnsatisfiedLinkError when I try to call the constructors for them, while other objects (RBin) are constructed fine. The example .java file that comes with the bindings runs fine because it only uses a RBin object, RBinSection object, and RBinSectionVector object but all of the other objects I have tried to create so far have not worked.

Is anyone else having this same problem? Any ideas for how I might be able to fix this?

Thanks,
-4leaf

Cannot start a few examples for Nodejs bindings

# node r2irc.js 
 [=>] Initializing r2 core... 
/home/radare/bindings/radare2-bindings/node-ffi/node_modules/ffi/lib/_foreign_function.js:36
      throw new TypeError('Expected ' + numArgs +
            ^
TypeError: Expected 7 arguments, got 3
    at ForeignFunction.proxy (/home/radare/bindings/radare2-bindings/node-ffi/node_modules/ffi/lib/_foreign_function.js:36:13)
    at StructType.load (/home/radare/bindings/radare2-bindings/node-ffi/r_core.js:141:13)
    at Object.<anonymous> (/home/radare/bindings/radare2-bindings/node-ffi/examples/r2irc.js:59:10)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
# node bin.js 
/home/radare/bindings/radare2-bindings/node-ffi/node_modules/ffi/lib/_foreign_function.js:36
      throw new TypeError('Expected ' + numArgs +
            ^
TypeError: Expected 7 arguments, got 5
    at ForeignFunction.proxy (/home/radare/bindings/radare2-bindings/node-ffi/node_modules/ffi/lib/_foreign_function.js:36:13)
    at StructType.load (/home/radare/bindings/radare2-bindings/node-ffi/r_bin.js:141:13)
    at Object.<anonymous> (/home/radare/bindings/radare2-bindings/node-ffi/examples/bin.js:4:7)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Other examples are normally start.

RBin depends on RIO

Which breaks how all bindings examples work. For simplicity it would be good that RBin could load the file directly from disk. or make the RIO dependency explicit. so the bindings get the apis to load the file on io or associate the io in the rbin thing.

see python/test-r_bin.py example

Support of arrays and constants in ctypes bindings

valabind-cc ctypes r_asm -NRadare -x --vapidir=../vapi ../vapi/r_asm -I/usr/include/libr -lr_asm -lr_lib -lr_util -lr_parse -lr_db -lr_syscall
valabind --ctypes -I /usr/include/libr -x -N Radare --vapidir ../vapi -o r_asm.py -m r_asm ../vapi/r_asm
NOTICE Adding dependency package glib-2.0
NOTICE Adding dependency package gobject-2.0
NOTICE Adding dependency package ../vapi/r_asm
NOTICE Adding dependency package r_util
WARNING Constants not yet supported on ctypes (R2_VERSION)
WARNING Constants not yet supported on ctypes (R2_PREFIX)
WARNING Constants not yet supported on ctypes (R2_LIBDIR)
--> RAsm (0)
--> RAsmOp (1)
WARNING Arrays not yet supported in ctypes bindings
WARNING Arrays not yet supported in ctypes bindings
WARNING Arrays not yet supported in ctypes bindings
WARNING Arrays not yet supported in ctypes bindings
--> RAsmCode (2)
--> RAsmPlugin (3)
--> RStrBuf (4)
WARNING Unknown datatype

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.