Initial support for xref sizes ##analysis

This commit is contained in:
pancake 2023-11-21 23:56:12 +01:00 committed by pancake
parent 90de71bcbc
commit 0ec20ce172
3 changed files with 29 additions and 6 deletions

View File

@ -344,11 +344,11 @@ static void r_anal_xrefs_list_table(RAnal *anal, RVecAnalRef *anal_refs, const c
if (!t) {
t = ' ';
}
char *fromname = anal->coreb.getNameDelta (anal->coreb.core, ref->addr);
char *toname = anal->coreb.getNameDelta (anal->coreb.core, ref->at);
r_table_add_rowf (table, "xxnssss",
ref->at, ref->addr, ref->size,
ref->at, ref->addr,
r_anal_ref_size (ref),
r_anal_ref_type_tostring (t),
r_anal_ref_perm_tostring (ref),
toname, fromname
@ -597,6 +597,20 @@ R_API const char *r_anal_ref_perm_tostring(RAnalRef *ref) {
return r_str_rwx_i (perm);
}
R_API int r_anal_ref_size(RAnalRef *ref) {
int size = R_ANAL_REF_TYPE_SIZE (ref->type);
if (size) {
return size;
}
switch (R_ANAL_REF_TYPE_MASK (ref->type)) {
case R_ANAL_REF_TYPE_ICOD:
return 4; // or 8?
case R_ANAL_REF_TYPE_DATA:
return 4; // or 8?
}
return 0;
}
R_API const char *r_anal_ref_type_tostring(RAnalRefType type) {
switch (R_ANAL_REF_TYPE_MASK (type)) {
case ' ':

View File

@ -10096,12 +10096,13 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
}
const char *typestr = r_anal_ref_type_tostring (ref->type);
const char *permstr = r_anal_ref_perm_tostring (ref);
int size = r_anal_ref_size (ref);
r_table_add_rowf (table, "sxxxnss",
fcn_name,
fcn_addr,
ref->addr,
addr,
ref->size,
size,
typestr,
permstr
);

View File

@ -631,22 +631,29 @@ typedef enum {
R_ANAL_REF_TYPE_DATA = 'd', // mem ref
R_ANAL_REF_TYPE_ICOD = 'i', // indirect code reference
R_ANAL_REF_TYPE_STRN = 's', // string ref
R_ANAL_REF_TYPE_MASK = 0xff,
// perm / direction
R_ANAL_REF_TYPE_READ = 4 << 8,
R_ANAL_REF_TYPE_WRITE = 2 << 8,
R_ANAL_REF_TYPE_EXEC = 1 << 8,
R_ANAL_REF_TYPE_MASK = 0xff,
R_ANAL_REF_TYPE_DIRECTION_MASK = 0xff00
R_ANAL_REF_PERM_MASK = 0xff00, // direction -> perm
R_ANAL_REF_DIRECTION_MASK = 0xff00, // direction -> perm
// SIZE
R_ANAL_REF_TYPE_SIZE_1 = 1 << 16,
R_ANAL_REF_TYPE_SIZE_2 = 2 << 16,
R_ANAL_REF_TYPE_SIZE_4 = 4 << 16,
R_ANAL_REF_TYPE_SIZE_8 = 8 << 16,
R_ANAL_REF_SIZE_MASK = 0xff0000
} RAnalRefType;
#define R_ANAL_REF_TYPE_PERM(x) (((x)>>8) & 0xff)
#define R_ANAL_REF_TYPE_MASK(x) r_anal_ref_typemask((x))
#define R_ANAL_REF_TYPE_SIZE(x) (((x)>>16) & 0xff)
typedef struct r_anal_ref_t {
ut64 at;
ut64 addr;
RAnalRefType type;
ut8 size;
} RAnalRef;
typedef struct r_vec_RVecAnalRef_t RVecAnalRef;
@ -1073,6 +1080,7 @@ R_API bool r_anal_pin_set(RAnal *a, const char *name, const char *cmd);
typedef bool (* RAnalRefCmp)(RAnalRef *ref, void *data);
R_API RList *r_anal_ref_list_new(void);
R_API const char *r_anal_ref_type_tostring(RAnalRefType t);
R_API int r_anal_ref_size(RAnalRef *ref);
R_API int r_anal_ref_typemask(int x);
R_DEPRECATE R_API RAnalRefType r_anal_xrefs_type(char ch);