2019-03-16 10:20:20 +01:00
|
|
|
/* radare2 - LGPL - Copyright 2009-2019 - nibble, pancake, xvilka */
|
2009-02-06 18:22:27 +01:00
|
|
|
|
2014-03-27 16:34:17 +01:00
|
|
|
#ifndef R2_ANAL_H
|
|
|
|
#define R2_ANAL_H
|
2009-02-06 18:22:27 +01:00
|
|
|
|
2014-09-23 00:40:35 +02:00
|
|
|
/* use old refs and function storage */
|
|
|
|
// still required by core in lot of places
|
2014-03-31 03:05:48 +02:00
|
|
|
#define FCN_OLD 1
|
2014-02-19 04:18:25 +01:00
|
|
|
#define USE_VARSUBS 0
|
|
|
|
|
2010-02-26 13:08:42 +01:00
|
|
|
#include <r_types.h>
|
2011-02-03 00:20:39 +01:00
|
|
|
#include <r_io.h>
|
2010-06-16 09:42:46 +02:00
|
|
|
#include <r_reg.h>
|
2010-02-26 13:08:42 +01:00
|
|
|
#include <r_list.h>
|
2010-05-24 11:15:32 +02:00
|
|
|
#include <r_util.h>
|
2016-09-26 17:04:26 +02:00
|
|
|
#include <r_bind.h>
|
2011-02-02 13:05:48 +01:00
|
|
|
#include <r_syscall.h>
|
2016-10-27 01:02:26 +02:00
|
|
|
#include <r_flag.h>
|
2014-01-10 10:20:23 -06:00
|
|
|
#include <r_bin.h>
|
2009-02-16 00:57:03 +01:00
|
|
|
|
2018-03-14 23:43:53 +01:00
|
|
|
#define esilprintf(op, fmt, ...) r_strbuf_setf (&op->esil, fmt, ##__VA_ARGS__)
|
|
|
|
|
2013-06-18 12:09:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-06-14 02:51:33 +02:00
|
|
|
R_LIB_VERSION_HEADER(r_anal);
|
|
|
|
|
2011-11-15 09:56:22 +01:00
|
|
|
// TODO: save memory2 : fingerprints must be pointers to a buffer
|
|
|
|
// containing a dupped file in memory
|
|
|
|
|
|
|
|
/* save memory:
|
2012-07-17 10:00:23 +02:00
|
|
|
bb_has_ops=1 -> 600M
|
2011-11-15 09:56:22 +01:00
|
|
|
bb_has_ops=0 -> 350MB
|
2015-10-22 03:11:03 +02:00
|
|
|
*/
|
2013-02-12 02:42:34 +01:00
|
|
|
|
2011-03-02 00:02:50 +01:00
|
|
|
/* meta */
|
2014-01-23 03:28:25 +01:00
|
|
|
typedef struct r_anal_meta_item_t {
|
2011-03-02 00:02:50 +01:00
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
|
|
|
ut64 size;
|
|
|
|
int type;
|
2017-10-21 15:28:42 +08:00
|
|
|
int subtype;
|
2011-03-02 00:02:50 +01:00
|
|
|
char *str;
|
2019-01-28 16:41:42 +01:00
|
|
|
const RSpace *space;
|
2014-01-23 04:34:59 +01:00
|
|
|
} RAnalMetaItem;
|
2011-03-02 00:02:50 +01:00
|
|
|
|
2015-06-01 03:05:15 +02:00
|
|
|
typedef struct {
|
|
|
|
struct r_anal_t *anal;
|
|
|
|
int type;
|
|
|
|
int rad;
|
|
|
|
SdbForeachCallback cb;
|
|
|
|
void *user;
|
2015-06-15 04:19:29 +02:00
|
|
|
int count;
|
2018-11-22 15:41:33 +01:00
|
|
|
struct r_anal_function_t *fcn;
|
2015-06-01 03:05:15 +02:00
|
|
|
} RAnalMetaUserItem;
|
|
|
|
|
2014-11-03 04:05:19 +01:00
|
|
|
typedef struct r_anal_range_t {
|
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
2016-08-10 18:49:44 +02:00
|
|
|
int bits;
|
2018-11-22 21:31:54 +01:00
|
|
|
ut64 rb_max_addr;
|
|
|
|
RBNode rb;
|
2014-11-03 04:05:19 +01:00
|
|
|
} RAnalRange;
|
2012-07-17 07:08:52 +04:00
|
|
|
|
2012-08-29 12:59:31 +02:00
|
|
|
#define R_ANAL_UNMASK_TYPE(x) (x&R_ANAL_VAR_TYPE_SIZE_MASK)
|
2013-06-05 16:10:00 +02:00
|
|
|
#define R_ANAL_UNMASK_SIGN(x) (((x& R_ANAL_VAR_TYPE_SIGN_MASK)>> R_ANAL_VAR_TYPE_SIGN_SHIFT)==R_ANAL_VAR_TYPE_UNSIGNED)?0:1
|
2012-08-29 12:59:31 +02:00
|
|
|
|
2016-05-14 10:39:39 +02:00
|
|
|
#define R_ANAL_GET_OFFSET(x,y,z) \
|
|
|
|
(x && x->binb.bin && x->binb.get_offset)? \
|
|
|
|
x->binb.get_offset (x->binb.bin, y, z): -1
|
2012-11-20 03:59:00 +01:00
|
|
|
enum {
|
|
|
|
R_ANAL_DATA_TYPE_NULL = 0,
|
2014-10-15 02:24:22 +02:00
|
|
|
R_ANAL_DATA_TYPE_UNKNOWN = 1,
|
|
|
|
R_ANAL_DATA_TYPE_STRING = 2,
|
|
|
|
R_ANAL_DATA_TYPE_WIDE_STRING = 3,
|
|
|
|
R_ANAL_DATA_TYPE_POINTER = 4,
|
|
|
|
R_ANAL_DATA_TYPE_NUMBER = 5,
|
|
|
|
R_ANAL_DATA_TYPE_INVALID = 6,
|
|
|
|
R_ANAL_DATA_TYPE_HEADER = 7,
|
|
|
|
R_ANAL_DATA_TYPE_SEQUENCE = 8,
|
|
|
|
R_ANAL_DATA_TYPE_PATTERN = 9,
|
2012-11-20 03:59:00 +01:00
|
|
|
};
|
|
|
|
|
2014-10-15 02:24:22 +02:00
|
|
|
// used from core/anal.c
|
2014-10-24 21:31:46 +02:00
|
|
|
#define R_ANAL_ADDR_TYPE_EXEC 1
|
2015-10-05 14:43:17 +02:00
|
|
|
#define R_ANAL_ADDR_TYPE_READ 1 << 1
|
|
|
|
#define R_ANAL_ADDR_TYPE_WRITE 1 << 2
|
|
|
|
#define R_ANAL_ADDR_TYPE_FLAG 1 << 3
|
|
|
|
#define R_ANAL_ADDR_TYPE_FUNC 1 << 4
|
|
|
|
#define R_ANAL_ADDR_TYPE_HEAP 1 << 5
|
|
|
|
#define R_ANAL_ADDR_TYPE_STACK 1 << 6
|
|
|
|
#define R_ANAL_ADDR_TYPE_REG 1 << 7
|
|
|
|
#define R_ANAL_ADDR_TYPE_PROGRAM 1 << 8
|
|
|
|
#define R_ANAL_ADDR_TYPE_LIBRARY 1 << 9
|
|
|
|
#define R_ANAL_ADDR_TYPE_ASCII 1 << 10
|
|
|
|
#define R_ANAL_ADDR_TYPE_SEQUENCE 1 << 11
|
2014-10-15 02:24:22 +02:00
|
|
|
|
2015-10-14 02:11:53 +02:00
|
|
|
#define R_ANAL_ARCHINFO_MIN_OP_SIZE 0
|
|
|
|
#define R_ANAL_ARCHINFO_MAX_OP_SIZE 1
|
|
|
|
#define R_ANAL_ARCHINFO_ALIGN 2
|
2017-08-01 14:51:29 +02:00
|
|
|
#define R_ANAL_ARCHINFO_DATA_ALIGN 4
|
2015-10-14 02:11:53 +02:00
|
|
|
|
2016-12-15 00:14:33 +01:00
|
|
|
/* copypaste from r_asm.h */
|
|
|
|
|
|
|
|
#define R_ANAL_GET_OFFSET(x,y,z) \
|
|
|
|
(x && x->binb.bin && x->binb.get_offset)? \
|
|
|
|
x->binb.get_offset (x->binb.bin, y, z): -1
|
|
|
|
|
|
|
|
#define R_ANAL_GET_NAME(x,y,z) \
|
|
|
|
(x && x->binb.bin && x->binb.get_name)? \
|
|
|
|
x->binb.get_name (x->binb.bin, y, z): NULL
|
|
|
|
|
2012-07-17 07:08:52 +04:00
|
|
|
/* type = (R_ANAL_VAR_TYPE_BYTE & R_ANAL_VAR_TYPE_SIZE_MASK) |
|
|
|
|
* ( RANAL_VAR_TYPE_SIGNED & RANAL_VAR_TYPE_SIGN_MASK) |
|
|
|
|
* ( RANAL_VAR_TYPE_CONST & RANAL_VAR_TYPE_MODIFIER_MASK)
|
2012-09-28 02:20:52 +02:00
|
|
|
*/
|
2012-07-17 07:08:52 +04:00
|
|
|
typedef struct r_anal_type_var_t {
|
|
|
|
char *name;
|
2014-04-04 03:42:22 +02:00
|
|
|
int index;
|
|
|
|
int scope;
|
2012-07-19 06:54:22 +04:00
|
|
|
ut16 type; // contain (type || signedness || modifier)
|
2012-07-17 07:08:52 +04:00
|
|
|
ut8 size;
|
|
|
|
union {
|
2015-04-16 06:42:07 +02:00
|
|
|
ut8 v8;
|
2012-07-17 07:08:52 +04:00
|
|
|
ut16 v16;
|
|
|
|
ut32 v32;
|
|
|
|
ut64 v64;
|
|
|
|
} value;
|
|
|
|
} RAnalTypeVar;
|
|
|
|
|
|
|
|
typedef struct r_anal_type_ptr_t {
|
|
|
|
char *name;
|
2012-07-19 06:54:22 +04:00
|
|
|
ut16 type; // contain (type || signedness || modifier)
|
2012-07-17 07:08:52 +04:00
|
|
|
ut8 size;
|
|
|
|
union {
|
2015-04-16 06:42:07 +02:00
|
|
|
ut8 v8;
|
2012-07-17 07:08:52 +04:00
|
|
|
ut16 v16;
|
|
|
|
ut32 v32;
|
|
|
|
ut64 v64;
|
|
|
|
} value;
|
|
|
|
} RAnalTypePtr;
|
|
|
|
|
|
|
|
typedef struct r_anal_type_array_t {
|
|
|
|
char *name;
|
2012-07-19 06:54:22 +04:00
|
|
|
ut16 type; // contain (type || signedness || modifier)
|
2012-07-17 07:08:52 +04:00
|
|
|
ut8 size;
|
|
|
|
ut64 count;
|
|
|
|
union {
|
2012-11-20 12:17:46 +01:00
|
|
|
ut8 *v8;
|
2012-07-17 07:08:52 +04:00
|
|
|
ut16 *v16;
|
|
|
|
ut32 *v32;
|
|
|
|
ut64 *v64;
|
|
|
|
} value;
|
|
|
|
} RAnalTypeArray;
|
|
|
|
|
|
|
|
typedef struct r_anal_type_struct_t RAnalTypeStruct;
|
|
|
|
typedef struct r_anal_type_t RAnalType;
|
|
|
|
|
|
|
|
struct r_anal_type_struct_t {
|
|
|
|
char *name;
|
|
|
|
ut8 type;
|
|
|
|
ut32 size;
|
|
|
|
void *parent;
|
|
|
|
RAnalType *items;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct r_anal_type_union_t {
|
|
|
|
char *name;
|
|
|
|
ut8 type;
|
|
|
|
ut32 size;
|
|
|
|
void *parent;
|
|
|
|
RAnalType *items;
|
|
|
|
} RAnalTypeUnion;
|
|
|
|
|
2012-08-28 06:56:59 +04:00
|
|
|
typedef struct r_anal_type_alloca_t {
|
|
|
|
long address;
|
|
|
|
long size;
|
|
|
|
void *parent;
|
|
|
|
RAnalType *items;
|
|
|
|
} RAnalTypeAlloca;
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
enum {
|
|
|
|
R_ANAL_FQUALIFIER_NONE = 0,
|
|
|
|
R_ANAL_FQUALIFIER_STATIC = 1,
|
|
|
|
R_ANAL_FQUALIFIER_VOLATILE = 2,
|
|
|
|
R_ANAL_FQUALIFIER_INLINE = 3,
|
|
|
|
R_ANAL_FQUALIFIER_NAKED = 4,
|
|
|
|
R_ANAL_FQUALIFIER_VIRTUAL = 5,
|
|
|
|
};
|
|
|
|
|
2018-10-30 22:43:28 +00:00
|
|
|
/*--------------------Function Conventions-----------*/
|
2019-06-20 12:45:00 +08:00
|
|
|
//XXX don't use them in the future
|
2016-08-04 22:52:33 +02:00
|
|
|
#define R_ANAL_CC_TYPE_STDCALL 0
|
|
|
|
#define R_ANAL_CC_TYPE_PASCAL 1
|
2016-04-22 19:33:23 +02:00
|
|
|
#define R_ANAL_CC_TYPE_FASTCALL 'A' // syscall
|
2016-04-21 21:19:01 +02:00
|
|
|
#define R_ANAL_CC_TYPE_SYSV 8
|
2012-07-19 06:54:22 +04:00
|
|
|
|
|
|
|
enum {
|
2016-07-25 21:24:19 +02:00
|
|
|
R_ANAL_FCN_TYPE_NULL = 0,
|
|
|
|
R_ANAL_FCN_TYPE_FCN = 1 << 0,
|
|
|
|
R_ANAL_FCN_TYPE_LOC = 1 << 1,
|
|
|
|
R_ANAL_FCN_TYPE_SYM = 1 << 2,
|
|
|
|
R_ANAL_FCN_TYPE_IMP = 1 << 3,
|
2019-06-20 12:45:00 +08:00
|
|
|
R_ANAL_FCN_TYPE_INT = 1 << 4, /* privileged function - ends with iret/reti/.. */
|
2016-07-25 21:24:19 +02:00
|
|
|
R_ANAL_FCN_TYPE_ROOT = 1 << 5 /* matching flag */
|
2012-07-19 06:54:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define R_ANAL_VARSUBS 32
|
|
|
|
|
2017-02-15 22:42:24 +01:00
|
|
|
#define RAnalBlock struct r_anal_bb_t
|
2017-02-08 11:34:08 +00:00
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
typedef struct r_anal_varsub_t {
|
2012-08-07 16:53:09 +02:00
|
|
|
char pat[128];
|
|
|
|
char sub[128];
|
2012-07-19 06:54:22 +04:00
|
|
|
} RAnalVarSub;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_DIFF_TYPE_NULL = 0,
|
|
|
|
R_ANAL_DIFF_TYPE_MATCH = 'm',
|
|
|
|
R_ANAL_DIFF_TYPE_UNMATCH = 'u'
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct r_anal_diff_t {
|
|
|
|
int type;
|
|
|
|
ut64 addr;
|
|
|
|
double dist;
|
|
|
|
char *name;
|
2015-10-27 05:13:46 +08:00
|
|
|
ut32 size;
|
2012-07-19 06:54:22 +04:00
|
|
|
} RAnalDiff;
|
|
|
|
|
2012-08-28 06:56:59 +04:00
|
|
|
typedef struct r_anal_locals_t {
|
|
|
|
RAnalType *items;
|
|
|
|
} RAnalLocals;
|
|
|
|
|
2013-06-26 01:44:21 +04:00
|
|
|
typedef struct r_anal_fcn_local_t {
|
2014-03-31 03:05:48 +02:00
|
|
|
ut64 index;
|
2013-06-26 01:44:21 +04:00
|
|
|
char* name;
|
2014-03-31 03:05:48 +02:00
|
|
|
char* type;
|
2013-06-26 01:44:21 +04:00
|
|
|
} RAnalFcnLocal;
|
|
|
|
|
2012-09-07 03:26:32 +04:00
|
|
|
typedef struct r_anal_attr_t RAnalAttr;
|
|
|
|
struct r_anal_attr_t {
|
2012-09-07 02:32:26 +04:00
|
|
|
char *key;
|
|
|
|
long value;
|
2012-09-07 03:26:32 +04:00
|
|
|
RAnalAttr *next;
|
2012-09-07 02:32:26 +04:00
|
|
|
};
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
typedef struct r_anal_fcn_store_t {
|
2018-11-14 10:47:28 +01:00
|
|
|
HtPP *h;
|
2012-07-19 06:54:22 +04:00
|
|
|
RList *l;
|
|
|
|
} RAnalFcnStore;
|
|
|
|
|
2016-06-14 17:54:17 +02:00
|
|
|
/* Stores useful function metadata */
|
|
|
|
/* TODO: Think about moving more stuff to this structure? */
|
|
|
|
typedef struct r_anal_fcn_meta_t {
|
|
|
|
ut64 min; // min address
|
|
|
|
ut64 max; // max address
|
|
|
|
int numrefs; // number of cross references
|
|
|
|
int numcallrefs; // number of calls
|
|
|
|
int sgnc; // node cardinality of the functions callgraph
|
|
|
|
int sgec; // edge cardinality of the functions callgraph
|
|
|
|
} RAnalFcnMeta;
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
/* Store various function information,
|
|
|
|
* variables, arguments, refs and even
|
|
|
|
* description */
|
2018-11-22 03:05:46 +01:00
|
|
|
typedef struct r_anal_function_t {
|
2015-10-29 23:37:51 +01:00
|
|
|
char* name;
|
|
|
|
char* dsc; // For producing nice listings
|
2016-05-15 14:37:22 +02:00
|
|
|
ut32 _size;
|
2015-10-29 23:37:51 +01:00
|
|
|
int bits; // ((> bits 0) (set-bits bits))
|
2016-07-25 20:15:50 +02:00
|
|
|
int type;
|
2015-10-29 23:37:51 +01:00
|
|
|
/*item_list *rets; // Type of return value */
|
2016-07-05 23:44:53 +03:00
|
|
|
char *rets;
|
2015-10-29 23:37:51 +01:00
|
|
|
short fmod; // static, inline or volatile?
|
2016-07-27 14:50:14 +03:00
|
|
|
const char *cc; // calling convention
|
2015-10-29 23:37:51 +01:00
|
|
|
char* attr; // __attribute__(()) list
|
|
|
|
ut64 addr;
|
2019-03-06 22:04:06 +08:00
|
|
|
ut64 rb_max_addr; // maximum of meta.min + _size - 1 in the subtree, for fcn interval tree
|
2016-06-06 01:33:42 +03:00
|
|
|
int stack; //stack frame size
|
2016-05-16 03:46:23 +02:00
|
|
|
int maxstack;
|
2015-10-29 23:37:51 +01:00
|
|
|
int ninstr;
|
|
|
|
int nargs; // Function arguments counter
|
|
|
|
int depth;
|
2015-12-14 10:19:07 +01:00
|
|
|
bool folded;
|
2018-11-29 17:00:26 +01:00
|
|
|
bool is_pure;
|
|
|
|
bool has_changed; // true if function may have changed since last anaysis TODO: set this attribute where necessary
|
2019-04-14 17:40:53 +02:00
|
|
|
bool bp_frame;
|
2015-10-29 23:37:51 +01:00
|
|
|
RAnalType *args; // list of arguments
|
|
|
|
ut8 *fingerprint; // TODO: make is fuzzy and smarter
|
|
|
|
RAnalDiff *diff;
|
|
|
|
RList *locs; // list of local variables
|
2016-09-09 19:28:47 +02:00
|
|
|
RList *fcn_locs; //sorted list of a function *.loc refs
|
2015-10-29 23:37:51 +01:00
|
|
|
//RList *locals; // list of local labels -> moved to anal->sdb_fcns
|
|
|
|
RList *bbs;
|
2016-06-17 14:26:24 +02:00
|
|
|
RAnalFcnMeta meta;
|
2016-08-21 00:53:39 +02:00
|
|
|
RRangeTiny bbr;
|
2017-12-17 13:55:32 -08:00
|
|
|
RBNode rb;
|
2019-03-06 22:04:06 +08:00
|
|
|
RBNode addr_rb;
|
2019-06-29 02:44:36 +02:00
|
|
|
RList *imports; // maybe bound to class?
|
2015-10-29 23:37:51 +01:00
|
|
|
} RAnalFunction;
|
2012-07-17 07:08:52 +04:00
|
|
|
|
2018-02-22 10:51:41 +05:30
|
|
|
typedef struct r_anal_func_arg_t {
|
|
|
|
const char *name;
|
|
|
|
const char *fmt;
|
|
|
|
const char *cc_source;
|
|
|
|
char *orig_c_type;
|
|
|
|
char *c_type;
|
|
|
|
ut64 size;
|
|
|
|
ut64 src; //Function-call argument value or pointer to it
|
|
|
|
} RAnalFuncArg;
|
|
|
|
|
2012-07-17 07:08:52 +04:00
|
|
|
struct r_anal_type_t {
|
2012-07-19 06:54:22 +04:00
|
|
|
char *name;
|
2014-02-24 11:57:02 +01:00
|
|
|
ut32 type;
|
2016-07-05 23:44:53 +03:00
|
|
|
ut32 size;
|
|
|
|
RList *content;
|
2012-07-17 07:08:52 +04:00
|
|
|
};
|
|
|
|
|
2011-03-02 00:02:50 +01:00
|
|
|
enum {
|
|
|
|
R_META_WHERE_PREV = -1,
|
|
|
|
R_META_WHERE_HERE = 0,
|
|
|
|
R_META_WHERE_NEXT = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2018-12-01 23:44:29 +08:00
|
|
|
R_META_TYPE_NONE = 0,
|
2011-03-02 00:02:50 +01:00
|
|
|
R_META_TYPE_ANY = -1,
|
|
|
|
R_META_TYPE_DATA = 'd',
|
|
|
|
R_META_TYPE_CODE = 'c',
|
|
|
|
R_META_TYPE_STRING = 's',
|
|
|
|
R_META_TYPE_FORMAT = 'f',
|
|
|
|
R_META_TYPE_MAGIC = 'm',
|
2013-03-01 09:57:30 +01:00
|
|
|
R_META_TYPE_HIDE = 'h',
|
2011-03-02 00:02:50 +01:00
|
|
|
R_META_TYPE_COMMENT = 'C',
|
2016-11-06 01:16:02 +01:00
|
|
|
R_META_TYPE_RUN = 'r',
|
2017-06-20 22:48:46 +02:00
|
|
|
R_META_TYPE_HIGHLIGHT = 'H',
|
2018-07-20 12:45:51 +02:00
|
|
|
R_META_TYPE_VARTYPE = 't',
|
2011-03-02 00:02:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// anal
|
2009-04-02 10:23:32 +00:00
|
|
|
enum {
|
2015-10-03 13:52:52 +02:00
|
|
|
R_ANAL_OP_FAMILY_UNKNOWN = -1,
|
|
|
|
R_ANAL_OP_FAMILY_CPU = 0,/* normal cpu instruction */
|
2015-03-08 22:32:23 +01:00
|
|
|
R_ANAL_OP_FAMILY_FPU, /* fpu (floating point) */
|
|
|
|
R_ANAL_OP_FAMILY_MMX, /* multimedia instruction (packed data) */
|
2017-05-22 00:56:24 +02:00
|
|
|
R_ANAL_OP_FAMILY_SSE, /* extended multimedia instruction (packed data) */
|
2019-06-20 12:45:00 +08:00
|
|
|
R_ANAL_OP_FAMILY_PRIV, /* privileged instruction */
|
2015-03-08 22:32:23 +01:00
|
|
|
R_ANAL_OP_FAMILY_CRYPTO, /* cryptographic instructions */
|
2018-08-06 10:38:02 +02:00
|
|
|
R_ANAL_OP_FAMILY_THREAD, /* thread/lock/sync instructions */
|
2016-06-16 01:43:41 +02:00
|
|
|
R_ANAL_OP_FAMILY_VIRT, /* virtualization instructions */
|
2019-04-12 13:12:10 +02:00
|
|
|
R_ANAL_OP_FAMILY_PAC, /* pointer authentication instructions */
|
2016-10-13 00:18:03 +02:00
|
|
|
R_ANAL_OP_FAMILY_IO, /* IO instructions (i.e. IN/OUT) */
|
2009-10-12 17:41:52 +02:00
|
|
|
R_ANAL_OP_FAMILY_LAST
|
2009-04-02 10:23:32 +00:00
|
|
|
};
|
|
|
|
|
2014-10-17 01:15:17 +02:00
|
|
|
#if 0
|
2019-06-20 12:45:00 +08:00
|
|
|
On x86 according to Wikipedia
|
2014-10-17 01:15:17 +02:00
|
|
|
|
2015-10-22 03:11:03 +02:00
|
|
|
Prefix group 1
|
|
|
|
0xF0: LOCK prefix
|
|
|
|
0xF2: REPNE/REPNZ prefix
|
|
|
|
0xF3: REP or REPE/REPZ prefix
|
|
|
|
Prefix group 2
|
|
|
|
0x2E: CS segment override
|
|
|
|
0x36: SS segment override
|
|
|
|
0x3E: DS segment override
|
|
|
|
0x26: ES segment override
|
|
|
|
0x64: FS segment override
|
|
|
|
0x65: GS segment override
|
|
|
|
0x2E: Branch not taken (hinting)
|
|
|
|
0x3E: Branch taken
|
|
|
|
Prefix group 3
|
|
|
|
0x66: Operand-size override prefix
|
|
|
|
Prefix group 4
|
|
|
|
0x67: Address-size override prefix
|
2014-10-17 01:15:17 +02:00
|
|
|
#endif
|
2015-10-22 03:11:03 +02:00
|
|
|
typedef enum {
|
|
|
|
R_ANAL_OP_PREFIX_COND = 1,
|
|
|
|
R_ANAL_OP_PREFIX_REP = 1<<1,
|
|
|
|
R_ANAL_OP_PREFIX_REPNE = 1<<2,
|
|
|
|
R_ANAL_OP_PREFIX_LOCK = 1<<3,
|
|
|
|
R_ANAL_OP_PREFIX_LIKELY = 1<<4,
|
|
|
|
R_ANAL_OP_PREFIX_UNLIKELY = 1<<5
|
2018-12-13 02:35:35 +01:00
|
|
|
/* TODO: add segment override typemods? */
|
2015-10-22 03:11:03 +02:00
|
|
|
} RAnalOpPrefix;
|
2014-10-17 01:15:17 +02:00
|
|
|
|
2012-11-13 00:53:52 +01:00
|
|
|
// XXX: this definition is plain wrong. use enum or empower bits
|
2016-09-18 23:02:49 +02:00
|
|
|
#define R_ANAL_OP_TYPE_MASK 0x8000ffff
|
2019-03-26 00:21:05 +01:00
|
|
|
#define R_ANAL_OP_HINT_MASK 0xf0000000
|
2014-03-25 01:21:25 +01:00
|
|
|
typedef enum {
|
2014-10-17 01:15:17 +02:00
|
|
|
R_ANAL_OP_TYPE_COND = 0x80000000, // TODO must be moved to prefix?
|
|
|
|
//TODO: MOVE TO PREFIX .. it is used by anal_ex.. must be updated
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_REP = 0x40000000, /* repeats next instruction N times */
|
2016-05-29 01:35:41 +02:00
|
|
|
R_ANAL_OP_TYPE_MEM = 0x20000000, // TODO must be moved to prefix?
|
2016-09-22 13:42:06 +02:00
|
|
|
R_ANAL_OP_TYPE_REG = 0x10000000, // operand is a register
|
|
|
|
R_ANAL_OP_TYPE_IND = 0x08000000, // operand is indirect
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_NULL = 0,
|
|
|
|
R_ANAL_OP_TYPE_JMP = 1, /* mandatory jump */
|
|
|
|
R_ANAL_OP_TYPE_UJMP = 2, /* unknown jump (register or so) */
|
2016-09-22 13:42:06 +02:00
|
|
|
R_ANAL_OP_TYPE_RJMP = R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_UJMP,
|
|
|
|
R_ANAL_OP_TYPE_IJMP = R_ANAL_OP_TYPE_IND | R_ANAL_OP_TYPE_UJMP,
|
|
|
|
R_ANAL_OP_TYPE_IRJMP = R_ANAL_OP_TYPE_IND | R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_UJMP,
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_CJMP = R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_JMP, /* conditional jump */
|
2018-08-23 19:41:58 +07:00
|
|
|
R_ANAL_OP_TYPE_RCJMP = R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_CJMP, /* conditional jump register */
|
2018-09-08 19:52:33 +02:00
|
|
|
R_ANAL_OP_TYPE_MJMP = R_ANAL_OP_TYPE_MEM | R_ANAL_OP_TYPE_JMP, /* memory jump */
|
|
|
|
R_ANAL_OP_TYPE_MCJMP = R_ANAL_OP_TYPE_MEM | R_ANAL_OP_TYPE_CJMP, /* memory conditional jump */
|
2014-03-25 00:48:42 +01:00
|
|
|
R_ANAL_OP_TYPE_UCJMP = R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_UJMP, /* conditional unknown jump */
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_CALL = 3, /* call to subroutine (branch+link) */
|
|
|
|
R_ANAL_OP_TYPE_UCALL = 4, /* unknown call (register or so) */
|
2016-09-22 13:42:06 +02:00
|
|
|
R_ANAL_OP_TYPE_RCALL = R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_UCALL,
|
|
|
|
R_ANAL_OP_TYPE_ICALL = R_ANAL_OP_TYPE_IND | R_ANAL_OP_TYPE_UCALL,
|
|
|
|
R_ANAL_OP_TYPE_IRCALL= R_ANAL_OP_TYPE_IND | R_ANAL_OP_TYPE_REG | R_ANAL_OP_TYPE_UCALL,
|
2014-02-26 00:03:42 +01:00
|
|
|
R_ANAL_OP_TYPE_CCALL = R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_CALL, /* conditional call to subroutine */
|
2014-03-25 00:48:42 +01:00
|
|
|
R_ANAL_OP_TYPE_UCCALL= R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_UCALL, /* conditional unknown call */
|
2014-02-26 00:03:42 +01:00
|
|
|
R_ANAL_OP_TYPE_RET = 5, /* returns from subroutine */
|
|
|
|
R_ANAL_OP_TYPE_CRET = R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_RET, /* conditional return from subroutine */
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_ILL = 6, /* illegal instruction // trap */
|
|
|
|
R_ANAL_OP_TYPE_UNK = 7, /* unknown opcode type */
|
|
|
|
R_ANAL_OP_TYPE_NOP = 8, /* does nothing */
|
|
|
|
R_ANAL_OP_TYPE_MOV = 9, /* register move */
|
2015-03-08 22:32:23 +01:00
|
|
|
R_ANAL_OP_TYPE_CMOV = 9 | R_ANAL_OP_TYPE_COND, /* conditional move */
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_TRAP = 10, /* it's a trap! */
|
|
|
|
R_ANAL_OP_TYPE_SWI = 11, /* syscall, software interrupt */
|
2018-10-27 11:28:16 +02:00
|
|
|
R_ANAL_OP_TYPE_CSWI = 11 | R_ANAL_OP_TYPE_COND, /* syscall, software interrupt */
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_UPUSH = 12, /* unknown push of data into stack */
|
2019-05-15 15:34:41 +05:30
|
|
|
R_ANAL_OP_TYPE_RPUSH = R_ANAL_OP_TYPE_UPUSH | R_ANAL_OP_TYPE_REG, /* push register */
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_PUSH = 13, /* push value into stack */
|
|
|
|
R_ANAL_OP_TYPE_POP = 14, /* pop value from stack to register */
|
2014-03-25 00:48:42 +01:00
|
|
|
R_ANAL_OP_TYPE_CMP = 15, /* compare something */
|
|
|
|
R_ANAL_OP_TYPE_ACMP = 16, /* compare via and */
|
|
|
|
R_ANAL_OP_TYPE_ADD = 17,
|
|
|
|
R_ANAL_OP_TYPE_SUB = 18,
|
|
|
|
R_ANAL_OP_TYPE_IO = 19,
|
|
|
|
R_ANAL_OP_TYPE_MUL = 20,
|
|
|
|
R_ANAL_OP_TYPE_DIV = 21,
|
|
|
|
R_ANAL_OP_TYPE_SHR = 22,
|
|
|
|
R_ANAL_OP_TYPE_SHL = 23,
|
|
|
|
R_ANAL_OP_TYPE_SAL = 24,
|
|
|
|
R_ANAL_OP_TYPE_SAR = 25,
|
|
|
|
R_ANAL_OP_TYPE_OR = 26,
|
|
|
|
R_ANAL_OP_TYPE_AND = 27,
|
|
|
|
R_ANAL_OP_TYPE_XOR = 28,
|
2015-09-17 01:25:00 +02:00
|
|
|
R_ANAL_OP_TYPE_NOR = 29,
|
|
|
|
R_ANAL_OP_TYPE_NOT = 30,
|
|
|
|
R_ANAL_OP_TYPE_STORE = 31, /* store from register to memory */
|
|
|
|
R_ANAL_OP_TYPE_LOAD = 32, /* load from memory to register */
|
2016-08-04 22:52:33 +02:00
|
|
|
R_ANAL_OP_TYPE_LEA = 33, /* TODO add ulea */
|
2015-09-17 01:25:00 +02:00
|
|
|
R_ANAL_OP_TYPE_LEAVE = 34,
|
|
|
|
R_ANAL_OP_TYPE_ROR = 35,
|
|
|
|
R_ANAL_OP_TYPE_ROL = 36,
|
|
|
|
R_ANAL_OP_TYPE_XCHG = 37,
|
|
|
|
R_ANAL_OP_TYPE_MOD = 38,
|
|
|
|
R_ANAL_OP_TYPE_SWITCH = 39,
|
|
|
|
R_ANAL_OP_TYPE_CASE = 40,
|
|
|
|
R_ANAL_OP_TYPE_LENGTH = 41,
|
|
|
|
R_ANAL_OP_TYPE_CAST = 42,
|
|
|
|
R_ANAL_OP_TYPE_NEW = 43,
|
2015-10-08 11:55:01 +02:00
|
|
|
R_ANAL_OP_TYPE_ABS = 44,
|
2015-10-15 00:22:27 +00:00
|
|
|
R_ANAL_OP_TYPE_CPL = 45, /* complement */
|
2015-10-15 18:02:36 +00:00
|
|
|
R_ANAL_OP_TYPE_CRYPTO = 46,
|
2016-10-06 03:38:28 +02:00
|
|
|
R_ANAL_OP_TYPE_SYNC = 47,
|
2015-03-24 00:08:48 +01:00
|
|
|
//R_ANAL_OP_TYPE_DEBUG = 43, // monitor/trace/breakpoint
|
2015-03-08 22:09:59 +01:00
|
|
|
#if 0
|
2019-06-20 12:45:00 +08:00
|
|
|
R_ANAL_OP_TYPE_PRIV = 40, /* privileged instruction */
|
2015-03-04 00:46:59 +01:00
|
|
|
R_ANAL_OP_TYPE_FPU = 41, /* floating point stuff */
|
2015-03-08 22:09:59 +01:00
|
|
|
#endif
|
2014-03-25 04:10:44 +01:00
|
|
|
} _RAnalOpType;
|
2009-02-06 18:22:27 +01:00
|
|
|
|
2018-03-15 12:31:01 +01:00
|
|
|
typedef enum {
|
2019-01-16 16:22:45 +01:00
|
|
|
R_ANAL_OP_MASK_BASIC = 0, // Just fills basic op info , it's fast
|
|
|
|
R_ANAL_OP_MASK_ESIL = 1, // It fills RAnalop->esil info
|
|
|
|
R_ANAL_OP_MASK_VAL = 2, // It fills RAnalop->dst/src info
|
|
|
|
R_ANAL_OP_MASK_HINT = 4, // It calls r_anal_op_hint to override anal options
|
2019-03-16 21:07:29 +01:00
|
|
|
R_ANAL_OP_MASK_OPEX = 8, // It fills RAnalop->opex info
|
2019-03-27 10:19:18 +01:00
|
|
|
R_ANAL_OP_MASK_DISASM = 16, // It fills RAnalop->mnemonic // should be RAnalOp->disasm // only from r_core_anal_op()
|
2019-04-14 18:48:14 +02:00
|
|
|
R_ANAL_OP_MASK_ALL = 1 | 2 | 4 | 8 | 16
|
2018-03-15 12:31:01 +01:00
|
|
|
} RAnalOpMask;
|
|
|
|
|
2009-08-19 18:38:35 +02:00
|
|
|
/* TODO: what to do with signed/unsigned conditionals? */
|
2014-03-25 00:34:23 +01:00
|
|
|
typedef enum {
|
2016-04-01 12:06:02 +02:00
|
|
|
R_ANAL_COND_AL = 0, // Always executed (no condition)
|
|
|
|
R_ANAL_COND_EQ, // Equal
|
|
|
|
R_ANAL_COND_NE, // Not equal
|
|
|
|
R_ANAL_COND_GE, // Greater or equal
|
|
|
|
R_ANAL_COND_GT, // Greater than
|
|
|
|
R_ANAL_COND_LE, // Less or equal
|
|
|
|
R_ANAL_COND_LT, // Less than
|
|
|
|
R_ANAL_COND_NV, // Never executed must be a nop? :D
|
|
|
|
R_ANAL_COND_HS, // Carry set >, ==, or unordered
|
|
|
|
R_ANAL_COND_LO, // Carry clear Less than
|
|
|
|
R_ANAL_COND_MI, // Minus, negative Less than
|
|
|
|
R_ANAL_COND_PL, // Plus, positive or zero >, ==, or unordered
|
|
|
|
R_ANAL_COND_VS, // Overflow Unordered
|
|
|
|
R_ANAL_COND_VC, // No overflow Not unordered
|
|
|
|
R_ANAL_COND_HI, // Unsigned higher Greater than, or unordered
|
|
|
|
R_ANAL_COND_LS // Unsigned lower or same Less than or equal
|
2014-03-25 01:21:25 +01:00
|
|
|
} _RAnalCond;
|
2009-08-19 18:38:35 +02:00
|
|
|
|
2014-03-25 00:34:23 +01:00
|
|
|
typedef enum {
|
2012-07-22 12:00:35 +04:00
|
|
|
R_ANAL_VAR_SCOPE_NULL = 0,
|
2014-12-13 18:06:01 +01:00
|
|
|
R_ANAL_VAR_SCOPE_GLOBAL = 0x00,
|
|
|
|
R_ANAL_VAR_SCOPE_LOCAL = 0x01,
|
2012-07-22 12:00:35 +04:00
|
|
|
R_ANAL_VAR_SCOPE_ARG = 0x04,
|
|
|
|
R_ANAL_VAR_SCOPE_ARGREG = 0x08,
|
|
|
|
R_ANAL_VAR_SCOPE_RET = 0x10,
|
|
|
|
} _RAnalVarScope;
|
2010-12-06 16:26:21 +01:00
|
|
|
|
2010-12-03 13:52:11 +01:00
|
|
|
typedef enum {
|
|
|
|
R_ANAL_VAR_DIR_NONE = 0,
|
|
|
|
R_ANAL_VAR_DIR_IN = 0x100,
|
|
|
|
R_ANAL_VAR_DIR_OUT = 0x200
|
|
|
|
} _RAnalVarDir;
|
2010-03-11 17:19:33 +01:00
|
|
|
|
2010-05-21 17:35:05 +02:00
|
|
|
typedef enum {
|
2009-02-06 18:22:27 +01:00
|
|
|
R_ANAL_DATA_NULL = 0,
|
|
|
|
R_ANAL_DATA_HEX, /* hex byte pairs */
|
|
|
|
R_ANAL_DATA_STR, /* ascii string */
|
|
|
|
R_ANAL_DATA_CODE, /* plain assembly code */
|
|
|
|
R_ANAL_DATA_FUN, /* plain assembly code */
|
2009-04-11 21:22:20 +00:00
|
|
|
R_ANAL_DATA_STRUCT, /* memory */
|
|
|
|
R_ANAL_DATA_LAST
|
2010-10-28 12:10:21 +02:00
|
|
|
} _RAnalData;
|
2009-02-06 18:22:27 +01:00
|
|
|
|
2010-05-21 17:35:05 +02:00
|
|
|
typedef enum {
|
2010-02-26 13:08:42 +01:00
|
|
|
R_ANAL_BB_TYPE_NULL = 0,
|
2010-05-21 19:20:42 +02:00
|
|
|
R_ANAL_BB_TYPE_HEAD = 0x1, /* first block */
|
|
|
|
R_ANAL_BB_TYPE_BODY = 0x2, /* conditional jump */
|
|
|
|
R_ANAL_BB_TYPE_LAST = 0x4, /* ret */
|
2010-11-23 17:15:33 +01:00
|
|
|
R_ANAL_BB_TYPE_FOOT = 0x8, /* unknown jump */
|
2014-01-01 23:09:46 -06:00
|
|
|
R_ANAL_BB_TYPE_SWITCH = 0x10, /* TODO: switch */
|
|
|
|
|
|
|
|
R_ANAL_BB_TYPE_RET = 0x0020, /* return bb */
|
|
|
|
R_ANAL_BB_TYPE_JMP = 0x0040, /* jmp bb */
|
|
|
|
R_ANAL_BB_TYPE_COND = 0x0100, /* conditional bb */
|
2014-01-22 22:55:48 -06:00
|
|
|
R_ANAL_BB_TYPE_CJMP = R_ANAL_BB_TYPE_COND | R_ANAL_BB_TYPE_JMP,
|
2014-01-01 23:09:46 -06:00
|
|
|
R_ANAL_BB_TYPE_CALL = 0x0200,
|
|
|
|
R_ANAL_BB_TYPE_CMP = 0x0400,
|
|
|
|
R_ANAL_BB_TYPE_LD = 0x0800,
|
|
|
|
R_ANAL_BB_TYPE_ST = 0x1000,
|
|
|
|
R_ANAL_BB_TYPE_BINOP= 0x2000,
|
|
|
|
R_ANAL_BB_TYPE_TAIL = 0x8000,
|
2010-10-28 12:10:21 +02:00
|
|
|
} _RAnalBlockType;
|
2009-02-06 18:22:27 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_STACK_NULL = 0,
|
2009-02-09 00:19:06 +01:00
|
|
|
R_ANAL_STACK_NOP,
|
2013-04-23 03:38:39 +02:00
|
|
|
R_ANAL_STACK_INC,
|
2010-05-14 23:04:10 +02:00
|
|
|
R_ANAL_STACK_GET,
|
|
|
|
R_ANAL_STACK_SET,
|
2016-05-11 12:59:32 +02:00
|
|
|
R_ANAL_STACK_RESET,
|
2016-04-13 23:33:30 +02:00
|
|
|
R_ANAL_STACK_ALIGN,
|
2009-02-06 18:22:27 +01:00
|
|
|
};
|
|
|
|
|
2011-06-14 04:49:10 +02:00
|
|
|
enum {
|
2015-09-08 23:21:35 +02:00
|
|
|
R_ANAL_REFLINE_TYPE_UTF8 = 1,
|
2015-11-06 15:46:14 +01:00
|
|
|
R_ANAL_REFLINE_TYPE_WIDE = 2, /* reflines have a space between them */
|
2019-01-10 23:57:58 +08:00
|
|
|
R_ANAL_REFLINE_TYPE_MIDDLE_BEFORE = 4, /* do not consider starts/ends of
|
|
|
|
* reflines (used for comment lines before disasm) */
|
2018-12-26 06:25:51 +08:00
|
|
|
R_ANAL_REFLINE_TYPE_MIDDLE_AFTER = 8 /* as above but for lines after disasm */
|
2011-06-14 04:49:10 +02:00
|
|
|
};
|
2009-04-02 00:41:10 +02:00
|
|
|
|
2010-03-01 16:50:37 +01:00
|
|
|
enum {
|
|
|
|
R_ANAL_RET_ERROR = -1,
|
2010-03-05 18:55:39 +01:00
|
|
|
R_ANAL_RET_DUP = -2,
|
|
|
|
R_ANAL_RET_NEW = -3,
|
|
|
|
R_ANAL_RET_END = -4
|
2010-03-01 16:50:37 +01:00
|
|
|
};
|
|
|
|
|
2014-01-01 23:09:46 -06:00
|
|
|
typedef struct r_anal_case_obj_t {
|
|
|
|
ut64 addr;
|
|
|
|
ut64 jump;
|
|
|
|
ut64 value;
|
|
|
|
ut32 cond; // TODO: treat like a regular condition
|
|
|
|
ut64 bb_ref_to;
|
|
|
|
ut64 bb_ref_from;
|
2017-02-08 11:34:08 +00:00
|
|
|
RAnalBlock *jumpbb;
|
2014-01-01 23:09:46 -06:00
|
|
|
} RAnalCaseOp;
|
|
|
|
|
|
|
|
typedef struct r_anal_switch_obj_t {
|
|
|
|
ut64 addr;
|
|
|
|
ut64 min_val;
|
|
|
|
ut64 def_val;
|
|
|
|
ut64 max_val;
|
|
|
|
RList *cases;
|
|
|
|
} RAnalSwitchOp;
|
|
|
|
|
2018-08-30 16:06:25 -07:00
|
|
|
struct r_anal_t;
|
|
|
|
struct r_anal_bb_t;
|
2015-03-16 02:52:26 +01:00
|
|
|
typedef struct r_anal_callbacks_t {
|
2018-08-30 16:06:25 -07:00
|
|
|
int (*on_fcn_new) (struct r_anal_t *, void *user, RAnalFunction *fcn);
|
|
|
|
int (*on_fcn_delete) (struct r_anal_t *, void *user, RAnalFunction *fcn);
|
|
|
|
int (*on_fcn_rename) (struct r_anal_t *, void *user, RAnalFunction *fcn, const char *oldname);
|
|
|
|
int (*on_fcn_bb_new) (struct r_anal_t *, void *user, RAnalFunction *fcn, struct r_anal_bb_t *bb);
|
2015-03-16 02:52:26 +01:00
|
|
|
} RAnalCallbacks;
|
|
|
|
|
2015-04-01 00:38:24 +02:00
|
|
|
#define R_ANAL_ESIL_GOTO_LIMIT 4096
|
|
|
|
|
2015-09-07 00:30:48 +02:00
|
|
|
typedef struct r_anal_options_t {
|
2018-02-07 00:02:40 +01:00
|
|
|
int depth;
|
2018-11-19 02:35:23 +01:00
|
|
|
int graph_depth;
|
2018-05-16 02:44:09 +05:30
|
|
|
bool vars; //analyze local var and arguments
|
2015-09-07 00:30:48 +02:00
|
|
|
int cjmpref;
|
2015-11-23 18:00:11 +03:00
|
|
|
int jmpref;
|
2015-11-24 15:01:26 +03:00
|
|
|
int jmpabove;
|
2018-04-18 18:20:03 +08:00
|
|
|
bool ijmp;
|
2018-10-31 18:47:17 +08:00
|
|
|
bool jmpmid; // continue analysis after jmp into middle of insn
|
2019-04-10 23:51:28 +02:00
|
|
|
bool loads;
|
2019-04-11 04:34:34 +02:00
|
|
|
bool ignbithints;
|
2015-11-24 16:49:44 +03:00
|
|
|
int followdatarefs;
|
2015-11-25 14:14:40 +03:00
|
|
|
int searchstringrefs;
|
2015-12-03 13:41:26 +03:00
|
|
|
int followbrokenfcnsrefs;
|
2015-12-10 18:22:24 +03:00
|
|
|
int bb_max_size;
|
2019-06-28 03:51:28 +02:00
|
|
|
bool trycatch;
|
2015-09-07 00:30:48 +02:00
|
|
|
int afterjmp; // continue analysis after jmp eax or forward jmp // option
|
|
|
|
int recont; // continue on recurse analysis mode
|
|
|
|
int eobjmp; // option
|
|
|
|
int noncode;
|
|
|
|
int nopskip; // skip nops at the beginning of functions
|
2016-09-05 20:42:04 +02:00
|
|
|
int hpskip; // skip `mov reg,reg` and `lea reg,[reg]`
|
2015-11-20 11:33:48 +03:00
|
|
|
int jmptbl; // analyze jump tables
|
2016-04-14 14:27:44 +02:00
|
|
|
bool pushret; // analyze push+ret as jmp
|
2017-12-07 15:25:27 +01:00
|
|
|
bool armthumb; //
|
2018-06-24 23:17:58 +02:00
|
|
|
bool endsize; // chop function size which is known to be buggy but goodie too
|
2015-09-07 00:30:48 +02:00
|
|
|
} RAnalOptions;
|
|
|
|
|
2018-03-12 21:48:44 +01:00
|
|
|
typedef enum {
|
|
|
|
R_ANAL_CPP_ABI_ITANIUM = 0,
|
|
|
|
R_ANAL_CPP_ABI_MSVC
|
|
|
|
} RAnalCPPABI;
|
|
|
|
|
2018-11-22 21:31:54 +01:00
|
|
|
typedef struct r_anal_hint_cb_t {
|
|
|
|
//add more cbs as needed
|
|
|
|
void (*on_bits) (struct r_anal_t *a, ut64 addr, int bits, bool set);
|
|
|
|
} RHintCb;
|
|
|
|
|
2010-03-19 13:51:28 +01:00
|
|
|
typedef struct r_anal_t {
|
2014-02-06 00:08:46 +04:00
|
|
|
char *cpu;
|
2015-10-30 03:07:22 +01:00
|
|
|
char *os;
|
2010-02-26 13:08:42 +01:00
|
|
|
int bits;
|
2011-10-19 10:01:01 +02:00
|
|
|
int lineswidth; // wtf
|
2010-02-26 13:08:42 +01:00
|
|
|
int big_endian;
|
2014-11-02 02:01:09 +01:00
|
|
|
int sleep; // sleep some usecs before analyzing more (avoid 100% cpu usages)
|
2018-03-12 21:48:44 +01:00
|
|
|
RAnalCPPABI cpp_abi;
|
2010-02-26 13:08:42 +01:00
|
|
|
void *user;
|
2014-11-07 03:48:27 +01:00
|
|
|
ut64 gp; // global pointer. used for mips. but can be used by other arches too in the future
|
2010-03-03 12:08:27 +01:00
|
|
|
RList *fcns;
|
2019-03-06 22:04:06 +08:00
|
|
|
RBNode *fcn_tree; // keyed on meta.min
|
|
|
|
RBNode *fcn_addr_tree; // keyed on addr
|
2011-09-14 02:07:06 +02:00
|
|
|
RListRange *fcnstore;
|
2010-09-28 13:58:03 +02:00
|
|
|
RList *refs;
|
2010-03-11 19:52:05 +01:00
|
|
|
RList *vartypes;
|
2010-09-18 02:51:17 +02:00
|
|
|
RReg *reg;
|
2016-10-24 14:31:03 +02:00
|
|
|
ut8 *last_disasm_reg;
|
2011-02-02 13:05:48 +01:00
|
|
|
RSyscall *syscall;
|
2011-03-28 10:24:01 +02:00
|
|
|
struct r_anal_op_t *queued;
|
2011-10-14 10:09:53 +02:00
|
|
|
int diff_ops;
|
|
|
|
double diff_thbb;
|
|
|
|
double diff_thfcn;
|
2011-02-03 00:20:39 +01:00
|
|
|
RIOBind iob;
|
2014-09-26 14:24:33 +02:00
|
|
|
RFlagBind flb;
|
2019-02-23 01:31:06 +01:00
|
|
|
RFlagSet flg_class_set;
|
|
|
|
RFlagGet flg_class_get;
|
|
|
|
RFlagSet flg_fcn_set;
|
2014-10-30 22:58:51 +01:00
|
|
|
RBinBind binb; // Set only from core when an analysis plugin is called.
|
2016-09-26 17:04:26 +02:00
|
|
|
RCoreBind coreb;
|
2014-11-26 01:12:54 +01:00
|
|
|
int maxreflines;
|
2015-02-22 11:18:40 +01:00
|
|
|
int trace;
|
2015-04-01 00:38:24 +02:00
|
|
|
int esil_goto_limit;
|
2015-10-14 02:11:53 +02:00
|
|
|
int pcalign;
|
2017-07-28 19:33:16 +08:00
|
|
|
int bitshift;
|
2011-10-19 10:01:01 +02:00
|
|
|
//struct r_anal_ctx_t *ctx;
|
2014-08-07 14:43:46 +02:00
|
|
|
struct r_anal_esil_t *esil;
|
2011-10-19 13:05:41 +02:00
|
|
|
struct r_anal_plugin_t *cur;
|
2014-11-03 04:05:19 +01:00
|
|
|
RAnalRange *limit;
|
2014-03-25 12:05:34 +01:00
|
|
|
RList *plugins;
|
2013-08-01 00:39:19 +02:00
|
|
|
Sdb *sdb_types;
|
2018-07-22 20:47:56 +05:30
|
|
|
Sdb *sdb_fmts;
|
2014-09-26 15:40:17 +02:00
|
|
|
Sdb *sdb_meta; // TODO: Future r_meta api
|
2017-03-07 23:20:48 +00:00
|
|
|
Sdb *sdb_zigns;
|
2018-11-14 10:47:28 +01:00
|
|
|
HtUP *dict_refs;
|
|
|
|
HtUP *dict_xrefs;
|
2017-12-24 19:01:51 +01:00
|
|
|
bool recursive_noreturn;
|
2015-06-15 04:19:29 +02:00
|
|
|
RSpaces meta_spaces;
|
2017-03-07 23:20:48 +00:00
|
|
|
RSpaces zign_spaces;
|
2017-04-28 14:37:00 +02:00
|
|
|
char *zign_path;
|
2015-08-08 14:15:13 -04:00
|
|
|
PrintfCallback cb_printf;
|
2015-07-31 12:40:04 +02:00
|
|
|
//moved from RAnalFcn
|
2014-03-05 03:52:42 +01:00
|
|
|
Sdb *sdb; // root
|
2014-03-31 03:05:48 +02:00
|
|
|
Sdb *sdb_fcns;
|
2015-06-30 10:50:46 +02:00
|
|
|
Sdb *sdb_pins;
|
2014-03-31 03:05:48 +02:00
|
|
|
#define DEPRECATE 1
|
|
|
|
#if DEPRECATE
|
|
|
|
Sdb *sdb_args; //
|
|
|
|
Sdb *sdb_vars; // globals?
|
|
|
|
#endif
|
|
|
|
Sdb *sdb_hints; // OK
|
2018-11-22 21:31:54 +01:00
|
|
|
RHintCb hint_cbs;
|
2015-10-30 03:07:22 +01:00
|
|
|
Sdb *sdb_fcnsign; // OK
|
2016-07-27 14:50:14 +03:00
|
|
|
Sdb *sdb_cc; // calling conventions
|
Heavy refactoring and sdbify the classes storage+logic ##anal
* New commands: aCb, aCm, aCmn, aCll, aClj, aCv, aCm, aC-, aCm-
* Fix Segfaults and Leaks in RTTI classes recovery
* Accept .?AU as prefix for msvc class name demangling
* Classes recovery refactoring
* Skip own type descriptor in msvc classes recovery
* Cleanup msvc rtti address calculation
* Recover vtable, classes, base class, virtual methods from MSVC RTTI
* Add flags for vtables and methods
* Add r_str_sanitize_sdb_key()
2018-12-29 11:16:33 +01:00
|
|
|
Sdb *sdb_classes;
|
2019-01-11 10:03:18 +01:00
|
|
|
Sdb *sdb_classes_attrs;
|
2014-03-11 02:47:10 +01:00
|
|
|
//RList *hints; // XXX use better data structure here (slist?)
|
2015-03-16 02:52:26 +01:00
|
|
|
RAnalCallbacks cb;
|
2015-09-07 00:30:48 +02:00
|
|
|
RAnalOptions opt;
|
2015-09-08 23:21:35 +02:00
|
|
|
RList *reflines;
|
2016-09-20 22:54:44 +03:00
|
|
|
//RList *noreturn;
|
2018-11-22 21:31:54 +01:00
|
|
|
RBNode *rb_hints_ranges; // <RAnalRange>
|
|
|
|
bool merge_hints;
|
2016-09-22 20:31:40 +02:00
|
|
|
RListComparator columnSort;
|
2017-01-31 10:00:24 +01:00
|
|
|
int stackptr;
|
2017-05-09 03:38:29 +02:00
|
|
|
bool (*log)(struct r_anal_t *anal, const char *msg);
|
2018-03-06 22:30:16 +08:00
|
|
|
bool (*read_at)(struct r_anal_t *anal, ut64 addr, ut8 *buf, int len);
|
2019-03-06 11:26:37 +01:00
|
|
|
bool verbose;
|
2017-05-23 23:55:22 +02:00
|
|
|
char *cmdtail;
|
2018-03-12 12:37:35 +01:00
|
|
|
int seggrn;
|
2019-03-05 14:43:49 -08:00
|
|
|
RFlagGetAtAddr flag_get;
|
2018-10-26 23:23:51 +02:00
|
|
|
REvent *ev;
|
2019-05-08 18:26:11 +02:00
|
|
|
bool use_ex;
|
2019-07-03 14:28:35 +02:00
|
|
|
RList *imports; // global imports
|
2010-03-19 12:00:04 +01:00
|
|
|
} RAnal;
|
2009-02-16 00:57:03 +01:00
|
|
|
|
2013-01-22 05:06:12 +01:00
|
|
|
typedef struct r_anal_hint_t {
|
2014-03-11 02:47:10 +01:00
|
|
|
ut64 addr;
|
2013-06-17 03:26:48 +02:00
|
|
|
ut64 ptr;
|
2019-07-07 18:51:21 +02:00
|
|
|
ut64 val; // used to hint jmp rax
|
2013-10-25 02:06:00 +02:00
|
|
|
ut64 jump;
|
|
|
|
ut64 fail;
|
2018-06-08 13:16:31 +05:30
|
|
|
ut64 ret; // hint for function ret values
|
2014-03-11 02:47:10 +01:00
|
|
|
char *arch;
|
|
|
|
char *opcode;
|
2015-05-10 00:12:33 +02:00
|
|
|
char *syntax;
|
2014-03-11 02:47:10 +01:00
|
|
|
char *esil;
|
2017-10-31 23:22:20 +08:00
|
|
|
char *offset;
|
2019-01-20 12:15:39 +01:00
|
|
|
ut32 type;
|
2013-12-06 05:31:54 +01:00
|
|
|
int size;
|
2013-01-22 05:06:12 +01:00
|
|
|
int bits;
|
2018-02-27 19:13:12 +01:00
|
|
|
int new_bits; // change asm.bits after evaluating this instruction
|
|
|
|
#if 0
|
|
|
|
int new_endian; // change the endianness
|
|
|
|
int new_bank; // select bank switch
|
|
|
|
#endif
|
2015-09-28 01:00:06 +02:00
|
|
|
int immbase;
|
2017-11-14 23:36:04 +09:00
|
|
|
bool high; // highlight hint
|
2018-12-17 12:56:07 +01:00
|
|
|
int nword;
|
2019-05-24 14:56:28 +02:00
|
|
|
ut64 stackframe;
|
2013-01-22 05:06:12 +01:00
|
|
|
} RAnalHint;
|
|
|
|
|
2016-02-15 17:49:17 +01:00
|
|
|
typedef struct r_anal_var_access_t {
|
|
|
|
ut64 addr;
|
|
|
|
int set;
|
|
|
|
} RAnalVarAccess;
|
|
|
|
|
2019-04-25 11:22:06 +02:00
|
|
|
typedef RAnalFunction *(* RAnalGetFcnIn)(RAnal *anal, ut64 addr, int type);
|
|
|
|
typedef RAnalHint *(* RAnalGetHint)(RAnal *anal, ut64 addr);
|
|
|
|
|
|
|
|
typedef struct r_anal_bind_t {
|
|
|
|
RAnal *anal;
|
|
|
|
RAnalGetFcnIn get_fcn_in;
|
|
|
|
RAnalGetHint get_hint;
|
|
|
|
} RAnalBind;
|
|
|
|
|
|
|
|
|
2016-08-08 01:00:47 +02:00
|
|
|
#define R_ANAL_VAR_KIND_ANY 0
|
2016-02-15 17:49:17 +01:00
|
|
|
#define R_ANAL_VAR_KIND_ARG 'a'
|
|
|
|
#define R_ANAL_VAR_KIND_REG 'r'
|
2016-08-08 01:00:47 +02:00
|
|
|
#define R_ANAL_VAR_KIND_BPV 'b'
|
|
|
|
#define R_ANAL_VAR_KIND_SPV 's'
|
2016-02-15 17:49:17 +01:00
|
|
|
|
2019-01-31 20:59:21 +05:30
|
|
|
#define VARPREFIX "var"
|
|
|
|
#define ARGPREFIX "arg"
|
|
|
|
|
2016-02-15 17:49:17 +01:00
|
|
|
// generic for args and locals
|
|
|
|
typedef struct r_anal_var_t {
|
2016-08-08 01:00:47 +02:00
|
|
|
char *name; /* name of the variable */
|
|
|
|
char *type; // cparse type of the variable
|
2018-05-16 02:44:09 +05:30
|
|
|
char kind; // reg , stack ...
|
2016-08-08 01:00:47 +02:00
|
|
|
ut64 addr; // not used correctly?
|
|
|
|
ut64 eaddr; // not used correctly?
|
2016-02-15 17:49:17 +01:00
|
|
|
int size;
|
2018-05-16 02:44:09 +05:30
|
|
|
bool isarg;
|
2016-08-08 01:00:47 +02:00
|
|
|
int delta; /* delta offset inside stack frame */
|
|
|
|
int scope; /* global, local... | in, out... */
|
2016-02-15 17:49:17 +01:00
|
|
|
/* probably dupped or so */
|
|
|
|
RList/*RAnalVarAccess*/ *accesses; /* list of accesses for this var */
|
|
|
|
RList/*RAnalValue*/ *stores; /* where this */
|
|
|
|
} RAnalVar;
|
|
|
|
|
2010-06-16 21:44:19 +02:00
|
|
|
// mul*value+regbase+regidx+delta
|
|
|
|
typedef struct r_anal_value_t {
|
2010-06-17 02:22:50 +02:00
|
|
|
int absolute; // if true, unsigned cast is used
|
2010-06-17 01:48:51 +02:00
|
|
|
int memref; // is memory reference? which size? 1, 2 ,4, 8
|
2010-06-16 21:44:19 +02:00
|
|
|
ut64 base ; // numeric address
|
2010-09-22 18:31:15 +02:00
|
|
|
st64 delta; // numeric delta
|
2010-09-23 13:25:46 +02:00
|
|
|
st64 imm; // immediate value
|
2010-06-16 21:44:19 +02:00
|
|
|
int mul; // multiplier (reg*4+base)
|
2010-09-22 18:31:15 +02:00
|
|
|
ut16 sel; // segment selector
|
2010-09-18 02:51:17 +02:00
|
|
|
RRegItem *reg; // register index used (-1 if no reg)
|
|
|
|
RRegItem *regdelta; // register index used (-1 if no reg)
|
2010-06-16 21:44:19 +02:00
|
|
|
} RAnalValue;
|
|
|
|
|
2017-10-17 00:03:34 +02:00
|
|
|
enum RAnalOpDirection {
|
|
|
|
R_ANAL_OP_DIR_READ = 1,
|
|
|
|
R_ANAL_OP_DIR_WRITE = 2,
|
|
|
|
R_ANAL_OP_DIR_EXEC = 4,
|
|
|
|
R_ANAL_OP_DIR_REF = 8,
|
|
|
|
};
|
|
|
|
|
2019-02-17 23:55:10 +01:00
|
|
|
typedef enum r_anal_data_type_t {
|
|
|
|
R_ANAL_DATATYPE_NULL = 0,
|
|
|
|
R_ANAL_DATATYPE_ARRAY,
|
|
|
|
R_ANAL_DATATYPE_OBJECT, // instance
|
|
|
|
R_ANAL_DATATYPE_STRING,
|
|
|
|
R_ANAL_DATATYPE_CLASS,
|
|
|
|
R_ANAL_DATATYPE_BOOLEAN,
|
|
|
|
R_ANAL_DATATYPE_INT16,
|
|
|
|
R_ANAL_DATATYPE_INT32,
|
|
|
|
R_ANAL_DATATYPE_INT64,
|
|
|
|
R_ANAL_DATATYPE_FLOAT,
|
|
|
|
} RAnalDataType;
|
|
|
|
|
2011-02-24 14:06:49 +01:00
|
|
|
typedef struct r_anal_op_t {
|
2019-04-12 13:12:10 +02:00
|
|
|
char *mnemonic; /* mnemonic.. it actually contains the args too, we should replace rasm with this */
|
2010-06-16 09:42:46 +02:00
|
|
|
ut64 addr; /* address */
|
2017-12-23 02:40:45 +01:00
|
|
|
ut32 type; /* type of opcode */
|
2014-10-17 01:15:17 +02:00
|
|
|
ut64 prefix; /* type of opcode prefix (rep,lock,..) */
|
2017-12-23 02:40:45 +01:00
|
|
|
ut32 type2; /* used by java */
|
2015-03-08 22:09:59 +01:00
|
|
|
int group; /* is fpu, is privileged, mmx, etc */
|
2010-06-16 09:42:46 +02:00
|
|
|
int stackop; /* operation on stack? */
|
|
|
|
int cond; /* condition type */
|
2013-12-06 05:04:17 +01:00
|
|
|
int size; /* size in bytes of opcode */
|
2016-06-17 14:26:24 +02:00
|
|
|
int nopcode; /* number of bytes representing the opcode (not the arguments) TODO: find better name */
|
2014-02-10 23:01:19 +01:00
|
|
|
int cycles; /* cpu-cycles taken by instruction */
|
2014-02-26 00:03:42 +01:00
|
|
|
int failcycles; /* conditional cpu-cycles */
|
2010-06-16 09:42:46 +02:00
|
|
|
int family; /* family of opcode */
|
2016-11-01 23:42:12 +01:00
|
|
|
int id; /* instruction id */
|
|
|
|
bool eob; /* end of block (boolean) */
|
2018-06-03 23:43:13 +02:00
|
|
|
bool sign; /* operates on signed values, false by default */
|
2011-03-28 10:24:01 +02:00
|
|
|
/* Run N instructions before executing the current one */
|
|
|
|
int delay; /* delay N slots (mips, ..)*/
|
2010-06-16 09:42:46 +02:00
|
|
|
ut64 jump; /* true jmp */
|
|
|
|
ut64 fail; /* false jmp */
|
2017-10-16 23:38:10 +02:00
|
|
|
int direction; /* 1 = read, 2 = write, 4 = exec, 8 = reference, */
|
2013-06-09 03:25:32 +02:00
|
|
|
st64 ptr; /* reference to memory */ /* XXX signed? */
|
2014-08-24 14:35:15 +02:00
|
|
|
ut64 val; /* reference to value */ /* XXX signed? */
|
2015-01-10 03:21:27 +01:00
|
|
|
int ptrsize; /* f.ex: zero extends for 8, 16 or 32 bits only */
|
2010-06-16 09:42:46 +02:00
|
|
|
st64 stackptr; /* stack pointer */
|
2014-11-07 00:41:29 +01:00
|
|
|
int refptr; /* if (0) ptr = "reference" else ptr = "load memory of refptr bytes" */
|
2016-02-15 17:49:17 +01:00
|
|
|
RAnalVar *var; /* local var/arg used by this instruction */
|
2010-06-16 21:44:19 +02:00
|
|
|
RAnalValue *src[3];
|
|
|
|
RAnalValue *dst;
|
2016-06-17 14:26:24 +02:00
|
|
|
struct r_anal_op_t *next; // TODO deprecate
|
2013-12-10 03:35:59 +01:00
|
|
|
RStrBuf esil;
|
2017-03-09 18:51:58 +01:00
|
|
|
RStrBuf opex;
|
2016-06-17 14:26:24 +02:00
|
|
|
const char *reg; /* destination register */
|
2016-08-27 19:19:58 +02:00
|
|
|
const char *ireg; /* register used for indirect memory computation*/
|
|
|
|
int scale;
|
|
|
|
ut64 disp;
|
2014-01-01 23:09:46 -06:00
|
|
|
RAnalSwitchOp *switch_op;
|
2018-02-27 19:13:12 +01:00
|
|
|
RAnalHint hint;
|
2019-02-17 23:55:10 +01:00
|
|
|
RAnalDataType datatype;
|
2010-05-21 01:46:26 +02:00
|
|
|
} RAnalOp;
|
2009-02-06 18:22:27 +01:00
|
|
|
|
2010-06-16 09:42:46 +02:00
|
|
|
#define R_ANAL_COND_SINGLE(x) (!x->arg[1] || x->arg[0]==x->arg[1])
|
2010-06-14 16:20:54 +02:00
|
|
|
|
|
|
|
typedef struct r_anal_cond_t {
|
2010-06-16 09:42:46 +02:00
|
|
|
int type; // filled by CJMP opcode
|
|
|
|
RAnalValue *arg[2]; // filled by CMP opcode
|
2010-06-14 16:20:54 +02:00
|
|
|
} RAnalCond;
|
|
|
|
|
2010-02-26 13:08:42 +01:00
|
|
|
typedef struct r_anal_bb_t {
|
2013-11-21 19:19:16 -06:00
|
|
|
char *name;
|
2010-02-26 13:08:42 +01:00
|
|
|
ut64 addr;
|
|
|
|
ut64 jump;
|
2014-01-05 14:43:57 -06:00
|
|
|
ut64 type2;
|
2010-02-26 13:08:42 +01:00
|
|
|
ut64 fail;
|
2014-06-13 12:06:29 +02:00
|
|
|
int size;
|
2010-05-21 18:23:01 +02:00
|
|
|
int type;
|
2014-01-01 23:09:46 -06:00
|
|
|
int type_ex;
|
2010-05-23 12:51:37 +02:00
|
|
|
int ninstr;
|
2011-02-11 11:22:43 +01:00
|
|
|
int returnbb;
|
2010-11-22 15:14:54 +01:00
|
|
|
int conditional;
|
2010-06-18 11:09:19 +02:00
|
|
|
int traced;
|
2018-08-25 05:11:12 -04:00
|
|
|
ut32 colorize;
|
2013-11-23 18:44:00 -06:00
|
|
|
char *label;
|
2010-12-04 15:14:53 +01:00
|
|
|
ut8 *fingerprint;
|
2010-12-05 08:46:56 +01:00
|
|
|
RAnalDiff *diff;
|
2010-06-15 00:46:18 +02:00
|
|
|
RAnalCond *cond;
|
2014-01-01 23:09:46 -06:00
|
|
|
RAnalSwitchOp *switch_op;
|
2016-02-11 00:18:09 +01:00
|
|
|
// offsets of instructions in this block
|
|
|
|
ut16 *op_pos;
|
|
|
|
// size of the op_pos array
|
2016-06-17 14:26:24 +02:00
|
|
|
int op_pos_size;
|
2014-01-06 19:02:52 -06:00
|
|
|
ut8 *op_bytes;
|
2014-01-01 23:09:46 -06:00
|
|
|
ut8 op_sz;
|
2015-04-16 06:42:07 +02:00
|
|
|
/* deprecate ??? where is this used? */
|
|
|
|
/* iirc only java. we must use r_anal_bb_from_offset(); instead */
|
2017-02-08 11:34:08 +00:00
|
|
|
RAnalBlock *head;
|
|
|
|
RAnalBlock *tail;
|
|
|
|
RAnalBlock *next;
|
2016-10-24 14:31:03 +02:00
|
|
|
/* these are used also in pdr: */
|
2017-02-08 11:34:08 +00:00
|
|
|
RAnalBlock *prev;
|
|
|
|
RAnalBlock *failbb;
|
|
|
|
RAnalBlock *jumpbb;
|
2014-01-01 23:09:46 -06:00
|
|
|
RList /*struct r_anal_bb_t*/ *cases;
|
2016-10-24 14:31:03 +02:00
|
|
|
ut8 *parent_reg_arena;
|
2017-01-31 10:00:24 +01:00
|
|
|
int stackptr;
|
|
|
|
int parent_stackptr;
|
2019-03-18 02:51:12 +01:00
|
|
|
bool folded;
|
2019-03-18 16:15:56 +01:00
|
|
|
ut64 cmpval;
|
|
|
|
const char *cmpreg;
|
2017-02-15 22:42:24 +01:00
|
|
|
#undef RAnalBlock
|
2010-05-21 01:46:26 +02:00
|
|
|
} RAnalBlock;
|
2009-04-01 00:32:26 +02:00
|
|
|
|
2011-06-14 04:49:10 +02:00
|
|
|
typedef enum {
|
2010-11-23 14:05:23 +01:00
|
|
|
R_ANAL_REF_TYPE_NULL = 0,
|
2010-07-02 02:01:51 +02:00
|
|
|
R_ANAL_REF_TYPE_CODE = 'c', // code ref
|
2010-11-23 14:05:23 +01:00
|
|
|
R_ANAL_REF_TYPE_CALL = 'C', // code ref (call)
|
2014-01-23 01:56:35 +01:00
|
|
|
R_ANAL_REF_TYPE_DATA = 'd', // mem ref
|
|
|
|
R_ANAL_REF_TYPE_STRING='s' // string ref
|
2010-06-14 00:57:40 +02:00
|
|
|
} RAnalRefType;
|
|
|
|
|
|
|
|
typedef struct r_anal_ref_t {
|
|
|
|
ut64 addr;
|
2010-09-28 13:58:03 +02:00
|
|
|
ut64 at;
|
2018-09-22 00:11:44 +02:00
|
|
|
RAnalRefType type;
|
2010-06-14 00:57:40 +02:00
|
|
|
} RAnalRef;
|
2019-01-22 11:51:22 +01:00
|
|
|
R_API const char *r_anal_ref_type_tostring(RAnalRefType t);
|
2009-10-12 17:41:52 +02:00
|
|
|
|
2015-11-02 21:30:55 +01:00
|
|
|
/* represents a reference line from one address (from) to another (to) */
|
2010-02-26 13:08:42 +01:00
|
|
|
typedef struct r_anal_refline_t {
|
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
|
|
|
int index;
|
2015-11-06 15:46:14 +01:00
|
|
|
int level;
|
2016-12-29 01:52:33 +01:00
|
|
|
int type;
|
|
|
|
int direction;
|
2010-03-19 12:00:04 +01:00
|
|
|
} RAnalRefline;
|
2010-02-22 04:02:13 +01:00
|
|
|
|
2014-01-05 14:43:57 -06:00
|
|
|
typedef struct r_anal_state_type_t {
|
2014-01-02 16:12:59 -06:00
|
|
|
ut64 start;
|
|
|
|
ut64 end;
|
|
|
|
const ut8* buffer;
|
|
|
|
ut64 len;
|
|
|
|
ut64 bytes_consumed;
|
|
|
|
ut64 last_addr;
|
|
|
|
ut64 current_addr;
|
|
|
|
ut64 next_addr;
|
|
|
|
RList *bbs;
|
2018-11-14 10:47:28 +01:00
|
|
|
HtUP *ht;
|
2014-01-02 16:12:59 -06:00
|
|
|
ut64 ht_sz;
|
|
|
|
RAnalFunction *current_fcn;
|
|
|
|
RAnalOp *current_op;
|
|
|
|
RAnalBlock *current_bb;
|
|
|
|
RAnalBlock *current_bb_head;
|
|
|
|
ut8 done;
|
|
|
|
int anal_ret_val;
|
|
|
|
ut32 current_depth;
|
|
|
|
ut32 max_depth;
|
|
|
|
void *user_state;
|
2014-01-05 17:21:09 -06:00
|
|
|
} RAnalState;
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2014-03-25 00:48:42 +01:00
|
|
|
typedef struct r_anal_cycle_frame_t {
|
|
|
|
ut64 naddr; //next addr
|
|
|
|
RList *hooks;
|
|
|
|
struct r_anal_cycle_frame_t *prev;
|
|
|
|
} RAnalCycleFrame;
|
|
|
|
|
|
|
|
typedef struct r_anal_cycle_hook_t { //rename ?
|
|
|
|
ut64 addr;
|
|
|
|
int cycles;
|
|
|
|
} RAnalCycleHook;
|
|
|
|
|
2014-06-20 18:01:33 +02:00
|
|
|
typedef struct r_anal_esil_word_t {
|
|
|
|
int type;
|
|
|
|
const char *str;
|
|
|
|
} RAnalEsilWord;
|
|
|
|
|
|
|
|
// only flags that affect control flow
|
|
|
|
enum {
|
|
|
|
R_ANAL_ESIL_FLAG_ZERO = 1,
|
|
|
|
R_ANAL_ESIL_FLAG_CARRY = 2,
|
|
|
|
R_ANAL_ESIL_FLAG_OVERFLOW = 4,
|
|
|
|
R_ANAL_ESIL_FLAG_PARITY = 8,
|
2014-07-21 04:18:27 +02:00
|
|
|
R_ANAL_ESIL_FLAG_SIGN = 16,
|
2014-06-20 18:01:33 +02:00
|
|
|
// ...
|
|
|
|
};
|
2014-08-04 16:03:50 +02:00
|
|
|
|
2014-07-21 04:18:27 +02:00
|
|
|
enum {
|
|
|
|
R_ANAL_TRAP_NONE = 0,
|
|
|
|
R_ANAL_TRAP_UNHANDLED = 1,
|
|
|
|
R_ANAL_TRAP_BREAKPOINT = 2,
|
|
|
|
R_ANAL_TRAP_DIVBYZERO = 3,
|
2015-09-09 01:17:55 +02:00
|
|
|
R_ANAL_TRAP_WRITE_ERR = 4,
|
|
|
|
R_ANAL_TRAP_READ_ERR = 5,
|
2015-09-23 12:46:22 +02:00
|
|
|
R_ANAL_TRAP_EXEC_ERR = 6,
|
2018-08-12 01:01:37 +02:00
|
|
|
R_ANAL_TRAP_INVALID = 7,
|
|
|
|
R_ANAL_TRAP_UNALIGNED = 8,
|
|
|
|
R_ANAL_TRAP_TODO = 9,
|
|
|
|
R_ANAL_TRAP_HALT = 10,
|
2014-07-21 04:18:27 +02:00
|
|
|
};
|
2014-08-04 16:03:50 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_ESIL_PARM_INVALID = 0,
|
|
|
|
R_ANAL_ESIL_PARM_REG,
|
|
|
|
R_ANAL_ESIL_PARM_NUM,
|
|
|
|
};
|
|
|
|
|
2015-03-30 18:45:25 +05:30
|
|
|
/* Constructs to convert from ESIL to REIL */
|
|
|
|
#define FOREACHOP(GENERATE) \
|
|
|
|
/* No Operation */ GENERATE(NOP) \
|
|
|
|
/* Unknown/Undefined */ GENERATE(UNK) \
|
|
|
|
/* Conditional Jump */ GENERATE(JCC) \
|
|
|
|
/* Store Value to register */ GENERATE(STR) \
|
|
|
|
/* Store value to memory */ GENERATE(STM) \
|
|
|
|
/* Load value from memory */ GENERATE(LDM) \
|
|
|
|
/* Addition */ GENERATE(ADD) \
|
|
|
|
/* Subtraction */ GENERATE(SUB) \
|
|
|
|
/* Negation */ GENERATE(NEG) \
|
|
|
|
/* Multiplication */ GENERATE(MUL) \
|
|
|
|
/* Division */ GENERATE(DIV) \
|
|
|
|
/* Modulo */ GENERATE(MOD) \
|
|
|
|
/* Signed Multiplication */ GENERATE(SMUL) \
|
|
|
|
/* Sugned Division */ GENERATE(SDIV) \
|
|
|
|
/* Signed Modulus */ GENERATE(SMOD) \
|
|
|
|
/* Shift Left */ GENERATE(SHL) \
|
|
|
|
/* Shift Right */ GENERATE(SHR) \
|
|
|
|
/* Binary and */ GENERATE(AND) \
|
|
|
|
/* Binary or */ GENERATE(OR) \
|
|
|
|
/* Binary xor */ GENERATE(XOR) \
|
|
|
|
/* Binary not */ GENERATE(NOT) \
|
|
|
|
/* Equation */ GENERATE(EQ) \
|
|
|
|
/* Less Than */ GENERATE(LT)
|
|
|
|
|
|
|
|
#define MAKE_ENUM(OP) REIL_##OP,
|
|
|
|
#define REIL_OP_STRING(STRING) #STRING,
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FOREACHOP(MAKE_ENUM)
|
|
|
|
} RAnalReilOpcode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ARG_REG, // CPU Register
|
|
|
|
ARG_TEMP, // Temporary register used by REIL
|
|
|
|
ARG_CONST, // Constant value
|
|
|
|
ARG_ESIL_INTERNAL, // Used to resolve ESIL internal flags
|
|
|
|
ARG_NONE // Operand not used by the instruction
|
|
|
|
} RAnalReilArgType;
|
|
|
|
|
|
|
|
// Arguments to a REIL instruction.
|
|
|
|
typedef struct r_anal_reil_arg {
|
|
|
|
RAnalReilArgType type; // Type of the argument
|
|
|
|
ut8 size; // Size of the argument in bytes
|
2015-11-24 18:26:10 +01:00
|
|
|
char name[32]; // Name of the argument
|
2015-03-30 18:45:25 +05:30
|
|
|
} RAnalReilArg;
|
|
|
|
|
2019-05-27 21:50:03 +05:30
|
|
|
typedef struct r_anal_ref_char {
|
|
|
|
char *str;
|
|
|
|
char *cols;
|
|
|
|
} RAnalRefStr;
|
|
|
|
|
2015-03-30 18:45:25 +05:30
|
|
|
// Instruction arg1, arg2, arg3
|
|
|
|
typedef struct r_anal_reil_inst {
|
|
|
|
RAnalReilOpcode opcode;
|
|
|
|
RAnalReilArg *arg[3];
|
|
|
|
} RAnalReilInst;
|
|
|
|
|
|
|
|
typedef struct r_anal_reil {
|
|
|
|
char old[32]; // Used to compute flags.
|
|
|
|
char cur[32];
|
|
|
|
ut8 lastsz;
|
|
|
|
ut64 reilNextTemp; // Used to store the index of the next REIL temp register to be used.
|
|
|
|
ut64 addr; // Used for instruction sequencing. Check esil2reil.c for details.
|
|
|
|
ut8 seq_num; // Incremented and used when noInc is set to 1.
|
|
|
|
int skip;
|
|
|
|
int cmd_count;
|
|
|
|
char if_buf[64];
|
|
|
|
char pc[8];
|
|
|
|
} RAnalReil;
|
|
|
|
|
2015-11-12 13:47:44 +01:00
|
|
|
// must be a char
|
|
|
|
#define ESIL_INTERNAL_PREFIX '$'
|
2017-07-29 19:59:41 +09:00
|
|
|
#define ESIL_STACK_NAME "esil.ram"
|
2014-06-20 18:01:33 +02:00
|
|
|
#define ESIL struct r_anal_esil_t
|
2014-08-04 16:03:50 +02:00
|
|
|
|
2018-08-31 00:36:38 +00:00
|
|
|
typedef struct r_anal_esil_source_t {
|
|
|
|
ut32 id;
|
|
|
|
ut32 claimed;
|
|
|
|
void *content;
|
|
|
|
} RAnalEsilSource;
|
|
|
|
|
|
|
|
R_API void r_anal_esil_sources_init(ESIL *esil);
|
|
|
|
R_API ut32 r_anal_esil_load_source(ESIL *esil, const char *path);
|
|
|
|
R_API void *r_anal_esil_get_source(ESIL *esil, ut32 src_id);
|
|
|
|
R_API bool r_anal_esil_claim_source(ESIL *esil, ut32 src_id);
|
|
|
|
R_API void r_anal_esil_release_source(ESIL *esil, ut32 src_id);
|
|
|
|
R_API void r_anal_esil_sources_fini(ESIL *esil);
|
|
|
|
|
|
|
|
typedef bool (*RAnalEsilInterruptCB)(ESIL *esil, ut32 interrupt, void *user);
|
|
|
|
|
|
|
|
typedef struct r_anal_esil_interrupt_handler_t {
|
|
|
|
const ut32 num;
|
2018-09-17 16:29:03 +02:00
|
|
|
const char* name;
|
2018-08-31 00:36:38 +00:00
|
|
|
void *(*init)(ESIL *esil);
|
|
|
|
RAnalEsilInterruptCB cb;
|
|
|
|
void (*fini)(void *user);
|
|
|
|
} RAnalEsilInterruptHandler;
|
|
|
|
|
|
|
|
typedef struct r_anal_esil_interrupt_t {
|
|
|
|
RAnalEsilInterruptHandler *handler;
|
|
|
|
void *user;
|
|
|
|
ut32 src_id;
|
|
|
|
} RAnalEsilInterrupt;
|
|
|
|
|
2017-07-29 19:59:41 +09:00
|
|
|
typedef struct r_anal_esil_session_t {
|
|
|
|
ut64 key;
|
|
|
|
ut64 addr;
|
|
|
|
ut64 size;
|
|
|
|
ut8 *data;
|
|
|
|
RListIter *reg[R_REG_TYPE_LAST];
|
|
|
|
} RAnalEsilSession;
|
|
|
|
|
2018-02-16 12:42:54 +08:00
|
|
|
typedef int (*RAnalEsilHookRegWriteCB)(ESIL *esil, const char *name, ut64 *val);
|
|
|
|
|
2015-02-22 11:18:40 +01:00
|
|
|
typedef struct r_anal_esil_callbacks_t {
|
2014-06-20 18:01:33 +02:00
|
|
|
void *user;
|
2015-02-22 11:18:40 +01:00
|
|
|
/* callbacks */
|
|
|
|
int (*hook_flag_read)(ESIL *esil, const char *flag, ut64 *num);
|
|
|
|
int (*hook_command)(ESIL *esil, const char *op);
|
|
|
|
int (*hook_mem_read)(ESIL *esil, ut64 addr, ut8 *buf, int len);
|
|
|
|
int (*mem_read)(ESIL *esil, ut64 addr, ut8 *buf, int len);
|
|
|
|
int (*hook_mem_write)(ESIL *esil, ut64 addr, const ut8 *buf, int len);
|
|
|
|
int (*mem_write)(ESIL *esil, ut64 addr, const ut8 *buf, int len);
|
2015-09-14 01:00:09 +02:00
|
|
|
int (*hook_reg_read)(ESIL *esil, const char *name, ut64 *res, int *size);
|
|
|
|
int (*reg_read)(ESIL *esil, const char *name, ut64 *res, int *size);
|
2018-02-16 12:42:54 +08:00
|
|
|
RAnalEsilHookRegWriteCB hook_reg_write;
|
2015-02-22 11:18:40 +01:00
|
|
|
int (*reg_write)(ESIL *esil, const char *name, ut64 val);
|
|
|
|
} RAnalEsilCallbacks;
|
|
|
|
|
|
|
|
typedef struct r_anal_esil_t {
|
2014-06-20 18:01:33 +02:00
|
|
|
RAnal *anal;
|
2016-01-19 23:36:21 +00:00
|
|
|
char **stack;
|
Fix #9595 (#9673)
* Added an address mask inside the RAnalEsil struct in order to be sure that the address accessed is relevant with the asm.bits of the file + Changed the calls to r_anal_esil_new
* Corrected the addrmask in r_anal_esil_new
* RTTI: Read MSVC Complete Object Locator
* RTTI: Read MSVC Class Hierarchy Descriptor
* VTable End on Reference
* RTTI: Read MSVC Type Descriptor
* RTTI: Read MSVC Base Class Array, Better Printing
* Add anal.cpp.abi
* Minor Code Style Changes in RTTI
* Fix rahash2 entropy to show non truncated double (#9629)
* Anal - whitespace fixes
* Honor CFLAGS on the static build test compilation (#9677)
* change coding style tab width to 4 (#9670)
* Meson: use more built-in options (#9678)
* Add support for extended regex in asm search (#9675)
* Fix #9665 - Backwardly handle scr.color={bool}
* Fix #9676 - Infinite loop in ecs with scr.color=2
* Adding help for redirection (#9679)
* Refactores function r_str_split_list to receive the character to split by (#9672)
* Fix #9666 - lines with comments do not use Unicode reflines
* Fix uninitialized optypes_list issue in cmd_debug
* update asan.sh to actually take the env for ASAN
* removed incorrect return (#9685)
* Fix UB in ESIL
* Initial import of the CoreUndo API and uc command
* Initial implementation of cmd.pdc to select pseudo-decompiler
* Handle recursive pdc calls
* Fix RPrint.strconv_mode memleak
* Fix leaks in RSyscall.srdb
* Use r_syscall_ref to avoid dblfree-or-leak issue
* Arm thumb/thumb selector for the armass (#9681)
* added function to translate number to imm12
* added function to get thumb shifts easily
* added selector, newfangled implementation of adc
* add bitmask for command suffixes
* added new routine for parsing suffixes to opcodes. Error check added in getnum. Bugfixes.
* Few improvements to 8051 memory mapping (#9686)
* update memory map when idata/sfr/xdata regs change
* set address space name on map
* fix regression, remove debug output
* fix regression, enable map name
* Some fixups for #9682 (#9688)
* Fix: coredump generation for huge programs (#9680)
* Refix #9666 - lines with comments do not use Unicode reflines
* Removed code unnecessary due to dcf3db025085c45124ec21890550a4ef19bd015c
* Fixed free const warning
* Fix another memleak in RSyscall
* Fix more memleaks
* Fix leak in RConsPal.rainbow
* Fix 18K leak in anal.x86.cs
* Fix some more memleaks in disasm and fix issue in str overlap
* Fix memleak in RCore.anal_refs and fix regression
* Revert "Fix some more memleaks in disasm and fix issue in str overlap"
This reverts commit a902df837b0d499e1723179ed5c957c078703b51.
* Fix memleak regressions
* Bring back another memleak fix
* Fix an undefined behaviour in RParse.filter
* Fix memleaks in disasm.c
* Add cundo.c to Meson (#9694)
* Bring back an ugly buffer pack access issue to make it work
* Cast to void * in R_FREE (#9692)
* Set anal.cpp.abi to msvc for pe
* Add better help for av
* Split avr into avr and avra
* Make av, avr and avra breakable
* Add RTTI struct specific print functions
* RTTI: Support MSVC x86_64
* PE: Fix too short section name.
* PDB: define a constant to store the max length of a section name and use id.
* PDB: dump the size of structure and union in JSON mode.
* Fix cast issue in eprintf for debug.core.linux
* Move the asm and anal plugins for x86.udis to extras
Available via r2pm -ci udis86
* Remove more udis86 references
* Fix warnings
* fix pcache ptr-fuckup
* Fix defragger theme
* Fix crash in asl and fix its behaviour
* Fix memory leak in blaze anal and silent a warning
* Implement ?q to be like ?v but in quiet mode
* Fix Meson build
* Add missing 8, 16, 32 bit registers (and flags) for the linux-arm64 debugger reg profile
* Fix 'Cannot find function at UT64_MAX message'
* Add some Pingu to fortunes.fun
* Loading Core (x86, x86_64, aarch64) (#9669)
* Ragg2-cc -> Ragg2 merge (#9658)
- change of 'access' function for 'r_file_exists' for windows portability
- several changes in the way ragg2.c is done, see PR #9658 pancake comments
- change function for the remove of 'file'.text
- open changed for r_file_dump
- some elt of cEnv_t are now const
- skip all the pointers verification in set_cEnv but do them in check_cEnv instead
- add 2 r_str_sanitize for file and CC in parseCFile
- rewrite the removal of .o, .tmp, .bin, .s files, with cleaner code
- changed the long command with sed and grep to 2 C functions.
- The function parseCompiled that basically does what the command was doing
- And r_str_stripLines that is equivalent to "grep -v" (maybe we should put this one in str.c ?)
- simplify a bit getCompiler function with a const char* array
- add ternary operator for armOrMips condition
- use r_file_path for finding path to compilers
- new file created in libr/egg which contains all the C file parser
- modifications of 2 files to match the change :
- libr/egg/r_egg.h
- libr/egg/Makefile
- the function r_str_stripLine is simplier (the mallocs wasn't needed)
- the function r_str_stripLine is moved to libr/util/str.c
- libr/include/r_util/r_str.h is changed accordingly
* Revert bd3465c9a3fbeddf83980dc07eaac588320f7d (warning remains fixed)
This reverts commit titled "Fixed free const warning".
* Added an address mask inside the RAnalEsil struct in order to be sure that the address accessed is relevant with the asm.bits of the file + Changed the calls to r_anal_esil_new
* Corrected the addrmask in r_anal_esil_new
* Cleanup expressions in esil.c (addr &=...)
* Corrected r_anal_esil_new definition in r_anal.h
* Added an address size max in the ESIL config (maximum address size reachable by the ESIL VM)
2018-03-16 10:45:17 +01:00
|
|
|
ut64 addrmask;
|
2016-01-19 23:36:21 +00:00
|
|
|
int stacksize;
|
2014-06-20 18:01:33 +02:00
|
|
|
int stackptr;
|
2018-09-13 23:47:44 +00:00
|
|
|
ut32 skip;
|
2014-09-11 04:18:23 +02:00
|
|
|
int nowrite;
|
2015-09-09 01:17:55 +02:00
|
|
|
int iotrap;
|
2015-09-23 12:46:22 +02:00
|
|
|
int exectrap;
|
2014-06-20 18:01:33 +02:00
|
|
|
int repeat;
|
2014-09-01 23:26:01 +02:00
|
|
|
int parse_stop;
|
|
|
|
int parse_goto;
|
|
|
|
int parse_goto_count;
|
2016-11-14 01:17:58 +01:00
|
|
|
int verbose;
|
2014-06-20 18:01:33 +02:00
|
|
|
ut64 flags;
|
2015-09-14 11:31:54 +02:00
|
|
|
ut64 address;
|
2017-07-29 19:59:41 +09:00
|
|
|
ut64 stack_addr;
|
|
|
|
ut32 stack_size;
|
2016-11-14 01:17:58 +01:00
|
|
|
int delay; // mapped to $ds in ESIL
|
|
|
|
ut64 jump_target; // mapped to $jt in ESIL
|
2015-12-06 19:38:50 +01:00
|
|
|
int jump_target_set; // mapped to $js in ESIL
|
2014-07-21 04:18:27 +02:00
|
|
|
int trap;
|
|
|
|
ut32 trap_code; // extend into a struct to store more exception info?
|
2015-10-22 03:11:03 +02:00
|
|
|
// parity flag? done with cur
|
2014-08-04 16:03:50 +02:00
|
|
|
ut64 old; //used for carry-flagging and borrow-flagging
|
2014-08-05 02:07:09 +02:00
|
|
|
ut64 cur; //used for carry-flagging and borrow-flagging
|
2015-03-07 03:04:05 +01:00
|
|
|
ut8 lastsz; //in bits //used for signature-flag
|
2014-08-05 18:44:55 +02:00
|
|
|
/* native ops and custom ops */
|
|
|
|
Sdb *ops;
|
2019-06-02 20:33:36 +00:00
|
|
|
char *current_opstr;
|
2018-08-31 00:36:38 +00:00
|
|
|
RIDStorage *sources;
|
|
|
|
SdbMini *interrupts;
|
2018-10-30 13:05:18 +01:00
|
|
|
//this is a disgusting workaround, because we have no ht-like storage without magic keys, that you cannot use, with int-keys
|
|
|
|
RAnalEsilInterrupt *intr0;
|
2014-09-11 04:18:23 +02:00
|
|
|
/* deep esil parsing fills this */
|
|
|
|
Sdb *stats;
|
2015-02-22 11:18:40 +01:00
|
|
|
Sdb *db_trace;
|
|
|
|
int trace_idx;
|
|
|
|
RAnalEsilCallbacks cb;
|
2015-03-30 18:45:25 +05:30
|
|
|
RAnalReil *Reil;
|
2019-06-10 05:57:20 +00:00
|
|
|
// this is so cursed, can we please remove external commands from esil internals.
|
|
|
|
// Function pointers are fine, but not commands
|
2019-03-06 14:46:01 +01:00
|
|
|
char *cmd_step; // r2 (external) command to run before a step is performed
|
2019-06-20 02:17:29 +02:00
|
|
|
char *cmd_step_out; // r2 (external) command to run after a step is performed
|
2015-09-08 02:53:33 +02:00
|
|
|
char *cmd_intr; // r2 (external) command to run when an interrupt occurs
|
2017-06-10 18:00:07 +02:00
|
|
|
char *cmd_trap; // r2 (external) command to run when a trap occurs
|
|
|
|
char *cmd_mdev; // r2 (external) command to run when an memory mapped device address is used
|
|
|
|
char *cmd_todo; // r2 (external) command to run when esil expr contains TODO
|
2017-06-10 20:40:16 +02:00
|
|
|
char *cmd_ioer; // r2 (external) command to run when esil fails to IO
|
2017-03-25 03:29:03 +01:00
|
|
|
char *mdev_range; // string containing the r_str_range to match for read/write accesses
|
|
|
|
bool (*cmd)(ESIL *esil, const char *name, ut64 a0, ut64 a1);
|
2016-01-15 01:50:08 +01:00
|
|
|
void *user;
|
2018-09-13 23:47:44 +00:00
|
|
|
int stack_fd; // ahem, let's not do this
|
2017-07-29 19:59:41 +09:00
|
|
|
RList *sessions; // <RAnalEsilSession*>
|
2014-06-20 18:01:33 +02:00
|
|
|
} RAnalEsil;
|
|
|
|
|
2014-09-01 19:40:56 +02:00
|
|
|
#undef ESIL
|
|
|
|
|
2019-06-10 05:57:20 +00:00
|
|
|
|
2019-06-02 20:33:36 +00:00
|
|
|
enum {
|
2019-06-10 05:57:20 +00:00
|
|
|
R_ANAL_ESIL_OP_TYPE_UNKNOWN = 0x1,
|
|
|
|
R_ANAL_ESIL_OP_TYPE_CONTROL_FLOW,
|
|
|
|
R_ANAL_ESIL_OP_TYPE_MEM_READ = 0x4,
|
|
|
|
R_ANAL_ESIL_OP_TYPE_MEM_WRITE = 0x8,
|
|
|
|
R_ANAL_ESIL_OP_TYPE_REG_WRITE = 0x10,
|
|
|
|
R_ANAL_ESIL_OP_TYPE_MATH = 0x20,
|
|
|
|
R_ANAL_ESIL_OP_TYPE_CUSTOM = 0x40
|
2019-06-02 20:33:36 +00:00
|
|
|
};
|
2019-06-10 05:57:20 +00:00
|
|
|
|
2019-06-02 20:33:36 +00:00
|
|
|
|
|
|
|
typedef bool (*RAnalEsilOpCb)(RAnalEsil *esil);
|
|
|
|
|
|
|
|
typedef struct r_anal_esil_operation_t {
|
|
|
|
RAnalEsilOpCb code;
|
2019-06-10 06:01:24 +00:00
|
|
|
ut32 push; // amount of operands pushed
|
|
|
|
ut32 pop; // amount of operands popped
|
2019-06-10 05:57:20 +00:00
|
|
|
ut32 type;
|
2019-06-02 20:33:36 +00:00
|
|
|
} RAnalEsilOp;
|
|
|
|
|
|
|
|
|
2014-01-14 18:07:57 -06:00
|
|
|
typedef int (*RAnalCmdExt)(/* Rcore */RAnal *anal, const char* input);
|
2014-01-01 23:09:46 -06:00
|
|
|
typedef int (*RAnalAnalyzeFunctions)(RAnal *a, ut64 at, ut64 from, int reftype, int depth);
|
2014-01-05 14:43:57 -06:00
|
|
|
typedef int (*RAnalExCallback)(RAnal *a, struct r_anal_state_type_t *state, ut64 addr);
|
|
|
|
typedef RList *(*RAnalExAnalysisAlgorithm)(RAnal *a, struct r_anal_state_type_t *state, ut64 addr);
|
2014-01-01 23:09:46 -06:00
|
|
|
|
|
|
|
typedef RAnalOp * (*RAnalOpFromBuffer) (RAnal *a, ut64 addr, const ut8* buf, ut64 len);
|
|
|
|
typedef RAnalBlock * (*RAnalBbFromBuffer) (RAnal *a, ut64 addr, const ut8* buf, ut64 len);
|
|
|
|
typedef RAnalFunction * (*RAnalFnFromBuffer)(RAnal *a, ut64 addr, const ut8* buf, ut64 len);
|
|
|
|
|
2019-03-16 10:20:20 +01:00
|
|
|
// TODO: rm data + len
|
2019-03-15 19:39:24 +01:00
|
|
|
typedef int (*RAnalOpCallback)(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *data, int len, RAnalOpMask mask);
|
2014-01-01 23:09:46 -06:00
|
|
|
typedef int (*RAnalBbCallback)(RAnal *a, RAnalBlock *bb, ut64 addr, const ut8 *data, int len);
|
2019-03-16 10:20:20 +01:00
|
|
|
typedef int (*RAnalFnCallback)(RAnal *a, RAnalFunction *fcn, ut64 addr, int reftype);
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2011-02-18 13:08:09 +01:00
|
|
|
typedef int (*RAnalRegProfCallback)(RAnal *a);
|
2016-04-08 00:54:15 +02:00
|
|
|
typedef char*(*RAnalRegProfGetCallback)(RAnal *a);
|
2011-03-06 15:21:13 +01:00
|
|
|
typedef int (*RAnalFPBBCallback)(RAnal *a, RAnalBlock *bb);
|
2012-07-19 06:54:22 +04:00
|
|
|
typedef int (*RAnalFPFcnCallback)(RAnal *a, RAnalFunction *fcn);
|
|
|
|
typedef int (*RAnalDiffBBCallback)(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2);
|
2011-03-06 15:21:13 +01:00
|
|
|
typedef int (*RAnalDiffFcnCallback)(RAnal *anal, RList *fcns, RList *fcns2);
|
|
|
|
typedef int (*RAnalDiffEvalCallback)(RAnal *anal);
|
2010-07-02 02:01:51 +02:00
|
|
|
|
2016-10-11 14:28:46 +02:00
|
|
|
typedef bool (*RAnalIsValidOffsetCB)(RAnal *anal, ut64 offset, int hasperm);
|
|
|
|
|
2014-06-20 18:01:33 +02:00
|
|
|
typedef int (*RAnalEsilCB)(RAnalEsil *esil);
|
|
|
|
typedef int (*RAnalEsilLoopCB)(RAnalEsil *esil, RAnalOp *op);
|
2015-09-19 19:39:25 +02:00
|
|
|
typedef int (*RAnalEsilTrapCB)(RAnalEsil *esil, int trap_type, int trap_code);
|
2014-06-20 18:01:33 +02:00
|
|
|
|
2010-05-26 01:42:22 +02:00
|
|
|
typedef struct r_anal_plugin_t {
|
2009-02-16 02:12:02 +01:00
|
|
|
char *name;
|
|
|
|
char *desc;
|
2013-12-05 18:41:13 +01:00
|
|
|
char *license;
|
2015-10-22 02:23:52 +02:00
|
|
|
char *arch;
|
2017-02-28 02:29:54 +01:00
|
|
|
char *author;
|
|
|
|
char *version;
|
2011-05-06 19:56:16 +02:00
|
|
|
int bits;
|
2014-08-24 14:35:15 +02:00
|
|
|
int esil; // can do esil or not
|
2014-01-01 23:09:46 -06:00
|
|
|
int fileformat_type;
|
|
|
|
int custom_fn_anal;
|
2009-02-16 02:12:02 +01:00
|
|
|
int (*init)(void *user);
|
|
|
|
int (*fini)(void *user);
|
2014-02-14 13:40:22 -06:00
|
|
|
int (*reset_counter) (RAnal *anal, ut64 start_addr);
|
2015-10-14 02:11:53 +02:00
|
|
|
int (*archinfo)(RAnal *anal, int query);
|
2017-03-29 00:18:29 +00:00
|
|
|
ut8* (*anal_mask)(RAnal *anal, int size, const ut8 *data, ut64 at);
|
2014-08-24 14:35:15 +02:00
|
|
|
|
2014-01-01 23:09:46 -06:00
|
|
|
// legacy r_anal_functions
|
2011-02-24 14:06:49 +01:00
|
|
|
RAnalOpCallback op;
|
2014-01-01 23:09:46 -06:00
|
|
|
RAnalBbCallback bb;
|
|
|
|
RAnalFnCallback fcn;
|
|
|
|
|
2019-06-20 12:45:00 +08:00
|
|
|
// override the default analysis function in r_core_anal_fcn
|
2014-01-01 23:09:46 -06:00
|
|
|
RAnalAnalyzeFunctions analyze_fns;
|
|
|
|
|
|
|
|
// parse elements from a buffer
|
|
|
|
RAnalOpFromBuffer op_from_buffer;
|
|
|
|
RAnalBbFromBuffer bb_from_buffer;
|
|
|
|
RAnalFnFromBuffer fn_from_buffer;
|
|
|
|
|
|
|
|
// analysis algorithm to use instead of the default
|
2015-07-12 15:55:55 +02:00
|
|
|
// r_anal_ex_recursive_descent when using perform_analysis from
|
2014-01-05 14:43:57 -06:00
|
|
|
// RAnalEx stuffs
|
|
|
|
RAnalExAnalysisAlgorithm analysis_algorithm;
|
2014-09-26 15:40:17 +02:00
|
|
|
// order in which these call backs are
|
2014-01-01 23:09:46 -06:00
|
|
|
// used with the recursive descent disassembler
|
|
|
|
// analysis
|
2014-09-26 15:40:17 +02:00
|
|
|
// 0) Before performing any analysis is start, opportunity to do any pre analysis.
|
2014-01-01 23:09:46 -06:00
|
|
|
// in the current function
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback pre_anal;
|
2014-01-01 23:09:46 -06:00
|
|
|
// 1) Before any ops are bbs are created
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback pre_anal_fn_cb;
|
2014-09-26 15:40:17 +02:00
|
|
|
// 2) Just Before an op is created.
|
|
|
|
// if current_op is set in state, then an op in the main alg wont be processed
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback pre_anal_op_cb;
|
2014-09-26 15:40:17 +02:00
|
|
|
// 3) After a op is created.
|
|
|
|
// the current_op in state is used to fix-up the state of op before creating a bb
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback post_anal_op_cb;
|
2014-09-26 15:40:17 +02:00
|
|
|
// 4) Before a bb is created.
|
|
|
|
// if current_op is set in state, then an op in the main alg wont be processed
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback pre_anal_bb_cb;
|
2014-09-26 15:40:17 +02:00
|
|
|
// 5) After a bb is created.
|
|
|
|
// the current_bb in state is used to fix-up the state of before performing analysis
|
|
|
|
// with the current bb
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback post_anal_bb_cb;
|
2014-09-26 15:40:17 +02:00
|
|
|
// 6) After processing is bb and cb is completed, opportunity to do any post analysis.
|
2014-01-01 23:09:46 -06:00
|
|
|
// in the current function
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback post_anal_fn_cb;
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2014-09-26 15:40:17 +02:00
|
|
|
// 6) After bb in a node is completed, opportunity to do any post analysis.
|
2014-01-01 23:09:46 -06:00
|
|
|
// in the current function
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback post_anal;
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2014-01-05 14:43:57 -06:00
|
|
|
RAnalExCallback revisit_bb_anal;
|
2014-09-26 15:40:17 +02:00
|
|
|
|
2014-01-01 23:09:46 -06:00
|
|
|
// command extension to directly call any analysis functions
|
|
|
|
RAnalCmdExt cmd_ext;
|
|
|
|
|
2011-02-18 13:08:09 +01:00
|
|
|
RAnalRegProfCallback set_reg_profile;
|
2016-04-08 00:54:15 +02:00
|
|
|
RAnalRegProfGetCallback get_reg_profile;
|
2011-03-06 15:21:13 +01:00
|
|
|
RAnalFPBBCallback fingerprint_bb;
|
|
|
|
RAnalFPFcnCallback fingerprint_fcn;
|
|
|
|
RAnalDiffBBCallback diff_bb;
|
|
|
|
RAnalDiffFcnCallback diff_fcn;
|
|
|
|
RAnalDiffEvalCallback diff_eval;
|
2014-09-26 15:40:17 +02:00
|
|
|
|
2015-09-08 00:46:04 +02:00
|
|
|
RAnalEsilCB esil_init; // initialize esil-related stuff
|
|
|
|
RAnalEsilLoopCB esil_post_loop; //cycle-counting, firing interrupts, ...
|
2015-09-19 19:39:25 +02:00
|
|
|
RAnalEsilTrapCB esil_trap; // traps / exceptions
|
2015-09-08 00:46:04 +02:00
|
|
|
RAnalEsilCB esil_fini; // deinitialize
|
2010-05-26 01:42:22 +02:00
|
|
|
} RAnalPlugin;
|
2009-02-16 02:12:02 +01:00
|
|
|
|
2016-09-22 20:48:26 +05:30
|
|
|
/*----------------------------------------------------------------------------------------------*/
|
2016-09-22 22:00:42 +05:30
|
|
|
int * (r_anal_compare) (RAnalFunction , RAnalFunction );
|
2016-09-22 20:48:26 +05:30
|
|
|
/*----------------------------------------------------------------------------------------------*/
|
2011-09-14 13:22:57 +02:00
|
|
|
|
|
|
|
#ifdef R_API
|
2011-09-14 02:07:06 +02:00
|
|
|
/* --------- */ /* REFACTOR */ /* ---------- */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RListRange* r_listrange_new (void);
|
2011-09-14 02:07:06 +02:00
|
|
|
R_API void r_listrange_free(RListRange *s);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API void r_listrange_add(RListRange *s, RAnalFunction *f);
|
|
|
|
R_API void r_listrange_del(RListRange *s, RAnalFunction *f);
|
|
|
|
R_API void r_listrange_resize(RListRange *s, RAnalFunction *f, int newsize);
|
|
|
|
R_API RAnalFunction *r_listrange_find_in_range(RListRange* s, ut64 addr);
|
|
|
|
R_API RAnalFunction *r_listrange_find_root(RListRange* s, ut64 addr);
|
2011-09-14 02:07:06 +02:00
|
|
|
/* --------- */ /* REFACTOR */ /* ---------- */
|
2012-07-22 12:00:35 +04:00
|
|
|
/* type.c */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalType *r_anal_type_new(void);
|
2012-08-28 11:02:25 +02:00
|
|
|
R_API void r_anal_type_add(RAnal *l, RAnalType *t);
|
|
|
|
R_API RAnalType *r_anal_type_find(RAnal *a, const char* name);
|
|
|
|
R_API void r_anal_type_list(RAnal *a, short category, short enabled);
|
2019-02-17 23:55:10 +01:00
|
|
|
R_API const char *r_anal_datatype_to_string(RAnalDataType t);
|
2012-08-28 11:02:25 +02:00
|
|
|
R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* s);
|
2018-05-29 10:21:31 +05:30
|
|
|
R_API bool r_anal_op_nonlinear(int t);
|
2018-06-06 01:13:32 +05:30
|
|
|
R_API bool r_anal_op_ismemref(int t);
|
2015-03-04 00:46:59 +01:00
|
|
|
R_API const char *r_anal_optype_to_string(int t);
|
2019-01-17 00:26:39 +01:00
|
|
|
R_API int r_anal_optype_from_string(const char *type);
|
2014-12-02 00:36:42 +01:00
|
|
|
R_API const char *r_anal_op_family_to_string (int n);
|
2016-06-16 01:43:41 +02:00
|
|
|
R_API int r_anal_op_family_from_string(const char *f);
|
2016-12-12 14:47:42 +01:00
|
|
|
R_API int r_anal_op_hint(RAnalOp *op, RAnalHint *hint);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API RAnalType *r_anal_type_free(RAnalType *t);
|
2012-08-28 11:02:25 +02:00
|
|
|
R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path);
|
2018-05-18 14:02:31 +05:30
|
|
|
|
2010-03-12 03:05:20 +01:00
|
|
|
/* anal.c */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnal *r_anal_new(void);
|
2015-01-22 02:22:29 +01:00
|
|
|
R_API int r_anal_purge (RAnal *anal);
|
2014-08-29 16:26:43 +02:00
|
|
|
R_API RAnal *r_anal_free(RAnal *r);
|
2010-03-19 12:23:14 +01:00
|
|
|
R_API void r_anal_set_user_ptr(RAnal *anal, void *user);
|
2014-03-25 12:05:34 +01:00
|
|
|
R_API void r_anal_plugin_free (RAnalPlugin *p);
|
|
|
|
R_API int r_anal_add(RAnal *anal, RAnalPlugin *foo);
|
2015-10-14 02:11:53 +02:00
|
|
|
R_API int r_anal_archinfo(RAnal *anal, int query);
|
2016-04-08 00:54:15 +02:00
|
|
|
R_API bool r_anal_use(RAnal *anal, const char *name);
|
|
|
|
R_API bool r_anal_set_reg_profile(RAnal *anal);
|
|
|
|
R_API char *r_anal_get_reg_profile(RAnal *anal);
|
|
|
|
R_API bool r_anal_set_bits(RAnal *anal, int bits);
|
|
|
|
R_API bool r_anal_set_os(RAnal *anal, const char *os);
|
2014-02-06 00:08:46 +04:00
|
|
|
R_API void r_anal_set_cpu(RAnal *anal, const char *cpu);
|
2010-03-19 12:23:14 +01:00
|
|
|
R_API int r_anal_set_big_endian(RAnal *anal, int boolean);
|
2017-03-29 00:18:29 +00:00
|
|
|
R_API ut8 *r_anal_mask(RAnal *anal, int size, const ut8 *data, ut64 at);
|
2011-02-11 11:22:43 +01:00
|
|
|
R_API void r_anal_trace_bb(RAnal *anal, ut64 addr);
|
2014-04-27 02:48:42 +02:00
|
|
|
R_API const char *r_anal_fcn_type_tostring(int type);
|
2016-09-01 23:50:28 +03:00
|
|
|
R_API void r_anal_bind(RAnal *b, RAnalBind *bnd);
|
2010-03-12 03:05:20 +01:00
|
|
|
|
2015-10-30 03:07:22 +01:00
|
|
|
/* fcnsign */
|
2019-06-17 02:23:58 +02:00
|
|
|
R_API bool r_anal_set_triplet(RAnal *anal, const char *os, const char *arch, int bits);
|
2015-10-30 03:07:22 +01:00
|
|
|
R_API bool r_anal_set_fcnsign(RAnal *anal, const char *name);
|
|
|
|
R_API const char *r_anal_get_fcnsign(RAnal *anal, const char *sym);
|
|
|
|
|
2010-03-12 03:05:20 +01:00
|
|
|
/* bb.c */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalBlock *r_anal_bb_new(void);
|
|
|
|
R_API RList *r_anal_bb_list_new(void);
|
2011-11-14 00:21:25 +01:00
|
|
|
R_API void r_anal_bb_free(RAnalBlock *bb);
|
2016-10-26 18:49:25 +02:00
|
|
|
R_API int r_anal_bb(RAnal *anal, RAnalBlock *bb, ut64 addr, ut8 *buf, ut64 len, int head);
|
2011-02-28 13:07:41 +01:00
|
|
|
R_API RAnalBlock *r_anal_bb_from_offset(RAnal *anal, ut64 off);
|
2016-02-11 00:18:09 +01:00
|
|
|
R_API int r_anal_bb_is_in_offset(RAnalBlock *bb, ut64 addr);
|
2016-08-22 18:32:18 +02:00
|
|
|
R_API bool r_anal_bb_set_offset(RAnalBlock *bb, int i, ut16 v);
|
2016-02-11 00:18:09 +01:00
|
|
|
R_API ut16 r_anal_bb_offset_inst(RAnalBlock *bb, int i);
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API ut64 r_anal_bb_opaddr_i(RAnalBlock *bb, int i);
|
2016-02-11 00:18:09 +01:00
|
|
|
R_API ut64 r_anal_bb_opaddr_at(RAnalBlock *bb, ut64 addr);
|
2018-10-31 18:47:17 +08:00
|
|
|
R_API bool r_anal_bb_op_starts_at(RAnalBlock *bb, ut64 addr);
|
2016-10-24 14:31:03 +02:00
|
|
|
R_API RAnalBlock *r_anal_bb_get_failbb(RAnalFunction *fcn, RAnalBlock *bb);
|
|
|
|
R_API RAnalBlock *r_anal_bb_get_jumpbb(RAnalFunction *fcn, RAnalBlock *bb);
|
2010-03-12 03:05:20 +01:00
|
|
|
|
2011-02-24 14:06:49 +01:00
|
|
|
/* op.c */
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API const char *r_anal_stackop_tostring(int s);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalOp *r_anal_op_new(void);
|
2011-02-24 14:06:49 +01:00
|
|
|
R_API void r_anal_op_free(void *op);
|
2019-03-06 15:04:22 +02:00
|
|
|
R_API void r_anal_op_init(RAnalOp *op);
|
2016-05-24 12:32:45 +02:00
|
|
|
R_API bool r_anal_op_fini(RAnalOp *op);
|
2018-07-03 21:56:06 +05:30
|
|
|
R_API RAnalVar *get_link_var(RAnal *anal, ut64 faddr, RAnalVar *var);
|
2019-03-16 10:20:20 +01:00
|
|
|
R_API int r_anal_op_reg_delta(RAnal *anal, ut64 addr, const char *name);
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API bool r_anal_op_is_eob(RAnalOp *op);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RList *r_anal_op_list_new(void);
|
2011-02-24 14:06:49 +01:00
|
|
|
R_API int r_anal_op(RAnal *anal, RAnalOp *op, ut64 addr,
|
2019-03-15 19:39:24 +01:00
|
|
|
const ut8 *data, int len, RAnalOpMask mask);
|
2013-07-19 11:51:51 +02:00
|
|
|
R_API RAnalOp *r_anal_op_hexstr(RAnal *anal, ut64 addr,
|
|
|
|
const char *hexstr);
|
2011-02-24 14:06:49 +01:00
|
|
|
R_API char *r_anal_op_to_string(RAnal *anal, RAnalOp *op);
|
2014-06-16 05:58:00 +02:00
|
|
|
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API RAnalEsil *r_anal_esil_new(int stacksize, int iotrap, unsigned int addrsize);
|
|
|
|
R_API void r_anal_esil_trace(RAnalEsil *esil, RAnalOp *op);
|
|
|
|
R_API void r_anal_esil_trace_list(RAnalEsil *esil);
|
|
|
|
R_API void r_anal_esil_trace_show(RAnalEsil *esil, int idx);
|
|
|
|
R_API bool r_anal_esil_set_pc(RAnalEsil *esil, ut64 addr);
|
|
|
|
R_API int r_anal_esil_setup(RAnalEsil *esil, RAnal *anal, int romem, int stats, int nonull);
|
|
|
|
R_API void r_anal_esil_free(RAnalEsil *esil);
|
|
|
|
R_API int r_anal_esil_runword(RAnalEsil *esil, const char *word);
|
|
|
|
R_API int r_anal_esil_parse(RAnalEsil *esil, const char *str);
|
2019-06-20 18:04:02 +00:00
|
|
|
R_API bool r_anal_esil_dumpstack(RAnalEsil *esil);
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API int r_anal_esil_mem_read(RAnalEsil *esil, ut64 addr, ut8 *buf, int len);
|
|
|
|
R_API int r_anal_esil_mem_write(RAnalEsil *esil, ut64 addr, const ut8 *buf, int len);
|
|
|
|
R_API int r_anal_esil_reg_read(RAnalEsil *esil, const char *regname, ut64 *num, int *size);
|
|
|
|
R_API int r_anal_esil_reg_write(RAnalEsil *esil, const char *dst, ut64 num);
|
2019-06-10 06:01:24 +00:00
|
|
|
R_API bool r_anal_esil_pushnum(RAnalEsil *esil, ut64 num);
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API bool r_anal_esil_push(RAnalEsil *esil, const char *str);
|
|
|
|
R_API char *r_anal_esil_pop(RAnalEsil *esil);
|
2019-06-10 05:57:20 +00:00
|
|
|
R_API bool r_anal_esil_set_op(RAnalEsil *esil, const char *op, RAnalEsilOpCb code, ut32 push, ut32 pop, ut32 type);
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API void r_anal_esil_stack_free(RAnalEsil *esil);
|
|
|
|
R_API int r_anal_esil_get_parm_type(RAnalEsil *esil, const char *str);
|
|
|
|
R_API int r_anal_esil_get_parm(RAnalEsil *esil, const char *str, ut64 *num);
|
|
|
|
R_API int r_anal_esil_condition(RAnalEsil *esil, const char *str);
|
2018-08-31 00:36:38 +00:00
|
|
|
|
|
|
|
// esil_interrupt.c
|
2019-01-16 15:03:54 +01:00
|
|
|
R_API void r_anal_esil_interrupts_init(RAnalEsil *esil);
|
|
|
|
R_API RAnalEsilInterrupt *r_anal_esil_interrupt_new(RAnalEsil *esil, ut32 src_id, RAnalEsilInterruptHandler *ih);
|
|
|
|
R_API void r_anal_esil_interrupt_free(RAnalEsil *esil, RAnalEsilInterrupt *intr);
|
|
|
|
R_API bool r_anal_esil_set_interrupt(RAnalEsil *esil, RAnalEsilInterrupt *intr);
|
|
|
|
R_API int r_anal_esil_fire_interrupt(RAnalEsil *esil, ut32 intr_num);
|
|
|
|
R_API bool r_anal_esil_load_interrupts(RAnalEsil *esil, RAnalEsilInterruptHandler **handlers, ut32 src_id);
|
|
|
|
R_API bool r_anal_esil_load_interrupts_from_lib(RAnalEsil *esil, const char *path);
|
|
|
|
R_API void r_anal_esil_interrupts_fini(RAnalEsil *esil);
|
2010-03-12 03:05:20 +01:00
|
|
|
|
2014-09-11 04:18:23 +02:00
|
|
|
R_API void r_anal_esil_mem_ro(RAnalEsil *esil, int mem_readonly);
|
|
|
|
R_API void r_anal_esil_stats(RAnalEsil *esil, int enable);
|
2015-06-30 10:50:46 +02:00
|
|
|
|
2017-07-29 19:59:41 +09:00
|
|
|
/* session */
|
|
|
|
R_API void r_anal_esil_session_list(RAnalEsil *esil);
|
|
|
|
R_API RAnalEsilSession *r_anal_esil_session_add(RAnalEsil *esil);
|
|
|
|
R_API void r_anal_esil_session_set(RAnalEsil *esil, RAnalEsilSession *session);
|
2017-08-01 01:30:05 +09:00
|
|
|
R_API void r_anal_esil_session_free(void *p);
|
2017-07-29 19:59:41 +09:00
|
|
|
|
2015-06-30 10:50:46 +02:00
|
|
|
/* pin */
|
|
|
|
R_API void r_anal_pin_init(RAnal *a);
|
|
|
|
R_API void r_anal_pin_fini(RAnal *a);
|
|
|
|
R_API void r_anal_pin (RAnal *a, ut64 addr, const char *name);
|
|
|
|
R_API void r_anal_pin_unset (RAnal *a, ut64 addr);
|
2017-06-09 02:50:28 -11:00
|
|
|
R_API const char *r_anal_pin_call(RAnal *a, ut64 addr);
|
2015-06-30 10:50:46 +02:00
|
|
|
R_API void r_anal_pin_list(RAnal *a);
|
|
|
|
|
2010-03-12 03:05:20 +01:00
|
|
|
/* fcn.c */
|
2017-01-13 23:08:37 +01:00
|
|
|
R_API ut32 r_anal_fcn_cost(RAnal *anal, RAnalFunction *fcn);
|
2019-03-03 19:28:36 +08:00
|
|
|
R_API bool r_anal_fcn_tree_delete(RAnal *anal, RAnalFunction *data);
|
|
|
|
R_API void r_anal_fcn_tree_insert(RAnal *anal, RAnalFunction *fcn);
|
2017-03-18 07:46:35 +00:00
|
|
|
R_API int r_anal_fcn_count_edges(RAnalFunction *fcn, int *ebbs);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalFunction *r_anal_fcn_new(void);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_fcn_is_in_offset (RAnalFunction *fcn, ut64 addr);
|
2016-08-21 03:07:19 +02:00
|
|
|
R_API bool r_anal_fcn_in(RAnalFunction *fcn, ut64 addr);
|
2014-09-26 15:40:17 +02:00
|
|
|
R_API RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr, int type);
|
|
|
|
R_API RAnalFunction *r_anal_get_fcn_in(RAnal *anal, ut64 addr, int type);
|
2016-06-10 15:31:38 +02:00
|
|
|
R_API RAnalFunction *r_anal_get_fcn_in_bounds(RAnal *anal, ut64 addr, int type);
|
2013-06-26 01:44:21 +04:00
|
|
|
R_API RAnalFunction *r_anal_fcn_find_name(RAnal *anal, const char *name);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RList *r_anal_fcn_list_new(void);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_fcn_insert(RAnal *anal, RAnalFunction *fcn);
|
2010-03-12 03:05:20 +01:00
|
|
|
R_API void r_anal_fcn_free(void *fcn);
|
2019-03-16 10:20:20 +01:00
|
|
|
R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int reftype);
|
2010-05-24 13:57:49 +02:00
|
|
|
R_API int r_anal_fcn_add(RAnal *anal, ut64 addr, ut64 size,
|
2010-12-05 08:46:56 +01:00
|
|
|
const char *name, int type, RAnalDiff *diff);
|
2010-04-07 13:43:50 +02:00
|
|
|
R_API int r_anal_fcn_del(RAnal *anal, ut64 addr);
|
2012-09-28 02:20:52 +02:00
|
|
|
R_API int r_anal_fcn_del_locs(RAnal *anal, ut64 addr);
|
2019-02-14 02:21:17 +01:00
|
|
|
R_API bool r_anal_fcn_add_bb(RAnal *anal, RAnalFunction *fcn,
|
2015-03-16 02:52:26 +01:00
|
|
|
ut64 addr, ut64 size,
|
2011-02-11 11:22:43 +01:00
|
|
|
ut64 jump, ut64 fail, int type, RAnalDiff *diff);
|
2016-05-15 02:33:03 +02:00
|
|
|
R_API bool r_anal_check_fcn(RAnal *anal, ut8 *buf, ut16 bufsz, ut64 addr, ut64 low, ut64 high);
|
2017-09-04 08:56:54 +08:00
|
|
|
R_API void r_anal_fcn_update_tinyrange_bbs(RAnalFunction *fcn);
|
2019-03-16 10:20:20 +01:00
|
|
|
R_API void r_anal_fcn_invalidate_read_ahead_cache(void);
|
2019-04-14 17:40:53 +02:00
|
|
|
R_API void r_anal_fcn_check_bp_use(RAnal *anal, RAnalFunction *fcn);
|
2014-03-31 03:05:48 +02:00
|
|
|
|
2018-02-09 22:25:30 +01:00
|
|
|
|
2014-03-31 03:05:48 +02:00
|
|
|
/* locals */
|
|
|
|
#if 0
|
|
|
|
R_API int r_anal_fcn_local_add(RAnal *anal, RAnalFunction *fcn, int index, const char *name, const char *type);
|
2013-06-26 01:44:21 +04:00
|
|
|
R_API int r_anal_fcn_local_del_name(RAnal *anal, RAnalFunction *fcn, const char *name);
|
2014-03-31 03:05:48 +02:00
|
|
|
R_API int r_anal_fcn_local_del_index(RAnal *anal, RAnalFunction *fcn, ut32 index);
|
|
|
|
#endif
|
|
|
|
|
2014-03-31 04:42:55 +02:00
|
|
|
#define R_ANAL_FCN_VARKIND_LOCAL 'v'
|
|
|
|
#define R_ANAL_FCN_VARKIND_ARG 'a'
|
|
|
|
#define R_ANAL_FCN_VARKIND_FASTARG 'A'
|
2014-03-31 03:05:48 +02:00
|
|
|
|
|
|
|
#define r_anal_fcn_local_del_index(x,y,z) r_anal_fcn_var_del_byindex(x, y,\
|
2015-10-22 03:11:03 +02:00
|
|
|
R_ANAL_FCN_VARKIND_LOCAL, z)
|
2014-03-31 03:05:48 +02:00
|
|
|
#define r_anal_fcn_local_del_name(x,y,z) error
|
2014-04-28 11:37:48 +02:00
|
|
|
|
2014-09-22 04:22:47 +02:00
|
|
|
|
2014-04-28 11:37:48 +02:00
|
|
|
R_API int r_anal_fcn_var_del_bydelta (RAnal *a, ut64 fna, const char kind, int scope, ut32 delta);
|
2018-05-10 17:33:34 +02:00
|
|
|
R_API int r_anal_fcn_var_del_byindex (RAnal *a, ut64 fna, const char kind, int scope, ut32 idx);
|
2014-03-31 03:05:48 +02:00
|
|
|
/* args */
|
2016-07-19 22:50:55 +03:00
|
|
|
R_API int r_anal_var_count(RAnal *a, RAnalFunction *fcn, int kind, int type);
|
2014-03-31 03:05:48 +02:00
|
|
|
|
|
|
|
/* vars // globals. not here */
|
2016-09-14 16:42:23 +02:00
|
|
|
R_API bool r_anal_var_display(RAnal *anal, int delta, char kind, const char *type);
|
2016-05-15 14:37:22 +02:00
|
|
|
R_API ut32 r_anal_fcn_size(const RAnalFunction *fcn);
|
2019-03-03 19:28:36 +08:00
|
|
|
R_API void r_anal_fcn_set_size(RAnal *anal, RAnalFunction *fcn, ut32 size);
|
2016-09-09 19:28:47 +02:00
|
|
|
R_API ut32 r_anal_fcn_contsize(const RAnalFunction *fcn);
|
2016-05-15 14:37:22 +02:00
|
|
|
R_API ut32 r_anal_fcn_realsize(const RAnalFunction *fcn);
|
2019-03-06 11:26:37 +01:00
|
|
|
R_API int r_anal_fcn_cc(RAnal *anal, RAnalFunction *fcn);
|
2017-11-24 14:22:29 +01:00
|
|
|
R_API int r_anal_fcn_loops(RAnalFunction *fcn);
|
2018-11-20 04:09:27 +08:00
|
|
|
R_API int r_anal_fcn_split_bb(RAnal *anal, RAnalFunction *fcn, RAnalBlock *bbi, ut64 addr);
|
2014-09-22 01:39:24 +02:00
|
|
|
R_API int r_anal_fcn_bb_overlaps(RAnalFunction *fcn, RAnalBlock *bb);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RAnalVar *r_anal_fcn_get_var(RAnalFunction *fs, int num, int dir);
|
2014-09-02 02:41:40 +02:00
|
|
|
R_API void r_anal_fcn_fit_overlaps (RAnal *anal, RAnalFunction *fcn);
|
2018-02-09 22:25:30 +01:00
|
|
|
R_API void r_anal_trim_jmprefs(RAnal *anal, RAnalFunction *fcn);
|
2018-11-12 00:28:36 +08:00
|
|
|
R_API void r_anal_del_jmprefs(RAnal *anal, RAnalFunction *fcn);
|
2014-09-02 02:41:40 +02:00
|
|
|
R_API RAnalFunction *r_anal_fcn_next(RAnal *anal, ut64 addr);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFunction* fs);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API int r_anal_str_to_fcn(RAnal *a, RAnalFunction *f, const char *_str);
|
2012-11-20 03:59:00 +01:00
|
|
|
R_API int r_anal_fcn_count (RAnal *a, ut64 from, ut64 to);
|
2018-11-04 02:59:10 +08:00
|
|
|
R_API RAnalBlock *r_anal_fcn_bbget_in(const RAnal *anal, RAnalFunction *fcn, ut64 addr);
|
2018-05-10 17:33:34 +02:00
|
|
|
R_API RAnalBlock *r_anal_fcn_bbget_at(RAnalFunction *fcn, ut64 addr);
|
|
|
|
R_API bool r_anal_fcn_contains(RAnalFunction *fcn, ut64 addr);
|
2016-08-21 03:07:19 +02:00
|
|
|
R_API bool r_anal_fcn_bbadd(RAnalFunction *fcn, RAnalBlock *bb);
|
2019-03-03 19:28:36 +08:00
|
|
|
R_API int r_anal_fcn_resize (RAnal *anal, RAnalFunction *fcn, int newsize);
|
2018-11-29 17:00:26 +01:00
|
|
|
R_API bool r_anal_fcn_get_purity(RAnal *anal, RAnalFunction *fcn);
|
2012-06-05 17:50:12 +02:00
|
|
|
|
2018-02-09 22:25:30 +01:00
|
|
|
typedef bool (* RAnalRefCmp)(RAnalRef *ref, void *data);
|
|
|
|
R_API RList *r_anal_ref_list_new(void);
|
2016-03-29 01:13:00 +02:00
|
|
|
R_API int r_anal_xrefs_count(RAnal *anal);
|
2018-02-09 22:25:30 +01:00
|
|
|
R_API const char *r_anal_xrefs_type_tostring(RAnalRefType type);
|
|
|
|
R_API RAnalRefType r_anal_xrefs_type(char ch);
|
|
|
|
R_API RList *r_anal_xrefs_get(RAnal *anal, ut64 to);
|
|
|
|
R_API RList *r_anal_refs_get(RAnal *anal, ut64 to);
|
|
|
|
R_API RList *r_anal_xrefs_get_from(RAnal *anal, ut64 from);
|
2013-10-24 13:59:19 +02:00
|
|
|
R_API void r_anal_xrefs_list(RAnal *anal, int rad);
|
2018-01-09 20:38:08 +01:00
|
|
|
R_API RList *r_anal_fcn_get_refs(RAnal *anal, RAnalFunction *fcn);
|
|
|
|
R_API RList *r_anal_fcn_get_xrefs(RAnal *anal, RAnalFunction *fcn);
|
2018-02-09 22:25:30 +01:00
|
|
|
R_API int r_anal_xrefs_from(RAnal *anal, RList *list, const char *kind, const RAnalRefType type, ut64 addr);
|
|
|
|
R_API int r_anal_xrefs_set(RAnal *anal, ut64 from, ut64 to, const RAnalRefType type);
|
|
|
|
R_API int r_anal_xrefs_deln(RAnal *anal, ut64 from, ut64 to, const RAnalRefType type);
|
|
|
|
R_API int r_anal_xref_del(RAnal *anal, ut64 at, ut64 addr);
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RList* r_anal_fcn_get_vars (RAnalFunction *anal);
|
2012-06-06 11:48:40 +02:00
|
|
|
R_API RList* r_anal_get_fcns (RAnal *anal);
|
2010-02-26 13:08:42 +01:00
|
|
|
|
2019-03-30 07:17:15 -05:00
|
|
|
/* type.c */
|
|
|
|
R_API void r_anal_remove_parsed_type(RAnal *anal, const char *name);
|
|
|
|
R_API void r_anal_save_parsed_type(RAnal *anal, const char *parsed);
|
|
|
|
|
2010-03-11 17:19:33 +01:00
|
|
|
/* var.c */
|
2014-04-04 03:42:22 +02:00
|
|
|
R_API void r_anal_var_access_clear (RAnal *a, ut64 var_addr, int scope, int index);
|
|
|
|
R_API int r_anal_var_access (RAnal *a, ut64 var_addr, char kind, int scope, int index, int xs_type, ut64 xs_addr);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalVar *r_anal_var_new(void);
|
2018-07-18 01:32:02 +05:30
|
|
|
R_API int r_anal_var_rename (RAnal *a, ut64 var_addr, int scope, char kind,
|
|
|
|
const char *old_name, const char *new_name, bool verbose);
|
|
|
|
R_API int r_anal_var_retype (RAnal *a, ut64 addr, int scope, int delta, char kind,
|
|
|
|
const char *type, int size, bool isarg, const char *name);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalVarAccess *r_anal_var_access_new(void);
|
|
|
|
R_API RList *r_anal_var_list_new(void);
|
|
|
|
R_API RList *r_anal_var_access_list_new(void);
|
2014-04-04 03:42:22 +02:00
|
|
|
R_API void r_anal_var_free(RAnalVar *var);
|
2010-03-11 19:52:05 +01:00
|
|
|
R_API void r_anal_var_access_free(void *access);
|
2015-12-15 02:08:53 +01:00
|
|
|
R_API int r_anal_var_delete_all (RAnal *a, ut64 addr, const char kind);
|
2014-09-22 04:22:47 +02:00
|
|
|
R_API int r_anal_var_delete (RAnal *a, ut64 var_addr, const char kind, int scope, int delta);
|
2015-12-28 02:00:54 +01:00
|
|
|
R_API bool r_anal_var_delete_byname (RAnal *a, RAnalFunction *fcn, int type, const char *name);
|
2018-07-18 01:32:02 +05:30
|
|
|
R_API bool r_anal_var_add (RAnal *a, ut64 addr, int scope, int delta, char kind,
|
|
|
|
const char *type, int size, bool isarg, const char *name);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API int r_anal_var_del(RAnal *anal, RAnalFunction *fcn, int delta, int scope);
|
2018-06-10 21:24:41 +05:30
|
|
|
R_API ut64 r_anal_var_addr(RAnal *a, RAnalFunction *fcn, const char *name);
|
2014-09-22 13:45:36 +02:00
|
|
|
R_API RAnalVar *r_anal_var_get (RAnal *a, ut64 addr, char kind, int scope, int index);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API const char *r_anal_var_scope_to_str(RAnal *anal, int scope);
|
2010-03-19 12:00:04 +01:00
|
|
|
R_API int r_anal_var_access_add(RAnal *anal, RAnalVar *var, ut64 from, int set);
|
|
|
|
R_API int r_anal_var_access_del(RAnal *anal, RAnalVar *var, ut64 from);
|
|
|
|
R_API RAnalVarAccess *r_anal_var_access_get(RAnal *anal, RAnalVar *var, ut64 from);
|
2018-07-18 01:32:02 +05:30
|
|
|
R_API RAnalVar *r_anal_var_get_byname (RAnal *anal, ut64 addr, const char* name);
|
2019-03-03 23:41:19 +01:00
|
|
|
R_API void r_anal_extract_vars(RAnal *anal, RAnalFunction *fcn, RAnalOp *op);
|
|
|
|
R_API void r_anal_extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int *reg_set, int *count);
|
2010-03-11 17:19:33 +01:00
|
|
|
|
2019-01-08 10:44:51 +01:00
|
|
|
|
|
|
|
typedef struct r_anal_fcn_vars_cache {
|
|
|
|
RList *bvars;
|
|
|
|
RList *rvars;
|
|
|
|
RList *svars;
|
|
|
|
} RAnalFcnVarsCache;
|
|
|
|
R_API void r_anal_fcn_vars_cache_init(RAnal *anal, RAnalFcnVarsCache *cache, RAnalFunction *fcn);
|
|
|
|
R_API void r_anal_fcn_vars_cache_fini(RAnalFcnVarsCache *cache);
|
|
|
|
|
2019-01-09 16:18:52 +01:00
|
|
|
R_API char *r_anal_fcn_format_sig(R_NONNULL RAnal *anal, R_NONNULL RAnalFunction *fcn, R_NULLABLE char *fcn_name,
|
2019-01-08 10:44:51 +01:00
|
|
|
R_NULLABLE RAnalFcnVarsCache *reuse_cache, R_NULLABLE const char *fcn_name_pre, R_NULLABLE const char *fcn_name_post);
|
|
|
|
|
|
|
|
|
2013-04-18 03:58:44 +02:00
|
|
|
/* project */
|
2016-06-14 01:40:46 +02:00
|
|
|
R_API bool r_anal_xrefs_init (RAnal *anal);
|
2013-04-18 03:58:44 +02:00
|
|
|
|
2011-03-06 15:21:13 +01:00
|
|
|
#define R_ANAL_THRESHOLDFCN 0.7F
|
|
|
|
#define R_ANAL_THRESHOLDBB 0.7F
|
2011-10-14 10:09:53 +02:00
|
|
|
|
2010-12-05 08:46:56 +01:00
|
|
|
/* diff.c */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalDiff *r_anal_diff_new(void);
|
2011-10-14 10:09:53 +02:00
|
|
|
R_API void r_anal_diff_setup(RAnal *anal, int doops, double thbb, double thfcn);
|
2011-10-18 22:07:53 +02:00
|
|
|
R_API void r_anal_diff_setup_i(RAnal *anal, int doops, int thbb, int thfcn);
|
2010-12-05 08:46:56 +01:00
|
|
|
R_API void* r_anal_diff_free(RAnalDiff *diff);
|
2011-03-06 15:21:13 +01:00
|
|
|
R_API int r_anal_diff_fingerprint_bb(RAnal *anal, RAnalBlock *bb);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFunction *fcn);
|
2016-08-22 18:32:18 +02:00
|
|
|
R_API bool r_anal_diff_bb(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2);
|
2011-03-06 15:21:13 +01:00
|
|
|
R_API int r_anal_diff_fcn(RAnal *anal, RList *fcns, RList *fcns2);
|
|
|
|
R_API int r_anal_diff_eval(RAnal *anal);
|
2010-12-05 08:46:56 +01:00
|
|
|
|
2011-03-06 15:21:13 +01:00
|
|
|
/* value.c */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalValue *r_anal_value_new(void);
|
2011-03-28 10:24:01 +02:00
|
|
|
R_API RAnalValue *r_anal_value_copy (RAnalValue *ov);
|
2010-06-16 21:44:19 +02:00
|
|
|
R_API RAnalValue *r_anal_value_new_from_string(const char *str);
|
|
|
|
R_API st64 r_anal_value_eval(RAnalValue *value);
|
|
|
|
R_API char *r_anal_value_to_string (RAnalValue *value);
|
2010-06-18 00:53:47 +02:00
|
|
|
R_API ut64 r_anal_value_to_ut64(RAnal *anal, RAnalValue *val);
|
2011-02-03 00:20:39 +01:00
|
|
|
R_API int r_anal_value_set_ut64(RAnal *anal, RAnalValue *val, ut64 num);
|
2010-06-16 21:44:19 +02:00
|
|
|
R_API void r_anal_value_free(RAnalValue *value);
|
|
|
|
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalCond *r_anal_cond_new(void);
|
2011-02-24 14:06:49 +01:00
|
|
|
R_API RAnalCond *r_anal_cond_new_from_op(RAnalOp *op);
|
2011-11-14 00:21:25 +01:00
|
|
|
R_API void r_anal_cond_fini (RAnalCond *c);
|
|
|
|
R_API void r_anal_cond_free (RAnalCond *c);
|
2010-06-16 09:42:46 +02:00
|
|
|
R_API char *r_anal_cond_to_string(RAnalCond *cond);
|
2010-06-18 00:53:47 +02:00
|
|
|
R_API int r_anal_cond_eval (RAnal *anal, RAnalCond *cond);
|
2010-06-16 09:42:46 +02:00
|
|
|
R_API RAnalCond *r_anal_cond_new_from_string(const char *str);
|
2016-04-01 12:06:02 +02:00
|
|
|
R_API const char *r_anal_cond_tostring(int cc);
|
2010-06-15 00:46:18 +02:00
|
|
|
|
2010-02-26 13:08:42 +01:00
|
|
|
/* reflines.c */
|
2015-09-08 23:21:35 +02:00
|
|
|
R_API RList* /*<RAnalRefline>*/ r_anal_reflines_get(RAnal *anal,
|
2015-10-22 03:11:03 +02:00
|
|
|
ut64 addr, const ut8 *buf, ut64 len, int nlines, int linesout, int linescall);
|
2015-09-08 23:21:35 +02:00
|
|
|
R_API int r_anal_reflines_middle(RAnal *anal, RList *list, ut64 addr, int len);
|
2019-05-27 21:50:03 +05:30
|
|
|
R_API RAnalRefStr *r_anal_reflines_str(void *core, ut64 addr, int opts);
|
2015-09-08 23:21:35 +02:00
|
|
|
R_API RList *r_anal_reflines_fcn_get(struct r_anal_t *anal, RAnalFunction *fcn, int nlines, int linesout, int linescall);
|
2011-02-18 10:08:24 +01:00
|
|
|
/* TODO move to r_core */
|
2019-03-06 14:10:13 +05:30
|
|
|
R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, int kind, int mode, PJ* pj);
|
2014-12-13 18:06:01 +01:00
|
|
|
R_API RList *r_anal_var_list(RAnal *anal, RAnalFunction *fcn, int kind);
|
2017-03-09 23:46:02 +01:00
|
|
|
R_API RList *r_anal_var_all_list(RAnal *anal, RAnalFunction *fcn);
|
2016-09-12 22:43:05 +02:00
|
|
|
R_API RList *r_anal_var_list_dynamic(RAnal *anal, RAnalFunction *fcn, int kind);
|
2010-08-22 18:41:57 +02:00
|
|
|
|
2011-02-02 13:05:48 +01:00
|
|
|
// calling conventions API
|
2018-10-30 09:09:39 +01:00
|
|
|
R_API bool r_anal_cc_exist (RAnal *anal, const char *convention);
|
2019-02-13 14:05:36 +01:00
|
|
|
R_API void r_anal_cc_del(RAnal *anal, const char *name);
|
|
|
|
R_API void r_anal_cc_set(RAnal *anal, const char *expr);
|
|
|
|
R_API char *r_anal_cc_get(RAnal *anal, const char *name);
|
2016-07-27 14:50:14 +03:00
|
|
|
R_API const char *r_anal_cc_arg(RAnal *anal, const char *convention, int n);
|
2018-06-27 00:22:04 +05:30
|
|
|
R_API int r_anal_cc_max_arg(RAnal *anal, const char *cc);
|
2016-07-27 14:50:14 +03:00
|
|
|
R_API const char *r_anal_cc_ret(RAnal *anal, const char *convention);
|
|
|
|
R_API const char *r_anal_cc_default(RAnal *anal);
|
2018-05-18 14:02:31 +05:30
|
|
|
R_API const char *r_anal_cc_func(RAnal *anal, const char *func_name);
|
2015-11-16 23:04:55 +01:00
|
|
|
R_API bool r_anal_noreturn_at(RAnal *anal, ut64 addr);
|
2011-02-02 13:05:48 +01:00
|
|
|
|
2012-11-20 12:17:46 +01:00
|
|
|
typedef struct r_anal_data_t {
|
|
|
|
ut64 addr;
|
|
|
|
int type;
|
|
|
|
ut64 ptr;
|
|
|
|
char *str;
|
|
|
|
int len;
|
2013-02-26 22:03:02 +01:00
|
|
|
ut8 *buf;
|
|
|
|
ut8 sbuf[8];
|
2012-11-20 12:17:46 +01:00
|
|
|
} RAnalData;
|
|
|
|
|
2017-04-10 02:18:47 +02:00
|
|
|
R_API RAnalData *r_anal_data (RAnal *anal, ut64 addr, const ut8 *buf, int size, int wordsize);
|
2012-11-20 03:59:00 +01:00
|
|
|
R_API const char *r_anal_data_kind (RAnal *anal, ut64 addr, const ut8 *buf, int len);
|
2013-02-26 22:03:02 +01:00
|
|
|
R_API RAnalData *r_anal_data_new_string (ut64 addr, const char *p, int size, int wide);
|
2012-11-20 12:17:46 +01:00
|
|
|
R_API RAnalData *r_anal_data_new (ut64 addr, int type, ut64 n, const ut8 *buf, int len);
|
|
|
|
R_API void r_anal_data_free (RAnalData *d);
|
2017-04-16 11:41:27 +02:00
|
|
|
#include <r_cons.h>
|
2018-02-23 19:00:47 +01:00
|
|
|
R_API char *r_anal_data_to_string(RAnalData *d, RConsPrintablePalette *pal);
|
2012-11-20 03:59:00 +01:00
|
|
|
|
2014-01-23 03:28:25 +01:00
|
|
|
R_API void r_meta_free(RAnal *m);
|
2019-04-26 04:20:42 +05:30
|
|
|
R_API RList *r_meta_find_list_in(RAnal *a, ut64 at, int type, int where);
|
2019-01-28 16:41:42 +01:00
|
|
|
R_API void r_meta_space_unset_for(RAnal *a, const RSpace *space);
|
|
|
|
R_API int r_meta_space_count_for(RAnal *a, const RSpace *space_name);
|
2015-06-15 04:19:29 +02:00
|
|
|
R_API RList *r_meta_enumerate(RAnal *a, int type);
|
2014-01-23 03:28:25 +01:00
|
|
|
R_API int r_meta_count(RAnal *m, int type, ut64 from, ut64 to);
|
|
|
|
R_API char *r_meta_get_string(RAnal *m, int type, ut64 addr);
|
2016-06-13 00:39:40 +03:00
|
|
|
R_API char *r_meta_get_var_comment (RAnal *a, int type, ut64 idx, ut64 addr);
|
2014-01-23 03:28:25 +01:00
|
|
|
R_API int r_meta_set_string(RAnal *m, int type, ut64 addr, const char *s);
|
2016-06-13 00:39:40 +03:00
|
|
|
R_API int r_meta_set_var_comment (RAnal *a, int type, ut64 idx, ut64 addr, const char *s);
|
2017-10-30 23:01:46 +08:00
|
|
|
R_API int r_meta_del(RAnal *m, int type, ut64 from, ut64 size);
|
2016-06-13 00:39:40 +03:00
|
|
|
R_API int r_meta_var_comment_del(RAnal *a, int type, ut64 idx, ut64 addr);
|
2019-03-07 09:00:48 +01:00
|
|
|
R_API int r_meta_add(RAnal *m, int type, ut64 from, ut64 to, const char *str);
|
|
|
|
R_API int r_meta_add_with_subtype(RAnal *m, int type, int subtype, ut64 from, ut64 to, const char *str);
|
2014-01-23 04:34:59 +01:00
|
|
|
R_API RAnalMetaItem *r_meta_find(RAnal *m, ut64 off, int type, int where);
|
2018-12-01 23:44:29 +08:00
|
|
|
R_API RAnalMetaItem *r_meta_find_any_except(RAnal *m, ut64 at, int type, int where);
|
2018-04-15 02:29:03 +02:00
|
|
|
R_API RAnalMetaItem *r_meta_find_in(RAnal *m, ut64 off, int type, int where);
|
2014-01-23 03:28:25 +01:00
|
|
|
R_API int r_meta_cleanup(RAnal *m, ut64 from, ut64 to);
|
2011-03-01 19:06:22 +01:00
|
|
|
R_API const char *r_meta_type_to_string(int type);
|
2015-06-15 04:19:29 +02:00
|
|
|
R_API RList *r_meta_enumerate(RAnal *a, int type);
|
2014-01-23 03:28:25 +01:00
|
|
|
R_API int r_meta_list(RAnal *m, int type, int rad);
|
2016-11-06 01:40:51 +01:00
|
|
|
R_API int r_meta_list_at(RAnal *m, int type, int rad, ut64 addr);
|
|
|
|
R_API int r_meta_list_cb(RAnal *m, int type, int rad, SdbForeachCallback cb, void *user, ut64 addr);
|
2018-12-14 11:39:32 +00:00
|
|
|
R_API void r_meta_list_offset(RAnal *m, ut64 addr, char input);
|
2011-03-01 19:06:22 +01:00
|
|
|
R_API void r_meta_item_free(void *_item);
|
2014-01-23 04:34:59 +01:00
|
|
|
R_API RAnalMetaItem *r_meta_item_new(int type);
|
2019-01-28 16:41:42 +01:00
|
|
|
R_API bool r_meta_deserialize_val(RAnal *a, RAnalMetaItem *it, int type, ut64 from, const char *v);
|
2017-10-16 05:29:43 +08:00
|
|
|
R_API void r_meta_print(RAnal *a, RAnalMetaItem *d, int rad, bool show_full);
|
2011-03-01 19:06:22 +01:00
|
|
|
|
2013-01-22 05:06:12 +01:00
|
|
|
/* hints */
|
2016-08-10 18:49:44 +02:00
|
|
|
|
2018-11-22 21:31:54 +01:00
|
|
|
R_API void r_anal_build_range_on_hints (RAnal *a, ut64 addr, int bits);
|
|
|
|
R_API void r_anal_merge_hint_ranges(RAnal *a);
|
2013-01-22 18:08:33 +01:00
|
|
|
//R_API void r_anal_hint_list (RAnal *anal, int mode);
|
2013-06-26 13:34:17 +02:00
|
|
|
R_API void r_anal_hint_del (RAnal *anal, ut64 addr, int size);
|
2013-01-23 01:53:32 +01:00
|
|
|
R_API void r_anal_hint_clear (RAnal *a);
|
2019-01-17 00:26:39 +01:00
|
|
|
R_API RAnalHint *r_anal_hint_from_string(RAnal *a, ut64 addr, const char *str);
|
2013-01-22 05:06:12 +01:00
|
|
|
R_API void r_anal_hint_free (RAnalHint *h);
|
|
|
|
R_API RAnalHint *r_anal_hint_get(RAnal *anal, ut64 addr);
|
2015-05-10 00:12:33 +02:00
|
|
|
R_API void r_anal_hint_set_syntax (RAnal *a, ut64 addr, const char *syn);
|
2019-01-17 00:26:39 +01:00
|
|
|
R_API void r_anal_hint_set_type (RAnal *a, ut64 addr, int type);
|
2013-10-25 02:06:00 +02:00
|
|
|
R_API void r_anal_hint_set_jump (RAnal *a, ut64 addr, ut64 ptr);
|
2018-12-17 12:56:07 +01:00
|
|
|
R_API void r_anal_hint_set_nword(RAnal *a, ut64 addr, int nword);
|
2017-10-31 23:22:20 +08:00
|
|
|
R_API void r_anal_hint_set_offset (RAnal *a, ut64 addr, const char *typeoff);
|
2015-09-28 01:00:06 +02:00
|
|
|
R_API void r_anal_hint_set_immbase (RAnal *a, ut64 addr, int base);
|
2013-10-25 02:06:00 +02:00
|
|
|
R_API void r_anal_hint_set_fail (RAnal *a, ut64 addr, ut64 ptr);
|
2014-03-11 02:47:10 +01:00
|
|
|
R_API void r_anal_hint_set_length (RAnal *a, ut64 addr, int length);
|
|
|
|
R_API void r_anal_hint_set_bits (RAnal *a, ut64 addr, int bits);
|
2014-08-15 02:04:20 +02:00
|
|
|
R_API void r_anal_hint_set_arch (RAnal *a, ut64 addr, const char *arch);
|
2014-03-11 02:47:10 +01:00
|
|
|
R_API void r_anal_hint_set_size (RAnal *a, ut64 addr, int length);
|
2014-08-15 02:04:20 +02:00
|
|
|
R_API void r_anal_hint_set_opcode (RAnal *a, ut64 addr, const char *str);
|
|
|
|
R_API void r_anal_hint_set_esil (RAnal *a, ut64 addr, const char *str);
|
2013-06-17 03:26:48 +02:00
|
|
|
R_API void r_anal_hint_set_pointer (RAnal *a, ut64 addr, ut64 jump);
|
2018-06-08 13:16:31 +05:30
|
|
|
R_API void r_anal_hint_set_ret(RAnal *a, ut64 addr, ut64 val);
|
2017-11-14 23:36:04 +09:00
|
|
|
R_API void r_anal_hint_set_high(RAnal *a, ut64 addr);
|
2019-05-24 14:56:28 +02:00
|
|
|
R_API void r_anal_hint_set_stackframe(RAnal *a, ut64 addr, ut64 size);
|
2019-07-07 18:51:21 +02:00
|
|
|
R_API void r_anal_hint_set_val (RAnal *a, ut64 addr, ut64 v);
|
|
|
|
R_API void r_anal_hint_unset_val (RAnal *a, ut64 addr);
|
2017-11-14 23:36:04 +09:00
|
|
|
R_API void r_anal_hint_unset_high(RAnal *a, ut64 addr);
|
2016-11-01 19:47:34 +01:00
|
|
|
R_API void r_anal_hint_unset_size(RAnal *a, ut64 addr);
|
|
|
|
R_API void r_anal_hint_unset_bits(RAnal *a, ut64 addr);
|
2019-01-17 00:26:39 +01:00
|
|
|
R_API void r_anal_hint_unset_type(RAnal *a, ut64 addr);
|
2016-11-01 19:47:34 +01:00
|
|
|
R_API void r_anal_hint_unset_esil(RAnal *a, ut64 addr);
|
|
|
|
R_API void r_anal_hint_unset_opcode(RAnal *a, ut64 addr);
|
|
|
|
R_API void r_anal_hint_unset_arch(RAnal *a, ut64 addr);
|
|
|
|
R_API void r_anal_hint_unset_syntax(RAnal *a, ut64 addr);
|
|
|
|
R_API void r_anal_hint_unset_pointer(RAnal *a, ut64 addr);
|
2018-06-08 13:16:31 +05:30
|
|
|
R_API void r_anal_hint_unset_ret(RAnal *a, ut64 addr);
|
2017-10-31 23:22:20 +08:00
|
|
|
R_API void r_anal_hint_unset_offset(RAnal *a, ut64 addr);
|
2016-11-01 19:47:34 +01:00
|
|
|
R_API void r_anal_hint_unset_jump(RAnal *a, ut64 addr);
|
|
|
|
R_API void r_anal_hint_unset_fail(RAnal *a, ut64 addr);
|
2019-05-24 14:56:28 +02:00
|
|
|
R_API void r_anal_hint_unset_stackframe(RAnal *a, ut64 addr);
|
2018-11-22 21:31:54 +01:00
|
|
|
|
|
|
|
R_API int r_anal_hint_get_bits_at(RAnal *a, ut64 addr, const char *str);
|
|
|
|
R_API int r_anal_range_tree_find_bits_at(RBNode *root, ut64 addr);
|
|
|
|
|
2013-06-07 10:26:37 +02:00
|
|
|
R_API int r_anal_esil_eval(RAnal *anal, const char *str);
|
|
|
|
|
2014-01-01 23:09:46 -06:00
|
|
|
/* switch.c APIs */
|
2014-01-05 17:21:09 -06:00
|
|
|
R_API RAnalSwitchOp * r_anal_switch_op_new(ut64 addr, ut64 min_val, ut64 max_val);
|
2014-01-01 23:09:46 -06:00
|
|
|
R_API void r_anal_switch_op_free(RAnalSwitchOp * swop);
|
2014-08-10 21:52:53 -05:00
|
|
|
R_API RAnalCaseOp* r_anal_switch_op_add_case(RAnalSwitchOp * swop, ut64 addr, ut64 value, ut64 jump);
|
2014-01-05 14:43:57 -06:00
|
|
|
|
2014-03-25 00:48:42 +01:00
|
|
|
/* cycles.c */
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RAnalCycleFrame* r_anal_cycle_frame_new (void);
|
2014-03-25 00:48:42 +01:00
|
|
|
R_API void r_anal_cycle_frame_free (RAnalCycleFrame *cf);
|
|
|
|
|
2014-09-26 15:40:17 +02:00
|
|
|
/*
|
2014-01-05 17:21:09 -06:00
|
|
|
* RAnalState maintains state during analysis.
|
2014-09-26 15:40:17 +02:00
|
|
|
* there are standard values current_fcn, current_op, current_bb, addr,
|
2014-01-05 14:43:57 -06:00
|
|
|
* data buffer, etc. but there is also a void * for user defined structures
|
|
|
|
* that can be updated during the callbacks.
|
|
|
|
*/
|
2014-01-05 17:21:09 -06:00
|
|
|
R_API RAnalState * r_anal_state_new (ut64 start, ut8* buffer, ut64 len);
|
|
|
|
R_API void r_anal_state_insert_bb (RAnalState* state, RAnalBlock *bb);
|
|
|
|
R_API int r_anal_state_need_rehash (RAnalState* state, RAnalBlock *bb);
|
|
|
|
R_API RAnalBlock * r_anal_state_search_bb (RAnalState* state, ut64 addr);
|
|
|
|
R_API void r_anal_state_free (RAnalState * state);
|
|
|
|
R_API ut64 r_anal_state_get_len (RAnalState *state, ut64 addr);
|
|
|
|
R_API const ut8 * r_anal_state_get_buf_by_addr (RAnalState *state, ut64 addr);
|
2015-12-01 12:39:12 +01:00
|
|
|
R_API bool r_anal_state_addr_is_valid (RAnalState *state, ut64 addr);
|
2014-01-05 17:21:09 -06:00
|
|
|
R_API void r_anal_state_merge_bb_list (RAnalState *state, RList* bbs);
|
|
|
|
R_API void r_anal_state_set_depth(RAnalState *state, ut32 depth);
|
2014-01-05 14:43:57 -06:00
|
|
|
|
2014-09-23 09:35:37 +02:00
|
|
|
/* labels */
|
|
|
|
R_API ut64 r_anal_fcn_label_get (RAnal *anal, RAnalFunction *fcn, const char *name);
|
|
|
|
R_API const char *r_anal_fcn_label_at (RAnal *anal, RAnalFunction *fcn, ut64 addr);
|
|
|
|
R_API int r_anal_fcn_label_set (RAnal *anal, RAnalFunction *fcn, const char *name, ut64 addr);
|
|
|
|
R_API int r_anal_fcn_label_del (RAnal *anal, RAnalFunction *fcn, const char *name, ut64 addr);
|
|
|
|
R_API int r_anal_fcn_labels (RAnal *anal, RAnalFunction *fcn, int rad);
|
|
|
|
|
2014-11-03 04:05:19 +01:00
|
|
|
/* limits */
|
|
|
|
R_API void r_anal_set_limits(RAnal *anal, ut64 from, ut64 to);
|
|
|
|
R_API void r_anal_unset_limits(RAnal *anal);
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2015-03-30 18:45:25 +05:30
|
|
|
/* ESIL to REIL */
|
|
|
|
R_API int r_anal_esil_to_reil_setup (RAnalEsil *esil, RAnal *anal, int romem, int stats);
|
|
|
|
|
2015-11-12 13:47:44 +01:00
|
|
|
/* no-return stuff */
|
|
|
|
R_API void r_anal_noreturn_list(RAnal *anal, int mode);
|
|
|
|
R_API bool r_anal_noreturn_add(RAnal *anal, const char *name, ut64 addr);
|
2019-06-17 02:23:58 +02:00
|
|
|
R_API bool r_anal_noreturn_drop(RAnal *anal, const char *expr);
|
2017-02-13 17:14:08 +01:00
|
|
|
R_API bool r_anal_noreturn_at_addr(RAnal *anal, ut64 addr);
|
2015-11-12 13:47:44 +01:00
|
|
|
|
2017-03-07 23:20:48 +00:00
|
|
|
/* zign spaces */
|
2019-01-28 16:41:42 +01:00
|
|
|
R_API int r_sign_space_count_for(RAnal *a, const RSpace *space);
|
|
|
|
R_API void r_sign_space_unset_for(RAnal *a, const RSpace *space);
|
|
|
|
R_API void r_sign_space_rename_for(RAnal *a, const RSpace *space, const char *oname, const char *nname);
|
2017-03-07 23:20:48 +00:00
|
|
|
|
2018-03-09 13:02:39 +01:00
|
|
|
/* vtables */
|
2018-03-10 20:54:19 +01:00
|
|
|
typedef struct {
|
|
|
|
RAnal *anal;
|
2018-03-12 21:48:44 +01:00
|
|
|
RAnalCPPABI abi;
|
2018-03-11 18:11:47 +01:00
|
|
|
ut8 word_size;
|
2018-03-10 20:54:19 +01:00
|
|
|
bool (*read_addr) (RAnal *anal, ut64 addr, ut64 *buf);
|
|
|
|
} RVTableContext;
|
|
|
|
|
|
|
|
typedef struct vtable_info_t {
|
|
|
|
ut64 saddr; //starting address
|
2018-08-26 21:11:55 +02:00
|
|
|
RVector methods;
|
2018-03-10 20:54:19 +01:00
|
|
|
} RVTableInfo;
|
|
|
|
|
|
|
|
typedef struct vtable_method_info_t {
|
|
|
|
ut64 addr; // addr of the function
|
|
|
|
ut64 vtable_offset; // offset inside the vtable
|
|
|
|
} RVTableMethodInfo;
|
|
|
|
|
2018-08-26 20:54:02 +02:00
|
|
|
R_API void r_anal_vtable_info_free(RVTableInfo *vtable);
|
2018-03-10 20:54:19 +01:00
|
|
|
R_API ut64 r_anal_vtable_info_get_size(RVTableContext *context, RVTableInfo *vtable);
|
|
|
|
R_API bool r_anal_vtable_begin(RAnal *anal, RVTableContext *context);
|
2018-08-26 20:54:02 +02:00
|
|
|
R_API RVTableInfo *r_anal_vtable_parse_at(RVTableContext *context, ut64 addr);
|
2018-03-10 20:54:19 +01:00
|
|
|
R_API RList *r_anal_vtable_search(RVTableContext *context);
|
2018-03-10 21:28:27 +01:00
|
|
|
R_API void r_anal_list_vtables(RAnal *anal, int rad);
|
2018-03-09 13:02:39 +01:00
|
|
|
|
|
|
|
/* rtti */
|
2018-08-22 13:15:28 +02:00
|
|
|
R_API char *r_anal_rtti_msvc_demangle_class_name(const char *name);
|
2018-03-14 16:44:48 +01:00
|
|
|
R_API void r_anal_rtti_msvc_print_complete_object_locator(RVTableContext *context, ut64 addr, int mode);
|
|
|
|
R_API void r_anal_rtti_msvc_print_type_descriptor(RVTableContext *context, ut64 addr, int mode);
|
|
|
|
R_API void r_anal_rtti_msvc_print_class_hierarchy_descriptor(RVTableContext *context, ut64 addr, int mode);
|
|
|
|
R_API void r_anal_rtti_msvc_print_base_class_descriptor(RVTableContext *context, ut64 addr, int mode);
|
2018-07-24 13:16:35 +02:00
|
|
|
R_API bool r_anal_rtti_msvc_print_at_vtable(RVTableContext *context, ut64 addr, int mode, bool strict);
|
Heavy refactoring and sdbify the classes storage+logic ##anal
* New commands: aCb, aCm, aCmn, aCll, aClj, aCv, aCm, aC-, aCm-
* Fix Segfaults and Leaks in RTTI classes recovery
* Accept .?AU as prefix for msvc class name demangling
* Classes recovery refactoring
* Skip own type descriptor in msvc classes recovery
* Cleanup msvc rtti address calculation
* Recover vtable, classes, base class, virtual methods from MSVC RTTI
* Add flags for vtables and methods
* Add r_str_sanitize_sdb_key()
2018-12-29 11:16:33 +01:00
|
|
|
R_API void r_anal_rtti_msvc_recover_all(RVTableContext *vt_context, RList *vtables);
|
2018-03-14 16:44:48 +01:00
|
|
|
|
2018-03-21 15:58:58 +05:30
|
|
|
R_API void r_anal_rtti_itanium_print_class_type_info(RVTableContext *context, ut64 addr, int mode);
|
2018-04-07 13:42:00 +05:30
|
|
|
R_API void r_anal_rtti_itanium_print_si_class_type_info(RVTableContext *context, ut64 addr, int mode);
|
|
|
|
R_API void r_anal_rtti_itanium_print_vmi_class_type_info(RVTableContext *context, ut64 addr, int mode);
|
2018-03-21 15:58:58 +05:30
|
|
|
R_API void r_anal_rtti_itanium_print_at_vtable(RVTableContext *context, ut64 addr, int mode);
|
2018-03-16 14:28:45 +05:30
|
|
|
|
2018-08-22 13:15:28 +02:00
|
|
|
R_API char *r_anal_rtti_demangle_class_name(RAnal *anal, const char *name);
|
2018-03-14 16:44:48 +01:00
|
|
|
R_API void r_anal_rtti_print_at_vtable(RAnal *anal, ut64 addr, int mode);
|
|
|
|
R_API void r_anal_rtti_print_all(RAnal *anal, int mode);
|
Heavy refactoring and sdbify the classes storage+logic ##anal
* New commands: aCb, aCm, aCmn, aCll, aClj, aCv, aCm, aC-, aCm-
* Fix Segfaults and Leaks in RTTI classes recovery
* Accept .?AU as prefix for msvc class name demangling
* Classes recovery refactoring
* Skip own type descriptor in msvc classes recovery
* Cleanup msvc rtti address calculation
* Recover vtable, classes, base class, virtual methods from MSVC RTTI
* Add flags for vtables and methods
* Add r_str_sanitize_sdb_key()
2018-12-29 11:16:33 +01:00
|
|
|
R_API void r_anal_rtti_recover_all(RAnal *anal);
|
2018-03-09 13:02:39 +01:00
|
|
|
|
2018-08-25 05:11:12 -04:00
|
|
|
R_API void r_anal_colorize_bb(RAnal *anal, ut64 addr, ut32 color);
|
|
|
|
|
Heavy refactoring and sdbify the classes storage+logic ##anal
* New commands: aCb, aCm, aCmn, aCll, aClj, aCv, aCm, aC-, aCm-
* Fix Segfaults and Leaks in RTTI classes recovery
* Accept .?AU as prefix for msvc class name demangling
* Classes recovery refactoring
* Skip own type descriptor in msvc classes recovery
* Cleanup msvc rtti address calculation
* Recover vtable, classes, base class, virtual methods from MSVC RTTI
* Add flags for vtables and methods
* Add r_str_sanitize_sdb_key()
2018-12-29 11:16:33 +01:00
|
|
|
/* classes */
|
|
|
|
typedef struct r_anal_method_t {
|
|
|
|
char *name;
|
|
|
|
ut64 addr;
|
|
|
|
st64 vtable_offset; // >= 0 if method is virtual, else -1
|
|
|
|
} RAnalMethod;
|
|
|
|
|
|
|
|
typedef struct r_anal_base_class_t {
|
|
|
|
char *id; // id to identify the class attr
|
|
|
|
ut64 offset; // offset of the base class inside the derived class
|
|
|
|
char *class_name;
|
|
|
|
} RAnalBaseClass;
|
|
|
|
|
|
|
|
typedef struct r_anal_vtable_t {
|
|
|
|
char *id; // id to identify the class attr
|
|
|
|
ut64 offset; // offset inside the class
|
|
|
|
ut64 addr; // where the content of the vtable is
|
|
|
|
} RAnalVTable;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
R_ANAL_CLASS_ERR_SUCCESS = 0,
|
|
|
|
R_ANAL_CLASS_ERR_CLASH,
|
|
|
|
R_ANAL_CLASS_ERR_NONEXISTENT_ATTR,
|
|
|
|
R_ANAL_CLASS_ERR_NONEXISTENT_CLASS,
|
|
|
|
R_ANAL_CLASS_ERR_OTHER
|
|
|
|
} RAnalClassErr;
|
|
|
|
|
|
|
|
R_API void r_anal_class_create(RAnal *anal, const char *name);
|
|
|
|
R_API void r_anal_class_delete(RAnal *anal, const char *name);
|
|
|
|
R_API bool r_anal_class_exists(RAnal *anal, const char *name);
|
2019-01-11 10:03:18 +01:00
|
|
|
R_API SdbList *r_anal_class_get_all(RAnal *anal, bool sorted);
|
|
|
|
R_API void r_anal_class_foreach(RAnal *anal, SdbForeachCallback cb, void *user);
|
Heavy refactoring and sdbify the classes storage+logic ##anal
* New commands: aCb, aCm, aCmn, aCll, aClj, aCv, aCm, aC-, aCm-
* Fix Segfaults and Leaks in RTTI classes recovery
* Accept .?AU as prefix for msvc class name demangling
* Classes recovery refactoring
* Skip own type descriptor in msvc classes recovery
* Cleanup msvc rtti address calculation
* Recover vtable, classes, base class, virtual methods from MSVC RTTI
* Add flags for vtables and methods
* Add r_str_sanitize_sdb_key()
2018-12-29 11:16:33 +01:00
|
|
|
R_API RAnalClassErr r_anal_class_rename(RAnal *anal, const char *old_name, const char *new_name);
|
|
|
|
|
|
|
|
R_API void r_anal_class_method_fini(RAnalMethod *meth);
|
|
|
|
R_API RAnalClassErr r_anal_class_method_get(RAnal *anal, const char *class_name, const char *meth_name, RAnalMethod *meth);
|
|
|
|
R_API RVector/*<RAnalMethod>*/ *r_anal_class_method_get_all(RAnal *anal, const char *class_name);
|
|
|
|
R_API RAnalClassErr r_anal_class_method_set(RAnal *anal, const char *class_name, RAnalMethod *meth);
|
|
|
|
R_API RAnalClassErr r_anal_class_method_rename(RAnal *anal, const char *class_name, const char *old_meth_name, const char *new_meth_name);
|
|
|
|
R_API RAnalClassErr r_anal_class_method_delete(RAnal *anal, const char *class_name, const char *meth_name);
|
|
|
|
|
|
|
|
R_API void r_anal_class_base_fini(RAnalBaseClass *base);
|
|
|
|
R_API RAnalClassErr r_anal_class_base_get(RAnal *anal, const char *class_name, const char *base_id, RAnalBaseClass *base);
|
|
|
|
R_API RVector/*<RAnalBaseClass>*/ *r_anal_class_base_get_all(RAnal *anal, const char *class_name);
|
|
|
|
R_API RAnalClassErr r_anal_class_base_set(RAnal *anal, const char *class_name, RAnalBaseClass *base);
|
|
|
|
R_API RAnalClassErr r_anal_class_base_delete(RAnal *anal, const char *class_name, const char *base_id);
|
|
|
|
|
|
|
|
R_API void r_anal_class_vtable_fini(RAnalVTable *vtable);
|
|
|
|
R_API RAnalClassErr r_anal_class_vtable_get(RAnal *anal, const char *class_name, const char *vtable_id, RAnalVTable *vtable);
|
|
|
|
R_API RVector/*<RAnalVTable>*/ *r_anal_class_vtable_get_all(RAnal *anal, const char *class_name);
|
|
|
|
R_API RAnalClassErr r_anal_class_vtable_set(RAnal *anal, const char *class_name, RAnalVTable *vtable);
|
|
|
|
R_API RAnalClassErr r_anal_class_vtable_delete(RAnal *anal, const char *class_name, const char *vtable_id);
|
|
|
|
|
|
|
|
R_API void r_anal_class_list(RAnal *anal, int mode);
|
|
|
|
R_API void r_anal_class_list_bases(RAnal *anal, const char *class_name);
|
|
|
|
R_API void r_anal_class_list_vtables(RAnal *anal, const char *class_name);
|
|
|
|
|
|
|
|
|
2010-03-10 15:15:50 +01:00
|
|
|
/* plugin pointers */
|
2014-09-27 03:10:44 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_null;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_6502;
|
2018-12-29 16:22:08 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_6502_cs;
|
2013-04-10 02:04:50 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_8051;
|
2012-09-23 17:33:19 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_arc;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_arm_cs;
|
|
|
|
extern RAnalPlugin r_anal_plugin_arm_gnu;
|
|
|
|
extern RAnalPlugin r_anal_plugin_avr;
|
|
|
|
extern RAnalPlugin r_anal_plugin_bf;
|
|
|
|
extern RAnalPlugin r_anal_plugin_chip8;
|
|
|
|
extern RAnalPlugin r_anal_plugin_cr16;
|
|
|
|
extern RAnalPlugin r_anal_plugin_cris;
|
|
|
|
extern RAnalPlugin r_anal_plugin_dalvik;
|
2013-11-29 17:55:34 +04:00
|
|
|
extern RAnalPlugin r_anal_plugin_ebc;
|
2013-12-11 16:00:36 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_gb;
|
2014-02-21 21:00:28 +04:00
|
|
|
extern RAnalPlugin r_anal_plugin_h8300;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_hexagon;
|
|
|
|
extern RAnalPlugin r_anal_plugin_i4004;
|
|
|
|
extern RAnalPlugin r_anal_plugin_i8080;
|
|
|
|
extern RAnalPlugin r_anal_plugin_java;
|
|
|
|
extern RAnalPlugin r_anal_plugin_m68k_cs;
|
2018-12-29 17:31:09 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_m680x_cs;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_malbolge;
|
|
|
|
extern RAnalPlugin r_anal_plugin_mcore;
|
|
|
|
extern RAnalPlugin r_anal_plugin_mips_cs;
|
|
|
|
extern RAnalPlugin r_anal_plugin_mips_gnu;
|
2014-09-23 11:36:37 +04:00
|
|
|
extern RAnalPlugin r_anal_plugin_msp430;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_nios2;
|
|
|
|
extern RAnalPlugin r_anal_plugin_pic;
|
|
|
|
extern RAnalPlugin r_anal_plugin_ppc_cs;
|
|
|
|
extern RAnalPlugin r_anal_plugin_ppc_gnu;
|
|
|
|
extern RAnalPlugin r_anal_plugin_propeller;
|
2015-10-30 22:31:57 -07:00
|
|
|
extern RAnalPlugin r_anal_plugin_riscv;
|
2019-05-21 02:24:24 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_riscv_cs;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_rsp;
|
|
|
|
extern RAnalPlugin r_anal_plugin_sh;
|
|
|
|
extern RAnalPlugin r_anal_plugin_snes;
|
|
|
|
extern RAnalPlugin r_anal_plugin_sparc_cs;
|
|
|
|
extern RAnalPlugin r_anal_plugin_sparc_gnu;
|
|
|
|
extern RAnalPlugin r_anal_plugin_sysz;
|
|
|
|
extern RAnalPlugin r_anal_plugin_tms320;
|
|
|
|
extern RAnalPlugin r_anal_plugin_tms320c64x;
|
|
|
|
extern RAnalPlugin r_anal_plugin_v810;
|
|
|
|
extern RAnalPlugin r_anal_plugin_v850;
|
2015-11-23 12:34:53 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_vax;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_wasm;
|
|
|
|
extern RAnalPlugin r_anal_plugin_ws;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86_cs;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86_im;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86_simple;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86_udis;
|
|
|
|
extern RAnalPlugin r_anal_plugin_xap;
|
|
|
|
extern RAnalPlugin r_anal_plugin_xcore_cs;
|
2016-01-30 01:37:04 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_xtensa;
|
2018-09-08 19:52:33 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_z80;
|
2013-06-18 12:09:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
#endif
|
2009-02-06 18:22:27 +01:00
|
|
|
#endif
|