Fix #6060 - Add Cr command to run commands in meta for disasm

This commit is contained in:
pancake 2016-11-06 01:16:02 +01:00
parent babfd7e10a
commit b04e1f2c4c
4 changed files with 21 additions and 15 deletions

View File

@ -250,11 +250,13 @@ R_API int r_meta_add(RAnal *a, int type, ut64 from, ut64 to, const char *str) {
int space_idx = a->meta_spaces.space_idx;
char *e_str, key[100], val[2048];
int exists;
if (from > to)
if (from > to) {
return false;
if (from == to)
}
if (from == to) {
to = from + 1;
if (type == 100 && (to-from)<1) {
}
if (type == 100 && (to - from) < 1) {
return false;
}
/* set entry */

View File

@ -64,38 +64,34 @@ static int print_addrinfo (void *user, const char *k, const char *v) {
char *colonpos, *subst;
offset = sdb_atoi (v);
if (!offset)
if (!offset) {
return true;
}
subst = strdup (k);
colonpos = strchr (subst, '|');
if (colonpos)
if (colonpos) {
*colonpos = ':';
}
r_cons_printf ("CL %s %s\n", subst, v);
free (subst);
return true;
}
static int cmd_meta_add_fileline(Sdb *s, char *fileline, ut64 offset) {
char aoffset[64], *aoffsetptr;
char aoffset[64];
char *aoffsetptr = sdb_itoa (offset, aoffset, 16);
aoffsetptr = sdb_itoa (offset, aoffset, 16);
if (!aoffsetptr)
if (!aoffsetptr) {
return -1;
}
if (!sdb_add (s, aoffsetptr, fileline, 0)) {
sdb_set (s, aoffsetptr, fileline, 0);
}
if (!sdb_add (s, fileline, aoffsetptr, 0)) {
sdb_set (s, fileline, aoffsetptr, 0);
}
return 0;
}
@ -729,6 +725,7 @@ static int cmd_meta(void *data, const char *input) {
case 'C': // "CC"
cmd_meta_comment (core, input);
break;
case 'r': /* Cr run command*/
case 'h': /* Ch comment */
case 's': /* Cs string */
case 'z': /* Cz zero-terminated string */

View File

@ -1908,6 +1908,12 @@ static int ds_print_meta_infos(RDisasmState *ds, ut8* buf, int len, int idx) {
ds->oplen = mi->size;
ds->mi_found = 1;
break;
case R_META_TYPE_RUN:
r_core_cmdf (core, "%s @ 0x%"PFMT64x, mi->str, ds->at);
ds->asmop.size = mi->size;
ds->oplen = mi->size;
ds->mi_found = 1;
break;
case R_META_TYPE_DATA:
hexlen = len - idx;
delta = ds->at-mi->from;

View File

@ -311,6 +311,7 @@ enum {
R_META_TYPE_MAGIC = 'm',
R_META_TYPE_HIDE = 'h',
R_META_TYPE_COMMENT = 'C',
R_META_TYPE_RUN = 'r',
};
// anal