Node-ffi bindings: minor fixes in the examples.

This commit is contained in:
Eduard Burtescu 2012-07-01 18:30:05 +03:00
parent 0ecca40e71
commit 41db950d22
3 changed files with 14 additions and 13 deletions

View File

@ -2,16 +2,16 @@ const r2 = require ('../r_asm');
/* Using the RAsm API */
function Assembler(arch, bits) {
var $this = new r2.RAsm();
$this.use(arch);
$this.set_bits(bits);
var $this = new r2.RAsm();
$this.use(arch);
$this.set_bits(bits);
this.assemble = function(x) {
return $this.massemble(x).buf_hex;
};
this.disassemble = function(x) {
return $this.mdisassemble_hexstr(x).buf_asm;
};
this.assemble = function(x) {
return $this.massemble(x).buf_hex;
};
this.disassemble = function(x) {
return $this.mdisassemble_hexstr(x).buf_asm;
};
}
var asm = new Assembler('x86', 32);

View File

@ -1,7 +1,8 @@
var r2 = require('../r_bin')
var b = new r2.RBin()
b.load(process.argv[2] || '/bin/ls', false);
var b = new r2.RBin(), fileName = process.argv[2] || '/bin/ls';
if(!b.load(fileName, false))
console.error('Cannot open '+fileName), process.exit(1);
console.log('Base address:', b.get_baddr().toString(16));
console.log('Sections:');

View File

@ -5,8 +5,8 @@ var core = new r2.RCore(), cons = r2.RCons;
var fileName = process.argv[2] || '/bin/ls';
var file = core.file_open(fileName, 0, 0);
if(file._pointer.isNull())
console.error('Cannot open '+fileName), process.exit(1);
if(file == null)
console.error('Cannot open '+fileName), process.exit(1);
//core.bin_load('test.js');
//core.seek(0, true); core.block_read(0);