mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-19 12:22:43 +00:00
Honor $. variables to get regs and fix Ps string filter bug
This commit is contained in:
parent
caaccaddc9
commit
baae1f6e6a
@ -285,7 +285,8 @@ static void printmetaitem(RMeta *m, RMetaItem *d, int rad) {
|
||||
if (str) {
|
||||
if (d->type=='s' && !*str)
|
||||
return;
|
||||
r_str_sanitize (str);
|
||||
r_name_filter (str, 0);
|
||||
// XXX r_str_sanitize (str);
|
||||
if (rad)
|
||||
m->printf ("%s %d %s @ 0x%08"PFMT64x"\n",
|
||||
r_meta_type_to_string (d->type),
|
||||
|
@ -11,7 +11,7 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
|
||||
char str[R_FLAG_NAME_SIZE];
|
||||
|
||||
/* bin str limits */
|
||||
int hasstr= r_config_get_i (r->config, "bin.strings");
|
||||
int hasstr = r_config_get_i (r->config, "bin.strings");
|
||||
int rawstr = r_config_get_i (r->config, "bin.rawstr");
|
||||
int minstr = r_config_get_i (r->config, "bin.minstr");
|
||||
if (!hasstr) return 0;
|
||||
@ -52,7 +52,9 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
|
||||
if ((mode & R_CORE_BIN_SET)) {
|
||||
if (r_config_get_i (r->config, "bin.strings"))
|
||||
r_flag_space_set (r->flags, "strings");
|
||||
r_cons_break (NULL, NULL);
|
||||
r_list_foreach (list, iter, string) {
|
||||
if (r_cons_singleton()->breaked) break;
|
||||
/* Jump the withespaces before the string */
|
||||
for (i=0; *(string->string+i)==' '; i++);
|
||||
r_meta_add (r->anal->meta, R_META_TYPE_STRING,
|
||||
@ -64,6 +66,7 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
|
||||
va? baddr+string->rva:string->offset,
|
||||
string->size, 0);
|
||||
}
|
||||
r_cons_break_end ();
|
||||
} else {
|
||||
if (mode) r_cons_printf ("fs strings\n");
|
||||
else r_cons_printf ("[strings]\n");
|
||||
@ -147,7 +150,8 @@ static int bin_info (RCore *r, int mode) {
|
||||
r_config_set (r->config, "anal.plugin", info->arch);
|
||||
snprintf (str, R_FLAG_NAME_SIZE, "%i", info->bits);
|
||||
r_config_set (r->config, "asm.bits", str);
|
||||
r_config_set (r->config, "asm.dwarf", R_BIN_DBG_STRIPPED (info->dbg_info)?"false":"true");
|
||||
r_config_set (r->config, "asm.dwarf",
|
||||
R_BIN_DBG_STRIPPED (info->dbg_info)?"false":"true");
|
||||
}
|
||||
} else {
|
||||
if (mode) {
|
||||
@ -226,7 +230,9 @@ static int bin_dwarf (RCore *core, int mode) {
|
||||
}
|
||||
}
|
||||
if (!list) return R_FALSE;
|
||||
r_cons_break (NULL, NULL);
|
||||
r_list_foreach (list, iter, row) {
|
||||
if (r_cons_singleton()->breaked) break;
|
||||
if (mode) {
|
||||
// TODO: use 'Cl' instead of CC
|
||||
const char *path = row->file;
|
||||
@ -249,6 +255,7 @@ static int bin_dwarf (RCore *core, int mode) {
|
||||
r_cons_printf ("0x%08"PFMT64x"\t%s\t%d\n", row->address, row->file, row->line);
|
||||
}
|
||||
}
|
||||
r_cons_break_end ();
|
||||
r_list_destroy (list);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
@ -82,23 +82,12 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
|
||||
} else
|
||||
if (str[0]=='$') {
|
||||
*ok = 1;
|
||||
r_anal_op (core->anal, &op, core->offset, core->block, core->blocksize);
|
||||
/* debug */ // XXX spaguetti!
|
||||
if (!strcmp (str+1, "pc")) {
|
||||
return r_debug_reg_get (core->dbg, "pc");
|
||||
} else if (!strcmp (str+1, "sp")) {
|
||||
return r_debug_reg_get (core->dbg, "sp");
|
||||
} else if (!strcmp (str+1, "bp")) {
|
||||
return r_debug_reg_get (core->dbg, "bp");
|
||||
} else if (!strcmp (str+1, "a0")) {
|
||||
return r_debug_reg_get (core->dbg, "a0");
|
||||
} else if (!strcmp (str+1, "a1")) {
|
||||
return r_debug_reg_get (core->dbg, "a1");
|
||||
} else if (!strcmp (str+1, "a2")) {
|
||||
return r_debug_reg_get (core->dbg, "a2");
|
||||
}
|
||||
/* other */
|
||||
// TODO: group analop-dependant vars after a char, so i can filter
|
||||
r_anal_op (core->anal, &op, core->offset,
|
||||
core->block, core->blocksize);
|
||||
switch (str[1]) {
|
||||
case '.': // can use pc, sp, a0, a1, ...
|
||||
return r_debug_reg_get (core->dbg, str+2);
|
||||
case '{':
|
||||
{
|
||||
char *ptr, *bptr = strdup (str+2);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2012 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2010-2012 - pancake */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_list.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2012 - pancake */
|
||||
|
||||
#include <r_util.h>
|
||||
|
||||
@ -6,6 +6,9 @@
|
||||
|
||||
static int r_name_validate_char(const char ch) {
|
||||
switch (ch) {
|
||||
case '{':
|
||||
case '}':
|
||||
case '$':
|
||||
case '=':
|
||||
case '*':
|
||||
case '/':
|
||||
|
@ -634,6 +634,10 @@ R_API void r_str_sanitize(char *c) {
|
||||
char *d = c;
|
||||
for (; *d; c++, d++) {
|
||||
switch (*d) {
|
||||
case '`':
|
||||
case '$':
|
||||
case '{':
|
||||
case '}':
|
||||
case '~':
|
||||
case '|':
|
||||
case ';':
|
||||
@ -643,7 +647,8 @@ R_API void r_str_sanitize(char *c) {
|
||||
case '<':
|
||||
case '>':
|
||||
d++;
|
||||
break;
|
||||
*c = '_';
|
||||
continue;
|
||||
}
|
||||
*c = *d;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user