radareorg/radare2-r2pipe

ioplugin and map file

pipothebit opened this issue · 3 comments

Hi,
I'm using r2pipe to try to map a "virtual" file at certain address. The command line that i am using is:

r2 \  
  -a arm \  
  -b 32 \  
  -e cfg.bigendian=true \  
  -c "e asm.emu=true" \  
  -c "on malloc://16K 0x10000000 rwx" \  
  -c "omn 0x10000000 sram_1" \  
  -c "on malloc://128M 0x20000000 rwx" \  
  -c "omn 0x20000000 sram_2" \  
  -c 'on "r2pipe://node test-r2io-plugin.js" 0x3c000000 rw  '
  bios.hex

That command give me this memory map:

 5 fd: 6 +0x00000000 0x3c000000 - 0xffffffffffffffff rw-   
 4 fd: 6 +0xffffffffc4000000 0x00000000 - 0x3bfffffe rw-   
 3 fd: 5 +0x00000000 0x20000000 - 0x27ffffff rwx sram_2  
 2 fd: 4 +0x00000000 0x10000000 - 0x10003fff rwx sram_1  
 1 fd: 3 +0x00000000 0x00000000 - 0x001fffff rwx

When I use the original file dumped I use this command line lo launch r2:

r2 \
  -a arm \
  -b 32 \
  -e cfg.bigendian=true \
  -c "e asm.emu=true" \
  -c "on malloc://16K 0x10000000 rwx" \
  -c "omn 0x10000000 sram_1" \
  -c "on malloc://128M 0x20000000 rwx" \
  -c "omn 0x20000000 sram_2" \
  -c "on 0x3c000000.bin 0x3c000000 rw" \
  bios.hex

And I get this is the memory map:

 4 fd: 6 +0x00000000 0x3c000000 - 0x3c3fffff rw- 
 3 fd: 5 +0x00000000 0x20000000 - 0x27ffffff rwx sram_2
 2 fd: 4 +0x00000000 0x10000000 - 0x10003fff rwx sram_1
 1 fd: 3 +0x00000000 0x00000000 - 0x001fffff r-x 

Is posible to do this with r2pipe?

yes you can do this with r2pipe.

can you point me in some direction how to do this with r2pipe?
What fails in the command line with which I launch r2?

you can pass arguments to the r2 process you spawn by using the 2rd argument of the open() call in the python API. also you can do the same by opening "--" file which means no-file, and then running thos ecommands and o to open the file.

btw, see pydoc r2pipe, but the 2nd arg is an array of arguments passed to the r2 process.

but that wont work if you use the native r2pipe api or http api