2023-01-20 16:04:05 +01:00
/* radare2 - LGPL - Copyright 2009-2023 - 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-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>
2022-11-13 01:22:32 +01:00
# include <r_esil.h>
2022-04-24 20:33:03 +02:00
# include <r_arch.h>
2010-02-26 13:08:42 +01:00
# include <r_list.h>
2021-10-14 12:40:55 +02:00
# include <r_util/r_print.h>
2019-11-15 16:48:00 +01:00
# include <r_search.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>
2021-03-30 00:20:06 +02:00
# include <r_codemeta.h>
2022-11-19 01:05:18 +01:00
# include <sdb/set.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 ) ;
2020-08-19 12:21:20 +02:00
/* dwarf processing context */
typedef struct r_anal_dwarf_context {
const RBinDwarfDebugInfo * info ;
HtUP /*<offset, RBinDwarfLocList*>*/ * loc ;
// const RBinDwarfCfa *cfa; TODO
} RAnalDwarfContext ;
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 - > 600 M
2011-11-15 09:56:22 +01:00
bb_has_ops = 0 - > 350 MB
2015-10-22 03:11:03 +02:00
*/
2013-02-12 02:42:34 +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 ;
2019-07-14 13:57:25 +02:00
PJ * pj ;
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-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 ,
2023-06-27 19:47:14 +02:00
R_ANAL_DATA_TYPE_ZERO = 10 ,
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
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 ,
} ;
2019-08-21 00:18:57 +02:00
# define R_ANAL_CC_MAXARG 16
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-09-12 16:06:55 +02:00
R_ANAL_FCN_TYPE_INT = 1 < < 4 , /* privileged function - ends with iret/reti/.. */
R_ANAL_FCN_TYPE_ROOT = 1 < < 5 , /* matching flag */
R_ANAL_FCN_TYPE_ANY = - 1 /* all the bits set */
2012-07-19 06:54:22 +04:00
} ;
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
enum {
R_ANAL_DIFF_TYPE_NULL = 0 ,
R_ANAL_DIFF_TYPE_MATCH = ' m ' ,
R_ANAL_DIFF_TYPE_UNMATCH = ' u '
} ;
2020-05-13 20:49:25 +02:00
typedef struct r_anal_enum_case_t {
char * name ;
2020-07-15 12:17:05 +02:00
int val ;
2020-05-13 20:49:25 +02:00
} RAnalEnumCase ;
typedef struct r_anal_struct_member_t {
char * name ;
char * type ;
2020-07-15 12:17:05 +02:00
size_t offset ; // in bytes
2022-05-05 09:44:03 +02:00
size_t size ; // in bits? rename to 'bitsize'
2020-05-13 20:49:25 +02:00
} RAnalStructMember ;
typedef struct r_anal_union_member_t {
char * name ;
char * type ;
2020-07-15 12:17:05 +02:00
size_t offset ; // in bytes
2022-05-05 09:44:03 +02:00
size_t size ; // in bits? TODO rename to 'bitsize'
2020-05-13 20:49:25 +02:00
} RAnalUnionMember ;
typedef enum {
R_ANAL_BASE_TYPE_KIND_STRUCT ,
R_ANAL_BASE_TYPE_KIND_UNION ,
R_ANAL_BASE_TYPE_KIND_ENUM ,
2020-07-15 12:17:05 +02:00
R_ANAL_BASE_TYPE_KIND_TYPEDEF , // probably temporary addition, dev purposes
R_ANAL_BASE_TYPE_KIND_ATOMIC , // For real atomic base types
2020-05-13 20:49:25 +02:00
} RAnalBaseTypeKind ;
typedef struct r_anal_base_type_struct_t {
RVector /*<RAnalStructMember>*/ members ;
} RAnalBaseTypeStruct ;
typedef struct r_anal_base_type_union_t {
RVector /*<RAnalUnionMember>*/ members ;
} RAnalBaseTypeUnion ;
typedef struct r_anal_base_type_enum_t {
RVector /*<RAnalEnumCase*/ cases ; // list of all the enum casessssss
} RAnalBaseTypeEnum ;
typedef struct r_anal_base_type_t {
2020-07-15 12:17:05 +02:00
char * name ;
2020-07-24 19:40:55 +02:00
char * type ; // Used by typedef, atomic type, enum
2020-07-15 12:17:05 +02:00
ut64 size ; // size of the whole type in bits
2020-05-13 20:49:25 +02:00
RAnalBaseTypeKind kind ;
union {
RAnalBaseTypeStruct struct_data ;
RAnalBaseTypeEnum enum_data ;
RAnalBaseTypeUnion union_data ;
} ;
} RAnalBaseType ;
2012-07-19 06:54:22 +04:00
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-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
} ;
2016-06-14 17:54:17 +02:00
/* Stores useful function metadata */
2021-11-21 20:18:46 +01:00
typedef struct r_anal_function_meta_t {
2020-01-15 10:58:30 +01:00
// _min and _max are calculated lazily when queried.
// On changes, they will either be updated (if this can be done trivially) or invalidated.
// They are invalid iff _min == UT64_MAX.
ut64 _min ; // PRIVATE, min address, use r_anal_function_min_addr() to access
ut64 _max ; // PRIVATE, max address, use r_anal_function_max_addr() to access
2016-06-14 17:54:17 +02:00
int numrefs ; // number of cross references
int numcallrefs ; // number of calls
} RAnalFcnMeta ;
2018-11-22 03:05:46 +01:00
typedef struct r_anal_function_t {
2020-04-12 14:17:45 +02:00
char * name ;
2023-08-25 18:45:02 +02:00
char * realname ; // R2_590: add realname for the mangled one
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 ;
2019-10-20 12:31:45 +02:00
const char * cc ; // calling convention, should come from RAnal.constpool
2015-10-29 23:37:51 +01:00
ut64 addr ;
2020-09-16 09:54:33 +02:00
HtUP /*<ut64, char *>*/ * labels ;
HtPP /*<char *, ut64 *>*/ * label_addrs ;
2020-04-17 22:10:49 +02:00
RPVector vars ;
2020-04-19 17:56:27 +02:00
HtUP /*<st64, RPVector<RAnalVar *>>*/ * inst_vars ; // offset of instructions => the variables they access
2021-12-02 17:39:59 +01:00
ut64 reg_save_area ; // size of stack area pre-reserved for saving registers
2020-05-25 01:55:31 -03:00
st64 bp_off ; // offset of bp inside owned stack frame
st64 stack ; // stack frame size
2016-05-16 03:46:23 +02:00
int maxstack ;
2015-10-29 23:37:51 +01:00
int ninstr ;
2015-12-14 10:19:07 +01:00
bool folded ;
2018-11-29 17:00:26 +01:00
bool is_pure ;
2020-05-17 01:08:49 -03:00
bool is_variadic ;
2018-11-29 17:00:26 +01:00
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 ;
2019-08-14 14:21:41 +02:00
bool is_noreturn ; // true if function does not return
2015-10-29 23:37:51 +01:00
ut8 * fingerprint ; // TODO: make is fuzzy and smarter
2020-01-15 10:18:55 +01:00
size_t fingerprint_size ;
2015-10-29 23:37:51 +01:00
RAnalDiff * diff ;
2020-01-15 10:58:30 +01:00
RList * bbs ; // TODO: should be RPVector
2016-06-17 14:26:24 +02:00
RAnalFcnMeta meta ;
2019-06-29 02:44:36 +02:00
RList * imports ; // maybe bound to class?
2020-01-15 10:58:30 +01:00
struct r_anal_t * anal ; // this function is associated with this instance
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
} ;
2020-05-09 20:49:28 +02:00
typedef enum {
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 ' ,
2020-05-09 20:49:28 +02:00
} RAnalMetaType ;
/* meta */
typedef struct r_anal_meta_item_t {
2023-01-20 19:42:55 +01:00
// XXX missing size
2020-05-09 20:49:28 +02:00
RAnalMetaType type ;
int subtype ;
char * str ;
const RSpace * space ;
} RAnalMetaItem ;
2011-03-02 00:02:50 +01:00
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 ;
2022-11-17 10:22:55 +01:00
# define R_ESIL_GOTO_LIMIT 4096
2015-04-01 00:38:24 +02:00
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
2020-05-25 01:55:31 -03:00
bool varname_stack ; // name vars based on their offset in the stack
2022-09-14 00:18:38 +02:00
bool var_newstack ; // new sp-relative variable analysis
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 ;
2019-09-17 00:46:07 +02:00
bool norevisit ;
2015-09-07 00:30:48 +02:00
int recont ; // continue on recurse analysis mode
int noncode ;
2022-12-13 20:23:35 +01:00
bool 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
2019-09-12 16:59:10 +02:00
int nonull ;
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 ; //
2019-09-23 10:53:25 +02:00
bool delay ;
2022-12-14 10:42:24 +01:00
bool tailcall ;
int tailcall_delta ;
2020-04-01 16:49:39 +02:00
bool retpoline ;
2022-11-02 05:23:21 +01:00
bool propagate_noreturn ;
bool recursive_noreturn ; // anal.rnr
2015-09-07 00:30:48 +02:00
} RAnalOptions ;
2018-03-12 21:48:44 +01:00
typedef enum {
2022-05-06 10:30:11 +02:00
R_ANAL_CPP_ABI_ITANIUM = 0 , // default for GCC
2018-03-12 21:48:44 +01:00
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 ;
2022-12-20 12:31:42 +01:00
typedef struct r_anal_thread_t {
int id ;
int map ; // tls map id
ut64 birth ;
RReg * reg ;
} RAnalThread ;
2023-07-07 16:01:48 +02:00
typedef struct r_ref_manager_t RefManager ;
2010-03-19 13:51:28 +01:00
typedef struct r_anal_t {
2022-04-24 20:33:03 +02:00
RArchConfig * config ;
2020-07-06 06:18:17 +02:00
int lineswidth ; // asm.lines.width
int sleep ; // anal.sleep, sleep some usecs before analyzing more (avoid 100% cpu usages)
2022-05-06 10:30:11 +02:00
RAnalCPPABI cxxabi ; // anal.cpp.abi
2010-02-26 13:08:42 +01:00
void * user ;
2020-07-06 06:18:17 +02:00
ut64 gp ; // anal.gp, global pointer. used for mips. but can be used by other arches too in the future
2020-02-04 08:31:55 +01:00
RBTree bb_tree ; // all basic blocks by address. They can overlap each other, but must never start at the same address.
2010-03-03 12:08:27 +01:00
RList * fcns ;
2020-01-15 10:58:30 +01:00
HtUP * ht_addr_fun ; // address => function
HtPP * ht_name_fun ; // name => function
2010-09-18 02:51:17 +02:00
RReg * reg ;
2016-10-24 14:31:03 +02:00
ut8 * last_disasm_reg ;
2021-11-01 22:38:53 +01:00
int last_disasm_reg_size ;
2011-02-02 13:05:48 +01:00
RSyscall * syscall ;
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 ;
2020-07-06 06:18:17 +02:00
int maxreflines ; // asm.lines.maxref
int esil_goto_limit ; // esil.gotolimit
2023-06-13 15:09:20 +02:00
struct r_esil_t * esil ; // R2_590 remove
2011-10-19 13:05:41 +02:00
struct r_anal_plugin_t * cur ;
2022-11-17 10:22:55 +01:00
struct r_esil_plugin_t * esil_cur ; // ???
2022-09-25 03:19:52 +02:00
RArch * arch ;
2020-07-06 06:18:17 +02:00
RAnalRange * limit ; // anal.from, anal.to
2021-01-24 16:39:45 +01:00
RList * plugins ; // anal plugins
2013-08-01 00:39:19 +02:00
Sdb * sdb_types ;
2018-07-22 20:47:56 +05:30
Sdb * sdb_fmts ;
2017-03-07 23:20:48 +00:00
Sdb * sdb_zigns ;
2023-07-07 16:01:48 +02:00
RefManager * rm ;
2017-03-07 23:20:48 +00:00
RSpaces zign_spaces ;
2020-07-06 06:18:17 +02:00
char * zign_path ; // dir.zigns
2015-08-08 14:15:13 -04:00
PrintfCallback cb_printf ;
2021-10-14 12:40:55 +02:00
RPrint * print ;
2015-07-31 12:40:04 +02:00
//moved from RAnalFcn
2014-03-05 03:52:42 +01:00
Sdb * sdb ; // root
2015-06-30 10:50:46 +02:00
Sdb * sdb_pins ;
2020-02-13 11:48:24 +01:00
HtUP /*<RVector<RAnalAddrHintRecord>>*/ * addr_hints ; // all hints that correspond to a single address
RBTree /*<RAnalArchHintRecord>*/ arch_hints ;
RBTree /*<RAnalArchBitsRecord>*/ bits_hints ;
2018-11-22 21:31:54 +01:00
RHintCb hint_cbs ;
2020-05-09 20:49:28 +02:00
RIntervalTree meta ;
RSpaces meta_spaces ;
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 ;
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-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 ;
2019-03-05 14:43:49 -08:00
RFlagGetAtAddr flag_get ;
2018-10-26 23:23:51 +02:00
REvent * ev ;
2020-09-24 02:15:22 +02:00
RList /*<char *>*/ * imports ; // global imports
2019-09-17 01:06:22 +02:00
SetU * visited ;
2019-10-20 12:31:45 +02:00
RStrConstPool constpool ;
2019-11-06 00:02:02 +08:00
RList * leaddrs ;
2021-07-30 10:25:57 +02:00
char * pincmd ;
2022-09-21 22:12:08 +02:00
/* private */
2022-09-23 21:37:50 +02:00
RThreadLock * lock ;
2022-09-21 22:12:08 +02:00
ut64 cmpval ;
ut64 lea_jmptbl_ip ;
int cs_obits ;
int cs_omode ;
size_t cs_handle ;
2022-12-20 12:31:42 +01:00
int thread ; // see apt command
RList * threads ;
2023-06-22 21:41:37 +02:00
RColor tracetagcolors [ 64 ] ; // each trace color for each bit
2022-09-21 22:12:08 +02:00
/* end private */
2022-01-25 09:39:15 +00:00
R_DIRTY_VAR ;
2010-03-19 12:00:04 +01:00
} RAnal ;
2009-02-16 00:57:03 +01:00
2020-09-16 09:54:33 +02:00
typedef const char * ( * RAnalLabelAt ) ( RAnalFunction * fcn , ut64 ) ;
2019-04-25 11:22:06 +02:00
2020-04-17 22:10:49 +02:00
typedef enum {
R_ANAL_VAR_KIND_REG = ' r ' ,
R_ANAL_VAR_KIND_BPV = ' b ' ,
R_ANAL_VAR_KIND_SPV = ' s '
} RAnalVarKind ;
2016-02-15 17:49:17 +01:00
2019-01-31 20:59:21 +05:30
# define VARPREFIX "var"
# define ARGPREFIX "arg"
2020-04-19 17:56:27 +02:00
typedef enum {
2020-11-12 01:26:12 -03:00
R_ANAL_VAR_ACCESS_TYPE_PTR = 0 ,
2020-04-19 17:56:27 +02:00
R_ANAL_VAR_ACCESS_TYPE_READ = ( 1 < < 0 ) ,
R_ANAL_VAR_ACCESS_TYPE_WRITE = ( 1 < < 1 )
} RAnalVarAccessType ;
typedef struct r_anal_var_access_t {
2020-05-25 01:55:31 -03:00
const char * reg ; // register used for access
2020-04-19 17:56:27 +02:00
st64 offset ; // relative to the function's entrypoint
2020-05-25 01:55:31 -03:00
st64 stackptr ; // delta added to register to get the var, e.g. [rbp - 0x10]
2020-04-19 17:56:27 +02:00
ut8 type ; // RAnalVarAccessType bits
} RAnalVarAccess ;
2020-09-23 09:40:39 +02:00
typedef struct r_anal_var_constraint_t {
_RAnalCond cond ;
ut64 val ;
} RAnalVarConstraint ;
2016-02-15 17:49:17 +01:00
// generic for args and locals
typedef struct r_anal_var_t {
2020-04-19 17:56:27 +02:00
RAnalFunction * fcn ;
2019-12-29 22:06:25 +00:00
char * name ; // name of the variable
char * type ; // cparse type of the variable
2020-04-17 22:10:49 +02:00
RAnalVarKind kind ;
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 */
2020-04-25 15:06:38 +02:00
char * regname ; // name of the register
2020-04-19 17:56:27 +02:00
RVector /*<RAnalVarAccess>*/ accesses ; // ordered by offset, touch this only through API or expect uaf
2020-04-25 17:23:36 +02:00
char * comment ;
2020-09-23 09:40:39 +02:00
RVector /*<RAnalVarConstraint>*/ constraints ;
2020-04-17 22:10:49 +02:00
// below members are just for caching, TODO: remove them and do it better
int argnum ;
2016-02-15 17:49:17 +01:00
} RAnalVar ;
2021-11-02 06:04:35 -04:00
// RAnalVar "prototype", RAnalVar w/o function used for serialization
typedef struct r_anal_var_proto_t {
char * name ;
char * type ;
RAnalVarKind kind ;
bool isarg ;
int delta ;
} RAnalVarProt ;
2020-04-17 22:10:49 +02:00
// Refers to a variable or a struct field inside a variable, only for varsub
R_DEPRECATE typedef struct r_anal_var_field_t {
char * name ;
2020-04-19 17:56:27 +02:00
st64 delta ;
2020-07-16 21:01:03 -03:00
bool field ;
2020-04-17 22:10:49 +02:00
} RAnalVarField ;
2022-08-19 21:36:54 +02:00
2023-06-20 16:30:41 +02:00
// TO DEPRECATE R2_590
2022-03-16 11:58:48 +01:00
// Use r_anal_get_functions_in¿() instead
R_DEPRECATE R_API RAnalFunction * r_anal_get_fcn_in ( RAnal * anal , ut64 addr , int type ) ;
R_DEPRECATE R_API RAnalFunction * r_anal_get_fcn_in_bounds ( RAnal * anal , ut64 addr , int type ) ;
R_API R_DEPRECATE RList /*<RAnalVar *>*/ * r_anal_var_all_list ( RAnal * anal , RAnalFunction * fcn ) ;
R_API R_DEPRECATE RList /*<RAnalVarField *>*/ * r_anal_function_get_var_fields ( RAnalFunction * fcn , int kind ) ;
// There could be multiple vars used in multiple functions. Use r_anal_get_functions_in()+r_anal_function_get_vars_used_at() instead.
R_API R_DEPRECATE RAnalVar * r_anal_get_used_function_var ( RAnal * anal , ut64 addr ) ;
2021-07-25 22:44:47 +02:00
typedef RAnalFunction * ( * RAnalGetFcnIn ) ( RAnal * anal , ut64 addr , int type ) ;
typedef RAnalHint * ( * RAnalGetHint ) ( RAnal * anal , ut64 addr ) ;
2022-05-07 21:19:04 +02:00
typedef char * ( * RAnalMnemonics ) ( RAnal * anal , int id , bool json ) ;
2022-12-06 12:16:45 +01:00
typedef int ( * RAnalEncode ) ( RAnal * anal , ut64 addr , const char * s , ut8 * data , int len ) ;
2021-07-25 22:44:47 +02:00
typedef int ( * RAnalDecode ) ( RAnal * anal , RAnalOp * op , ut64 addr , const ut8 * data , int len , RAnalOpMask mask ) ;
typedef void ( * RAnalOpInit ) ( RAnalOp * op ) ;
typedef void ( * RAnalOpFini ) ( RAnalOp * op ) ;
2022-04-19 01:50:13 +02:00
typedef bool ( * RAnalUse ) ( RAnal * op , const char * name ) ; // TODO: add bits and cpu too imho
2021-07-25 22:44:47 +02:00
typedef struct r_anal_bind_t {
RAnal * anal ;
RAnalGetFcnIn get_fcn_in ;
RAnalGetHint get_hint ;
2022-05-07 21:19:04 +02:00
RAnalMnemonics mnemonics ;
2022-01-09 22:55:34 +01:00
RAnalEncode encode ;
2021-07-25 22:44:47 +02:00
RAnalDecode decode ;
RAnalOpInit opinit ;
RAnalOpFini opfini ;
2022-04-19 01:50:13 +02:00
RAnalUse use ;
2021-07-25 22:44:47 +02:00
} RAnalBind ;
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
2022-12-09 18:42:56 +01:00
RArchValue * 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 {
2020-01-15 10:58:30 +01:00
RBNode _rb ; // private, node in the RBTree
ut64 _max_end ; // private, augmented value for RBTree
2010-02-26 13:08:42 +01:00
ut64 addr ;
2020-01-15 10:54:37 +01:00
ut64 size ;
2010-02-26 13:08:42 +01:00
ut64 jump ;
ut64 fail ;
2023-06-22 21:41:37 +02:00
ut64 traced ; // bitfield (each bit represents 1 trace)
2020-02-14 17:50:10 +01:00
bool folded ;
2021-02-09 14:23:25 +01:00
RColor color ;
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 ;
2020-03-09 07:12:48 +01:00
ut16 * op_pos ; // offsets of instructions in this block, count is ninstr - 1 (first is always 0)
2014-01-06 19:02:52 -06:00
ut8 * op_bytes ;
2016-10-24 14:31:03 +02:00
ut8 * parent_reg_arena ;
2021-11-01 22:38:53 +01:00
int parent_reg_arena_size ;
2020-03-09 07:12:48 +01:00
int op_pos_size ; // size of the op_pos array
2020-02-14 17:50:10 +01:00
int ninstr ;
2017-01-31 10:00:24 +01:00
int stackptr ;
int parent_stackptr ;
2019-03-18 16:15:56 +01:00
ut64 cmpval ;
const char * cmpreg ;
2020-10-29 19:55:49 -03:00
ut32 bbhash ; // calculated with xxhash
2020-02-14 17:50:10 +01:00
2020-01-15 10:58:30 +01:00
RList * fcns ;
RAnal * anal ;
2020-02-14 17:50:10 +01:00
int ref ;
2023-07-17 14:11:53 +02:00
int depth ;
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 {
2022-04-25 22:19:23 +02:00
R_ANAL_REF_TYPE_NULL = 0 , // find better name
2010-07-02 02:01:51 +02:00
R_ANAL_REF_TYPE_CODE = ' c ' , // code ref
2023-06-27 19:47:14 +02:00
R_ANAL_REF_TYPE_CALL = ' C ' , // code ref (call) -- maybe use 'k' for kall?
2022-04-25 22:19:23 +02:00
R_ANAL_REF_TYPE_JUMP = ' j ' , // code ref (call)
2014-01-23 01:56:35 +01:00
R_ANAL_REF_TYPE_DATA = ' d ' , // mem ref
2023-06-28 20:47:27 +02:00
R_ANAL_REF_TYPE_ICOD = ' i ' , // indirect code reference
R_ANAL_REF_TYPE_STRN = ' s ' , // string ref
2023-06-27 19:47:14 +02:00
// perm / direction
2022-04-25 22:19:23 +02:00
R_ANAL_REF_TYPE_READ = 4 < < 8 ,
R_ANAL_REF_TYPE_WRITE = 2 < < 8 ,
R_ANAL_REF_TYPE_EXEC = 1 < < 8 ,
R_ANAL_REF_TYPE_MASK = 0xff ,
R_ANAL_REF_TYPE_DIRECTION_MASK = 0xff00
2010-06-14 00:57:40 +02:00
} RAnalRefType ;
2022-04-25 22:19:23 +02:00
# define R_ANAL_REF_TYPE_PERM(x) (((x)>>8) & 0xff)
2023-06-28 20:47:51 +02:00
// #define R_ANAL_REF_TYPE_MASK(x) ((x) & 0xff)
# define R_ANAL_REF_TYPE_MASK(x) r_anal_ref_typemask((x))
2022-04-25 22:19:23 +02:00
2010-06-14 00:57:40 +02:00
typedef struct r_anal_ref_t {
2010-09-28 13:58:03 +02:00
ut64 at ;
2023-07-07 16:01:48 +02:00
ut64 addr ;
2018-09-22 00:11:44 +02:00
RAnalRefType type ;
2010-06-14 00:57:40 +02:00
} RAnalRef ;
2009-10-12 17:41:52 +02:00
2023-07-18 11:03:44 +02:00
typedef struct r_vec_RVecAnalRef_t RVecAnalRef ;
2023-07-07 16:01:48 +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-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 ;
2022-11-17 10:22:55 +01:00
typedef struct r_esil_word_t {
2014-06-20 18:01:33 +02:00
int type ;
const char * str ;
2022-11-17 10:22:55 +01:00
} REsilWord ;
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
2014-09-01 19:40:56 +02:00
2019-09-26 11:36:20 +02:00
2022-11-26 14:22:05 +01:00
typedef struct r_anal_esil_cfg_t {
2019-09-26 11:36:20 +02:00
RGraphNode * start ;
RGraphNode * end ;
RGraph * g ;
2022-11-26 14:22:05 +01:00
} RAnalEsilCFG ;
2019-09-26 11:36:20 +02:00
2020-08-11 13:06:39 +02:00
enum {
2022-11-26 14:22:05 +01:00
R_ANAL_ESIL_DFG_TAG_CONST = 1 ,
R_ANAL_ESIL_DFG_TAG_VAR = 2 ,
R_ANAL_ESIL_DFG_TAG_PTR = 4 ,
R_ANAL_ESIL_DFG_TAG_RESULT = 8 ,
R_ANAL_ESIL_DFG_TAG_GENERATIVE = 16 ,
R_ANAL_ESIL_DFG_TAG_REG = 32 ,
R_ANAL_ESIL_DFG_TAG_MEM = 64 ,
R_ANAL_ESIL_DFG_TAG_MERGE = 128 ,
2023-02-19 07:30:25 +01:00
R_ANAL_ESIL_DFG_TAG_SIBLING = 256 ,
2022-11-26 14:22:05 +01:00
} ; //RAnalEsilDFGTagType
typedef struct r_anal_esil_dfg_t {
2019-09-26 11:36:20 +02:00
ut32 idx ;
2022-10-24 02:57:13 +02:00
int fd ;
RIOBind iob ;
2022-11-07 02:24:42 +01:00
RReg * reg ;
2019-10-28 10:10:24 +01:00
Sdb * regs ; //resolves regnames to intervals
2022-10-06 20:16:39 +02:00
RRBTree * vars ; //vars represented in regs and mem
2019-10-28 10:10:24 +01:00
RQueue * todo ; //todo-queue allocated in this struct for perf
void * insert ; //needed for setting regs in dfg
2019-09-26 11:36:20 +02:00
RGraph * flow ;
2019-09-30 21:45:25 +02:00
RGraphNode * cur ;
RGraphNode * old ;
2022-11-17 10:22:55 +01:00
REsil * esil ;
2022-11-30 03:51:06 +01:00
bool use_map_info ;
bool use_maps ;
2019-10-29 17:05:29 +01:00
bool malloc_failed ;
2022-11-26 14:22:05 +01:00
} RAnalEsilDFG ;
2019-09-26 11:36:20 +02:00
2022-11-26 14:22:05 +01:00
typedef struct r_anal_esil_dfg_node_t {
2019-09-26 11:36:20 +02:00
// add more info here
ut32 idx ;
RStrBuf * content ;
2022-11-26 14:22:05 +01:00
ut32 /*RAnalEsilDFGTagType*/ type ;
} RAnalEsilDFGNode ;
2019-09-26 11:36:20 +02:00
2023-07-11 11:38:30 +02:00
typedef bool ( * RAnalCmdCallback ) ( /* Rcore */ RAnal * anal , const char * input ) ;
2014-01-01 23:09:46 -06:00
2019-03-15 19:39:24 +01:00
typedef int ( * RAnalOpCallback ) ( RAnal * a , RAnalOp * op , ut64 addr , const ut8 * data , int len , RAnalOpMask mask ) ;
2022-01-09 22:55:34 +01:00
typedef int ( * RAnalOpAsmCallback ) ( RAnal * a , ut64 addr , const char * str , ut8 * outbuf , int outlen ) ;
2014-01-01 23:09:46 -06:00
2020-04-13 21:09:39 +02:00
typedef bool ( * 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
2022-11-17 10:22:55 +01:00
typedef int ( * REsilCB ) ( REsil * esil ) ;
typedef int ( * REsilLoopCB ) ( REsil * esil , RAnalOp * op ) ;
typedef int ( * REsilTrapCB ) ( REsil * 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 {
2023-07-09 11:53:09 +02:00
RPluginMeta meta ;
2023-07-11 11:21:42 +02:00
2023-07-11 11:38:30 +02:00
const char * depends ; // comma separated list of dependencies
bool ( * init ) ( RAnal * a ) ;
bool ( * fini ) ( RAnal * a ) ;
2014-01-01 23:09:46 -06:00
// legacy r_anal_functions
2011-02-24 14:06:49 +01:00
RAnalOpCallback op ;
2023-07-11 11:21:42 +02:00
RAnalCmdCallback cmd ;
2023-07-09 11:53:09 +02:00
# if 1
/// XXX unused but referenced, maybe worth checking in case we want them for anal
2011-03-06 15:21:13 +01:00
RAnalFPBBCallback fingerprint_bb ;
RAnalFPFcnCallback fingerprint_fcn ;
RAnalDiffBBCallback diff_bb ;
RAnalDiffFcnCallback diff_fcn ;
RAnalDiffEvalCallback diff_eval ;
2023-07-09 11:53:09 +02:00
# endif
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
2022-12-09 18:42:56 +01:00
R_API ut64 r_anal_value_to_ut64 ( RAnal * anal , RArchValue * val ) ;
2023-06-13 13:38:23 +02:00
R_API bool r_anal_value_set_ut64 ( RAnal * anal , RArchValue * val , ut64 num ) ;
2023-07-07 16:01:48 +02:00
/* --------- */ /* R2_590 REFACTOR */ /* ---------- */
2021-12-21 12:52:17 -06: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 ) ;
2022-10-24 20:59:18 +02:00
R_API const char * r_anal_datatype_tostring ( RAnalDataType t ) ;
2012-08-28 11:02:25 +02:00
R_API RAnalType * r_anal_str_to_type ( RAnal * a , const char * s ) ;
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
2023-07-11 11:21:42 +02:00
R_API bool r_anal_cmd ( RAnal * a , const char * cmd ) ;
2020-01-15 10:58:30 +01:00
/* block.c */
typedef bool ( * RAnalBlockCb ) ( RAnalBlock * block , void * user ) ;
typedef bool ( * RAnalAddrCb ) ( ut64 addr , void * user ) ;
// lifetime
R_API void r_anal_block_ref ( RAnalBlock * bb ) ;
R_API void r_anal_block_unref ( RAnalBlock * bb ) ;
2022-01-12 12:07:26 +01:00
R_API void r_anal_block_reset ( RAnal * a ) ;
2020-01-15 10:58:30 +01:00
// Create one block covering the given range.
// This will fail if the range overlaps any existing blocks.
R_API RAnalBlock * r_anal_create_block ( RAnal * anal , ut64 addr , ut64 size ) ;
static inline bool r_anal_block_contains ( RAnalBlock * bb , ut64 addr ) {
2023-06-20 19:31:47 +02:00
return ( addr > = bb - > addr ) & & ( addr < bb - > addr + bb - > size ) ;
2020-01-15 10:58:30 +01:00
}
// Split the block at the given address into two blocks.
// bb will stay the first block, the second block will be returned (or NULL on failure)
// The returned block will always be refd, i.e. it is necessary to always call r_anal_block_unref() on the return value!
R_API RAnalBlock * r_anal_block_split ( RAnalBlock * bb , ut64 addr ) ;
2020-04-17 19:51:47 +02:00
static inline bool r_anal_block_is_contiguous ( RAnalBlock * a , RAnalBlock * b ) {
return ( a - > addr + a - > size ) = = b - > addr ;
}
2020-01-15 10:58:30 +01:00
// Merge block b into a.
// b will be FREED (not just unrefd) and is NOT VALID anymore if this function is successful!
// This only works if b follows directly after a and their function lists are identical.
// returns true iff the blocks could be merged
R_API bool r_anal_block_merge ( RAnalBlock * a , RAnalBlock * b ) ;
// Manually delete a block and remove it from all its functions
// If there are more references to it than from its functions only, it will not be removed immediately!
R_API void r_anal_delete_block ( RAnalBlock * bb ) ;
2022-01-12 12:07:26 +01:00
R_API void r_anal_delete_block_at ( RAnal * anal , ut64 addr ) ;
2020-01-15 10:58:30 +01:00
R_API void r_anal_block_set_size ( RAnalBlock * block , ut64 size ) ;
// Set the address and size of the block.
// This can fail (and return false) if there is already another block at the new address
R_API bool r_anal_block_relocate ( RAnalBlock * block , ut64 addr , ut64 size ) ;
2022-12-07 23:32:20 +01:00
R_API ut64 r_anal_block_ninstr ( RAnalBlock * block , int pos ) ;
2020-01-15 10:58:30 +01:00
R_API RAnalBlock * r_anal_get_block_at ( RAnal * anal , ut64 addr ) ;
R_API bool r_anal_blocks_foreach_in ( RAnal * anal , ut64 addr , RAnalBlockCb cb , void * user ) ;
R_API RList * r_anal_get_blocks_in ( RAnal * anal , ut64 addr ) ; // values from r_anal_blocks_foreach_in as a list
R_API void r_anal_blocks_foreach_intersect ( RAnal * anal , ut64 addr , ut64 size , RAnalBlockCb cb , void * user ) ;
R_API RList * r_anal_get_blocks_intersect ( RAnal * anal , ut64 addr , ut64 size ) ; // values from r_anal_blocks_foreach_intersect as a list
// Call cb on every direct successor address of block
2020-06-12 05:25:42 -03:00
// returns false if the loop was breaked by cb
2020-01-15 10:58:30 +01:00
R_API bool r_anal_block_successor_addrs_foreach ( RAnalBlock * block , RAnalAddrCb cb , void * user ) ;
// Call cb on block and every (recursive) successor of it
2020-06-12 05:25:42 -03:00
// returns false if the loop was breaked by cb
2020-01-15 10:58:30 +01:00
R_API bool r_anal_block_recurse ( RAnalBlock * block , RAnalBlockCb cb , void * user ) ;
2020-06-12 05:25:42 -03:00
// Call cb on block and every (recursive) successor of it
// If cb returns false, recursion stops only for that block
// returns false if the loop was breaked by cb
R_API bool r_anal_block_recurse_followthrough ( RAnalBlock * block , RAnalBlockCb cb , void * user ) ;
2020-07-28 23:41:26 -03:00
// Call cb on block and every (recursive) successor of it
// Call on_exit on block that doesn't have non-visited successors
// returns false if the loop was breaked by cb
R_API bool r_anal_block_recurse_depth_first ( RAnalBlock * block , RAnalBlockCb cb , R_NULLABLE RAnalBlockCb on_exit , void * user ) ;
2020-01-15 10:58:30 +01:00
// same as r_anal_block_recurse, but returns the blocks as a list
R_API RList * r_anal_block_recurse_list ( RAnalBlock * block ) ;
2020-03-13 20:59:17 +01:00
// return one shortest path from block to dst or NULL if none exists.
R_API R_NULLABLE RList /*<RAnalBlock *>*/ * r_anal_block_shortest_path ( RAnalBlock * block , ut64 dst ) ;
2020-03-07 20:07:12 +01:00
// Add a case to the block's switch_op.
// If block->switch_op is NULL, it will be created with the given switch_addr.
2020-07-20 03:29:48 -03:00
R_API void r_anal_block_add_switch_case ( RAnalBlock * block , ut64 switch_addr , ut64 case_value , ut64 case_addr ) ;
2020-03-07 20:07:12 +01:00
2020-04-17 19:51:47 +02:00
// Chop off the block at the specified address and remove all destinations.
// Blocks that have become unreachable after this operation will be automatically removed from all functions of block.
// addr must be the address directly AFTER the noreturn call!
// After the chopping, an r_anal_block_automerge() is performed on the touched blocks.
// IMPORTANT: The automerge might also FREE block! This function returns block iff it is still valid afterwards.
// If this function returns NULL, the pointer to block MUST not be touched anymore!
R_API RAnalBlock * r_anal_block_chop_noreturn ( RAnalBlock * block , ut64 addr ) ;
// Merge every block in blocks with their contiguous predecessor, if possible.
// IMPORTANT: Merged blocks will be FREED! The blocks list will be updated to contain only the survived blocks.
R_API void r_anal_block_automerge ( RList * blocks ) ;
// return true iff an instruction in the given basic block starts at the given address
R_API bool r_anal_block_op_starts_at ( RAnalBlock * block , ut64 addr ) ;
2020-10-29 19:55:49 -03:00
// Updates bbhash based on current bytes inside the block
R_API void r_anal_block_update_hash ( RAnalBlock * block ) ;
// returns true if a byte in the given basic block was modified
R_API bool r_anal_block_was_modified ( RAnalBlock * block ) ;
2020-01-15 10:58:30 +01:00
// ---------------------------------------
/* function.c */
R_API RAnalFunction * r_anal_function_new ( RAnal * anal ) ;
2021-03-08 15:45:30 +01:00
R_API void r_anal_function_free ( RAnalFunction * fcn ) ;
2020-01-15 10:58:30 +01:00
// Add a function created with r_anal_function_new() to anal
R_API bool r_anal_add_function ( RAnal * anal , RAnalFunction * fcn ) ;
// Create a new function and add it to anal (r_anal_function_new() + set members + r_anal_add_function())
R_API RAnalFunction * r_anal_create_function ( RAnal * anal , const char * name , ut64 addr , int type , RAnalDiff * diff ) ;
// returns all functions that have a basic block containing the given address
R_API RList * r_anal_get_functions_in ( RAnal * anal , ut64 addr ) ;
// returns the function that has its entrypoint at addr or NULL
R_API RAnalFunction * r_anal_get_function_at ( RAnal * anal , ut64 addr ) ;
R_API bool r_anal_function_delete ( RAnalFunction * fcn ) ;
// rhange the entrypoint of fcn
// This can fail (and return false) if there is already another function at the new address
R_API bool r_anal_function_relocate ( RAnalFunction * fcn , ut64 addr ) ;
// rename the given function
// This can fail (and return false) if there is another function with the name given
R_API bool r_anal_function_rename ( RAnalFunction * fcn , const char * name ) ;
R_API void r_anal_function_add_block ( RAnalFunction * fcn , RAnalBlock * bb ) ;
R_API void r_anal_function_remove_block ( RAnalFunction * fcn , RAnalBlock * bb ) ;
// size of the entire range that the function spans, including holes.
// this is exactly r_anal_function_max_addr() - r_anal_function_min_addr()
R_API ut64 r_anal_function_linear_size ( RAnalFunction * fcn ) ;
// lowest address covered by the function
R_API ut64 r_anal_function_min_addr ( RAnalFunction * fcn ) ;
// first address directly after the function
R_API ut64 r_anal_function_max_addr ( RAnalFunction * fcn ) ;
// size from the function entrypoint (fcn->addr) to the end of the function (r_anal_function_max_addr)
R_API ut64 r_anal_function_size_from_entry ( RAnalFunction * fcn ) ;
// the "real" size of the function, that is the sum of the size of the
// basicblocks this function is composed of
R_API ut64 r_anal_function_realsize ( const RAnalFunction * fcn ) ;
// returns whether the function contains a basic block that contains addr
// This is completely independent of fcn->addr, which is only the entrypoint!
R_API bool r_anal_function_contains ( RAnalFunction * fcn , ut64 addr ) ;
2020-10-29 19:55:49 -03:00
// returns true if function bytes were modified
R_API bool r_anal_function_was_modified ( RAnalFunction * fcn ) ;
2023-08-21 23:42:27 +02:00
R_API RGraph * r_anal_function_get_graph ( RAnalFunction * fcn , RGraphNode * * node_ptr , ut64 addr ) ;
2020-10-29 19:55:49 -03:00
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 ) ;
2020-09-27 06:39:50 +02:00
R_API void r_anal_purge ( RAnal * anal ) ;
2022-04-24 20:33:03 +02: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 ) ;
2021-12-21 12:52:17 -06:00
R_API void r_anal_plugin_free ( RAnalPlugin * p ) ;
2023-06-23 14:50:26 +02:00
R_API int r_anal_plugin_add ( RAnal * anal , RAnalPlugin * plugin ) ;
R_API bool r_anal_plugin_remove ( RAnal * anal , RAnalPlugin * plugin ) ;
2015-10-14 02:11:53 +02:00
R_API int r_anal_archinfo ( RAnal * anal , int query ) ;
2022-05-17 19:49:03 +02:00
R_API bool r_anal_is_aligned ( RAnal * anal , const ut64 addr ) ;
2016-04-08 00:54:15 +02:00
R_API bool r_anal_use ( RAnal * anal , const char * name ) ;
2022-11-17 10:22:55 +01:00
R_API bool r_esil_use ( RAnal * anal , const char * name ) ;
R_API const char * r_esil_trapstr ( int type ) ;
2021-07-28 12:09:23 +02:00
R_API bool r_anal_set_reg_profile ( RAnal * anal , const char * rp ) ;
2016-04-08 00:54:15 +02:00
R_API char * r_anal_get_reg_profile ( RAnal * anal ) ;
2019-09-26 22:01:52 +02:00
R_API ut64 r_anal_get_bbaddr ( RAnal * anal , ut64 addr ) ;
2016-04-08 00:54:15 +02:00
R_API bool r_anal_set_bits ( RAnal * anal , int bits ) ;
R_API bool r_anal_set_os ( RAnal * anal , const char * os ) ;
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 ) ;
2021-11-21 20:18:46 +01:00
R_API const char * r_anal_functiontype_tostring ( int type ) ;
2023-06-22 21:41:37 +02:00
R_API int r_anal_function_coverage ( RAnalFunction * fcn ) ;
2021-11-21 20:18:46 +01:00
R_API int r_anal_function_bb ( RAnal * anal , RAnalFunction * fcn , ut64 addr , int depth ) ;
2016-09-01 23:50:28 +03:00
R_API void r_anal_bind ( RAnal * b , RAnalBind * bnd ) ;
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 ) ;
2020-09-24 02:15:22 +02:00
R_API void r_anal_add_import ( RAnal * anal , const char * imp ) ;
R_API void r_anal_remove_import ( RAnal * anal , const char * imp ) ;
R_API void r_anal_purge_imports ( RAnal * anal ) ;
2015-10-30 03:07:22 +01:00
2010-03-12 03:05:20 +01:00
/* bb.c */
2011-02-28 13:07:41 +01:00
R_API RAnalBlock * r_anal_bb_from_offset ( RAnal * anal , ut64 off ) ;
2016-08-22 18:32:18 +02:00
R_API bool r_anal_bb_set_offset ( RAnalBlock * bb , int i , ut16 v ) ;
2020-09-16 14:21:32 +02:00
R_API ut16 r_anal_bb_offset_inst ( const 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 ) ;
2020-03-03 12:42:38 +01:00
R_API ut64 r_anal_bb_size_i ( RAnalBlock * bb , int i ) ;
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 ) ;
2021-07-25 22:44:47 +02:00
R_API void r_anal_op_fini ( RAnalOp * op ) ;
2022-05-07 21:19:04 +02:00
R_API char * r_anal_mnemonics ( RAnal * anal , int id , bool json ) ;
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 ) ;
2020-03-27 06:15:47 +01:00
R_API int r_anal_op ( RAnal * anal , RAnalOp * op , ut64 addr , const ut8 * data , int len , RAnalOpMask mask ) ;
2022-01-09 22:55:34 +01:00
R_API int r_anal_opasm ( RAnal * anal , ut64 pc , const char * s , ut8 * outbuf , int outlen ) ;
2022-10-24 20:59:18 +02:00
R_API char * r_anal_op_tostring ( RAnal * anal , RAnalOp * op ) ;
2014-06-16 05:58:00 +02:00
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 ) ;
2020-09-27 06:39:50 +02:00
R_API void r_anal_pin ( RAnal * a , ut64 addr , const char * name ) ;
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 ) ;
2022-03-16 11:58:48 +01:00
R_API void r_anal_pin_unset ( RAnal * a , ut64 addr ) ;
2015-06-30 10:50:46 +02:00
2010-03-12 03:05:20 +01:00
/* fcn.c */
2020-03-17 12:58:39 +01:00
R_API ut32 r_anal_function_cost ( RAnalFunction * fcn ) ;
R_API int r_anal_function_count_edges ( const RAnalFunction * fcn , R_NULLABLE int * ebbs ) ;
R_API RAnalFunction * r_anal_get_function_byname ( RAnal * anal , const char * name ) ;
2021-07-18 15:45:59 -07:00
R_API int r_anal_function ( RAnal * anal , RAnalFunction * fcn , ut64 addr , ut64 len , int reftype ) ;
2021-11-21 20:18:46 +01:00
R_API int r_anal_function_del ( RAnal * anal , ut64 addr ) ;
R_API int r_anal_function_del_locs ( RAnal * anal , ut64 addr ) ;
R_API bool r_anal_function_add_bb ( RAnal * anal , RAnalFunction * fcn ,
2015-03-16 02:52:26 +01:00
ut64 addr , ut64 size ,
2020-02-14 17:50:10 +01:00
ut64 jump , ut64 fail , R_BORROW 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 ) ;
2014-03-31 03:05:48 +02:00
2020-03-17 12:58:39 +01:00
R_API void r_anal_function_check_bp_use ( RAnalFunction * fcn ) ;
2020-10-29 20:07:53 -03:00
R_API void r_anal_update_analysis_range ( RAnal * anal , ut64 addr , int size ) ;
R_API void r_anal_function_update_analysis ( RAnalFunction * fcn ) ;
2014-03-31 03:05:48 +02:00
2014-03-31 04:42:55 +02:00
# define R_ANAL_FCN_VARKIND_LOCAL 'v'
2014-04-28 11:37:48 +02:00
2014-09-22 04:22:47 +02:00
2021-12-21 12:52:17 -06:00
R_API int r_anal_function_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 ) ;
2022-01-30 18:04:24 -05:00
R_API int r_anal_var_count_all ( RAnalFunction * fcn ) ;
R_API int r_anal_var_count_args ( RAnalFunction * fcn ) ;
R_API int r_anal_var_count_locals ( RAnalFunction * fcn ) ;
2014-03-31 03:05:48 +02:00
/* vars // globals. not here */
2020-05-25 01:55:31 -03:00
R_API bool r_anal_var_display ( RAnal * anal , RAnalVar * var ) ;
2020-01-15 10:58:30 +01:00
2020-03-17 12:58:39 +01:00
R_API int r_anal_function_complexity ( RAnalFunction * fcn ) ;
R_API int r_anal_function_loops ( 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 ) ;
2020-03-10 14:28:31 +01:00
R_API char * r_anal_function_get_json ( RAnalFunction * function ) ;
2021-11-21 20:18:46 +01:00
R_API RAnalFunction * r_anal_function_next ( RAnal * anal , ut64 addr ) ;
2020-03-13 21:28:25 +00:00
R_API char * r_anal_function_get_signature ( RAnalFunction * function ) ;
2012-07-22 12:00:35 +04:00
R_API int r_anal_str_to_fcn ( RAnal * a , RAnalFunction * f , const char * _str ) ;
2021-12-21 12:52:17 -06:00
R_API int r_anal_function_count ( RAnal * a , ut64 from , ut64 to ) ;
2022-05-16 22:33:02 +02:00
R_API RAnalBlock * r_anal_function_bbget_in ( RAnal * anal , RAnalFunction * fcn , ut64 addr ) ;
2021-11-21 20:18:46 +01:00
R_API RAnalBlock * r_anal_function_bbget_at ( RAnal * anal , RAnalFunction * fcn , ut64 addr ) ;
R_API bool r_anal_function_bbadd ( RAnalFunction * fcn , RAnalBlock * bb ) ;
2020-03-17 12:58:39 +01:00
R_API int r_anal_function_resize ( RAnalFunction * fcn , int newsize ) ;
R_API bool r_anal_function_purity ( RAnalFunction * fcn ) ;
2022-03-14 22:36:56 +01:00
R_API int r_anal_function_instrcount ( RAnalFunction * fcn ) ;
2022-03-11 13:12:43 +01:00
R_API bool r_anal_function_islineal ( RAnalFunction * fcn ) ;
2022-04-19 15:12:36 +02:00
R_API const char * r_anal_pin_get ( RAnal * a , const char * name ) ;
R_API const char * r_anal_pin_at ( RAnal * a , ut64 addr ) ;
2022-03-16 11:58:48 +01:00
R_API bool r_anal_pin_set ( RAnal * a , const char * name , const char * cmd ) ;
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 ) ;
2022-04-25 22:19:23 +02:00
R_API const char * r_anal_ref_type_tostring ( RAnalRefType t ) ;
2023-06-27 19:47:14 +02:00
R_API int r_anal_ref_typemask ( int x ) ;
2022-04-25 22:19:23 +02:00
R_DEPRECATE R_API RAnalRefType r_anal_xrefs_type ( char ch ) ;
R_API const char * r_anal_ref_perm_tostring ( RAnalRef * ref ) ;
R_API char r_anal_ref_perm_tochar ( RAnalRef * ref ) ;
R_API char r_anal_ref_permchar_tostring ( RAnalRef * ref ) ;
2023-07-07 16:01:48 +02:00
R_API bool r_anal_xrefs_init ( RAnal * anal ) ;
R_API void r_anal_xrefs_free ( RAnal * anal ) ;
2022-04-25 22:19:23 +02:00
R_API RAnalRefType r_anal_xrefs_type_from_string ( const char * s ) ;
2023-07-07 16:01:48 +02:00
R_API RVecAnalRef * r_anal_xrefs_get ( RAnal * anal , ut64 to ) ;
R_API RVecAnalRef * r_anal_refs_get ( RAnal * anal , ut64 from ) ;
2023-08-08 14:44:24 +02:00
R_API bool r_anal_xrefs_has_xrefs_at ( RAnal * anal , ut64 at ) ;
2023-07-07 16:01:48 +02:00
R_API RVecAnalRef * r_anal_xrefs_get_from ( RAnal * anal , ut64 to ) ;
2022-05-30 21:13:29 +02:00
R_API void r_anal_xrefs_list ( RAnal * anal , int rad , const char * arg ) ;
2023-07-07 16:01:48 +02:00
R_API ut64 r_anal_xrefs_count ( RAnal * anal ) ;
2023-08-05 20:48:38 -04:00
R_API ut64 r_anal_xrefs_count_at ( RAnal * anal , ut64 to ) ;
2023-07-07 16:01:48 +02:00
R_API RVecAnalRef * r_anal_function_get_refs ( RAnalFunction * fcn ) ;
R_API RVecAnalRef * r_anal_function_get_all_xrefs ( RAnalFunction * fcn ) ;
R_API RVecAnalRef * r_anal_function_get_xrefs ( RAnalFunction * fcn ) ;
2021-07-30 12:34:13 +02:00
R_API bool r_anal_xrefs_set ( RAnal * anal , ut64 from , ut64 to , const RAnalRefType type ) ;
2023-07-07 16:01:48 +02:00
R_API bool r_anal_xref_del ( RAnal * anal , ut64 from , ut64 to ) ;
2018-02-09 22:25:30 +01:00
2020-04-13 11:13:14 +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 */
2020-07-16 21:01:03 -03:00
R_API R_OWN char * r_anal_function_autoname_var ( RAnalFunction * fcn , char kind , const char * pfx , int ptr ) ;
2020-04-17 22:10:49 +02:00
R_API R_BORROW RAnalVar * r_anal_function_set_var ( RAnalFunction * fcn , int delta , char kind , R_NULLABLE const char * type , int size , bool isarg , R_NONNULL const char * name ) ;
2021-11-02 06:04:35 -04:00
R_API bool r_anal_function_set_var_prot ( RAnalFunction * fcn , RList /*<RAnalVarProt>*/ * l ) ;
2020-04-17 22:10:49 +02:00
R_API R_BORROW RAnalVar * r_anal_function_get_var ( RAnalFunction * fcn , char kind , int delta ) ;
2021-11-02 06:04:35 -04:00
R_API RList * r_anal_var_deserialize ( const char * ser ) ;
R_API char * r_anal_var_prot_serialize ( RList /*<RAnalVarProt>*/ * l , bool spaces ) ;
R_API RList /*<RAnalVarProt>*/ * r_anal_var_get_prots ( RAnalFunction * fcn ) ;
2020-04-19 17:56:27 +02:00
R_API R_BORROW RAnalVar * r_anal_function_get_var_byname ( RAnalFunction * fcn , const char * name ) ;
R_API void r_anal_function_delete_vars_by_kind ( RAnalFunction * fcn , RAnalVarKind kind ) ;
R_API void r_anal_function_delete_all_vars ( RAnalFunction * fcn ) ;
2020-10-29 19:57:12 -03:00
R_API void r_anal_function_delete_unused_vars ( RAnalFunction * fcn ) ;
2020-09-02 20:44:36 -03:00
R_API void r_anal_function_delete_var ( RAnalFunction * fcn , RAnalVar * var ) ;
2020-04-19 17:56:27 +02:00
R_API bool r_anal_function_rebase_vars ( RAnal * a , RAnalFunction * fcn ) ;
R_API st64 r_anal_function_get_var_stackptr_at ( RAnalFunction * fcn , st64 delta , ut64 addr ) ;
2020-05-25 01:55:31 -03:00
R_API const char * r_anal_function_get_var_reg_at ( RAnalFunction * fcn , st64 delta , ut64 addr ) ;
2020-04-19 17:56:27 +02:00
R_API R_BORROW RPVector * r_anal_function_get_vars_used_at ( RAnalFunction * fcn , ut64 op_addr ) ;
R_API bool r_anal_var_rename ( RAnalVar * var , const char * new_name , bool verbose ) ;
R_API void r_anal_var_set_type ( RAnalVar * var , const char * type ) ;
R_API void r_anal_var_delete ( RAnalVar * var ) ;
R_API ut64 r_anal_var_addr ( RAnalVar * var ) ;
2020-05-25 01:55:31 -03:00
R_API void r_anal_var_set_access ( RAnalVar * var , const char * reg , ut64 access_addr , int access_type , st64 stackptr ) ;
2020-09-02 20:44:36 -03:00
R_API void r_anal_var_remove_access_at ( RAnalVar * var , ut64 address ) ;
2020-04-19 17:56:27 +02:00
R_API void r_anal_var_clear_accesses ( RAnalVar * var ) ;
2020-09-23 09:40:39 +02:00
R_API void r_anal_var_add_constraint ( RAnalVar * var , R_BORROW RAnalVarConstraint * constraint ) ;
R_API char * r_anal_var_get_constraints_readable ( RAnalVar * var ) ;
2020-04-21 05:50:48 +02:00
// Get the access to var at exactly addr if there is one
R_API RAnalVarAccess * r_anal_var_get_access_at ( RAnalVar * var , ut64 addr ) ;
2020-04-19 17:56:27 +02:00
R_API int r_anal_var_get_argnum ( RAnalVar * var ) ;
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 ) ;
2020-04-21 05:50:48 +02:00
// Get the variable that var is written to at one of its accesses
// Useful for cases where a register-based argument is written away into a stack variable,
// so if var is the reg arg then this will return the stack var.
R_API RAnalVar * r_anal_var_get_dst_var ( RAnalVar * var ) ;
2010-03-11 17:19:33 +01:00
2021-11-21 20:18:46 +01:00
typedef struct r_anal_function_vars_cache {
2019-01-08 10:44:51 +01:00
RList * bvars ;
RList * rvars ;
RList * svars ;
} RAnalFcnVarsCache ;
2021-11-21 20:18:46 +01:00
R_API void r_anal_function_vars_cache_init ( RAnal * anal , RAnalFcnVarsCache * cache , RAnalFunction * fcn ) ;
R_API void r_anal_function_vars_cache_fini ( RAnalFcnVarsCache * cache ) ;
2019-01-08 10:44:51 +01:00
2021-11-21 20:18:46 +01:00
R_API char * r_anal_function_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 */
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 ) ;
2021-12-05 04:43:31 +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 ) ;
2020-01-15 10:18:55 +01:00
R_API size_t 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
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 ) ;
2020-03-17 12:58:39 +01:00
R_API void r_anal_cond_fini ( RAnalCond * c ) ;
R_API void r_anal_cond_free ( RAnalCond * c ) ;
2022-10-24 20:59:18 +02:00
R_API char * r_anal_cond_tostring ( RAnalCond * cond ) ;
2020-03-17 12:58:39 +01: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 ) ;
2022-10-24 20:59:18 +02:00
R_API const char * r_anal_cond_type_tostring ( int cc ) ;
2010-06-15 00:46:18 +02:00
2019-07-22 04:38:26 +02:00
/* jmptbl */
2020-03-07 20:07:12 +01:00
R_API bool r_anal_jmptbl ( RAnal * anal , RAnalFunction * fcn , RAnalBlock * block , ut64 jmpaddr , ut64 table , ut64 tablesize , ut64 default_addr ) ;
2019-07-22 04:38:26 +02:00
// TODO: should be renamed
2021-03-01 22:39:37 +01:00
R_API bool try_get_delta_jmptbl_info ( RAnal * a , RAnalFunction * fcn , ut64 jmp_addr , ut64 lea_addr , ut64 * table_size , ut64 * default_case , st64 * start_casenum_shift ) ;
R_API bool try_walkthrough_jmptbl ( RAnal * analysis , RAnalFunction * fcn , RAnalBlock * block , int depth , ut64 ip , st64 start_casenum_shift , ut64 jmptbl_loc , ut64 jmptbl_off , ut64 sz , ut64 jmptbl_size , ut64 default_case , bool ret0 ) ;
R_API bool try_walkthrough_casetbl ( RAnal * analysis , RAnalFunction * fcn , RAnalBlock * block , int depth , ut64 ip , st64 start_casenum_shift , ut64 jmptbl_loc , ut64 casetbl_loc , ut64 jmptbl_off , ut64 sz , ut64 jmptbl_size , ut64 default_case , bool ret0 ) ;
R_API bool try_get_jmptbl_info ( RAnal * analysis , RAnalFunction * fcn , ut64 addr , RAnalBlock * my_bb , ut64 * table_size , ut64 * default_case , st64 * start_casenum_shift ) ;
2020-03-07 20:07:12 +01:00
R_API int walkthrough_arm_jmptbl_style ( RAnal * anal , RAnalFunction * fcn , RAnalBlock * block , int depth , ut64 ip , ut64 jmptbl_loc , ut64 sz , ut64 jmptbl_size , ut64 default_case , int ret0 ) ;
2019-07-22 04:38:26 +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 ) ;
2019-10-25 23:13:16 +08:00
R_API void r_anal_reflines_str_free ( RAnalRefStr * refstr ) ;
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 ) ;
2010-08-22 18:41:57 +02:00
2011-02-02 13:05:48 +01:00
// calling conventions API
2020-02-11 21:58:14 -08:00
R_API bool r_anal_cc_exist ( RAnal * anal , const char * convention ) ;
2022-10-18 23:17:17 +02:00
R_API void r_anal_cc_reset ( RAnal * anal ) ;
2019-02-13 14:05:36 +01:00
R_API void r_anal_cc_del ( RAnal * anal , const char * name ) ;
2020-09-16 19:17:54 +02:00
R_API bool r_anal_cc_set ( RAnal * anal , const char * expr ) ;
2019-02-13 14:05:36 +01:00
R_API char * r_anal_cc_get ( RAnal * anal , const char * name ) ;
2021-01-25 00:24:19 +01:00
R_API bool r_anal_cc_once ( RAnal * anal ) ;
2021-01-05 01:11:09 +01:00
R_API void r_anal_cc_get_json ( RAnal * anal , PJ * pj , const char * name ) ;
2023-08-25 18:45:02 +02:00
R_API const char * r_anal_cc_arg ( RAnal * anal , const char * convention , int n , int lastn ) ;
2020-02-11 21:58:14 -08:00
R_API const char * r_anal_cc_self ( RAnal * anal , const char * convention ) ;
2020-09-30 07:39:20 +02:00
R_API void r_anal_cc_set_self ( RAnal * anal , const char * convention , const char * self ) ;
2020-02-11 21:58:14 -08:00
R_API const char * r_anal_cc_error ( RAnal * anal , const char * convention ) ;
2020-09-30 07:39:20 +02:00
R_API void r_anal_cc_set_error ( RAnal * anal , const char * convention , const char * error ) ;
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 ) ;
2020-11-22 23:28:52 +01:00
R_API void r_anal_set_cc_default ( RAnal * anal , const char * convention ) ;
R_API const char * r_anal_syscc_default ( RAnal * anal ) ;
R_API void r_anal_set_syscc_default ( RAnal * anal , const char * convention ) ;
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 ;
2021-12-21 12:52:17 -06:00
R_API RAnalData * r_anal_data ( RAnal * anal , ut64 addr , const ut8 * buf , int size , int wordsize ) ;
R_API const char * r_anal_data_kind ( RAnal * anal , ut64 addr , const ut8 * buf , int len ) ;
2023-06-28 20:44:39 +02:00
R_API int r_anal_data_type ( RAnal * a , ut64 da ) ;
2021-12-21 12:52:17 -06:00
R_API RAnalData * r_anal_data_new_string ( ut64 addr , const char * p , int size , int wide ) ;
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>
2022-10-24 20:59:18 +02:00
R_API char * r_anal_data_tostring ( RAnalData * d , RConsPrintablePalette * pal ) ;
2012-11-20 03:59:00 +01:00
2020-05-09 20:49:28 +02:00
/* meta
*
* Meta uses Condret ' s Klemmbaustein Priciple , i . e . intervals are defined inclusive / inclusive .
* A meta item from 0x42 to 0x42 has a size of 1. Items with size 0 do not exist .
* Meta items are allowed to overlap and the internal data structure allows for multiple meta items
* starting at the same address .
* Meta items are saved in an RIntervalTree . To access the interval of an item , use the members of RIntervalNode .
*/
static inline ut64 r_meta_item_size ( ut64 start , ut64 end ) {
// meta items use inclusive/inclusive intervals
return end - start + 1 ;
}
static inline ut64 r_meta_node_size ( RIntervalNode * node ) {
return r_meta_item_size ( node - > start , node - > end ) ;
}
// Set a meta item at addr with the given contents in the current space.
// If there already exists an item with this type and space at addr (regardless of its size) it will be overwritten.
R_API bool r_meta_set ( RAnal * a , RAnalMetaType type , ut64 addr , ut64 size , const char * str ) ;
// Same as r_meta_set() but also sets the subtype.
R_API bool r_meta_set_with_subtype ( RAnal * m , RAnalMetaType type , int subtype , ut64 addr , ut64 size , const char * str ) ;
// Delete all meta items in the current space that intersect with the given interval.
// If size == UT64_MAX, everything in the current space will be deleted.
R_API void r_meta_del ( RAnal * a , RAnalMetaType type , ut64 addr , ut64 size ) ;
// Same as r_meta_set() with a size of 1.
R_API bool r_meta_set_string ( RAnal * a , RAnalMetaType type , ut64 addr , const char * s ) ;
// Convenience function to get the str content of the item at addr with given type in the current space.
R_API const char * r_meta_get_string ( RAnal * a , RAnalMetaType type , ut64 addr ) ;
// Convenience function to add an R_META_TYPE_DATA item at the given addr in the current space.
R_API void r_meta_set_data_at ( RAnal * a , ut64 addr , ut64 wordsz ) ;
// Returns the item with given type that starts at addr in the current space or NULL. The size of this item optionally returned through size.
R_API RAnalMetaItem * r_meta_get_at ( RAnal * a , ut64 addr , RAnalMetaType type , R_OUT R_NULLABLE ut64 * size ) ;
// Returns the node for one meta item with the given type that contains addr in the current space or NULL.
// To get all the nodes, use r_meta_get_all_in().
R_API RIntervalNode * r_meta_get_in ( RAnal * a , ut64 addr , RAnalMetaType type ) ;
// Returns all nodes for items starting at the given address in the current space.
R_API RPVector /*<RIntervalNode<RMetaItem> *>*/ * r_meta_get_all_at ( RAnal * a , ut64 at ) ;
// Returns all nodes for items with the given type containing the given address in the current space.
R_API RPVector /*<RIntervalNode<RMetaItem> *>*/ * r_meta_get_all_in ( RAnal * a , ut64 at , RAnalMetaType type ) ;
// Returns all nodes for items with the given type intersecting the given interval in the current space.
R_API RPVector /*<RIntervalNode<RMetaItem> *>*/ * r_meta_get_all_intersect ( RAnal * a , ut64 start , ut64 size , RAnalMetaType type ) ;
// Delete all meta items in the given space
2019-01-28 16:41:42 +01:00
R_API void r_meta_space_unset_for ( RAnal * a , const RSpace * space ) ;
2020-05-09 20:49:28 +02:00
// Returns the number of meta items in the given space
R_API int r_meta_space_count_for ( RAnal * a , const RSpace * space ) ;
// Shift all meta items by the given delta, for rebasing between different memory layouts.
R_API void r_meta_rebase ( RAnal * anal , ut64 diff ) ;
// Calculate the total size covered by meta items of the given type.
R_API ut64 r_meta_get_size ( RAnal * a , RAnalMetaType type ) ;
2022-10-24 20:59:18 +02:00
R_API const char * r_meta_type_tostring ( int type ) ;
2020-05-09 20:49:28 +02:00
R_API void r_meta_print ( RAnal * a , RAnalMetaItem * d , ut64 start , ut64 size , int rad , PJ * pj , bool show_full ) ;
2021-01-15 01:20:32 +01:00
R_API void r_meta_print_list_all ( RAnal * a , int type , int rad , const char * tq ) ;
R_API void r_meta_print_list_at ( RAnal * a , ut64 addr , int rad , const char * tq ) ;
R_API void r_meta_print_list_in_function ( RAnal * a , int type , int rad , ut64 addr , const char * tq ) ;
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
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_del ( RAnal * anal , ut64 addr , ut64 size ) ; // delete all hints that are contained within the given range, if size > 1, this operation is quite heavy!
2021-12-21 12:52:17 -06:00
R_API void r_anal_hint_clear ( RAnal * a ) ;
R_API void r_anal_hint_free ( RAnalHint * h ) ;
R_API void r_anal_hint_set_syntax ( RAnal * a , ut64 addr , const char * syn ) ;
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_set_type ( RAnal * a , ut64 addr , int type ) ;
R_API void r_anal_hint_set_jump ( RAnal * a , ut64 addr , ut64 jump ) ;
R_API void r_anal_hint_set_fail ( RAnal * a , ut64 addr , ut64 fail ) ;
R_API void r_anal_hint_set_newbits ( RAnal * a , ut64 addr , int bits ) ;
2018-12-17 12:56:07 +01:00
R_API void r_anal_hint_set_nword ( RAnal * a , ut64 addr , int nword ) ;
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_set_offset ( RAnal * a , ut64 addr , const char * typeoff ) ;
R_API void r_anal_hint_set_immbase ( RAnal * a , ut64 addr , int base ) ;
R_API void r_anal_hint_set_size ( RAnal * a , ut64 addr , ut64 size ) ;
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 ) ;
R_API void r_anal_hint_set_pointer ( RAnal * a , ut64 addr , ut64 ptr ) ;
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 ) ;
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_set_val ( RAnal * a , ut64 addr , ut64 v ) ;
R_API void r_anal_hint_set_arch ( RAnal * a , ut64 addr , R_NULLABLE const char * arch ) ; // arch == NULL => use global default
R_API void r_anal_hint_set_bits ( RAnal * a , ut64 addr , int bits ) ; // bits == NULL => use global default
2021-12-21 12:52:17 -06:00
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 ) ;
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_unset_immbase ( RAnal * a , ut64 addr ) ;
R_API void r_anal_hint_unset_nword ( RAnal * a , ut64 addr ) ;
2016-11-01 19:47:34 +01:00
R_API void r_anal_hint_unset_size ( 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_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 ) ;
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_unset_newbits ( RAnal * a , ut64 addr ) ;
2019-05-24 14:56:28 +02:00
R_API void r_anal_hint_unset_stackframe ( RAnal * a , ut64 addr ) ;
2020-02-13 11:48:24 +01:00
R_API void r_anal_hint_unset_arch ( RAnal * a , ut64 addr ) ;
R_API void r_anal_hint_unset_bits ( RAnal * a , ut64 addr ) ;
R_API R_NULLABLE const RVector /*<const RAnalAddrHintRecord>*/ * r_anal_addr_hints_at ( RAnal * anal , ut64 addr ) ;
typedef bool ( * RAnalAddrHintRecordsCb ) ( ut64 addr , const RVector /*<const RAnalAddrHintRecord>*/ * records , void * user ) ;
R_API void r_anal_addr_hints_foreach ( RAnal * anal , RAnalAddrHintRecordsCb cb , void * user ) ;
typedef bool ( * RAnalArchHintCb ) ( ut64 addr , R_NULLABLE const char * arch , void * user ) ;
R_API void r_anal_arch_hints_foreach ( RAnal * anal , RAnalArchHintCb cb , void * user ) ;
typedef bool ( * RAnalBitsHintCb ) ( ut64 addr , int bits , void * user ) ;
R_API void r_anal_bits_hints_foreach ( RAnal * anal , RAnalBitsHintCb cb , void * user ) ;
// get the hint-specified arch value to be considered at addr
// hint_addr will optionally be set to the address where the hint that specifies this arch is placed or UT64_MAX
// if there is no hint affecting addr.
R_API R_NULLABLE R_BORROW const char * r_anal_hint_arch_at ( RAnal * anal , ut64 addr , R_NULLABLE ut64 * hint_addr ) ;
// get the hint-specified bits value to be considered at addr
// hint_addr will optionally be set to the address where the hint that specifies this arch is placed or UT64_MAX
// if there is no hint affecting addr.
R_API int r_anal_hint_bits_at ( RAnal * anal , ut64 addr , R_NULLABLE ut64 * hint_addr ) ;
R_API RAnalHint * r_anal_hint_get ( RAnal * anal , ut64 addr ) ; // accumulate all available hints affecting the given address
2013-06-07 10:26:37 +02:00
2014-03-25 00:48:42 +01:00
/* cycles.c */
2021-12-21 12:52:17 -06:00
R_API RAnalCycleFrame * r_anal_cycle_frame_new ( void ) ;
R_API void r_anal_cycle_frame_free ( RAnalCycleFrame * cf ) ;
2014-03-25 00:48:42 +01:00
2014-09-23 09:35:37 +02:00
/* labels */
2020-09-16 09:54:33 +02:00
R_API ut64 r_anal_function_get_label ( RAnalFunction * fcn , const char * name ) ;
R_API const char * r_anal_function_get_label_at ( RAnalFunction * fcn , ut64 addr ) ;
R_API bool r_anal_function_set_label ( RAnalFunction * fcn , const char * name , ut64 addr ) ;
R_API bool r_anal_function_delete_label ( RAnalFunction * fcn , const char * name ) ;
R_API bool r_anal_function_delete_label_at ( RAnalFunction * fcn , ut64 addr ) ;
2014-09-23 09:35:37 +02:00
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 */
2022-11-17 10:22:55 +01:00
R_API int r_esil_to_reil_setup ( REsil * esil , RAnal * anal , int romem , int stats ) ;
2015-03-30 18:45:25 +05:30
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 */
2019-09-22 18:58:42 -03:00
R_API char * r_anal_rtti_msvc_demangle_class_name ( RVTableContext * context , 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
2020-04-30 22:20:12 +02:00
R_API char * r_anal_rtti_itanium_demangle_class_name ( RVTableContext * context , const char * name ) ;
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 ) ;
2020-04-30 22:20:12 +02:00
R_API bool r_anal_rtti_itanium_print_at_vtable ( RVTableContext * context , ut64 addr , int mode ) ;
R_API void r_anal_rtti_itanium_recover_all ( RVTableContext * vt_context , RList * vtables ) ;
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
2019-11-15 16:48:00 +01:00
R_API RList * r_anal_preludes ( RAnal * anal ) ;
2022-12-14 10:42:24 +01:00
R_API bool r_anal_is_prelude ( RAnal * anal , ut64 addr , const ut8 * data , int len ) ;
2019-11-15 16:48:00 +01:00
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
2020-03-05 18:06:27 +01:00
ut64 size ; // size (in bytes) of the vtable
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
} 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 ;
2022-11-28 10:28:07 +01:00
/* c */
R_API char * r_anal_cparse ( RAnal * anal , const char * code , char * * error_msg ) ;
R_API char * r_anal_cparse_file ( RAnal * anal , const char * path , const char * dir , char * * error_msg ) ;
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_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 ) ;
2020-07-24 07:20:31 +02:00
R_API void r_anal_class_print ( RAnal * anal , const char * class_name , bool detailed ) ;
R_API void r_anal_class_json ( RAnal * anal , PJ * j , const char * class_name ) ;
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_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 ) ;
2020-03-10 14:08:14 +01:00
R_API void r_anal_class_list_vtable_offset_functions ( RAnal * anal , const char * class_name , ut64 offset ) ;
2020-08-07 11:23:52 +02:00
R_API RGraph /*<RGraphNodeInfo>*/ * r_anal_class_get_inheritance_graph ( RAnal * anal ) ;
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
2022-11-26 14:22:05 +01:00
R_API RAnalEsilCFG * r_anal_esil_cfg_new ( void ) ;
R_API RAnalEsilCFG * r_anal_esil_cfg_expr ( RAnalEsilCFG * cfg , RAnal * anal , const ut64 off , char * expr ) ;
R_API RAnalEsilCFG * r_anal_esil_cfg_op ( RAnalEsilCFG * cfg , RAnal * anal , RAnalOp * op ) ;
R_API void r_anal_esil_cfg_merge_blocks ( RAnalEsilCFG * cfg ) ;
R_API void r_anal_esil_cfg_free ( RAnalEsilCFG * cfg ) ;
2021-05-20 00:22:20 +02:00
R_API SdbGperf * r_anal_get_gperf_cc ( const char * k ) ;
R_API SdbGperf * r_anal_get_gperf_types ( const char * k ) ;
2019-09-26 11:36:20 +02:00
2022-11-26 14:22:05 +01:00
R_API RAnalEsilDFGNode * r_anal_esil_dfg_node_new ( RAnalEsilDFG * edf , const char * c ) ;
2022-11-30 03:51:06 +01:00
R_API RAnalEsilDFG * r_anal_esil_dfg_new ( RAnal * anal , bool use_map_info , bool use_maps ) ;
2022-11-26 14:22:05 +01:00
R_API void r_anal_esil_dfg_free ( RAnalEsilDFG * dfg ) ;
2022-11-30 03:51:06 +01:00
R_API RAnalEsilDFG * r_anal_esil_dfg_expr ( RAnal * anal , RAnalEsilDFG * dfg , const char * expr , bool use_map_info , bool use_maps ) ;
2022-11-26 14:22:05 +01:00
R_API void r_anal_esil_dfg_fold_const ( RAnal * anal , RAnalEsilDFG * dfg ) ;
R_API RStrBuf * r_anal_esil_dfg_filter ( RAnalEsilDFG * dfg , const char * reg ) ;
2022-11-30 03:51:06 +01:00
R_API RStrBuf * r_anal_esil_dfg_filter_expr ( RAnal * anal , const char * expr , const char * reg , bool use_map_info , bool use_maps ) ;
2022-11-26 14:22:05 +01:00
R_API bool r_anal_esil_dfg_reg_is_const ( RAnalEsilDFG * dfg , const char * reg ) ;
2019-09-10 14:04:12 +01:00
R_API RList * r_anal_types_from_fcn ( RAnal * anal , RAnalFunction * fcn ) ;
2020-07-24 19:40:55 +02:00
2020-05-13 20:49:25 +02:00
R_API RAnalBaseType * r_anal_get_base_type ( RAnal * anal , const char * name ) ;
2020-07-24 19:40:55 +02:00
R_API void r_parse_pdb_types ( const RAnal * anal , const RPdb * pdb ) ;
2020-07-15 12:17:05 +02:00
R_API void r_anal_save_base_type ( const RAnal * anal , const RAnalBaseType * type ) ;
2020-09-05 21:24:50 +02:00
R_API void r_anal_base_type_free ( RAnalBaseType * type ) ;
R_API RAnalBaseType * r_anal_base_type_new ( RAnalBaseTypeKind kind ) ;
2020-08-19 12:21:20 +02:00
R_API void r_anal_dwarf_process_info ( const RAnal * anal , RAnalDwarfContext * ctx ) ;
R_API void r_anal_dwarf_integrate_functions ( RAnal * anal , RFlag * flags , Sdb * dwarf_sdb ) ;
2021-10-14 12:40:55 +02:00
/* global.c */
R_API RFlagItem * r_anal_global_get ( RAnal * anal , ut64 addr ) ;
R_API bool r_anal_global_add ( RAnal * anal , ut64 addr , const char * type_name , const char * name ) ;
R_API bool r_anal_global_del ( RAnal * anal , ut64 addr ) ;
R_API bool r_anal_global_retype ( RAnal * anal , ut64 addr , const char * new_type ) ;
R_API bool r_anal_global_rename ( RAnal * anal , ut64 addr , const char * new_name ) ;
R_API const char * r_anal_global_get_type ( RAnal * anal , ut64 addr ) ;
2022-01-25 09:39:15 +00:00
/*return anal->is_dirty and sets it to false*/
R_API bool r_anal_is_dirty ( RAnal * anal ) ;
2022-12-20 23:35:57 +01:00
// threads
R_API bool r_anal_tid_kill ( RAnal * anal , int tid ) ;
R_API RAnalThread * r_anal_tid_get ( RAnal * anal , int tid ) ;
R_API int r_anal_tid_add ( RAnal * anal , int map ) ;
R_API bool r_anal_tid_select ( RAnal * anal , int tid ) ;
2010-03-10 15:15:50 +01:00
/* plugin pointers */
2014-09-27 03:10:44 +02:00
extern RAnalPlugin r_anal_plugin_null ;
2023-07-31 01:41:03 +02:00
extern RAnalPlugin r_anal_plugin_a2f ;
2021-01-24 16:39:45 +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