mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-03 19:01:31 +00:00
wb -> wX, wb = write big endian bits in byte ##write
This commit is contained in:
parent
efebb04b34
commit
85c77e26b3
@ -14,7 +14,7 @@ static const char *help_msg_w[] = {
|
||||
"waF"," f.asm","assemble file and write bytes and show 'wx' op with hexpair bytes of assembled code",
|
||||
"wao","[?] op","modify opcode (change conditional of jump. nop, etc)",
|
||||
"wA","[?] r 0","alter/modify opcode at current seek (see wA?)",
|
||||
"wb"," 010203","fill current block with cyclic hexpairs",
|
||||
"wb"," 011001","write bits in bit big endian",
|
||||
"wB","[-]0xVALUE","set or unset bits with given value",
|
||||
"wc","[?][jir+-*?]","write cache list/undo/commit/reset (io.cache)",
|
||||
"wd"," [off] [n]","duplicate N bytes from offset at current seek (memcpy) (see y?)",
|
||||
@ -29,6 +29,7 @@ static const char *help_msg_w[] = {
|
||||
"wt","[?] file [sz]","write to file (from current seek, blocksize or sz bytes)",
|
||||
"ww"," foobar","write wide string 'f\\x00o\\x00o\\x00b\\x00a\\x00r\\x00'",
|
||||
"wx","[?][fs] 9090","write two intel nops (from wxfile or wxseek)",
|
||||
"wX"," 1b2c3d","fill current block with cyclic hexpairs",
|
||||
"wv","[?] eip+34","write 32-64 bit value honoring cfg.bigendian",
|
||||
"wz"," string","write zero terminated string (like w + \\x00)",
|
||||
NULL
|
||||
@ -1917,6 +1918,28 @@ repeat:
|
||||
}
|
||||
|
||||
static int cmd_wb(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
ut8 b = core->block[0];
|
||||
char *ui = r_str_newf ("%sb", r_str_trim_head_ro (input));
|
||||
int uil = strlen (ui) - 1;
|
||||
int n = r_num_get (NULL, ui);
|
||||
free (ui);
|
||||
if (uil > 8) {
|
||||
eprintf ("wb only operates on bytes\n");
|
||||
} else if (uil > 0) {
|
||||
int shift = 8 - uil;
|
||||
b <<= shift;
|
||||
b >>= shift;
|
||||
b |= (n << shift);
|
||||
r_io_write_at (core->io, core->offset, &b, 1);
|
||||
} else {
|
||||
eprintf ("Usage: wb 010101 (see pb)\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_wX(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
size_t len = strlen (input);
|
||||
const size_t buf_size = len + 2;
|
||||
@ -2091,6 +2114,9 @@ static int cmd_write(void *data, const char *input) {
|
||||
case 'b': // "wb"
|
||||
cmd_wb (core, input + 1);
|
||||
break;
|
||||
case 'X': // "wX"
|
||||
cmd_wX (core, input + 1);
|
||||
break;
|
||||
case 'B': // "wB"
|
||||
cmd_wB (data, input + 1);
|
||||
break;
|
||||
|
@ -5,7 +5,7 @@ CMDS=<<EOF
|
||||
s 0
|
||||
e io.va=true
|
||||
b 64
|
||||
wb 33
|
||||
wX 33
|
||||
S 0 0x1000 64 64 test
|
||||
s 0x1000
|
||||
px 0x40
|
||||
|
@ -102,7 +102,7 @@ RUN
|
||||
NAME=tests: ppcps
|
||||
FILE=malloc://256
|
||||
CMDS=<<EOF
|
||||
wb E003D004E42230081045254C1062228CF0623008F4627008104322CE10C7460E10A03A1010A03A111022182A1022182B11822040118220C011822000118220801044302410443025100118BA100118BB102220DC102220DD102220DE102220DF10443420104434211044346010443461104434A0104434A1104434E0104434E11060289010602891104441B8104441B91043017210430173106401D8106401D9106401DA106401DB102029101020291110202850102028511023397E1023397F1023397C1023397D11201830112018311120183411201835102220EE102220EF10AB102810AB10291045525410455255104552561045525710032FECF3E10028
|
||||
wX E003D004E42230081045254C1062228CF0623008F4627008104322CE10C7460E10A03A1010A03A111022182A1022182B11822040118220C011822000118220801044302410443025100118BA100118BB102220DC102220DD102220DE102220DF10443420104434211044346010443461104434A0104434A1104434E0104434E11060289010602891104441B8104441B91043017210430173106401D8106401D9106401DA106401DB102029101020291110202850102028511023397E1023397F1023397C1023397D11201830112018311120183411201835102220EE102220EF10AB102810AB10291045525410455255104552561045525710032FECF3E10028
|
||||
e asm.arch=ppc
|
||||
e cfg.bigendian = true
|
||||
e asm.cpu=ps
|
||||
|
@ -832,7 +832,7 @@ BROKEN=1
|
||||
FILE=malloc://1024
|
||||
CMDS=<<EOF
|
||||
e cfg.bigendian=true
|
||||
wb 4142434431323334
|
||||
wX 4142434431323334
|
||||
"td enum ascii{ LETTER_A=0x41, LETTER_D=0x44, DIGIT_1=0x31, DIGIT_4=0x34}"
|
||||
pf.somestring [1]E[1]E[1]E[1]E[1]E[1]E[1]E[1]E (ascii)B1 (ascii)B2 (ascii)B3 (ascii)B4 (ascii)B5 (ascii)B6 (ascii)B7 (ascii)B8
|
||||
pf.somestring
|
||||
|
@ -41,3 +41,22 @@ V\__/\______________________________________________________________/
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=pbwb
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
pb 8
|
||||
wb 110
|
||||
pb 8
|
||||
wb 0001
|
||||
pb 8
|
||||
wb 1010001
|
||||
pb 8
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
00000000
|
||||
11000000
|
||||
00010000
|
||||
10110010
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
@ -208,9 +208,9 @@ FILE=malloc://0x4000
|
||||
CMDS=<<EOF
|
||||
s 0
|
||||
b 64
|
||||
wb 38
|
||||
wX 38
|
||||
s 64
|
||||
wb deadbeef
|
||||
wX deadbeef
|
||||
s-32
|
||||
px
|
||||
EOF
|
||||
|
@ -328,10 +328,10 @@ nop
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=wb
|
||||
NAME=wX
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
wb 0102 @!20
|
||||
wX 0102 @!20
|
||||
p8 20
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
@ -343,7 +343,7 @@ NAME=wm
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
wm f0ff
|
||||
wb 010203 @!20
|
||||
wX 010203 @!20
|
||||
p8 20
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
|
@ -1192,7 +1192,7 @@ FILE=malloc://0x200
|
||||
CMDS=<<EOF
|
||||
e asm.arch=arm
|
||||
e asm.bits=16
|
||||
wb 054b
|
||||
wX 054b
|
||||
pd 10
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
|
Loading…
Reference in New Issue
Block a user