2014-03-12 03:23:50 +01:00
|
|
|
/* radare - LGPL - Copyright 2010-2014 - nibble, pancake */
|
2010-03-12 03:05:20 +01:00
|
|
|
|
|
|
|
#include <r_anal.h>
|
|
|
|
#include <r_util.h>
|
|
|
|
#include <r_list.h>
|
|
|
|
|
2014-03-12 03:23:50 +01:00
|
|
|
// NOTE: This file uses the xrefs api which is sdb based
|
2010-09-28 13:58:03 +02:00
|
|
|
R_API RAnalRef *r_anal_ref_new() {
|
2010-06-14 00:57:40 +02:00
|
|
|
RAnalRef *ref = R_NEW (RAnalRef);
|
|
|
|
if (ref) {
|
|
|
|
ref->addr = -1;
|
2010-08-02 12:42:59 +02:00
|
|
|
ref->at = -1;
|
2010-09-28 13:58:03 +02:00
|
|
|
ref->type = R_ANAL_REF_TYPE_CODE;
|
2010-06-14 00:57:40 +02:00
|
|
|
}
|
2010-05-20 17:40:58 +02:00
|
|
|
return ref;
|
2010-03-12 03:05:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
R_API RList *r_anal_ref_list_new() {
|
|
|
|
RList *list = r_list_new ();
|
|
|
|
list->free = &r_anal_ref_free;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_API void r_anal_ref_free(void *ref) {
|
|
|
|
free (ref);
|
|
|
|
}
|
2010-09-28 13:58:03 +02:00
|
|
|
|
2013-07-19 03:35:45 +02:00
|
|
|
// TODO: use sdb or hashmap for fucks sake
|
2010-09-28 13:58:03 +02:00
|
|
|
R_API int r_anal_ref_add(RAnal *anal, ut64 addr, ut64 at, int type) {
|
2013-07-19 03:35:45 +02:00
|
|
|
const char *types = type=='c'?"jmp":
|
2014-01-20 00:14:00 +01:00
|
|
|
type=='C'?"call": type=='s'?"string": "data";
|
2013-07-19 03:35:45 +02:00
|
|
|
r_anal_xrefs_set (anal, types, at, addr);
|
2013-07-23 17:11:51 +02:00
|
|
|
return R_TRUE;
|
2010-09-28 13:58:03 +02:00
|
|
|
}
|
|
|
|
|
2013-07-19 03:35:45 +02:00
|
|
|
R_API int r_anal_ref_del(RAnal *anal, ut64 at, ut64 addr) {
|
|
|
|
r_anal_xrefs_deln (anal, "code", at, addr);
|
|
|
|
r_anal_xrefs_deln (anal, "data", at, addr);
|
2010-09-28 13:58:03 +02:00
|
|
|
return R_TRUE;
|
|
|
|
}
|
2010-09-28 18:05:31 +02:00
|
|
|
|
2013-04-23 03:38:39 +02:00
|
|
|
R_API RList *r_anal_xrefs_get (RAnal *anal, ut64 addr);
|
2013-04-16 19:48:59 +02:00
|
|
|
// XXX: MAJOR SLOWDOWN PLZ FIX
|
2010-09-28 18:05:31 +02:00
|
|
|
R_API RList *r_anal_xref_get(RAnal *anal, ut64 addr) {
|
2013-07-19 03:35:45 +02:00
|
|
|
return r_anal_xrefs_get (anal, addr);
|
|
|
|
}
|