Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle JSON parse to work with iterator("@@") #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

n4r1b
Copy link
Contributor

@n4r1b n4r1b commented Mar 13, 2018

Now it should work when parsing JSON object returned from an iterator for ex.

r2.cmdj("pdj 1@@hit0");

This should be done in other bindings too (maybe I should open an issue).
I tried to write some test cases, but I'm more used to mocha and I couldn't make it work with the testsuite, anyways I'll try to add some test as soon as possible

Copy link
Collaborator

@radare radare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using json with @@ should result in json stream so it should be valid too

@n4r1b
Copy link
Contributor Author

n4r1b commented Mar 13, 2018

The problem is that when parsing this json stream the delimiter between each result is a new line instead of a comma and every result is inside is own array. So right now when trying to execute a command like r2.cmdj("aoj @@=$$ $$+2") we'll get this error

{ SyntaxError: Unexpected token [ in JSON at position 368
    at Object.parse [as jsonParse] (<anonymous>)
    at Object.cb (/home/narib/test/node_modules/r2pipe/index.js:140:29)
    at Object.pipeCmdOutput (/home/narib/test/node_modules/r2pipe/index.js:118:21)
    at Socket.ls.stdout.on.data (/home/narib/test/node_modules/r2pipe/index.js:251:33)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:266:12)
    at readableAddChunk (_stream_readable.js:253:11)
    at Socket.Readable.push (_stream_readable.js:211:10)
    at Pipe.onread (net.js:587:20)
  res: '[{"opcode":"xor ebp, ebp","mnemonic":"xor","prefix":0,"id":334,"opex":{"operands":[{"size":4,"rw":3,"type":"reg","value":"ebp"},{"size":4,"rw":1,"type":"reg","value":"ebp"}],"modrm":true},"addr":22016,"bytes":"31ed","size": 2,"type": "xor","esil": "ebp,ebp,^=,$z,zf,=,$p,pf,=,$s,sf,=,$0,cf,=,$0,of,=,0xffffffff,rbp,&=","refptr":0,"cycles":1,"delay":0,"family":"cpu"}]\n[{"opcode":"mov r9, rdx","mnemonic":"mov","prefix":0,"id":449,"opex":{"operands":[{"size":8,"rw":2,"type":"reg","value":"r9"},{"size":8,"rw":1,"type":"reg","value":"rdx"}],"rex":true,"modrm":true},"addr":22018,"bytes":"4989d1","size": 3,"type": "mov","esil": "rdx,r9,=","refptr":0,"cycles":1,"delay":0,"family":"cpu"}]',
  cmd: 'aoj @@=$$ $$+2' }

I dont know if maybe I'm missing something, if its the case just cancel the pull request no prob :)

@trufae trufae requested a review from as0ler December 17, 2020 10:51
@trufae trufae force-pushed the master branch 2 times, most recently from 410c2d8 to d8b0642 Compare April 9, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants