Skip to content

Commit

Permalink
Fix t/cmd_pd_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Nov 18, 2014
1 parent 71f7fbb commit c90add5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,8 @@ static int handle_read_refptr (RCore *core, RDisasmState *ds, ut64 *word8, ut32
/* convert numeric value in opcode to ascii char or number */
static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
ut64 p = ds->analop.ptr;
int aligned = 0;
#define DOALIGN() if (!aligned) { handle_comment_align (core, ds); aligned = 1; }
if (!ds->show_comments)
return;
if (p == UT64_MAX) {
Expand Down Expand Up @@ -1585,13 +1587,14 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
*msg = 0;
else msg[sizeof (msg)-1] = 0;
#endif
handle_comment_align (core, ds);
f = r_flag_get_i (core->flags, p);
if (f) {
r_str_filter (msg, 0);
if (ds->show_color) {
DOALIGN();
r_cons_printf ("%s", ds->pal_comment);
}
DOALIGN();
if (*msg) {
r_cons_printf (" ; \"%s\" @ 0x%"PFMT64x, msg, p);
} else {
Expand All @@ -1601,13 +1604,16 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
r_cons_printf (Color_RESET);
} else {
if (p==UT64_MAX || p==UT32_MAX) {
DOALIGN();
r_cons_printf (" ; -1", p);
} else if (p>='!' && p<='~') {
DOALIGN();
r_cons_printf (" ; '%c'", p);
} else if (p>10) {
if ((st64)p<0) {
// resolve local var if possible
RAnalVar *v = r_anal_var_get (core->anal, ds->at, 'v', 1, (int)p);
DOALIGN();
if (v) {
r_cons_printf (" ; var %s", v->name);
r_anal_var_free (v);
Expand All @@ -1617,9 +1623,11 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
} else {
if (r_core_anal_address (core, p) & R_ANAL_ADDR_TYPE_ASCII) {
r_str_filter (msg, 0);
if (*msg)
if (*msg) {
DOALIGN();
r_cons_printf (" ; \"%s\" 0x%08"PFMT64x" ",
msg, p);
}
}
}
}
Expand All @@ -1630,6 +1638,7 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
if (*msg) {
if (ds->show_color)
r_cons_printf (ds->pal_comment);
DOALIGN();
r_cons_printf (" ; \"%s\" @ 0x%"PFMT64x, msg, p);
if (ds->show_color)
r_cons_printf (Color_RESET);
Expand All @@ -1639,6 +1648,7 @@ static void handle_print_ptr (RCore *core, RDisasmState *ds, int len, int idx) {
if (*n>-0xfff && *n < 0xfff) {
if (ds->show_color)
r_cons_printf (ds->pal_comment);
DOALIGN();
r_cons_printf (" ; %d", *n);
if (ds->show_color)
r_cons_printf (Color_RESET);
Expand Down
6 changes: 6 additions & 0 deletions libr/parse/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ static int filter(RParse *p, RFlag *f, char *data, char *str, int len) {
int x86 = (p&&p->cur&&p->cur->name)?
(strstr (p->cur->name, "x86")? 1: 0): 0;
if (!data || !p) return 0;
#if FILTER_DWORD
ptr2 = strstr (ptr, "dword ");
if (ptr2)
memmove (ptr2, ptr2+6, strlen (ptr2+6)+1);
#endif
ptr2 = NULL;
// remove "dword" ?
while ((ptr = strstr (ptr, "0x"))) {
if (x86) for (ptr2 = ptr; *ptr2 && !isx86separator (*ptr2); ptr2++);
else for (ptr2 = ptr; *ptr2 && ((*ptr2=='\x1b')||!isseparator (*ptr2)); ptr2++);
Expand Down

0 comments on commit c90add5

Please sign in to comment.