Implemented 'zp' command

This commit is contained in:
Dax 2015-12-24 11:56:12 +01:00 committed by pancake
parent d6974f7081
commit e350505f7b
3 changed files with 10 additions and 1 deletions

View File

@ -54,6 +54,7 @@ R_API bool r_sign_add(RSign *sig, RAnal *anal, int type, const char *name, const
break;
case R_SIGN_HEAD: // function prefix (push ebp..)
case R_SIGN_BYTE: // function mask
case R_SIGN_BODY: // function body
if (!(data = r_anal_strmask (anal, arg))) {
r_sign_item_free (si);
break;
@ -75,6 +76,8 @@ R_API bool r_sign_add(RSign *sig, RAnal *anal, int type, const char *name, const
sig->s_head++;
else if (type==R_SIGN_BYTE)
sig->s_byte++;
else if(type == R_SIGN_BODY)
sig->s_func++;
}
break;
default:
@ -181,7 +184,7 @@ R_API RSignItem *r_sign_check(RSign *sig, const ut8 *buf, int len) {
return NULL;
r_list_foreach (sig->items, iter, si) {
if (si->type == R_SIGN_BYTE) {
if ((si->type == R_SIGN_BYTE) || (si->type == R_SIGN_BODY)) {
int l = (len>si->size)?si->size:len;
if (!r_mem_cmp_mask (buf, si->bytes, si->mask, l))
return si;

View File

@ -84,6 +84,7 @@ static int cmd_zign(void *data, const char *input) {
case 'b':
case 'h':
case 'f':
case 'p':
if (*(input+1) == '\0' || *(input+2) == '\0')
eprintf ("Usage: z%c [name] [arg]\n", *input);
else{
@ -156,6 +157,9 @@ static int cmd_zign(void *data, const char *input) {
if (si->type == 'f')
r_cons_printf ("f sign.fun_%s_%d @ 0x%08"PFMT64x"\n",
si->name, idx, ini+idx); //core->offset);
else if(si->type == 'p')
r_cons_printf ("afn sign.fun_%s_%d 0x%08"PFMT64x"\n",
si->name, idx, ini+idx);
else r_cons_printf ("f sign.%s @ 0x%08"PFMT64x"\n",
si->name, ini+idx); //core->offset+idx);
eprintf ("- Found %d matching function signatures\r", count);
@ -214,6 +218,7 @@ static int cmd_zign(void *data, const char *input) {
"zn", " namespace", "Define namespace for following zignatures (until zn-)",
"zn", "", "Display current namespace",
"zn-", "", "Unset namespace",
"zp", " name bytes", "define new zignature for function body",
"NOTE:", "", "bytes can contain '.' (dots) to specify a binary mask",
NULL};
r_core_cmd_help (core, help_msg);

View File

@ -17,6 +17,7 @@ enum {
R_SIGN_FUNC = 'f',
R_SIGN_HEAD = 'h',
R_SIGN_ANAL = 'a',
R_SIGN_BODY = 'p',
};
/* signature struct */