rizin/test/db/cmd/cmd_pointer
Quentin Minster b82215965e
Refactor pointer write command * to use the API (#3793)
* Add tests for pointer write command `*`

Some test cases override `asm.arch` for bitness compatibility reasons.

* Refactor pointer write command `*` to use the API

* Allow use of more general exprs as value for pointer write command `*` ##shell

* Instead of detecting when to write a value, and write a hexpair
  otherwise, do the inverse: detect when to write a hexpair, and write a
  value otherwise. This allows more general value exprs such as
  variables, derefs, ...

* To enable this, add an option to `rz_hex_str_is_valid` so it can
  reject a 0x-prefixed string (because 0x-prefixed strings should be
  handled as values, not hexpairs, by the pointer write command)

* Add a test case to ensure a non-0x-prefixed value arg, that's not a
  valid hexpair, now gets eval'ed as an expr by the pointer write
  command (where previously it would throw an error)
2023-08-26 23:40:31 +08:00

68 lines
1.1 KiB
Text

NAME=pointer read
FILE=malloc://1024
CMDS=<<EOF
wv8 0xdeadbeefdeadbeef
*0
*0 @e:asm.bits=64
*0 @e:asm.bits=32
*0 @e:asm.arch=x86,asm.bits=16
*0 @e:asm.arch=6502,asm.bits=8
*0+2 @e:asm.bits=32
EOF
EXPECT=<<EOF
0xdeadbeefdeadbeef
0xdeadbeefdeadbeef
0xdeadbeef
0xbeef
0xef
0xbeefdead
EOF
RUN
NAME=pointer write value
FILE=malloc://1024
CMDS=<<EOF
wx ffffffffffffffff
*0=0xdeadbeefdeadbeef
*0 @e:asm.bits=64
wx ffffffffffffffff
*0=0xdeadbeefdeadbeef @e:asm.bits=64
*0 @e:asm.bits=64
wx ffffffffffffffff
*0=0xdeadbeef @e:asm.bits=32
*0 @e:asm.bits=64
wx ffffffffffffffff
*0=0xbeef @e:asm.arch=x86,asm.bits=16
*0 @e:asm.bits=64
wx ffffffffffffffff
*0=0xef @e:asm.arch=6502,asm.bits=8
*0 @e:asm.bits=64
wx ffffffffffffffff
*0+2=0xbeefdea0+0xd @e:asm.bits=32
*0 @e:asm.bits=64
wx efbeaddeffffffff
*0+4=[0] @e:asm.bits=64
*0 @e:asm.bits=64
EOF
EXPECT=<<EOF
0xdeadbeefdeadbeef
0xdeadbeefdeadbeef
0xffffffffdeadbeef
0xffffffffffffbeef
0xffffffffffffffef
0xffffbeefdeadffff
0xdeadbeefdeadbeef
EOF
RUN
NAME=pointer write hex
FILE=malloc://1024
CMDS=<<EOF
wx ffffffffffffffff
*0+2=addeefbe
*0 @e:asm.bits=64
EOF
EXPECT=<<EOF
0xffffbeefdeadffff
EOF
RUN