Oh!, also forgot to say that bindings can be also accessible from the r2 shell. 'core' instance is exposed to the language bindings together with an automatic import of the RCore api.

You can use access them using the '#!' (hashbang) command.

[0x00000000]> #!
 vala: VALA language extension
 perl: Perl language extension
 python: Python language extension

[0x00000000]> #!vala
vala> print("Hello World\n");
Hello World

vala> stdout.printf ("core is %p\n", core);
core is 0x6068c0

vala> core.cmd0("x"); core.cons.flush();
- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0x00000000  0000 0000 0000 0000 0000 0000 0000 0000  ................
0x00000010  0000 0000 0000 0000 0000 0000 0000 0000  ................
0x00000020  0000 0000 0000 0000 0000 0000 0000 0000  ................
0x00000030  0000 0000 0000 0000 0000 0000 0000 0000  ................


This "r_lang" plugin is compiled in 'radare2' directory, not r2-bindings.

Btw, passing --enable=python and so on is not really useful because bindings are automatically detected by valabind at configure time, you can disable them if you like, but if its not detected, the build it will not work.

Also, use valabind from git to get the latest bindings generator.

--pancake


On 07/15/13 17:01, pancake wrote:
Various comments here:

- in debian/arch/void/gentoo there are binary packages for those
bindings (i also built a version for windows too)
- it's recommended to use git version
- enable-devel is deprecated
- bindings are inside r2-bindings subdirectory
- r.py is just a r_core_cmd() wrapper api, not real api, just parses
commands text instead.
- current git have two different implementation of the python bindings,
both based on valabind (ctypes and swig)
- both implementations should be compatible and same code should run on
both
- there are scripts in sys/*.sh to automate those builds
- You may like to run sys/python.sh
- the bindings are compiled by the farm (see bin.rada.re and ci.rada.re)
- "import radare" are the old text-based bindings for radare1
- see r2-bindings/python/test-*.py to see some code examples.
- if you want to build bindings for windows see doc/windows

Hope this helps :)

Here's a sample program:

from r2.r_bin import *
b = RBin ()
b.load ("/bin/ls", False)
baddr= b.get_baddr ()
print '-> Sections'
for i in b.get_sections ():
         print 'offset=0x%08x va=0x%08x size=%05i %s' % (
                         i.offset, baddr+i.rva, i.size, i.name)



On 07/15/13 04:20, Andrew Case wrote:
Hello,

I have compiled radare with python bindings following the instructions
in the source code:

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

but I cannot import radare as it will error with being unable to find
a module named 'r', which from reading docs and source code seems to
be the module that drives everything.

I did a search across disk and could not find a "r.py" file.

Is there other documentation I should be following?
_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org


_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org


_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org

Reply via email to