NAME=cmd.hit sugar for /x
FILE=malloc://1024
CMDS=<<EOF
wx 90 @ 10
e cmd.hit="wx 91"
/x 90
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a hit0_0 90
91
EOF
RUN

NAME=cmd.hit sugar for /j
FILE=malloc://1024
CMDS=<<EOF
w hello @ 10
psz @@/j hello
EOF
EXPECT=<<EOF
hello
[{"offset":10,"type":"string","data":"hello"}]
EOF
RUN

NAME=/xj utf16
FILE=malloc://1024
CMDS=<<EOF
wx 005c
/xj 005c
EOF
EXPECT=<<EOF
[{"offset":0,"type":"hexpair","data":"005c"}]
EOF
RUN

NAME=/j utf16
FILE=malloc://1024
CMDS=<<EOF
wx 0067
/j g
EOF
EXPECT=<<EOF
[{"offset":1,"type":"string","data":"g"}]
EOF
RUN

NAME=cmd.hit sugar for /x
FILE=malloc://1024
CMDS=<<EOF
wx 90 @ 10
wx 91 @@/x 90
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a hit0_0 90
91
EOF
RUN

NAME=cmd.hit sugar for /
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
w A @ 10
wx 33 @@/ A
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a hit0_0 "A"
33
EOF
RUN

NAME=cmd.hit sugar for /
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
wx 90 @ 10
wx 33 @@/ad nop
p8 1 @ 10
EOF
EXPECT=<<EOF
0x0000000a   # 1: nop
33
EOF
RUN

NAME=cmd.hit for /!x
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit="p8 1"
wx 90 @ 10
/!x 00
EOF
EXPECT=<<EOF
0x0000000a hit0_0 90
90
EOF
RUN

NAME=cmd.hit for /!
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit="p8 1"
w AAAAAAAAAAB
/! A
EOF
EXPECT=<<EOF
0x0000000a hit0_0 "AAAAAAAAAAB"
42
EOF
RUN

NAME=cmd.hit for /+
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit="p8 3"
w ABCDEF
/+ ABC
EOF
EXPECT=<<EOF
0x00000000 hit0_0 414243
414243
EOF
RUN

NAME=cmd.hit for //
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit="p8 1"
w AAAAAAAAAAB
/! A
//
EOF
EXPECT=<<EOF
0x0000000a hit0_0 "AAAAAAAAAAB"
42
0x0000000a hit1_0 "AAAAAAAAAAB"
42
EOF
RUN

NAME=cmd.hit for /ca
FILE=bins/other/aes.dump
CMDS=/ca
EXPECT=<<EOF
0x0000001e hit0_0 0000000000000000000000000000000000000000000000000000000000000000
EOF
RUN

NAME=cmd.hit for /ca
FILE=bins/other/aes_192.dump
CMDS=/ca
EXPECT=<<EOF
0x000000fa hit0_0 000102030405060708090a0b0c0d0e0f1011121314151617
EOF
RUN

NAME=cmd.hit for /cr
FILE=bins/other/rsa-private-4096.key
CMDS=/cr
EXPECT=<<EOF
0x0000000d hit0_0 308209280201000282020100c079f24b042787e4896db411fa7647e3bb62c88796fa979f126c575f...
EOF
RUN

NAME=cmd.hit for /cr on edd448
FILE=bins/other/ed448-private.key
CMDS=/cr
EXPECT=<<EOF
0x000000f5 hit0_0 3047020100300506032b6571043b0439176449168ec8fc66d9e67d375d1ea310b1427e8c178b2f83...
EOF
RUN

NAME=cmd.hit for /cd
FILE=bins/other/certificate.ber
CMDS=/cd
EXPECT=<<EOF
0x0000002f hit0_0 308203493082
EOF
RUN

NAME=cmd.hit for /a
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
e cmd.hit="pi 4"
"wa add esp,8;pop ebx; pop ebp; ret"
/a add esp, 8
EOF
EXPECT=<<EOF
0x00000000 hit0_0 83c408
add esp, 8
pop ebx
pop ebp
ret
EOF
RUN

NAME=cmd.hit for /A
FILE=malloc://1024
CMDS=<<EOF
e asm.arch=x86
e analysis.arch=x86
e cmd.hit="pi 1"
e asm.bits=32
"wa add esp,8;pop ebx; pop ebp; ret"
/at pop
EOF
EXPECT=<<EOF
0x00000003 1 pop ebx
pop ebx
0x00000004 1 pop ebp
pop ebp
EOF
RUN

NAME=cmd.hit for /bx
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit="p8 4"
w ABCD @ 0x100
e search.from=0x100
e search.to=0x104
b 0x100
/bx 41424344
EOF
EXPECT=<<EOF
0x00000100 hit0_0 41424344
41424344
EOF
RUN

NAME=cmd.hit for /B
FILE=malloc://1024
CMDS=<<EOF
wx cffa edfe
e cmd.hit="px 1"
e search.from=0
e search.to=0x10
/mb
EOF
EXPECT=<<EOF
0x00000000  mach064
EOF
RUN

NAME=cmd.hit for /i
FILE=malloc://1024
CMDS=<<EOF
e cmd.hit=ps
e search.from=0
e search.to=0x10
w AAAAAAAAAAB
/i aaaaaaaaaab
EOF
EXPECT=<<EOF
0x00000000 hit0_0 "AAAAAAAAAAB"
AAAAAAAAAAB
EOF
RUN

NAME=cmd.hit for /r
FILE=bins/elf/analysis/ls-linux64
CMDS=<<EOF
e cmd.hit="pi 1"
e search.from=0x00005c20
e search.to=0x00005c49
/r sym.imp.__libc_start_main
EOF
EXPECT=<<EOF
(nofunc) 0x5c44 [CALL] call sym.imp.__libc_start_main
call sym.imp.__libc_start_main
EOF
RUN

NAME=from/to for /r
FILE=bins/elf/analysis/ls-linux64
CMDS=<<EOF
e cmd.hit="pi 1"
e search.from=0x00005c20
e search.to=0x00005c44
/r sym.imp.__cxa_finalize
EOF
EXPECT=<<EOF
EOF
RUN

NAME=cmd.hit for /s
FILE=bins/elf/analysis/x86-simple
CMDS=<<EOF
aeim
aeip
e cmd.hit="pi 1"
/as
EOF
EXPECT=<<EOF
0x08048070 exit
int 0x80
EOF
RUN

NAME=from/to /v
FILE=-
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 01
e cmd.hit="pi 1"
e search.in=raw
e search.from=0x00000000
e search.to=0x00000004
/v1 1
EOF
EXPECT=<<EOF
0x00000000 hit0_0 01
add dword [rax], eax
EOF
RUN

NAME=from/to /v not in range
FILE=-
CMDS=<<EOF
wx 01
e cmd.hit="pi 1"
e search.in=raw
e search.from=0x00000000
e search.to=0x00000000
/v1 1
EOF
EXPECT=<<EOF
EOF
RUN

NAME=from/to /V
FILE=-
BROKEN=1
CMDS=<<EOF
wx 05
e cmd.hit = pi 1
e search.in =raw
e search.from=0x00000000
e search.to=0x00000004
/V1 1 5
EOF
EXPECT=<<EOF
0x00000000 hit0_0 05
add dword [rax], eax
EOF
RUN

NAME=from/to /V not in range
FILE=-
CMDS=<<EOF
wx 05
e cmd.hit=pi 1
e search.in=raw
e search.from=0x00000000
e search.to=0x00000000
/V1 1 5
EOF
EXPECT=<<EOF
EOF
RUN
