Skip to content

Instantly share code, notes, and snippets.

@trufae
Created February 28, 2023 16:11
Show Gist options
  • Save trufae/cce27bd20c8c7cc6f5d7be5a5f03a2bb to your computer and use it in GitHub Desktop.
Save trufae/cce27bd20c8c7cc6f5d7be5a5f03a2bb to your computer and use it in GitHub Desktop.
r2poke/json test
Q: whats "fields", whats "boffsets", the offset inside looks wrong. not 0x100003a3c :?
Q: will be good to have field offsets starting from struct map address and struct mapping absolute address
```sh
$ r2 /bin/ls
[0x100003a3c]> . ./json.pk
[0x100003a3c]> ""poke type Test = struct { byte a; byte b; }
[0x100003a3c]> ""poke var root = Test@0x100003a3c#B
[0x100003a3c]> poke print json_format(root)
{"value": {"fields": [127, 35], "boffsets": [119264, 119272], "mapping": {"mapped": 1, "strict": 1, "IOS": 0, "offset": {34359857632, "type": {"code": "Offset", "info": {"magnitude": {"code": "Integral", "info": {"size": 64, "signed_p": false}}, "unit": 1}}}}}, "type": {"code": "Struct", "info": {"name": "Test", "fields": [{"name": "a", "type": {"code": "Integral", "info": {"size": 8, "signed_p": false}}}, {"name": "b", "type": {"code": "Integral", "info": {"size": 8, "signed_p": false}}}]}}}
[0x100003a3c]> _~{}
{
"value": {
"fields": [
127,
35
],
"boffsets": [
119264,
119272
],
"mapping": {
"mapped": 1,
"strict": 1,
"IOS": 0,
"offset": {
34359857632,
"type": {
"code": "Offset",
"info": {
"magnitude": {
"code": "Integral",
"info": {
"size": 64,
"signed_p": false
}
},
"unit": 1
}
}
}
}
},
"type": {
"code": "Struct",
"info": {
"name": "Test",
"fields": [
{
"name": "a",
"type": {
"code": "Integral",
"info": {
"size": 8,
"signed_p": false
}
}
},
{
"name": "b",
"type": {
"code": "Integral",
"info": {
"size": 8,
"signed_p": false
}
}
}
]
}
}
}
[0x100003a3c]>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment