2013-01-22 05:06:12 +01:00
|
|
|
/* radare - LGPL - Copyright 2009-2013 - nibble, pancake, xvilka */
|
2009-02-06 18:22:27 +01:00
|
|
|
|
|
|
|
#ifndef _INCLUDE_R_ANAL_H_
|
|
|
|
#define _INCLUDE_R_ANAL_H_
|
|
|
|
|
2010-02-26 13:08:42 +01:00
|
|
|
#include <r_types.h>
|
|
|
|
#include <list.h>
|
2013-08-01 00:39:19 +02:00
|
|
|
#include <r_db.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>
|
2011-02-02 13:05:48 +01:00
|
|
|
#include <r_syscall.h>
|
2014-01-10 10:20:23 -06:00
|
|
|
#include <r_bin.h>
|
2009-02-16 00:57:03 +01:00
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
#define R_ANAL_BB_HAS_OPS 0
|
|
|
|
|
2013-02-12 02:42:34 +01:00
|
|
|
/* TODO: work in progress */
|
|
|
|
#define USE_NEW_FCN_STORE 0
|
|
|
|
|
2011-09-14 02:07:06 +02:00
|
|
|
// TODO: Remove this define? /cc @nibble_ds
|
2011-02-11 11:22:43 +01:00
|
|
|
#define VERBOSE_ANAL if(0)
|
|
|
|
|
2011-03-02 00:02:50 +01:00
|
|
|
/* meta */
|
|
|
|
typedef struct r_meta_item_t {
|
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
|
|
|
ut64 size;
|
|
|
|
int type;
|
|
|
|
char *str;
|
|
|
|
} RMetaItem;
|
|
|
|
|
|
|
|
typedef struct r_meta_t {
|
2013-02-07 03:09:53 +01:00
|
|
|
RList *data; // TODO: rename to 'list'
|
2011-03-02 00:02:50 +01:00
|
|
|
PrintfCallback printf;
|
|
|
|
} RMeta;
|
|
|
|
|
2012-07-17 07:08:52 +04:00
|
|
|
/* CPARSE stuff */
|
|
|
|
|
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
|
|
|
|
2012-07-17 07:08:52 +04:00
|
|
|
enum {
|
|
|
|
R_ANAL_TYPE_VARIABLE = 1,
|
|
|
|
R_ANAL_TYPE_POINTER = 2,
|
|
|
|
R_ANAL_TYPE_ARRAY = 3,
|
|
|
|
R_ANAL_TYPE_STRUCT = 4,
|
|
|
|
R_ANAL_TYPE_UNION = 5,
|
2012-08-28 06:56:59 +04:00
|
|
|
R_ANAL_TYPE_ALLOCA = 6,
|
|
|
|
R_ANAL_TYPE_FUNCTION = 7,
|
|
|
|
R_ANAL_TYPE_ANY = 8,
|
2012-07-17 07:08:52 +04:00
|
|
|
};
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
// [0:3] bits - place to store variable size
|
|
|
|
#define R_ANAL_VAR_TYPE_SIZE_MASK 0xF
|
2012-07-17 07:08:52 +04:00
|
|
|
|
|
|
|
enum {
|
2012-08-30 01:11:54 +04:00
|
|
|
R_ANAL_VAR_TYPE_CHAR = 1,
|
|
|
|
R_ANAL_VAR_TYPE_BYTE = 2,
|
|
|
|
R_ANAL_VAR_TYPE_WORD = 3,
|
|
|
|
R_ANAL_VAR_TYPE_DWORD = 4,
|
|
|
|
R_ANAL_VAR_TYPE_QWORD = 5,
|
|
|
|
R_ANAL_VAR_TYPE_SHORT = 6,
|
|
|
|
R_ANAL_VAR_TYPE_INT = 7,
|
|
|
|
R_ANAL_VAR_TYPE_LONG = 8,
|
|
|
|
R_ANAL_VAR_TYPE_LONGLONG = 9,
|
|
|
|
R_ANAL_VAR_TYPE_FLOAT = 10,
|
|
|
|
R_ANAL_VAR_TYPE_DOUBLE = 11,
|
|
|
|
R_ANAL_VAR_TYPE_VOID = 12,
|
2012-07-17 07:08:52 +04:00
|
|
|
};
|
|
|
|
|
2012-11-20 03:59:00 +01:00
|
|
|
enum {
|
|
|
|
R_ANAL_DATA_TYPE_NULL = 0,
|
|
|
|
R_ANAL_DATA_TYPE_STRING = 1,
|
|
|
|
R_ANAL_DATA_TYPE_WIDE_STRING = 2,
|
|
|
|
R_ANAL_DATA_TYPE_POINTER = 3,
|
|
|
|
R_ANAL_DATA_TYPE_NUMBER = 4,
|
|
|
|
R_ANAL_DATA_TYPE_INVALID = 5,
|
2012-11-20 12:17:46 +01:00
|
|
|
R_ANAL_DATA_TYPE_HEADER = 6,
|
2012-11-20 03:59:00 +01:00
|
|
|
R_ANAL_DATA_TYPE_UNKNOWN = 7,
|
|
|
|
};
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
// [4:7] bits - place to store sign of variable
|
|
|
|
#define R_ANAL_VAR_TYPE_SIGN_MASK 0xF0
|
|
|
|
#define R_ANAL_VAR_TYPE_SIGN_SHIFT 4
|
2012-07-17 07:08:52 +04:00
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_VAR_TYPE_SIGNED = 1,
|
|
|
|
R_ANAL_VAR_TYPE_UNSIGNED = 2,
|
|
|
|
};
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
// [8:11] bits - place to store variable modifiers/parameters
|
|
|
|
#define R_ANAL_VAR_TYPE_MODIFIER_MASK 0xF00
|
|
|
|
#define R_ANAL_VAR_TYPE_MODIFIER_SHIFT 8
|
2012-07-17 07:08:52 +04:00
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_VAR_TYPE_REGISTER = 1,
|
|
|
|
R_ANAL_VAR_TYPE_CONST = 2,
|
|
|
|
R_ANAL_VAR_TYPE_STATIC = 3,
|
|
|
|
R_ANAL_VAR_TYPE_VOLATILE = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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;
|
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 {
|
|
|
|
ut8 v8;
|
|
|
|
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 {
|
2012-09-28 02:20:52 +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,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_CC_TYPE_NONE,
|
|
|
|
R_ANAL_CC_TYPE_CDECL,
|
|
|
|
R_ANAL_CC_TYPE_STDCALL,
|
|
|
|
R_ANAL_CC_TYPE_FASTCALL,
|
|
|
|
R_ANAL_CC_TYPE_PASCAL,
|
|
|
|
R_ANAL_CC_TYPE_WINAPI, // Microsoft's pascal call clone
|
|
|
|
R_ANAL_CC_TYPE_MSFASTCALL, // microsoft fastcall
|
|
|
|
R_ANAL_CC_TYPE_BOFASTCALL, // borland fastcall
|
|
|
|
R_ANAL_CC_TYPE_WAFASTCALL, // wacom fastcall
|
2012-07-21 14:11:21 +04:00
|
|
|
R_ANAL_CC_TYPE_CLARION, // TopSpeed/Clarion/JPI
|
|
|
|
/* Clation:
|
|
|
|
* first four integer parameters are passed in registers:
|
|
|
|
* eax, ebx, ecx, edx. Floating point parameters are passed
|
|
|
|
* on the floating point stack - registers
|
|
|
|
* st0, st1, st2, st3, st4, st5, st6. Structure parameters
|
|
|
|
* are always passed on the stack. Additional parameters
|
|
|
|
* are passed on the stack after registers are exhausted.
|
|
|
|
* Integer values are returned in eax, pointers in edx
|
|
|
|
* and floating point types in st0.
|
|
|
|
*/
|
|
|
|
R_ANAL_CC_TYPE_SAFECALL, // Delphi and Free Pascal on Windows
|
2012-07-19 06:54:22 +04:00
|
|
|
R_ANAL_CC_TYPE_SYSV,
|
|
|
|
R_ANAL_CC_TYPE_THISCALL,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define R_ANAL_CC_ARGS 16
|
|
|
|
|
|
|
|
typedef struct r_anal_cc_t {
|
|
|
|
int type;
|
|
|
|
int bits;
|
|
|
|
int rel; // relative or absolute?
|
|
|
|
ut64 off; // offset of the call instruction (caller)
|
|
|
|
ut64 jump; // offset of the call instruction (caller)
|
|
|
|
int nargs;
|
|
|
|
ut64 args[R_ANAL_CC_ARGS];
|
|
|
|
// TODO: Store arguments someway
|
|
|
|
} RAnalCC;
|
|
|
|
|
|
|
|
typedef struct r_anal_cc_type_t {
|
|
|
|
int rtl; // right-to-left? if false use left-to-right
|
|
|
|
int alignstack;
|
|
|
|
//
|
|
|
|
//const char **reglist; //
|
|
|
|
} RAnalCCType;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
R_ANAL_FCN_TYPE_NULL = 0,
|
|
|
|
R_ANAL_FCN_TYPE_FCN = 1,
|
|
|
|
R_ANAL_FCN_TYPE_LOC = 2,
|
|
|
|
R_ANAL_FCN_TYPE_SYM = 4,
|
|
|
|
R_ANAL_FCN_TYPE_IMP = 8,
|
|
|
|
R_ANAL_FCN_TYPE_ROOT = 16 /* matching flag */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define R_ANAL_VARSUBS 32
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/*
|
|
|
|
typedef struct r_anal_fcn_t {
|
|
|
|
char *name;
|
|
|
|
ut64 addr;
|
|
|
|
ut64 size;
|
|
|
|
int type;
|
|
|
|
int calltype; // See R_ANAL_CC_TYPE_
|
|
|
|
int stack;
|
|
|
|
int ninstr;
|
|
|
|
int nargs;
|
|
|
|
int depth;
|
|
|
|
RAnalVarSub varsubs[R_ANAL_VARSUBS];
|
|
|
|
ut8 *fingerprint;
|
|
|
|
RAnalDiff *diff;
|
|
|
|
RList *bbs;
|
|
|
|
RList *vars;
|
|
|
|
RList *refs;
|
|
|
|
RList *xrefs;
|
|
|
|
} RAnalFcn;
|
|
|
|
*/
|
|
|
|
|
|
|
|
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;
|
|
|
|
} 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 {
|
|
|
|
ut64 addr;
|
|
|
|
char* name;
|
|
|
|
} 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 {
|
|
|
|
RHashTable64 *h;
|
|
|
|
RList *l;
|
|
|
|
} RAnalFcnStore;
|
|
|
|
|
|
|
|
/* Store various function information,
|
|
|
|
* variables, arguments, refs and even
|
|
|
|
* description */
|
2012-07-17 07:08:52 +04:00
|
|
|
typedef struct r_anal_type_function_t {
|
|
|
|
char* name;
|
2012-07-19 06:54:22 +04:00
|
|
|
char* dsc; // For producing nice listings
|
2012-09-28 02:20:52 +02:00
|
|
|
int size; // Size of function XXX. use int, or ut32. no need for ut64
|
2013-05-24 02:53:15 +02:00
|
|
|
int bits; // ((> bits 0) (set-bits bits))
|
2012-07-19 06:54:22 +04:00
|
|
|
short type;
|
2012-07-17 07:08:52 +04:00
|
|
|
/*item_list *rets; // Type of return value */
|
|
|
|
short rets;
|
|
|
|
short fmod; // static, inline or volatile?
|
2012-07-22 12:00:35 +04:00
|
|
|
/* TODO: Change to RAnalCC ??? */
|
2012-07-17 07:08:52 +04:00
|
|
|
short call; // calling convention
|
|
|
|
char* attr; // __attribute__(()) list
|
2012-07-19 06:54:22 +04:00
|
|
|
ut64 addr;
|
|
|
|
int stack;
|
|
|
|
int ninstr;
|
|
|
|
int nargs; // Function arguments counter
|
|
|
|
int depth;
|
2012-07-17 07:08:52 +04:00
|
|
|
RAnalType *args; // list of arguments
|
2012-07-19 06:54:22 +04:00
|
|
|
RAnalVarSub varsubs[R_ANAL_VARSUBS];
|
|
|
|
ut8 *fingerprint; // TODO: make is fuzzy and smarter
|
|
|
|
RAnalDiff *diff;
|
2013-06-26 01:44:21 +04:00
|
|
|
RList *locs; // list of local variables
|
|
|
|
RList *locals; // list of local labels
|
2012-07-19 06:54:22 +04:00
|
|
|
RList *bbs;
|
|
|
|
RList *vars;
|
|
|
|
RList *refs;
|
|
|
|
RList *xrefs;
|
|
|
|
} RAnalFunction;
|
2012-07-17 07:08:52 +04:00
|
|
|
|
|
|
|
struct r_anal_type_t {
|
2012-07-19 06:54:22 +04:00
|
|
|
char *name;
|
2012-07-17 07:08:52 +04:00
|
|
|
ut32 size;
|
|
|
|
int type;
|
|
|
|
union {
|
|
|
|
RAnalTypeVar *v;
|
|
|
|
RAnalTypePtr *p;
|
|
|
|
RAnalTypeArray *a;
|
|
|
|
RAnalTypeStruct *s;
|
|
|
|
RAnalTypeUnion *u;
|
2012-08-28 06:56:59 +04:00
|
|
|
RAnalTypeAlloca *al;
|
2012-07-19 06:54:22 +04:00
|
|
|
RAnalFunction *f;
|
2012-07-17 07:08:52 +04:00
|
|
|
} custom;
|
|
|
|
RAnalType *next;
|
|
|
|
RAnalType *prev;
|
|
|
|
RAnalType *head;
|
2012-08-27 07:59:44 +04:00
|
|
|
// Parent filename
|
|
|
|
char* filename;
|
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 {
|
|
|
|
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',
|
|
|
|
};
|
|
|
|
|
|
|
|
// anal
|
2009-04-02 10:23:32 +00:00
|
|
|
enum {
|
2009-10-12 17:41:52 +02:00
|
|
|
R_ANAL_OP_FAMILY_UNKNOWN = 0,
|
|
|
|
R_ANAL_OP_FAMILY_CPU, /* normal cpu insturction */
|
|
|
|
R_ANAL_OP_FAMILY_FPU, /* fpu (floating point) */
|
|
|
|
R_ANAL_OP_FAMILY_MMX, /* multimedia instruction (packed data) */
|
|
|
|
R_ANAL_OP_FAMILY_PRIV, /* priviledged instruction */
|
|
|
|
R_ANAL_OP_FAMILY_LAST
|
2009-04-02 10:23:32 +00:00
|
|
|
};
|
|
|
|
|
2012-11-13 00:53:52 +01:00
|
|
|
// XXX: this definition is plain wrong. use enum or empower bits
|
2009-02-06 18:22:27 +01:00
|
|
|
enum {
|
2013-10-25 02:06:00 +02:00
|
|
|
R_ANAL_OP_TYPE_COND = 0x80000000,
|
|
|
|
R_ANAL_OP_TYPE_REP = 0x40000000, /* repeats next instruction N times */
|
|
|
|
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) */
|
|
|
|
R_ANAL_OP_TYPE_CJMP = R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_JMP, /* conditional jump */
|
|
|
|
R_ANAL_OP_TYPE_CALL = 3, /* call to subroutine (branch+link) */
|
|
|
|
R_ANAL_OP_TYPE_UCALL = 4, /* unknown call (register or so) */
|
|
|
|
R_ANAL_OP_TYPE_RET = 5, /* returns from subrutine */
|
|
|
|
R_ANAL_OP_TYPE_CRET = R_ANAL_OP_TYPE_COND | R_ANAL_OP_TYPE_RET, /* returns from subrutine */
|
|
|
|
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 */
|
|
|
|
R_ANAL_OP_TYPE_TRAP = 10, /* it's a trap! */
|
|
|
|
R_ANAL_OP_TYPE_SWI = 11, /* syscall, software interrupt */
|
|
|
|
R_ANAL_OP_TYPE_UPUSH = 12, /* unknown push of data into stack */
|
|
|
|
R_ANAL_OP_TYPE_PUSH = 13, /* push value into stack */
|
|
|
|
R_ANAL_OP_TYPE_POP = 14, /* pop value from stack to register */
|
|
|
|
R_ANAL_OP_TYPE_CMP = 15, /* copmpare something */
|
|
|
|
R_ANAL_OP_TYPE_ADD = 16,
|
|
|
|
R_ANAL_OP_TYPE_SUB = 17,
|
|
|
|
R_ANAL_OP_TYPE_IO = 18,
|
|
|
|
R_ANAL_OP_TYPE_MUL = 19,
|
|
|
|
R_ANAL_OP_TYPE_DIV = 20,
|
|
|
|
R_ANAL_OP_TYPE_SHR = 21,
|
|
|
|
R_ANAL_OP_TYPE_SHL = 22,
|
2013-11-25 02:03:54 +01:00
|
|
|
R_ANAL_OP_TYPE_SAL = 23,
|
|
|
|
R_ANAL_OP_TYPE_SAR = 24,
|
|
|
|
R_ANAL_OP_TYPE_OR = 25,
|
|
|
|
R_ANAL_OP_TYPE_AND = 26,
|
|
|
|
R_ANAL_OP_TYPE_XOR = 27,
|
|
|
|
R_ANAL_OP_TYPE_NOT = 28,
|
|
|
|
R_ANAL_OP_TYPE_STORE = 29, /* store from register to memory */
|
|
|
|
R_ANAL_OP_TYPE_LOAD = 30, /* load from memory to register */
|
|
|
|
R_ANAL_OP_TYPE_LEA = 31,
|
|
|
|
R_ANAL_OP_TYPE_LEAVE = 32,
|
|
|
|
R_ANAL_OP_TYPE_ROR = 33,
|
|
|
|
R_ANAL_OP_TYPE_ROL = 34,
|
2014-01-01 23:09:46 -06:00
|
|
|
R_ANAL_OP_TYPE_XCHG = 35,
|
|
|
|
R_ANAL_OP_TYPE_MOD = 36,
|
|
|
|
R_ANAL_OP_TYPE_SWITCH = 37,
|
2009-02-06 18:22:27 +01:00
|
|
|
};
|
|
|
|
|
2009-08-19 18:38:35 +02:00
|
|
|
/* TODO: what to do with signed/unsigned conditionals? */
|
|
|
|
enum {
|
2010-06-16 09:42:46 +02:00
|
|
|
R_ANAL_COND_EQ = 0,
|
|
|
|
R_ANAL_COND_NE,
|
|
|
|
R_ANAL_COND_GE,
|
|
|
|
R_ANAL_COND_GT,
|
|
|
|
R_ANAL_COND_LE,
|
|
|
|
R_ANAL_COND_LT,
|
2012-12-07 03:12:25 +01:00
|
|
|
R_ANAL_COND_AL,
|
|
|
|
R_ANAL_COND_NV,
|
2009-08-19 18:38:35 +02:00
|
|
|
};
|
|
|
|
|
2010-03-11 17:19:33 +01:00
|
|
|
enum {
|
2012-07-22 12:00:35 +04:00
|
|
|
R_ANAL_VAR_SCOPE_NULL = 0,
|
|
|
|
R_ANAL_VAR_SCOPE_GLOBAL = 0x01,
|
|
|
|
R_ANAL_VAR_SCOPE_LOCAL = 0x02,
|
|
|
|
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 */
|
|
|
|
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,
|
2009-02-06 18:22:27 +01:00
|
|
|
};
|
|
|
|
|
2011-06-14 04:49:10 +02:00
|
|
|
enum {
|
2010-10-28 00:55:07 +02:00
|
|
|
R_ANAL_REFLINE_TYPE_STYLE = 1,
|
|
|
|
R_ANAL_REFLINE_TYPE_WIDE = 2,
|
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;
|
2014-01-06 19:02:52 -06:00
|
|
|
struct r_anal_bb_t *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;
|
|
|
|
|
2010-03-19 13:51:28 +01:00
|
|
|
typedef struct r_anal_t {
|
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;
|
2011-10-19 13:05:41 +02:00
|
|
|
int split; // used only from core
|
2010-02-26 13:08:42 +01:00
|
|
|
void *user;
|
2010-03-03 12:08:27 +01:00
|
|
|
RList *fcns;
|
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;
|
2011-03-02 00:02:50 +01:00
|
|
|
RMeta *meta;
|
2010-09-18 02:51:17 +02:00
|
|
|
RReg *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;
|
2013-05-04 02:35:52 +02:00
|
|
|
int decode;
|
2012-07-19 06:54:22 +04:00
|
|
|
RList *types;
|
2011-10-19 10:01:01 +02:00
|
|
|
//struct r_anal_ctx_t *ctx;
|
2011-10-19 13:05:41 +02:00
|
|
|
struct r_anal_plugin_t *cur;
|
2011-02-03 09:31:50 +01:00
|
|
|
struct list_head anals; // TODO: Reimplement with RList
|
2013-01-22 05:06:12 +01:00
|
|
|
RList *hints; // XXX use better data structure here (slist?)
|
2013-04-18 03:58:44 +02:00
|
|
|
Sdb *sdb_xrefs;
|
2013-08-01 00:39:19 +02:00
|
|
|
Sdb *sdb_types;
|
2013-10-24 13:59:19 +02:00
|
|
|
PrintfCallback printf;
|
2014-01-10 10:20:23 -06:00
|
|
|
RBinBind binb; // Set only from core when an analysis plugin is called.
|
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 {
|
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
2013-06-17 03:26:48 +02:00
|
|
|
ut64 ptr;
|
2013-01-22 05:06:12 +01:00
|
|
|
char *arch;
|
|
|
|
char *opcode;
|
|
|
|
char *analstr;
|
2013-10-25 02:06:00 +02:00
|
|
|
ut64 jump;
|
|
|
|
ut64 fail;
|
2013-12-06 05:31:54 +01:00
|
|
|
int size;
|
2013-01-22 05:06:12 +01:00
|
|
|
int bits;
|
|
|
|
} RAnalHint;
|
|
|
|
|
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;
|
|
|
|
|
2011-02-24 14:06:49 +01:00
|
|
|
typedef struct r_anal_op_t {
|
2010-06-16 09:42:46 +02:00
|
|
|
char *mnemonic; /* mnemonic */
|
|
|
|
ut64 addr; /* address */
|
2013-07-19 03:35:45 +02:00
|
|
|
ut64 type; /* type of opcode */
|
2014-01-01 23:09:46 -06:00
|
|
|
ut64 type2;
|
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 */
|
2010-06-23 17:30:16 +02:00
|
|
|
int nopcode; /* number of bytes representing the opcode (not the arguments) */
|
2010-06-16 09:42:46 +02:00
|
|
|
int family; /* family of opcode */
|
|
|
|
int eob; /* end of block (boolean) */
|
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 */
|
2010-09-05 21:20:56 +02:00
|
|
|
ut32 selector; /* segment selector */
|
2013-06-09 03:25:32 +02:00
|
|
|
#if 0
|
|
|
|
ref->ptr
|
|
|
|
value->val
|
|
|
|
#endif
|
|
|
|
st64 ptr; /* reference to memory */ /* XXX signed? */
|
|
|
|
ut64 val; /* reference to value */ /* XXX signed? */
|
2010-06-16 09:42:46 +02:00
|
|
|
st64 stackptr; /* stack pointer */
|
2013-06-09 03:25:32 +02:00
|
|
|
int refptr;
|
2010-06-16 21:44:19 +02:00
|
|
|
RAnalValue *src[3];
|
|
|
|
RAnalValue *dst;
|
2013-06-09 03:25:32 +02:00
|
|
|
struct r_anal_op_t *next; // XXX deprecate
|
2013-12-10 03:35:59 +01:00
|
|
|
RStrBuf esil;
|
2014-01-01 23:09:46 -06:00
|
|
|
RAnalSwitchOp *switch_op;
|
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;
|
|
|
|
|
2014-01-01 23:09:46 -06:00
|
|
|
struct r_anal_bb_t;
|
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 size;
|
|
|
|
ut64 jump;
|
2014-01-05 14:43:57 -06:00
|
|
|
ut64 type2;
|
2010-02-26 13:08:42 +01:00
|
|
|
ut64 fail;
|
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;
|
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;
|
2011-11-15 09:56:22 +01:00
|
|
|
#if R_ANAL_BB_HAS_OPS
|
2011-02-24 14:06:49 +01:00
|
|
|
RList *ops;
|
2011-11-15 09:56:22 +01:00
|
|
|
#endif
|
2010-06-15 00:46:18 +02:00
|
|
|
RAnalCond *cond;
|
2014-01-01 23:09:46 -06:00
|
|
|
RAnalSwitchOp *switch_op;
|
2014-01-06 19:02:52 -06:00
|
|
|
ut8 *op_bytes;
|
2014-01-01 23:09:46 -06:00
|
|
|
ut8 op_sz;
|
2014-01-06 20:48:49 -06:00
|
|
|
ut64 eflags;
|
2014-01-01 23:09:46 -06:00
|
|
|
struct r_anal_bb_t *head;
|
|
|
|
struct r_anal_bb_t *tail;
|
|
|
|
struct r_anal_bb_t *next;
|
|
|
|
struct r_anal_bb_t *prev;
|
|
|
|
struct r_anal_bb_t *failbb;
|
|
|
|
struct r_anal_bb_t *jumpbb;
|
|
|
|
RList /*struct r_anal_bb_t*/ *cases;
|
2010-05-21 01:46:26 +02:00
|
|
|
} RAnalBlock;
|
2009-04-01 00:32:26 +02:00
|
|
|
|
2010-07-02 02:01:51 +02:00
|
|
|
typedef struct r_anal_var_access_t {
|
|
|
|
ut64 addr;
|
|
|
|
int set;
|
|
|
|
} RAnalVarAccess;
|
|
|
|
|
2010-03-07 14:00:26 +01:00
|
|
|
typedef struct r_anal_var_t {
|
2012-07-19 06:54:22 +04:00
|
|
|
char *name; /* name of the variable */
|
2013-09-02 01:20:12 +02:00
|
|
|
char *type;
|
2012-07-19 06:54:22 +04:00
|
|
|
ut64 addr; // not used correctly?
|
|
|
|
ut64 eaddr; // not used correctly?
|
|
|
|
int delta; /* delta offset inside stack frame */
|
2012-07-22 12:00:35 +04:00
|
|
|
int scope; /* global, local... | in, out... */
|
2010-07-02 02:01:51 +02:00
|
|
|
/* probably dupped or so */
|
|
|
|
RList/*RAnalVarAccess*/ *accesses; /* list of accesses for this var */
|
|
|
|
RList/*RAnalValue*/ *stores; /* where this */
|
2010-03-19 12:00:04 +01:00
|
|
|
} RAnalVar;
|
2010-03-11 17:19:33 +01:00
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
/*
|
2010-03-11 19:52:05 +01:00
|
|
|
typedef struct r_anal_var_type_t {
|
|
|
|
char *name;
|
|
|
|
char *fmt;
|
2011-02-07 17:43:50 +01:00
|
|
|
ut32 size;
|
2010-03-19 12:00:04 +01:00
|
|
|
} RAnalVarType;
|
2012-07-19 06:54:22 +04:00
|
|
|
*/
|
2010-03-11 17:19:33 +01: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)
|
2011-02-08 00:15:12 +01:00
|
|
|
R_ANAL_REF_TYPE_DATA = 'd' // mem ref
|
2010-06-14 00:57:40 +02:00
|
|
|
} RAnalRefType;
|
|
|
|
|
|
|
|
typedef struct r_anal_ref_t {
|
|
|
|
int type;
|
|
|
|
ut64 addr;
|
2010-09-28 13:58:03 +02:00
|
|
|
ut64 at;
|
2010-06-14 00:57:40 +02:00
|
|
|
} RAnalRef;
|
2009-10-12 17:41:52 +02:00
|
|
|
|
2010-02-26 13:08:42 +01:00
|
|
|
typedef struct r_anal_refline_t {
|
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
|
|
|
int index;
|
|
|
|
struct list_head list;
|
2010-03-19 12:00:04 +01:00
|
|
|
} RAnalRefline;
|
2010-02-22 04:02:13 +01:00
|
|
|
|
2014-01-01 23:09:46 -06: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;
|
|
|
|
RHashTable64 *ht;
|
|
|
|
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
|
|
|
|
|
|
|
typedef int (*RAnalCmdExt)(/* Rcore */void *core, RAnal *anal, const char* input);
|
|
|
|
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);
|
|
|
|
|
2011-02-24 14:06:49 +01:00
|
|
|
typedef int (*RAnalOpCallback)(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *data, int len);
|
2014-01-01 23:09:46 -06:00
|
|
|
typedef int (*RAnalBbCallback)(RAnal *a, RAnalBlock *bb, ut64 addr, const ut8 *data, int len);
|
|
|
|
typedef int (*RAnalFnCallback)(RAnal *a, RAnalFunction *fcn, ut64 addr, const ut8 *data, int len, int reftype);
|
|
|
|
|
2011-02-18 13:08:09 +01:00
|
|
|
typedef int (*RAnalRegProfCallback)(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
|
|
|
|
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;
|
2011-05-06 19:56:16 +02:00
|
|
|
int arch;
|
|
|
|
int bits;
|
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-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;
|
|
|
|
|
|
|
|
// overide the default analysis function in r_core_anal_fcn
|
|
|
|
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
|
2014-01-05 14:43:57 -06:00
|
|
|
// r_anal_ex_recursive_decent when using perform_analysis from
|
|
|
|
// RAnalEx stuffs
|
|
|
|
RAnalExAnalysisAlgorithm analysis_algorithm;
|
2014-01-01 23:09:46 -06:00
|
|
|
// order in which these call backs are
|
|
|
|
// used with the recursive descent disassembler
|
|
|
|
// analysis
|
|
|
|
// 0) Before performing any analysis is start, opportunity to do any pre analysis.
|
|
|
|
// 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-01-01 23:09:46 -06: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-01-01 23:09:46 -06: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-01-01 23:09:46 -06: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-01-01 23:09:46 -06: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-01-01 23:09:46 -06:00
|
|
|
// 6) After processing is bb and cb is completed, opportunity to do any post analysis.
|
|
|
|
// 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
|
|
|
|
|
|
|
// 6) After bb in a node is completed, opportunity to do any post analysis.
|
|
|
|
// 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-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;
|
2011-03-06 15:21:13 +01:00
|
|
|
RAnalFPBBCallback fingerprint_bb;
|
|
|
|
RAnalFPFcnCallback fingerprint_fcn;
|
|
|
|
RAnalDiffBBCallback diff_bb;
|
|
|
|
RAnalDiffFcnCallback diff_fcn;
|
|
|
|
RAnalDiffEvalCallback diff_eval;
|
2009-02-16 02:12:02 +01:00
|
|
|
struct list_head list;
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2010-05-26 01:42:22 +02:00
|
|
|
} RAnalPlugin;
|
2009-02-16 02:12:02 +01:00
|
|
|
|
2011-09-14 13:22:57 +02:00
|
|
|
|
2014-01-01 23:09:46 -06:00
|
|
|
|
2011-09-14 13:22:57 +02:00
|
|
|
#ifdef R_API
|
2011-09-14 02:07:06 +02:00
|
|
|
/* --------- */ /* REFACTOR */ /* ---------- */
|
|
|
|
R_API RListRange* r_listrange_new ();
|
|
|
|
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 */
|
|
|
|
R_API RAnalType *r_anal_type_new();
|
2012-08-28 11:02:25 +02:00
|
|
|
R_API void r_anal_type_add(RAnal *l, RAnalType *t);
|
|
|
|
R_API void r_anal_type_del(RAnal *l, const char *name);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API RList *r_anal_type_list_new();
|
2012-08-28 11:02:25 +02:00
|
|
|
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);
|
|
|
|
R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* s);
|
2013-09-02 01:20:12 +02:00
|
|
|
R_API char *r_anal_type_to_str(RAnal *a, const char *name);
|
2012-11-08 09:49:27 +01:00
|
|
|
R_API char *r_anal_optype_to_string(int t);
|
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);
|
2012-09-03 01:27:52 +02:00
|
|
|
R_API void r_anal_type_define (RAnal *anal, const char *key, const char *value);
|
|
|
|
R_API void r_anal_type_header (RAnal *anal, const char *hdr);
|
2012-07-22 12:00:35 +04:00
|
|
|
|
2013-08-13 03:23:39 +02:00
|
|
|
R_API int r_anal_type_link (RAnal *anal, const char *val, ut64 addr);
|
|
|
|
R_API char *r_anal_type_format (RAnal *anal, const char *t);
|
2013-08-17 19:53:04 +02:00
|
|
|
R_API int r_anal_type_set(RAnal *anal, ut64 at, const char *field, ut64 val);
|
2013-08-13 03:23:39 +02:00
|
|
|
|
2010-03-12 03:05:20 +01:00
|
|
|
/* anal.c */
|
2010-03-19 12:00:04 +01:00
|
|
|
R_API RAnal *r_anal_new();
|
2011-11-14 00:21:25 +01:00
|
|
|
R_API void 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);
|
2010-05-26 01:42:22 +02:00
|
|
|
R_API int r_anal_add(RAnal *anal, struct r_anal_plugin_t *foo);
|
2010-03-19 12:23:14 +01:00
|
|
|
R_API int r_anal_list(RAnal *anal);
|
|
|
|
R_API int r_anal_use(RAnal *anal, const char *name);
|
2011-02-18 13:08:09 +01:00
|
|
|
R_API int r_anal_set_reg_profile(RAnal *anal);
|
2010-03-19 12:23:14 +01:00
|
|
|
R_API int r_anal_set_bits(RAnal *anal, int bits);
|
|
|
|
R_API int r_anal_set_big_endian(RAnal *anal, int boolean);
|
2010-05-16 14:04:08 +02:00
|
|
|
R_API char *r_anal_strmask (RAnal *anal, const char *data);
|
2011-02-11 11:22:43 +01:00
|
|
|
R_API void r_anal_trace_bb(RAnal *anal, ut64 addr);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RAnalFunction *r_anal_get_fcn_at(RAnal *anal, ut64 addr);
|
2010-03-12 03:05:20 +01:00
|
|
|
|
|
|
|
/* bb.c */
|
2010-05-21 01:46:26 +02:00
|
|
|
R_API RAnalBlock *r_anal_bb_new();
|
2010-03-12 03:05:20 +01:00
|
|
|
R_API RList *r_anal_bb_list_new();
|
2011-11-14 00:21:25 +01:00
|
|
|
R_API void r_anal_bb_free(RAnalBlock *bb);
|
2010-05-21 18:23:01 +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);
|
2012-06-14 02:18:15 +02:00
|
|
|
R_API int r_anal_bb_is_in_offset (RAnalBlock *bb, ut64 addr);
|
2010-03-12 03:05:20 +01:00
|
|
|
|
2011-02-24 14:06:49 +01:00
|
|
|
/* op.c */
|
|
|
|
R_API RAnalOp *r_anal_op_new();
|
|
|
|
R_API void r_anal_op_free(void *op);
|
2011-11-14 00:21:25 +01:00
|
|
|
R_API void r_anal_op_fini(RAnalOp *op);
|
2011-02-24 14:06:49 +01:00
|
|
|
R_API RList *r_anal_op_list_new();
|
|
|
|
R_API int r_anal_op(RAnal *anal, RAnalOp *op, ut64 addr,
|
2010-11-23 17:15:33 +01:00
|
|
|
const ut8 *data, int len);
|
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);
|
2013-06-09 03:25:32 +02:00
|
|
|
R_API const char *r_anal_op_to_esil_string(RAnal *anal, RAnalOp *op);
|
2010-03-12 03:05:20 +01:00
|
|
|
|
|
|
|
/* fcn.c */
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RAnalFunction *r_anal_fcn_new();
|
|
|
|
R_API int r_anal_fcn_is_in_offset (RAnalFunction *fcn, ut64 addr);
|
|
|
|
R_API RAnalFunction *r_anal_fcn_find(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);
|
2010-03-12 03:05:20 +01:00
|
|
|
R_API RList *r_anal_fcn_list_new();
|
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);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr,
|
2010-11-23 17:15:33 +01:00
|
|
|
ut8 *buf, 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);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_fcn_add_bb(RAnalFunction *fcn, ut64 addr, ut64 size,
|
2011-02-11 11:22:43 +01:00
|
|
|
ut64 jump, ut64 fail, int type, RAnalDiff *diff);
|
2013-06-26 01:44:21 +04:00
|
|
|
R_API int r_anal_fcn_local_add(RAnal *anal, RAnalFunction *fcn, ut64 addr, const char *name);
|
|
|
|
R_API int r_anal_fcn_local_del_name(RAnal *anal, RAnalFunction *fcn, const char *name);
|
|
|
|
R_API int r_anal_fcn_local_del_addr(RAnal *anal, RAnalFunction *fcn, ut64 addr);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_fcn_cc(RAnalFunction *fcn);
|
|
|
|
R_API int r_anal_fcn_split_bb(RAnalFunction *fcn, RAnalBlock *bb, ut64 addr);
|
|
|
|
R_API int r_anal_fcn_overlap_bb(RAnalFunction *fcn, RAnalBlock *bb);
|
|
|
|
R_API RAnalVar *r_anal_fcn_get_var(RAnalFunction *fs, int num, int dir);
|
|
|
|
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);
|
2013-11-21 19:19:16 -06:00
|
|
|
R_API RAnalBlock *r_anal_fcn_bbget(RAnalFunction *fcn, ut64 addr); // default 20
|
2012-06-05 17:50:12 +02:00
|
|
|
|
|
|
|
#if 0
|
2011-11-12 01:52:31 +01:00
|
|
|
#define r_anal_fcn_get_refs(x) x->refs
|
|
|
|
#define r_anal_fcn_get_xrefs(x) x->xrefs
|
|
|
|
#define r_anal_fcn_get_vars(x) x->vars
|
|
|
|
#define r_anal_fcn_get_bbs(x) x->bbs
|
2012-06-05 17:50:12 +02:00
|
|
|
#else
|
2013-10-24 13:59:19 +02:00
|
|
|
R_API void r_anal_xrefs_list(RAnal *anal, int rad);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RList* r_anal_fcn_get_refs (RAnalFunction *anal);
|
|
|
|
R_API RList* r_anal_fcn_get_xrefs (RAnalFunction *anal);
|
2013-06-09 02:55:03 +02:00
|
|
|
R_API RList *r_anal_xrefs_set (RAnal *anal, const char *type, ut64 from, ut64 to);
|
2013-07-23 17:11:51 +02:00
|
|
|
R_API RList *r_anal_xrefs_deln (RAnal *anal, const char *type, ut64 from, ut64 to);
|
2013-06-09 03:25:32 +02:00
|
|
|
R_API void r_anal_xrefs_save(RAnal *anal, const char *prjfile);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RList* r_anal_fcn_get_vars (RAnalFunction *anal);
|
|
|
|
R_API RList* r_anal_fcn_get_bbs (RAnalFunction *anal);
|
2012-06-06 11:48:40 +02:00
|
|
|
R_API RList* r_anal_get_fcns (RAnal *anal);
|
2012-06-05 17:50:12 +02:00
|
|
|
#endif
|
2010-03-12 03:05:20 +01:00
|
|
|
|
|
|
|
/* ref.c */
|
2010-03-19 12:00:04 +01:00
|
|
|
R_API RAnalRef *r_anal_ref_new();
|
2010-03-12 03:05:20 +01:00
|
|
|
R_API RList *r_anal_ref_list_new();
|
|
|
|
R_API void r_anal_ref_free(void *ref);
|
2010-09-28 13:58:03 +02:00
|
|
|
R_API int r_anal_ref_add(RAnal *anal, ut64 addr, ut64 at, int type);
|
2013-07-19 03:35:45 +02:00
|
|
|
R_API int r_anal_ref_del(RAnal *anal, ut64 at, ut64 addr);
|
2010-09-28 18:05:31 +02:00
|
|
|
R_API RList *r_anal_xref_get(RAnal *anal, ut64 addr);
|
2013-02-13 17:54:20 +01:00
|
|
|
R_API RList *r_anal_ref_get(RAnal *anal, ut64 addr);
|
2010-02-26 13:08:42 +01:00
|
|
|
|
2010-03-11 17:19:33 +01:00
|
|
|
/* var.c */
|
2010-03-19 12:00:04 +01:00
|
|
|
R_API RAnalVar *r_anal_var_new();
|
|
|
|
R_API RAnalVarAccess *r_anal_var_access_new();
|
2010-03-11 19:52:05 +01:00
|
|
|
R_API RList *r_anal_var_list_new();
|
|
|
|
R_API RList *r_anal_var_access_list_new();
|
|
|
|
R_API void r_anal_var_free(void *var);
|
|
|
|
R_API void r_anal_var_access_free(void *access);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API int r_anal_var_add(RAnal *anal, RAnalFunction *fcn, ut64 from, int delta, int scope,
|
2012-08-14 15:44:17 +02:00
|
|
|
RAnalType *type, const char *name, int set);
|
2012-07-22 12:00:35 +04:00
|
|
|
R_API int r_anal_var_del(RAnal *anal, RAnalFunction *fcn, int delta, int scope);
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API RAnalVar *r_anal_var_get(RAnal *anal, RAnalFunction *fcn, int delta, int type);
|
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);
|
2010-03-11 17:19:33 +01:00
|
|
|
|
2013-04-18 03:58:44 +02:00
|
|
|
/* project */
|
|
|
|
R_API int r_anal_project_load(RAnal *anal, const char *prjfile);
|
|
|
|
R_API int r_anal_project_save(RAnal *anal, const char *prjfile);
|
|
|
|
R_API void r_anal_xrefs_load(RAnal *anal, const char *prjfile);
|
|
|
|
R_API void r_anal_xrefs_init (RAnal *anal);
|
|
|
|
|
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 */
|
|
|
|
R_API RAnalDiff *r_anal_diff_new();
|
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);
|
|
|
|
R_API int 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 */
|
2010-06-16 21:44:19 +02:00
|
|
|
R_API RAnalValue *r_anal_value_new();
|
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);
|
|
|
|
|
2010-06-15 00:46:18 +02:00
|
|
|
R_API RAnalCond *r_anal_cond_new();
|
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);
|
2010-06-15 00:46:18 +02:00
|
|
|
|
2010-02-26 13:08:42 +01:00
|
|
|
/* reflines.c */
|
2013-07-19 00:20:23 +04:00
|
|
|
R_API RAnalRefline *r_anal_reflines_get(RAnal *anal,
|
2010-06-17 02:22:50 +02:00
|
|
|
ut64 addr, ut8 *buf, ut64 len, int nlines, int linesout, int linescall);
|
2010-03-19 12:23:14 +01:00
|
|
|
R_API int r_anal_reflines_middle(RAnal *anal, RAnalRefline *list, ut64 addr, int len);
|
2013-07-19 00:20:23 +04:00
|
|
|
R_API char* r_anal_reflines_str(void *core, ut64 addr, int opts);
|
2010-03-10 15:15:50 +01:00
|
|
|
|
2011-02-18 10:08:24 +01:00
|
|
|
/* TODO move to r_core */
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, ut64 addr);
|
|
|
|
R_API void r_anal_var_list(RAnal *anal, RAnalFunction *fcn, ut64 addr, int delta);
|
2010-08-22 18:41:57 +02:00
|
|
|
|
2011-02-02 13:05:48 +01:00
|
|
|
// calling conventions API
|
|
|
|
R_API RAnalCC* r_anal_cc_new ();
|
|
|
|
R_API void r_anal_cc_init (RAnalCC *cc);
|
|
|
|
R_API RAnalCC* r_anal_cc_new_from_string (const char *str, int type);
|
|
|
|
R_API void r_anal_cc_free (RAnalCC* cc);
|
|
|
|
R_API void r_anal_cc_reset (RAnalCC *cc);
|
|
|
|
R_API char *r_anal_cc_to_string (RAnal *anal, RAnalCC* cc);
|
|
|
|
R_API boolt r_anal_cc_update (RAnal *anal, RAnalCC *cc, RAnalOp *op);
|
|
|
|
//R_API int r_anal_cc_register (RAnal *anal, RAnalCC *cc);
|
|
|
|
//R_API int r_anal_cc_unregister (RAnal *anal, RAnalCC *cc);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
R_API RAnalData *r_anal_data (RAnal *anal, ut64 addr, const ut8 *buf, int size);
|
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);
|
|
|
|
R_API char *r_anal_data_to_string (RAnalData *d);
|
2012-11-20 03:59:00 +01:00
|
|
|
|
2011-03-01 19:06:22 +01:00
|
|
|
R_API RMeta *r_meta_new();
|
|
|
|
R_API void r_meta_free(RMeta *m);
|
|
|
|
R_API int r_meta_count(RMeta *m, int type, ut64 from, ut64 to);
|
|
|
|
R_API char *r_meta_get_string(RMeta *m, int type, ut64 addr);
|
2011-05-21 14:27:46 +02:00
|
|
|
R_API int r_meta_set_string(RMeta *m, int type, ut64 addr, const char *s);
|
2011-03-01 19:06:22 +01:00
|
|
|
R_API int r_meta_del(RMeta *m, int type, ut64 from, ut64 size, const char *str);
|
|
|
|
R_API int r_meta_add(RMeta *m, int type, ut64 from, ut64 size, const char *str);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API RMetaItem *r_meta_find(RMeta *m, ut64 off, int type, int where);
|
2011-03-01 19:06:22 +01:00
|
|
|
R_API int r_meta_cleanup(RMeta *m, ut64 from, ut64 to);
|
|
|
|
R_API const char *r_meta_type_to_string(int type);
|
2012-02-01 02:22:43 +01:00
|
|
|
R_API int r_meta_list(RMeta *m, int type, int rad);
|
2011-03-01 19:06:22 +01:00
|
|
|
R_API void r_meta_item_free(void *_item);
|
|
|
|
R_API RMetaItem *r_meta_item_new(int type);
|
|
|
|
|
2012-07-19 06:54:22 +04:00
|
|
|
R_API int r_anal_fcn_xref_add (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type);
|
|
|
|
R_API int r_anal_fcn_xref_del (RAnal *anal, RAnalFunction *fcn, ut64 at, ut64 addr, int type);
|
2011-09-28 02:48:03 +02:00
|
|
|
|
2013-01-22 05:06:12 +01:00
|
|
|
/* hints */
|
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);
|
2013-01-22 05:06:12 +01:00
|
|
|
R_API RAnalHint *r_anal_hint_at (RAnal *a, ut64 from, int size);
|
|
|
|
R_API RAnalHint *r_anal_hint_add (RAnal *a, ut64 from, int size);
|
|
|
|
R_API void r_anal_hint_free (RAnalHint *h);
|
|
|
|
R_API RAnalHint *r_anal_hint_get(RAnal *anal, ut64 addr);
|
2013-10-25 02:06:00 +02:00
|
|
|
R_API void r_anal_hint_set_jump (RAnal *a, ut64 addr, ut64 ptr);
|
|
|
|
R_API void r_anal_hint_set_fail (RAnal *a, ut64 addr, ut64 ptr);
|
2013-12-09 04:56:13 +01:00
|
|
|
R_API void r_anal_hint_set_length (RAnal *a, ut64 addr, int size, int length);
|
2013-01-22 05:06:12 +01:00
|
|
|
R_API void r_anal_hint_set_bits (RAnal *a, ut64 addr, int size, int bits);
|
|
|
|
R_API void r_anal_hint_set_arch (RAnal *a, ut64 addr, int size, const char *arch);
|
2013-12-06 05:31:54 +01:00
|
|
|
R_API void r_anal_hint_set_size (RAnal *a, ut64 addr, int size, int length);
|
2013-01-22 05:06:12 +01:00
|
|
|
R_API void r_anal_hint_set_opcode (RAnal *a, ut64 addr, int size, const char *str);
|
2013-12-06 05:31:54 +01:00
|
|
|
R_API void r_anal_hint_set_esil (RAnal *a, ut64 addr, int size, 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);
|
2013-01-22 05:06:12 +01:00
|
|
|
|
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-01-05 14:43:57 -06:00
|
|
|
R_API RAnalCaseOp* r_anal_switch_op_add_case(RAnalSwitchOp * swop, ut64 addr, ut64 jump, ut64 value);
|
|
|
|
|
|
|
|
/*
|
2014-01-05 17:21:09 -06:00
|
|
|
* RAnalState maintains state during analysis.
|
2014-01-05 14:43:57 -06:00
|
|
|
* there are standard values current_fcn, current_op, current_bb, addr,
|
|
|
|
* 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);
|
|
|
|
R_API int r_anal_state_addr_is_valid (RAnalState *state, ut64 addr);
|
|
|
|
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-01-01 23:09:46 -06:00
|
|
|
|
2010-03-10 15:15:50 +01:00
|
|
|
/* plugin pointers */
|
2010-05-26 01:42:22 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_csr;
|
2013-04-23 12:53:21 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_c55plus;
|
2011-01-26 21:54:39 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_avr;
|
2010-05-26 01:42:22 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_arm;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86;
|
2013-03-19 10:27:57 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_x86_im;
|
|
|
|
extern RAnalPlugin r_anal_plugin_x86_udis;
|
2010-11-20 16:47:15 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_x86_simple;
|
2010-05-26 01:42:22 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_ppc;
|
|
|
|
extern RAnalPlugin r_anal_plugin_java;
|
2010-06-23 04:02:57 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_mips;
|
2011-02-18 01:43:31 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_dalvik;
|
2011-03-29 14:55:41 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_sh;
|
2011-09-03 01:17:37 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_sparc;
|
2011-10-09 04:15:32 +02:00
|
|
|
extern RAnalPlugin r_anal_plugin_bf;
|
2012-02-02 01:06:22 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_m68k;
|
2012-02-04 03:51:22 +01:00
|
|
|
extern RAnalPlugin r_anal_plugin_z80;
|
2012-10-29 20:43:08 +00:00
|
|
|
extern RAnalPlugin r_anal_plugin_i8080;
|
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;
|
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;
|
2010-03-10 15:15:50 +01:00
|
|
|
|
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
|