mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-11 23:16:05 +00:00
Add bitmask feature in cx command
This commit is contained in:
parent
9f7f9f0ce8
commit
d7126c3d87
@ -20,7 +20,7 @@ static void showhelp(RCore *core) {
|
|||||||
"cud", " [addr] @at", "Unified diff disasm from $$ and given address",
|
"cud", " [addr] @at", "Unified diff disasm from $$ and given address",
|
||||||
"cv", "[1248] [addr] @at", "Compare 1,2,4,8-byte value",
|
"cv", "[1248] [addr] @at", "Compare 1,2,4,8-byte value",
|
||||||
"cw", "[us?] [...]", "Compare memory watchers",
|
"cw", "[us?] [...]", "Compare memory watchers",
|
||||||
"cx", " [hexpair]", "Compare hexpair string",
|
"cx", " [hexpair]", "Compare hexpair string (use '.' as nibble wildcard)",
|
||||||
"cX", " [addr]", "Like 'cc' but using hexdiff output",
|
"cX", " [addr]", "Like 'cc' but using hexdiff output",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
@ -348,12 +348,14 @@ static int cmd_cmp(void *data, const char *input) {
|
|||||||
static char *oldcwd = NULL;
|
static char *oldcwd = NULL;
|
||||||
RCore *core = data;
|
RCore *core = data;
|
||||||
ut64 val = UT64_MAX;
|
ut64 val = UT64_MAX;
|
||||||
|
char * filled;
|
||||||
ut8 *buf;
|
ut8 *buf;
|
||||||
ut16 v16;
|
ut16 v16;
|
||||||
ut32 v32;
|
ut32 v32;
|
||||||
ut64 v64;
|
ut64 v64;
|
||||||
int ret;
|
int ret;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
|
int i;
|
||||||
|
|
||||||
switch (*input) {
|
switch (*input) {
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -367,16 +369,30 @@ static int cmd_cmp(void *data, const char *input) {
|
|||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
if (input[1]!=' ') {
|
if (input[1]!=' ') {
|
||||||
eprintf ("Usage: cx 001122'\n");
|
eprintf ("Usage: cx 00..22'\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
filled = (char*) malloc (strlen (input + 2) + 1);
|
||||||
|
if (filled == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
memcpy (filled, input + 2, strlen (input + 2) + 1);
|
||||||
|
|
||||||
buf = (ut8*)malloc (strlen (input+2)+1);
|
buf = (ut8*)malloc (strlen (input+2)+1);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return false;
|
return false;
|
||||||
ret = r_hex_str2bin (input+2, buf);
|
|
||||||
|
ret = r_hex_bin2str (core->block, strlen (input + 2) / 2, (char *)buf);
|
||||||
|
|
||||||
|
for (i = 0; i < ret * 2; i++)
|
||||||
|
if (filled[i] == '.')
|
||||||
|
filled[i] = buf[i];
|
||||||
|
|
||||||
|
ret = r_hex_str2bin (filled, buf);
|
||||||
if (ret<1) eprintf ("Cannot parse hexpair\n");
|
if (ret<1) eprintf ("Cannot parse hexpair\n");
|
||||||
else val = radare_compare (core, core->block, buf, ret);
|
else val = radare_compare (core, core->block, buf, ret);
|
||||||
free (buf);
|
free (buf);
|
||||||
|
free (filled);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
buf = malloc (core->blocksize);
|
buf = malloc (core->blocksize);
|
||||||
|
Loading…
Reference in New Issue
Block a user