2015-01-11 19:40:26 +01:00
|
|
|
/* radare - LGPL - Copyright 2008-2015 - nibble, pancake */
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2014-03-27 16:34:17 +01:00
|
|
|
#ifndef R2_BIN_H
|
|
|
|
#define R2_BIN_H
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2010-02-07 14:11:05 +01:00
|
|
|
#include <r_util.h>
|
2009-03-08 16:49:15 +01:00
|
|
|
#include <r_types.h>
|
2013-12-20 01:20:17 +01:00
|
|
|
#include <r_db.h>
|
2013-12-09 04:56:13 +01:00
|
|
|
#include <r_io.h>
|
2010-01-14 12:13:48 +01:00
|
|
|
#include <r_list.h>
|
2012-07-12 02:47:04 +02:00
|
|
|
#include <r_bin_dwarf.h>
|
2014-10-13 11:20:45 +03:00
|
|
|
#include <r_pdb.h>
|
2009-02-05 22:08:46 +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_bin);
|
|
|
|
|
2015-08-25 13:20:19 +02:00
|
|
|
#define R_BIN_SCN_EXECUTABLE (1 << 0)
|
|
|
|
#define R_BIN_SCN_WRITABLE (1 << 1)
|
|
|
|
#define R_BIN_SCN_READABLE (1 << 2)
|
|
|
|
#define R_BIN_SCN_SHAREABLE (1 << 3)
|
|
|
|
#define R_BIN_SCN_MAP (1 << 4)
|
2014-06-13 15:19:09 +02:00
|
|
|
|
|
|
|
#define R_BIN_DBG_STRIPPED 0x01
|
|
|
|
#define R_BIN_DBG_STATIC 0x02
|
|
|
|
#define R_BIN_DBG_LINENUMS 0x04
|
|
|
|
#define R_BIN_DBG_SYMS 0x08
|
|
|
|
#define R_BIN_DBG_RELOCS 0x10
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2013-04-25 03:42:17 +02:00
|
|
|
#define R_BIN_SIZEOF_STRINGS 512
|
2010-10-01 04:26:52 +02:00
|
|
|
#define R_BIN_MAX_ARCH 1024
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2010-11-17 21:15:34 +01:00
|
|
|
enum {
|
|
|
|
R_BIN_SYM_ENTRY,
|
|
|
|
R_BIN_SYM_INIT,
|
|
|
|
R_BIN_SYM_MAIN,
|
2010-11-18 11:41:17 +01:00
|
|
|
R_BIN_SYM_FINI,
|
|
|
|
R_BIN_SYM_LAST
|
2010-11-17 21:15:34 +01:00
|
|
|
};
|
|
|
|
|
2011-02-23 20:53:56 +01:00
|
|
|
// name mangling types
|
2015-06-15 05:04:29 +02:00
|
|
|
// TODO: Rename to R_BIN_LANG_
|
2011-02-23 20:53:56 +01:00
|
|
|
enum {
|
2012-08-04 23:48:06 +02:00
|
|
|
R_BIN_NM_NONE = 0,
|
|
|
|
R_BIN_NM_JAVA = 1,
|
2015-06-15 05:04:29 +02:00
|
|
|
R_BIN_NM_CXX = 1<<1,
|
|
|
|
R_BIN_NM_OBJC = 1<<2,
|
|
|
|
R_BIN_NM_SWIFT = 1<<3,
|
|
|
|
R_BIN_NM_DLANG = 1<<4,
|
|
|
|
R_BIN_NM_MSVC = 1<<5,
|
2015-06-29 11:22:05 +02:00
|
|
|
R_BIN_NM_RUST = 1<<6,
|
2012-08-04 23:48:06 +02:00
|
|
|
R_BIN_NM_ANY = -1,
|
2011-02-23 20:53:56 +01:00
|
|
|
};
|
|
|
|
|
2011-10-05 02:38:37 +02:00
|
|
|
enum {
|
|
|
|
R_BIN_CLASS_PRIVATE,
|
|
|
|
R_BIN_CLASS_PUBLIC,
|
|
|
|
R_BIN_CLASS_FRIENDLY,
|
|
|
|
R_BIN_CLASS_PROTECTED,
|
|
|
|
};
|
2011-06-26 20:29:24 +02:00
|
|
|
|
2013-07-17 22:18:21 +03:00
|
|
|
enum {
|
2014-04-05 12:09:41 +02:00
|
|
|
R_BIN_RELOC_8 = 8,
|
|
|
|
R_BIN_RELOC_16 = 16,
|
|
|
|
R_BIN_RELOC_32 = 32,
|
|
|
|
R_BIN_RELOC_64 = 64
|
2013-07-17 22:18:21 +03:00
|
|
|
};
|
|
|
|
|
2012-07-21 14:11:21 +04:00
|
|
|
typedef struct r_bin_addr_t {
|
2014-05-21 03:18:00 +02:00
|
|
|
ut64 vaddr;
|
|
|
|
ut64 paddr;
|
2012-07-21 14:11:21 +04:00
|
|
|
} RBinAddr;
|
|
|
|
|
2013-04-11 01:25:25 +02:00
|
|
|
typedef struct r_bin_hash_t {
|
|
|
|
const char *type;
|
|
|
|
ut64 addr;
|
|
|
|
int len;
|
|
|
|
ut64 from;
|
|
|
|
ut64 to;
|
|
|
|
ut8 buf[32];
|
|
|
|
const char *cmd;
|
|
|
|
} RBinHash;
|
|
|
|
|
2012-07-21 14:11:21 +04:00
|
|
|
typedef struct r_bin_info_t {
|
2015-03-25 14:49:33 +01:00
|
|
|
char *file;
|
|
|
|
char *type;
|
|
|
|
char *bclass;
|
|
|
|
char *rclass;
|
|
|
|
char *arch;
|
|
|
|
char *cpu;
|
|
|
|
char *machine;
|
|
|
|
char *os;
|
|
|
|
char *subsystem;
|
|
|
|
char *rpath;
|
|
|
|
char *guid;
|
|
|
|
char *debug_file_name;
|
2012-11-07 04:25:42 +01:00
|
|
|
const char *lang;
|
2012-07-21 14:11:21 +04:00
|
|
|
int bits;
|
|
|
|
int has_va;
|
2012-11-07 18:18:52 +01:00
|
|
|
int has_pi; // pic/pie
|
2014-04-28 14:45:02 +02:00
|
|
|
int has_canary;
|
2014-05-14 05:48:03 +02:00
|
|
|
int has_crypto;
|
2014-05-09 19:25:12 +02:00
|
|
|
int has_nx;
|
2012-07-21 14:11:21 +04:00
|
|
|
int big_endian;
|
|
|
|
ut64 dbg_info;
|
2013-10-14 23:28:17 +02:00
|
|
|
RBinHash sum[3];
|
2015-06-17 11:13:03 +02:00
|
|
|
ut64 baddr;
|
2015-10-22 02:13:26 +02:00
|
|
|
char *intrp;
|
2014-05-14 05:48:03 +02:00
|
|
|
#if 0
|
|
|
|
// stored in sdb
|
|
|
|
/* crypto (iOS bins) */
|
|
|
|
int crypt_offset;
|
|
|
|
int crypt_size;
|
|
|
|
int crypt_enabled;
|
|
|
|
#endif
|
2012-07-21 14:11:21 +04:00
|
|
|
} RBinInfo;
|
|
|
|
|
2013-06-27 19:15:59 +02:00
|
|
|
typedef struct r_bin_object_t {
|
2014-05-08 18:35:04 -05:00
|
|
|
ut32 id;
|
2013-06-27 19:15:59 +02:00
|
|
|
ut64 baddr;
|
2015-08-18 00:18:04 +02:00
|
|
|
ut64 baddr_shift;
|
2014-01-11 00:56:02 -06:00
|
|
|
ut64 loadaddr;
|
2013-12-19 19:43:44 +01:00
|
|
|
ut64 boffset;
|
2014-09-20 14:43:18 +02:00
|
|
|
int size;
|
2014-05-08 18:35:04 -05:00
|
|
|
ut64 obj_size;
|
2013-06-27 19:15:59 +02:00
|
|
|
RList/*<RBinSection>*/ *sections;
|
|
|
|
RList/*<RBinImport>*/ *imports;
|
|
|
|
RList/*<RBinSymbol>*/ *symbols;
|
|
|
|
RList/*<??>*/ *entries;
|
|
|
|
RList/*<??>*/ *fields;
|
|
|
|
RList/*<??>*/ *libs;
|
|
|
|
RList/*<??>*/ *relocs;
|
|
|
|
RList/*<??>*/ *strings;
|
|
|
|
RList/*<RBinClass>*/ *classes;
|
|
|
|
RList/*<RBinDwarfRow>*/ *lines;
|
2015-03-18 13:35:03 +01:00
|
|
|
RList/*<??>*/ *mem;
|
2013-06-27 19:15:59 +02:00
|
|
|
RBinInfo *info;
|
|
|
|
RBinAddr *binsym[R_BIN_SYM_LAST];
|
2014-05-08 14:08:21 -05:00
|
|
|
struct r_bin_plugin_t *plugin;
|
2013-06-27 19:15:59 +02:00
|
|
|
int referenced;
|
|
|
|
int lang;
|
2013-12-20 01:20:17 +01:00
|
|
|
Sdb *kv;
|
2014-01-17 12:40:04 -06:00
|
|
|
void *bin_obj; // internal pointer used by formats
|
2013-06-27 19:15:59 +02:00
|
|
|
} RBinObject;
|
|
|
|
|
2012-08-04 23:48:06 +02:00
|
|
|
// XXX: this is a copy of RBinObject
|
2014-01-20 03:29:50 +01:00
|
|
|
typedef struct r_bin_file_t {
|
2010-10-01 04:26:52 +02:00
|
|
|
char *file;
|
2014-04-23 03:54:06 +02:00
|
|
|
int fd;
|
2014-09-20 14:43:18 +02:00
|
|
|
int size;
|
2013-04-26 00:04:05 +02:00
|
|
|
int rawstr;
|
2014-04-27 02:06:50 -05:00
|
|
|
ut32 id;
|
2014-04-23 03:54:06 +02:00
|
|
|
RBuffer *buf;
|
2011-11-22 00:59:20 +01:00
|
|
|
ut64 offset;
|
2013-06-27 19:15:59 +02:00
|
|
|
RBinObject *o;
|
2014-01-22 16:58:23 -06:00
|
|
|
void *xtr_obj;
|
2014-01-11 00:56:02 -06:00
|
|
|
ut64 loadaddr;
|
2014-10-24 20:13:18 +02:00
|
|
|
/* values used when searching the strings */
|
|
|
|
int minstrlen;
|
|
|
|
int maxstrlen;
|
2014-04-27 02:06:50 -05:00
|
|
|
int narch;
|
2014-01-18 09:26:09 -06:00
|
|
|
struct r_bin_xtr_plugin_t *curxtr;
|
|
|
|
struct r_bin_plugin_t *curplugin;
|
2014-05-08 18:35:04 -05:00
|
|
|
RList *objs;
|
2014-04-23 03:54:06 +02:00
|
|
|
Sdb *sdb;
|
2014-05-14 05:48:03 +02:00
|
|
|
Sdb *sdb_info;
|
2014-04-21 19:13:52 +04:00
|
|
|
Sdb *sdb_addrinfo;
|
2014-05-08 18:35:04 -05:00
|
|
|
struct r_bin_t *rbin;
|
2014-01-18 09:26:09 -06:00
|
|
|
} RBinFile;
|
2010-09-24 21:23:13 +02:00
|
|
|
|
|
|
|
typedef struct r_bin_t {
|
2014-01-18 09:26:09 -06:00
|
|
|
const char *file;
|
|
|
|
RBinFile *cur;
|
2010-09-24 21:23:13 +02:00
|
|
|
int narch;
|
2009-03-08 16:49:15 +01:00
|
|
|
void *user;
|
2014-10-24 20:13:18 +02:00
|
|
|
/* preconfigured values */
|
2012-12-09 01:39:27 +01:00
|
|
|
int minstrlen;
|
2014-10-21 04:39:37 +02:00
|
|
|
int maxstrlen;
|
2015-10-06 20:52:50 -04:00
|
|
|
ut64 maxstrbuf;
|
2014-05-19 02:41:53 +02:00
|
|
|
int rawstr;
|
2014-04-23 03:54:06 +02:00
|
|
|
Sdb *sdb;
|
|
|
|
RList/*<RBinPlugin>*/ *plugins;
|
|
|
|
RList/*<RBinXtrPlugin>*/ *binxtrs;
|
|
|
|
RList/*<RBinFile>*/ *binfiles;
|
2015-08-08 14:15:13 -04:00
|
|
|
PrintfCallback cb_printf;
|
2014-04-27 02:06:50 -05:00
|
|
|
int loadany;
|
2014-04-29 11:10:35 -05:00
|
|
|
RIOBind iob;
|
2015-01-11 19:40:26 +01:00
|
|
|
char *force;
|
2015-01-29 01:45:39 +01:00
|
|
|
int is_debugger;
|
2015-10-13 03:50:14 +02:00
|
|
|
int filter; // symbol filtering
|
|
|
|
char strfilter; // string filtering
|
|
|
|
int strpurge; // purge false positive strings
|
2015-10-29 12:37:14 +01:00
|
|
|
char *srcdir; // dir.source
|
2015-10-22 20:26:24 +02:00
|
|
|
char *prefix; // bin.prefix
|
2010-02-08 11:28:17 +01:00
|
|
|
} RBin;
|
2009-03-08 16:49:15 +01:00
|
|
|
|
2014-04-27 02:06:50 -05:00
|
|
|
typedef int (*FREE_XTR)(void *xtr_obj);
|
|
|
|
typedef struct r_bin_xtr_extract_t {
|
|
|
|
char *file;
|
|
|
|
RBuffer *buf;
|
|
|
|
ut64 size;
|
|
|
|
ut64 offset;
|
|
|
|
int file_count;
|
|
|
|
void *xtr_obj;
|
|
|
|
FREE_XTR free_xtr;
|
|
|
|
} RBinXtrData;
|
|
|
|
|
|
|
|
R_API RBinXtrData * r_bin_xtrdata_new (void *xtr_obj, FREE_XTR free_xtr, RBuffer *buf, ut64 offset, ut64 size, ut32 file_count);
|
|
|
|
R_API void r_bin_xtrdata_free (void /*RBinXtrData*/ *data);
|
2015-03-25 14:49:33 +01:00
|
|
|
R_API void r_bin_info_free (RBinInfo *rb);
|
2014-04-27 02:06:50 -05:00
|
|
|
|
2010-09-24 21:23:13 +02:00
|
|
|
typedef struct r_bin_xtr_plugin_t {
|
2009-03-08 16:49:15 +01:00
|
|
|
char *name;
|
|
|
|
char *desc;
|
2013-12-10 04:19:04 +01:00
|
|
|
char *license;
|
2009-03-08 16:49:15 +01:00
|
|
|
int (*init)(void *user);
|
|
|
|
int (*fini)(void *user);
|
2010-09-24 21:23:13 +02:00
|
|
|
int (*check)(RBin *bin);
|
2015-09-14 02:08:31 +02:00
|
|
|
// XXX: ut64 for size is maybe too much, what about st64? signed sizes are useful for detecting errors
|
2014-04-29 11:10:35 -05:00
|
|
|
int (*check_bytes)(const ut8 *bytes, ut64 sz);
|
2014-04-27 02:06:50 -05:00
|
|
|
RBinXtrData * (*extract_from_bytes)(const ut8 *buf, ut64 size, int idx);
|
|
|
|
RList * (*extractall_from_bytes)(const ut8 *buf, ut64 size);
|
|
|
|
RBinXtrData * (*extract)(RBin *bin, int idx);
|
|
|
|
RList * (*extractall)(RBin *bin);
|
2010-10-04 03:46:58 +02:00
|
|
|
int (*load)(RBin *bin);
|
2012-08-07 10:28:03 +02:00
|
|
|
int (*size)(RBin *bin);
|
2010-02-07 13:17:51 +01:00
|
|
|
int (*destroy)(RBin *bin);
|
2014-04-27 02:06:50 -05:00
|
|
|
int (*free_xtr)(void *xtr_obj);
|
2010-09-24 21:23:13 +02:00
|
|
|
} RBinXtrPlugin;
|
|
|
|
|
|
|
|
typedef struct r_bin_plugin_t {
|
|
|
|
char *name;
|
|
|
|
char *desc;
|
2013-12-10 04:19:04 +01:00
|
|
|
char *license;
|
2010-09-24 21:23:13 +02:00
|
|
|
int (*init)(void *user);
|
|
|
|
int (*fini)(void *user);
|
2014-05-08 18:35:04 -05:00
|
|
|
Sdb * (*get_sdb)(RBinObject *obj);
|
2014-01-18 09:26:09 -06:00
|
|
|
int (*load)(RBinFile *arch);
|
2015-05-11 18:23:38 +02:00
|
|
|
void *(*load_bytes)(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb);
|
2014-09-22 19:45:14 +02:00
|
|
|
int (*size)(RBinFile *bin); // return ut64 maybe? meh
|
2014-01-18 09:26:09 -06:00
|
|
|
int (*destroy)(RBinFile *arch);
|
|
|
|
int (*check)(RBinFile *arch);
|
2014-05-08 14:08:21 -05:00
|
|
|
int (*check_bytes)(const ut8 *buf, ut64 length);
|
2014-01-18 09:26:09 -06:00
|
|
|
ut64 (*baddr)(RBinFile *arch);
|
|
|
|
ut64 (*boffset)(RBinFile *arch);
|
|
|
|
RBinAddr* (*binsym)(RBinFile *arch, int num);
|
|
|
|
RList* (*entries)(RBinFile *arch);
|
|
|
|
RList* (*sections)(RBinFile *arch);
|
|
|
|
RList* (*lines)(RBinFile *arch);
|
|
|
|
RList* (*symbols)(RBinFile *arch);
|
|
|
|
RList* (*imports)(RBinFile *arch);
|
|
|
|
RList* (*strings)(RBinFile *arch);
|
|
|
|
RBinInfo* (*info)(RBinFile *arch);
|
|
|
|
RList* (*fields)(RBinFile *arch);
|
|
|
|
RList* (*libs)(RBinFile *arch);
|
|
|
|
RList* (*relocs)(RBinFile *arch);
|
|
|
|
RList* (*classes)(RBinFile *arch);
|
2015-03-13 21:52:57 +01:00
|
|
|
RList* (*mem)(RBinFile *arch);
|
2011-02-27 20:30:41 +01:00
|
|
|
int (*demangle_type)(const char *str);
|
2014-03-10 02:27:32 +01:00
|
|
|
struct r_bin_dbginfo_t *dbginfo;
|
2010-03-08 19:40:21 +01:00
|
|
|
struct r_bin_write_t *write;
|
2014-01-18 09:26:09 -06:00
|
|
|
int (*get_offset)(RBinFile *arch, int type, int idx);
|
|
|
|
ut64 (*get_vaddr)(RBinFile *arch, ut64 baddr, ut64 paddr, ut64 vaddr);
|
2011-07-25 21:10:25 +02:00
|
|
|
RBuffer* (*create)(RBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen);
|
2015-02-11 02:05:22 +01:00
|
|
|
char* (*demangle)(const char *str);
|
2014-10-24 20:13:18 +02:00
|
|
|
/* default value if not specified by user */
|
2012-12-09 01:39:27 +01:00
|
|
|
int minstrlen;
|
2015-10-29 13:55:03 +01:00
|
|
|
char strfilter;
|
2014-01-11 00:56:02 -06:00
|
|
|
void *user;
|
2010-05-26 01:42:22 +02:00
|
|
|
} RBinPlugin;
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2010-02-08 11:28:17 +01:00
|
|
|
typedef struct r_bin_section_t {
|
2014-04-21 02:58:05 +04:00
|
|
|
char name[R_BIN_SIZEOF_STRINGS+1];
|
2009-07-08 13:49:55 +02:00
|
|
|
ut64 size;
|
|
|
|
ut64 vsize;
|
2014-05-21 03:18:00 +02:00
|
|
|
ut64 vaddr;
|
|
|
|
ut64 paddr;
|
2015-09-16 12:59:52 +02:00
|
|
|
ut32 srwx;
|
2013-03-26 23:37:19 +01:00
|
|
|
// per section platform info
|
|
|
|
const char *arch;
|
|
|
|
int bits;
|
2015-09-29 00:42:31 +02:00
|
|
|
bool has_strings;
|
2010-02-08 11:28:17 +01:00
|
|
|
} RBinSection;
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2011-10-05 02:38:37 +02:00
|
|
|
typedef struct r_bin_class_t {
|
|
|
|
char *name;
|
|
|
|
char *super;
|
2013-12-15 22:04:34 -06:00
|
|
|
char *visibility_str;
|
2012-08-22 18:02:23 +02:00
|
|
|
int index;
|
2015-07-06 00:05:03 +02:00
|
|
|
ut64 addr;
|
2012-11-07 10:41:12 +01:00
|
|
|
RList *methods; // <RBinSymbol>
|
|
|
|
RList *fields; // <RBinField>
|
2011-10-05 02:38:37 +02:00
|
|
|
int visibility;
|
|
|
|
} RBinClass;
|
|
|
|
|
2010-09-01 20:32:24 +02:00
|
|
|
#define RBinSectionName r_offsetof(RBinSection, name)
|
|
|
|
#define RBinSectionOffset r_offsetof(RBinSection, offset)
|
|
|
|
// usage:
|
|
|
|
// r_list_get_by_name(bin->sections, RBinSectionName, ".text");
|
|
|
|
// bin.sections.get_by_name(SectionName, ".text");
|
|
|
|
|
2010-02-08 11:28:17 +01:00
|
|
|
typedef struct r_bin_symbol_t {
|
2015-11-09 12:12:18 +01:00
|
|
|
/* heap-allocated */
|
|
|
|
char *name;
|
2015-11-09 03:41:07 +01:00
|
|
|
char *classname;
|
2015-11-09 12:12:18 +01:00
|
|
|
/* const-unique-strings */
|
|
|
|
const char *forwarder;
|
|
|
|
const char *bind;
|
|
|
|
const char *type;
|
|
|
|
/* only used by java */
|
|
|
|
const char *visibility_str;
|
|
|
|
// ----------------
|
2015-11-09 03:41:07 +01:00
|
|
|
//char descriptor[R_BIN_SIZEOF_STRINGS+1];
|
2014-05-21 03:18:00 +02:00
|
|
|
ut64 vaddr;
|
|
|
|
ut64 paddr;
|
2014-06-14 00:01:58 +02:00
|
|
|
ut32 size;
|
|
|
|
ut32 ordinal;
|
2013-09-04 22:32:24 -05:00
|
|
|
ut32 visibility;
|
2015-02-26 02:48:54 +01:00
|
|
|
int bits;
|
2010-02-08 11:28:17 +01:00
|
|
|
} RBinSymbol;
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2010-02-08 11:28:17 +01:00
|
|
|
typedef struct r_bin_import_t {
|
2015-11-09 04:41:31 +01:00
|
|
|
char *name;
|
|
|
|
const char *bind;
|
|
|
|
const char *type;
|
|
|
|
char *classname;
|
|
|
|
char *descriptor;
|
2014-06-14 00:01:58 +02:00
|
|
|
ut32 ordinal;
|
2013-09-04 22:32:24 -05:00
|
|
|
ut32 visibility;
|
2010-02-08 11:28:17 +01:00
|
|
|
} RBinImport;
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2010-09-10 11:11:38 +02:00
|
|
|
typedef struct r_bin_reloc_t {
|
2013-07-17 22:18:21 +03:00
|
|
|
ut8 type;
|
|
|
|
ut8 additive;
|
2014-11-04 14:17:27 +03:00
|
|
|
RBinSymbol *symbol;
|
2013-07-17 22:18:21 +03:00
|
|
|
RBinImport *import;
|
|
|
|
st64 addend;
|
2014-05-21 03:18:00 +02:00
|
|
|
ut64 vaddr;
|
|
|
|
ut64 paddr;
|
2013-09-04 22:32:24 -05:00
|
|
|
ut32 visibility;
|
2010-09-10 11:11:38 +02:00
|
|
|
} RBinReloc;
|
|
|
|
|
2010-02-08 11:28:17 +01:00
|
|
|
typedef struct r_bin_string_t {
|
2010-11-22 01:22:27 +01:00
|
|
|
// TODO: rename string->name (avoid colisions)
|
2015-11-09 04:41:31 +01:00
|
|
|
char *string;
|
2014-05-21 03:18:00 +02:00
|
|
|
ut64 vaddr;
|
|
|
|
ut64 paddr;
|
2014-06-14 00:01:58 +02:00
|
|
|
ut32 ordinal;
|
|
|
|
ut32 size; // size of buffer containing the string in bytes
|
|
|
|
ut32 length; // length of string in chars
|
2014-02-11 00:08:12 +01:00
|
|
|
char type; // Ascii Wide cp850 utf8 ...
|
2010-02-08 11:28:17 +01:00
|
|
|
} RBinString;
|
2009-03-16 21:07:31 +01:00
|
|
|
|
2010-02-08 11:28:17 +01:00
|
|
|
typedef struct r_bin_field_t {
|
2015-11-09 12:12:18 +01:00
|
|
|
char *name;
|
2014-05-21 03:18:00 +02:00
|
|
|
ut64 vaddr;
|
|
|
|
ut64 paddr;
|
2013-09-04 22:32:24 -05:00
|
|
|
ut32 visibility;
|
2010-02-08 11:28:17 +01:00
|
|
|
} RBinField;
|
2009-04-24 12:12:15 +02:00
|
|
|
|
2015-03-13 21:52:57 +01:00
|
|
|
typedef struct r_bin_mem_t { //new toy for esil-init
|
2015-11-09 12:12:18 +01:00
|
|
|
char *name;
|
2015-03-13 21:52:57 +01:00
|
|
|
ut64 addr;
|
|
|
|
int size;
|
|
|
|
int perms;
|
|
|
|
RList *mirrors; //for mirror access; stuff here should only create new maps not new fds
|
|
|
|
} RBinMem;
|
|
|
|
|
2014-03-10 02:27:32 +01:00
|
|
|
typedef struct r_bin_dbginfo_t {
|
2014-01-18 09:26:09 -06:00
|
|
|
int (*get_line)(RBinFile *arch, ut64 addr, char *file, int len, int *line);
|
2014-03-10 02:27:32 +01:00
|
|
|
} RBinDbgInfo;
|
2010-03-09 15:12:04 +01:00
|
|
|
|
|
|
|
typedef struct r_bin_write_t {
|
2014-01-18 09:26:09 -06:00
|
|
|
ut64 (*scn_resize)(RBinFile *arch, const char *name, ut64 size);
|
|
|
|
int (*rpath_del)(RBinFile *arch);
|
2010-03-09 15:12:04 +01:00
|
|
|
} RBinWrite;
|
|
|
|
|
2010-10-04 10:55:43 +02:00
|
|
|
// TODO: deprecate r_bin_is_big_endian
|
|
|
|
// TODO: has_dbg_syms... maybe flags?
|
|
|
|
|
2011-06-26 20:29:24 +02:00
|
|
|
typedef int (*RBinGetOffset)(RBin *bin, int type, int idx);
|
2012-12-20 11:31:38 +01:00
|
|
|
typedef const char *(*RBinGetName)(RBin *bin, int off);
|
2011-06-26 20:29:24 +02:00
|
|
|
|
|
|
|
typedef struct r_bin_bind_t {
|
|
|
|
RBin *bin;
|
|
|
|
RBinGetOffset get_offset;
|
2012-12-20 11:31:38 +01:00
|
|
|
RBinGetName get_name;
|
2013-09-04 22:32:24 -05:00
|
|
|
ut32 visibility;
|
2011-06-26 20:29:24 +02:00
|
|
|
} RBinBind;
|
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
#ifdef R_API
|
2012-08-26 11:07:09 +02:00
|
|
|
|
|
|
|
#define r_bin_class_free(x) { free(x->name);free(x->super);free (x); }
|
|
|
|
|
2010-02-22 04:30:34 +01:00
|
|
|
/* bin.c */
|
2014-05-03 02:17:30 +02:00
|
|
|
R_API int r_bin_load(RBin *bin, const char *file, ut64 baseaddr, ut64 loadaddr, int xtr_idx, int fd, int rawstr);
|
2014-05-08 18:35:04 -05:00
|
|
|
R_API int r_bin_reload(RBin *bin, RIODesc *desc, ut64 baseaddr);
|
2014-05-03 02:17:30 +02:00
|
|
|
R_API int r_bin_load_as(RBin *bin, const char *file, ut64 baseaddr, ut64 loadaddr, int xtr_idx, int fd, int rawstr, int fileoffset, const char *name);
|
|
|
|
R_API int r_bin_load_io(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx);
|
|
|
|
R_API int r_bin_load_io_at_offset_as(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx, ut64 offset, const char *name);
|
2014-09-20 19:28:56 +02:00
|
|
|
R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int xtr_idx, ut64 offset, const char *name, ut64 sz);
|
2012-12-20 11:31:38 +01:00
|
|
|
R_API void r_bin_bind(RBin *b, RBinBind *bnd);
|
2010-05-26 01:42:22 +02:00
|
|
|
R_API int r_bin_add(RBin *bin, RBinPlugin *foo);
|
2010-09-24 21:23:13 +02:00
|
|
|
R_API int r_bin_xtr_add(RBin *bin, RBinXtrPlugin *foo);
|
2010-02-07 13:17:51 +01:00
|
|
|
R_API void* r_bin_free(RBin *bin);
|
2014-10-24 18:25:27 +02:00
|
|
|
R_API int r_bin_load_languages(RBinFile *binfile);
|
|
|
|
R_API int r_bin_dump_strings(RBinFile *a, int min);
|
2015-08-24 00:30:05 +02:00
|
|
|
//io-wrappers
|
|
|
|
R_API int r_bin_read_at (RBin *bin, ut64 addr, ut8 *buf, int size);
|
|
|
|
R_API int r_bin_write_at (RBin *bin, ut64 addr, const ut8 *buf, int size);
|
|
|
|
|
2014-05-03 02:17:30 +02:00
|
|
|
// ref
|
2014-04-23 18:04:25 -05:00
|
|
|
R_API int r_bin_file_deref_by_bind (RBinBind * binb);
|
|
|
|
R_API int r_bin_file_deref (RBin *bin, RBinFile * a);
|
|
|
|
R_API int r_bin_file_ref_by_bind (RBinBind * binb);
|
|
|
|
R_API int r_bin_file_ref (RBin *bin, RBinFile * a);
|
2015-10-20 11:17:24 +02:00
|
|
|
R_API int r_bin_list(RBin *bin, int json);
|
2013-03-03 05:03:48 +01:00
|
|
|
R_API RBinObject *r_bin_get_object(RBin *bin);
|
2015-08-25 00:53:49 +02:00
|
|
|
R_API ut64 r_binfile_get_baddr (RBinFile *binfile);
|
2010-02-07 13:17:51 +01:00
|
|
|
R_API ut64 r_bin_get_baddr(RBin *bin);
|
2014-02-02 23:50:06 -06:00
|
|
|
R_API void r_bin_set_baddr(RBin *bin, ut64 baddr);
|
2015-08-28 20:14:26 +02:00
|
|
|
R_API ut64 r_bin_get_laddr(RBin *bin);
|
2013-12-19 19:43:44 +01:00
|
|
|
R_API ut64 r_bin_get_boffset(RBin *bin);
|
2010-11-18 11:41:17 +01:00
|
|
|
R_API RBinAddr* r_bin_get_sym(RBin *bin, int sym);
|
2012-11-07 04:25:42 +01:00
|
|
|
|
2015-01-10 01:00:01 +01:00
|
|
|
R_API char* r_bin_demangle(RBinFile *binfile, const char *lang, const char *str);
|
2011-02-27 20:30:41 +01:00
|
|
|
R_API int r_bin_demangle_type (const char *str);
|
2011-02-23 20:53:56 +01:00
|
|
|
R_API char *r_bin_demangle_java(const char *str);
|
|
|
|
R_API char *r_bin_demangle_cxx(const char *str);
|
2015-02-19 19:39:55 +02:00
|
|
|
R_API char *r_bin_demangle_msvc(const char *str);
|
2015-01-10 01:00:01 +01:00
|
|
|
R_API char *r_bin_demangle_swift(const char *s);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API char *r_bin_demangle_objc(RBinFile *binfile, const char *sym);
|
2015-10-19 13:21:12 +02:00
|
|
|
R_API int r_bin_lang_type(RBinFile *binfile, const char *def, const char *sym);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API int r_bin_lang_objc(RBinFile *binfile);
|
2015-01-13 02:01:44 +01:00
|
|
|
R_API int r_bin_lang_swift(RBinFile *binfile);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API int r_bin_lang_cxx(RBinFile *binfile);
|
2015-02-19 21:31:24 +02:00
|
|
|
R_API int r_bin_lang_msvc(RBinFile *binfile);
|
2015-02-11 02:05:22 +01:00
|
|
|
R_API int r_bin_lang_dlang(RBinFile *binfile);
|
2015-06-30 12:36:13 +02:00
|
|
|
R_API int r_bin_lang_rust(RBinFile *binfile);
|
2012-11-07 04:25:42 +01:00
|
|
|
|
2010-03-10 11:01:38 +01:00
|
|
|
R_API RList* r_bin_get_entries(RBin *bin);
|
|
|
|
R_API RList* r_bin_get_fields(RBin *bin);
|
|
|
|
R_API RList* r_bin_get_imports(RBin *bin);
|
2010-02-07 14:11:05 +01:00
|
|
|
R_API RBinInfo* r_bin_get_info(RBin *bin);
|
2010-03-10 11:01:38 +01:00
|
|
|
R_API RList* r_bin_get_libs(RBin *bin);
|
2012-08-23 12:46:55 +02:00
|
|
|
R_API ut64 r_bin_get_size (RBin *bin);
|
2010-09-10 11:11:38 +02:00
|
|
|
R_API RList* r_bin_get_relocs(RBin *bin);
|
2010-03-10 11:01:38 +01:00
|
|
|
R_API RList* r_bin_get_sections(RBin *bin);
|
2011-10-05 02:38:37 +02:00
|
|
|
R_API RList* /*<RBinClass>*/r_bin_get_classes(RBin *bin);
|
2012-11-07 10:41:12 +01:00
|
|
|
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API RBinClass *r_bin_class_get (RBinFile *binfile, const char *name);
|
|
|
|
R_API RBinClass *r_bin_class_new (RBinFile *binfile, const char *name, const char *super, int view);
|
|
|
|
R_API int r_bin_class_add_method (RBinFile *binfile, const char *classname, const char *name, int nargs);
|
|
|
|
R_API void r_bin_class_add_field (RBinFile *binfile, const char *classname, const char *name);
|
2012-11-07 10:41:12 +01:00
|
|
|
|
2014-06-24 01:12:54 +02:00
|
|
|
R_API RBinSection* r_bin_get_section_at(RBinObject *o, ut64 off, int va);
|
2010-03-10 11:01:38 +01:00
|
|
|
R_API RList* r_bin_get_strings(RBin *bin);
|
2015-11-25 14:14:40 +03:00
|
|
|
R_API int r_bin_is_string(RBin *bin, ut64 va);
|
2013-12-05 23:51:17 -06:00
|
|
|
R_API RList* r_bin_reset_strings(RBin *bin);
|
2010-03-10 11:01:38 +01:00
|
|
|
R_API RList* r_bin_get_symbols(RBin *bin);
|
2010-03-13 20:25:03 +01:00
|
|
|
R_API int r_bin_is_big_endian (RBin *bin);
|
|
|
|
R_API int r_bin_is_stripped (RBin *bin);
|
|
|
|
R_API int r_bin_is_static (RBin *bin);
|
|
|
|
R_API int r_bin_has_dbg_linenums (RBin *bin);
|
|
|
|
R_API int r_bin_has_dbg_syms (RBin *bin);
|
|
|
|
R_API int r_bin_has_dbg_relocs (RBin *bin);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RBin* r_bin_new(void);
|
2014-05-28 18:58:53 +02:00
|
|
|
R_API void r_bin_iobind(RBin *bin, RIO *io);
|
2014-04-25 23:42:22 +02:00
|
|
|
R_API RBinFile * r_bin_cur (RBin *bin);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API RBinObject * r_bin_cur_object (RBin *bin);
|
2014-05-12 22:57:51 -05:00
|
|
|
R_API int r_bin_file_set_cur_binfile_obj (RBin * bin, RBinFile *bf, RBinObject *obj);
|
2014-01-11 00:56:02 -06:00
|
|
|
R_API int r_bin_io_load(RBin *bin, RIO *io, RIODesc *desc, ut64 baseaddr, ut64 loadaddr, int dummy);
|
2014-04-27 02:06:50 -05:00
|
|
|
|
2011-07-25 21:10:25 +02:00
|
|
|
R_API int r_bin_select(RBin *bin, const char *arch, int bits, const char *name);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API int r_bin_select_idx(RBin *bin, const char *name, int idx);
|
2014-05-12 22:57:51 -05:00
|
|
|
R_API int r_bin_select_by_ids(RBin *bin, ut32 binfile_id, ut32 binobj_id );
|
|
|
|
R_API int r_bin_object_delete (RBin *bin, ut32 binfile_id, ut32 binobj_id);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API int r_bin_use_arch(RBin *bin, const char *arch, int bits, const char *name);
|
|
|
|
R_API RBinFile * r_bin_file_find_by_arch_bits(RBin *bin, const char *arch, int bits, const char *name);
|
2014-05-08 18:35:04 -05:00
|
|
|
R_API RBinObject * r_bin_object_find_by_arch_bits (RBinFile *binfile, const char *arch, int bits, const char *name);
|
2014-04-23 03:54:06 +02:00
|
|
|
R_API void r_bin_list_archs(RBin *bin, int mode);
|
2010-02-07 13:17:51 +01:00
|
|
|
R_API void r_bin_set_user_ptr(RBin *bin, void *user);
|
2011-07-25 21:10:25 +02:00
|
|
|
R_API RBuffer *r_bin_create (RBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen);
|
2015-08-17 02:05:39 +02:00
|
|
|
R_API ut64 r_bin_get_vaddr (RBin *bin, ut64 paddr, ut64 vaddr);
|
|
|
|
R_API ut64 r_bin_a2b (RBin *bin, ut64 addr);
|
2014-10-17 00:04:52 +02:00
|
|
|
R_API int r_bin_file_delete(RBin *bin, ut32 bin_fd);
|
2015-01-22 02:22:29 +01:00
|
|
|
R_API int r_bin_file_delete_all(RBin *bin);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API int r_bin_file_set_cur_by_fd (RBin *bin, ut32 bin_fd);
|
2014-04-23 18:04:25 -05:00
|
|
|
R_API int r_bin_file_set_cur_by_name (RBin * bin, const char * name);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API RBinFile * r_bin_file_find_by_fd (RBin *bin, ut32 bin_fd);
|
2014-04-23 18:04:25 -05:00
|
|
|
R_API RBinFile * r_bin_file_find_by_name (RBin * bin, const char * name);
|
2014-04-27 02:06:50 -05:00
|
|
|
R_API RBinFile * r_bin_file_find_by_name_n (RBin * bin, const char * name, int idx);
|
|
|
|
R_API int r_bin_file_set_cur_binfile (RBin * bin, RBinFile *bf);
|
2014-05-08 18:35:04 -05:00
|
|
|
R_API RBinPlugin * r_bin_file_cur_plugin (RBinFile *binfile);
|
2015-01-11 19:40:26 +01:00
|
|
|
R_API void r_bin_force_plugin (RBin *bin, const char *pname);
|
2014-04-23 18:04:25 -05:00
|
|
|
|
2014-03-10 02:27:32 +01:00
|
|
|
/* dbginfo.c */
|
|
|
|
R_API int r_bin_addr2line(RBin *bin, ut64 addr, char *file, int len, int *line);
|
|
|
|
R_API char *r_bin_addr2text(RBin *bin, ut64 addr);
|
|
|
|
R_API char *r_bin_addr2fileline(RBin *bin, ut64 addr);
|
2010-03-08 19:40:21 +01:00
|
|
|
/* bin_write.c */
|
2010-03-11 02:14:34 +01:00
|
|
|
R_API ut64 r_bin_wr_scn_resize(RBin *bin, const char *name, ut64 size);
|
2010-03-16 02:24:12 +01:00
|
|
|
R_API int r_bin_wr_rpath_del(RBin *bin);
|
2010-03-11 02:14:34 +01:00
|
|
|
R_API int r_bin_wr_output(RBin *bin, const char *filename);
|
2014-05-29 18:31:24 +04:00
|
|
|
R_API int r_bin_dwarf_parse_info(RBinDwarfDebugAbbrev *da, RBin *a, int mode);
|
|
|
|
R_API RList *r_bin_dwarf_parse_line(RBin *a, int mode);
|
|
|
|
R_API RList *r_bin_dwarf_parse_aranges(RBin *a, int mode);
|
|
|
|
R_API RBinDwarfDebugAbbrev *r_bin_dwarf_parse_abbrev(RBin *a, int mode);
|
2011-02-23 20:53:56 +01:00
|
|
|
|
2014-08-11 03:48:51 +02:00
|
|
|
R_API RBinPlugin * r_bin_get_binplugin_by_bytes (RBin *bin, const ut8* bytes, ut64 sz);
|
|
|
|
|
2015-02-11 02:05:22 +01:00
|
|
|
R_API void r_bin_demangle_list(RBin *bin);
|
|
|
|
R_API char *r_bin_demangle_plugin(RBin *bin, const char *name, const char *str);
|
|
|
|
|
2015-03-18 13:35:03 +01:00
|
|
|
R_API RList *r_bin_get_mem (RBin *bin);
|
2015-07-04 23:42:48 +02:00
|
|
|
|
|
|
|
/* filter.c */
|
2015-07-06 00:58:51 +02:00
|
|
|
R_API void r_bin_filter_name(Sdb *db, ut64 addr, char *name, int maxlen);
|
2015-07-04 23:42:48 +02:00
|
|
|
R_API void r_bin_filter_symbols (RList *list);
|
2015-07-05 03:25:20 +02:00
|
|
|
R_API void r_bin_filter_sections (RList *list);
|
2015-07-06 00:58:51 +02:00
|
|
|
R_API void r_bin_filter_classes (RList *list);
|
2015-07-04 23:42:48 +02:00
|
|
|
|
2010-05-27 19:58:54 +02:00
|
|
|
/* plugin pointers */
|
2011-09-02 16:45:39 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_any;
|
2011-05-12 09:52:40 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_fs;
|
2015-09-08 20:35:57 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_cgc;
|
2010-05-27 19:58:54 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_elf;
|
|
|
|
extern RBinPlugin r_bin_plugin_elf64;
|
2011-11-12 04:51:45 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_p9;
|
2010-05-27 19:58:54 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_pe;
|
2012-03-07 01:34:57 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_mz;
|
2010-05-27 19:58:54 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_pe64;
|
2014-11-30 16:53:36 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_pebble;
|
2013-06-09 02:11:17 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_bios;
|
2013-12-10 03:35:59 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_bf;
|
2013-03-03 03:09:51 +04:00
|
|
|
extern RBinPlugin r_bin_plugin_te;
|
2010-05-27 19:58:54 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_mach0;
|
|
|
|
extern RBinPlugin r_bin_plugin_mach064;
|
|
|
|
extern RBinPlugin r_bin_plugin_java;
|
2011-04-28 02:09:43 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_dex;
|
2010-05-27 19:58:54 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_dummy;
|
2012-11-30 01:06:30 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_rar;
|
2014-02-17 00:02:47 +04:00
|
|
|
extern RBinPlugin r_bin_plugin_coff;
|
2014-09-24 23:51:40 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_ningb;
|
2014-03-12 11:36:45 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_ningba;
|
2014-09-24 23:51:40 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_ninds;
|
2014-05-26 20:07:24 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_xbe;
|
2010-09-24 21:23:13 +02:00
|
|
|
extern RBinXtrPlugin r_bin_xtr_plugin_fatmach0;
|
2010-10-01 04:26:52 +02:00
|
|
|
extern RBinXtrPlugin r_bin_xtr_plugin_dyldcache;
|
2015-04-06 21:48:21 -04:00
|
|
|
extern RBinPlugin r_bin_plugin_zimg;
|
2015-05-11 17:00:37 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_omf;
|
2015-06-17 11:13:03 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_art;
|
2015-09-16 12:59:52 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_dol;
|
2015-09-19 20:48:38 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_nes;
|
2015-09-29 00:42:31 +02:00
|
|
|
extern RBinPlugin r_bin_plugin_mbn;
|
2015-10-29 13:55:03 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_smd;
|
2015-10-27 09:19:34 +08:00
|
|
|
extern RBinPlugin r_bin_plugin_sms;
|
2015-11-22 23:00:50 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_psxexe;
|
2015-11-27 00:19:10 +01:00
|
|
|
extern RBinPlugin r_bin_plugin_spc700;
|
2013-06-18 12:09:23 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-27 19:58:54 +02:00
|
|
|
#endif
|
2009-02-05 22:08:46 +01:00
|
|
|
#endif
|