Skip to content

Commit

Permalink
Node-ffi bindings: minor fixes in the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jul 1, 2012
1 parent 0ecca40 commit 41db950
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
18 changes: 9 additions & 9 deletions r2-bindings/node-ffi/examples/asm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions r2-bindings/node-ffi/examples/bin.js
Original file line number Diff line number Diff line change
@@ -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:');
Expand Down
4 changes: 2 additions & 2 deletions r2-bindings/node-ffi/examples/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 41db950

Please sign in to comment.