mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 21:29:49 +00:00
Implement 'woi' command to inverse contents of current block ##io
This commit is contained in:
parent
e6a71ec9ba
commit
b4c4c0fe98
@ -141,15 +141,22 @@ R_API ut8* r_core_transform_op(RCore *core, const char *arg, char op) {
|
||||
int i, j;
|
||||
ut64 len;
|
||||
char *str = NULL;
|
||||
ut8 *buf;
|
||||
|
||||
buf = (ut8 *)malloc (core->blocksize);
|
||||
ut8 *buf = (ut8 *)malloc (core->blocksize);
|
||||
if (!buf) {
|
||||
return NULL;
|
||||
}
|
||||
if (op == 'i') { // "woi"
|
||||
int hbs = core->blocksize / 2;
|
||||
int j = core->blocksize - 1;
|
||||
for (i = 0; i < hbs; i++, j--) {
|
||||
buf[i] = core->block[j];
|
||||
buf[j] = core->block[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
memcpy (buf, core->block, core->blocksize);
|
||||
|
||||
if (op!='e') {
|
||||
if (op != 'e') {
|
||||
// fill key buffer either from arg or from clipboard
|
||||
if (arg) { // parse arg for key
|
||||
// r_hex_str2bin() is guaranteed to output maximum half the
|
||||
@ -177,7 +184,7 @@ R_API ut8* r_core_transform_op(RCore *core, const char *arg, char op) {
|
||||
}
|
||||
|
||||
// execute the operand
|
||||
if (op=='e') {
|
||||
if (op == 'e') {
|
||||
int wordsize = 1;
|
||||
char *os, *p, *s = strdup (arg);
|
||||
int n = 0, from = 0, to = UT8_MAX, dif = 0, step = 1;
|
||||
@ -312,7 +319,7 @@ beach:
|
||||
}
|
||||
|
||||
R_API int r_core_write_op(RCore *core, const char *arg, char op) {
|
||||
ut8 *buf = r_core_transform_op(core, arg, op);
|
||||
ut8 *buf = r_core_transform_op (core, arg, op);
|
||||
if (!buf) {
|
||||
return false;
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ static const char *help_msg_wo[] = {
|
||||
"woD","[algo] [key] [IV]","decrypt current block with given algo and key",
|
||||
"woe"," [from to] [step] [wsz=1]",".. create sequence",
|
||||
"woE"," [algo] [key] [IV]", "encrypt current block with given algo and key",
|
||||
"woi","", "inverse bytes in current block",
|
||||
"wol"," [val]","<<= shift left",
|
||||
"wom"," [val]", "*= multiply",
|
||||
"woo"," [val]","|= or",
|
||||
@ -311,27 +312,28 @@ static int wo_handler_old(void *data, const char *input) {
|
||||
int len;
|
||||
int value;
|
||||
switch (input[0]) {
|
||||
case 'e':
|
||||
case 'e': // "woe"
|
||||
if (input[1]!=' ') {
|
||||
r_cons_printf ("Usage: 'woe from-to step'\n");
|
||||
return -1;
|
||||
}
|
||||
/* fallthru */
|
||||
case 'a':
|
||||
case 's':
|
||||
case 'A':
|
||||
case 'x':
|
||||
case 'r':
|
||||
case 'l':
|
||||
case 'm':
|
||||
case 'd':
|
||||
case 'o':
|
||||
case 'w':
|
||||
case 'a': // "woa"
|
||||
case 's': // "wos"
|
||||
case 'A': // "woA"
|
||||
case 'x': // "wox"
|
||||
case 'r': // "wor"
|
||||
case 'l': // "wol"
|
||||
case 'm': // "wom"
|
||||
case 'i': // "woi"
|
||||
case 'd': // "wod"
|
||||
case 'o': // "woo"
|
||||
case 'w': // "wow"
|
||||
case '2': // "wo2"
|
||||
case '4': // "wo4"
|
||||
case '8': // "wo8"
|
||||
if (input[1]) { // parse val from arg
|
||||
r_core_write_op (core, input + 2, input[0]);
|
||||
r_core_write_op (core, r_str_trim_head_ro (input + 2), input[0]);
|
||||
} else { // use clipboard instead of val
|
||||
r_core_write_op (core, NULL, input[0]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user