2016-01-26 23:36:02 +01:00
|
|
|
/* radare - LGPL - Copyright 2009-2016 - pancake */
|
2009-02-05 22:08:46 +01:00
|
|
|
|
|
|
|
#include <r_core.h>
|
2013-07-17 22:12:14 +02:00
|
|
|
|
2014-07-02 07:43:09 -03:00
|
|
|
#define SETI(x,y,z) r_config_node_desc(r_config_set_i(cfg,x,y), z);
|
|
|
|
#define SETICB(w,x,y,z) r_config_node_desc(r_config_set_i_cb(cfg,w,x,y), z);
|
|
|
|
#define SETPREF(x,y,z) r_config_node_desc(r_config_set(cfg,x,y), z);
|
|
|
|
#define SETCB(w,x,y,z) r_config_node_desc(r_config_set_cb(cfg,w,x,y), z);
|
2010-11-20 16:47:15 +01:00
|
|
|
|
2014-08-24 14:35:30 +02:00
|
|
|
static const char *has_esil(RCore *core, const char *name) {
|
|
|
|
RListIter *iter;
|
|
|
|
RAnalPlugin *h;
|
|
|
|
RAnal *a = core->anal;
|
|
|
|
r_list_foreach (a->plugins, iter, h) {
|
|
|
|
if (!strcmp (name, h->name)) {
|
2016-07-03 20:05:01 +02:00
|
|
|
return h->esil? "Ae": "A_";
|
2014-08-24 14:35:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "__";
|
|
|
|
}
|
|
|
|
|
2014-04-10 22:18:26 +02:00
|
|
|
// copypasta from binr/rasm2/rasm2.c
|
2016-05-19 00:38:33 +02:00
|
|
|
static void rasm2_list(RCore *core, const char *arch, int fmt) {
|
2014-04-10 22:18:26 +02:00
|
|
|
int i;
|
2014-08-24 14:35:30 +02:00
|
|
|
const char *feat2, *feat;
|
|
|
|
RAsm *a = core->assembler;
|
2014-04-10 22:18:26 +02:00
|
|
|
char bits[32];
|
|
|
|
RAsmPlugin *h;
|
|
|
|
RListIter *iter;
|
2016-05-19 00:38:33 +02:00
|
|
|
if (fmt == 'j') {
|
|
|
|
r_cons_printf ("{");
|
|
|
|
}
|
2014-04-10 22:18:26 +02:00
|
|
|
r_list_foreach (a->plugins, iter, h) {
|
|
|
|
if (arch && *arch) {
|
|
|
|
if (h->cpus && !strcmp (arch, h->name)) {
|
|
|
|
char *c = strdup (h->cpus);
|
|
|
|
int n = r_str_split (c, ',');
|
2016-06-26 00:51:17 -04:00
|
|
|
for (i=0;i<n;i++) {
|
|
|
|
r_cons_println (r_str_word_get0 (c, i));
|
|
|
|
}
|
2014-04-10 22:18:26 +02:00
|
|
|
free (c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bits[0] = 0;
|
2014-09-12 20:18:55 +02:00
|
|
|
/* The underscore makes it easier to distinguish the
|
|
|
|
* columns */
|
2014-07-02 23:18:50 +02:00
|
|
|
if (h->bits&8) strcat (bits, "_8");
|
|
|
|
if (h->bits&16) strcat (bits, "_16");
|
|
|
|
if (h->bits&32) strcat (bits, "_32");
|
|
|
|
if (h->bits&64) strcat (bits, "_64");
|
|
|
|
if (!*bits) strcat (bits, "_0");
|
2014-08-24 14:35:30 +02:00
|
|
|
feat = "__";
|
2014-04-10 22:18:26 +02:00
|
|
|
if (h->assemble && h->disassemble) feat = "ad";
|
|
|
|
if (h->assemble && !h->disassemble) feat = "a_";
|
|
|
|
if (!h->assemble && h->disassemble) feat = "_d";
|
2014-08-24 14:35:30 +02:00
|
|
|
feat2 = has_esil (core, h->name);
|
2016-05-19 00:38:33 +02:00
|
|
|
if (fmt == 'q') {
|
2016-06-26 00:51:17 -04:00
|
|
|
r_cons_println (h->name);
|
2016-05-19 00:38:33 +02:00
|
|
|
} else if (fmt == 'j') {
|
|
|
|
const char *str_bits = "32, 64";
|
|
|
|
const char *license = "GPL";
|
|
|
|
r_cons_printf ("\"%s\":{\"bits\":[%s],\"license\":\"%s\",\"description\":\"%s\",\"features\":\"%s\"}%s",
|
|
|
|
h->name, str_bits, license, h->desc, feat, iter->n? ",": "");
|
|
|
|
} else {
|
|
|
|
r_cons_printf ("%s%s %-9s %-11s %-7s %s\n",
|
|
|
|
feat, feat2, bits, h->name,
|
|
|
|
h->license?h->license:"unknown", h->desc);
|
|
|
|
}
|
2014-04-10 22:18:26 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-19 00:38:33 +02:00
|
|
|
if (fmt == 'j') {
|
|
|
|
r_cons_printf ("}\n");
|
|
|
|
}
|
2014-04-10 22:18:26 +02:00
|
|
|
}
|
|
|
|
|
2013-06-09 03:25:32 +02:00
|
|
|
static inline void __setsegoff(RConfig *cfg, const char *asmarch, int asmbits) {
|
2016-08-07 17:37:33 +02:00
|
|
|
int autoseg = (!strncmp (asmarch, "x86", 3) && asmbits == 16);
|
2016-01-26 23:36:02 +01:00
|
|
|
r_config_set (cfg, "asm.segoff", r_str_bool (autoseg));
|
2013-06-09 01:21:06 +02:00
|
|
|
}
|
|
|
|
|
2016-09-01 19:11:46 +02:00
|
|
|
static int cb_debug_hitinfo(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->dbg->hitinfo = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-20 23:13:38 +02:00
|
|
|
static int cb_analeobjmp(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-09-07 00:30:48 +02:00
|
|
|
core->anal->opt.eobjmp = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-20 23:13:38 +02:00
|
|
|
}
|
2014-11-02 02:01:09 +01:00
|
|
|
|
2014-11-27 11:42:12 +01:00
|
|
|
static int cb_analafterjmp(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-09-07 00:30:48 +02:00
|
|
|
core->anal->opt.afterjmp = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-11-27 11:42:12 +01:00
|
|
|
}
|
|
|
|
|
2014-11-02 02:01:09 +01:00
|
|
|
static int cb_analsleep(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->sleep = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-11-02 02:01:09 +01:00
|
|
|
}
|
|
|
|
|
2014-11-26 01:12:54 +01:00
|
|
|
static int cb_analmaxrefs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->maxreflines = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-11-26 01:12:54 +01:00
|
|
|
}
|
|
|
|
|
2014-09-14 11:52:30 +02:00
|
|
|
static int cb_analnopskip (void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-09-07 00:30:48 +02:00
|
|
|
core->anal->opt.nopskip = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-09-14 11:52:30 +02:00
|
|
|
}
|
|
|
|
|
2016-09-05 20:42:04 +02:00
|
|
|
static int cb_analhpskip (void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.hpskip = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-29 23:27:18 +01:00
|
|
|
static int cb_analbbsplit (void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-09-07 00:30:48 +02:00
|
|
|
core->anal->opt.bbsplit = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-01-29 23:27:18 +01:00
|
|
|
}
|
|
|
|
|
2016-07-03 20:05:01 +02:00
|
|
|
/* obey section permissions */
|
2015-07-05 01:44:45 +02:00
|
|
|
static int cb_analnoncode(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2016-07-03 20:05:01 +02:00
|
|
|
core->anal->opt.noncode = !!node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-07-05 01:44:45 +02:00
|
|
|
}
|
|
|
|
|
2014-02-06 00:08:46 +04:00
|
|
|
static int cb_analarch(void *user, void *data) {
|
2013-11-05 02:58:00 +01:00
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (*node->value == '?') {
|
|
|
|
r_anal_list (core->anal);
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2016-07-03 20:05:01 +02:00
|
|
|
if (*node->value) {
|
|
|
|
if (r_anal_use (core->anal, node->value)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
const char *aa = r_config_get (core->config, "asm.arch");
|
|
|
|
if (!aa || strcmp (aa, node->value)) {
|
|
|
|
eprintf ("anal.arch: cannot find '%s'\n", node->value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2014-02-06 00:08:46 +04:00
|
|
|
static int cb_analcpu(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_anal_set_cpu (core->anal, node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-02-06 00:08:46 +04:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_analsplit(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->split = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2015-02-23 15:39:54 +01:00
|
|
|
static int cb_analrecont(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-09-07 00:30:48 +02:00
|
|
|
core->anal->opt.recont = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-02-23 15:39:54 +01:00
|
|
|
}
|
|
|
|
|
2016-05-30 18:53:32 +02:00
|
|
|
static int cb_asmassembler(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_asm_use_assembler (core->assembler, node->value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_asmarch(void *user, void *data) {
|
2014-06-10 11:48:02 +02:00
|
|
|
char asmparser[32];
|
2013-11-05 02:58:00 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2014-06-13 12:06:29 +02:00
|
|
|
const char *asmos = r_config_get (core->config, "asm.os");
|
2015-08-31 12:46:29 +02:00
|
|
|
int bits = R_SYS_BITS;
|
2015-08-31 13:54:24 +02:00
|
|
|
if (core->anal->bits) {
|
|
|
|
bits = core->anal->bits;
|
2015-08-31 12:46:29 +02:00
|
|
|
}
|
2016-05-19 00:38:33 +02:00
|
|
|
if (*node->value == '?') {
|
|
|
|
rasm2_list (core, NULL, node->value[1]);
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2014-04-10 22:18:26 +02:00
|
|
|
}
|
2015-08-31 13:54:24 +02:00
|
|
|
r_egg_setup (core->egg, node->value, bits, 0, R_SYS_OS);
|
2016-05-19 00:38:33 +02:00
|
|
|
|
|
|
|
if (!*node->value) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!r_asm_use (core->assembler, node->value)) {
|
|
|
|
eprintf ("asm.arch: cannot find (%s)\n", node->value);
|
|
|
|
return false;
|
|
|
|
}
|
2015-08-31 13:54:24 +02:00
|
|
|
if (core->assembler && core->assembler->cur) {
|
|
|
|
bits = core->assembler->cur->bits;
|
2016-08-07 17:37:33 +02:00
|
|
|
if (8 & bits) {
|
|
|
|
bits = 8;
|
|
|
|
} else if (16 & bits) {
|
|
|
|
bits = 16;
|
|
|
|
} else if (32 & bits) {
|
|
|
|
bits = 32;
|
|
|
|
} else {
|
|
|
|
bits = 64;
|
|
|
|
}
|
2015-08-31 13:54:24 +02:00
|
|
|
}
|
2014-06-10 11:48:02 +02:00
|
|
|
snprintf (asmparser, sizeof (asmparser), "%s.pseudo", node->value);
|
|
|
|
r_config_set (core->config, "asm.parser", asmparser);
|
2015-11-02 12:44:06 +01:00
|
|
|
if (core->assembler->cur && !(core->assembler->cur->bits & core->anal->bits)) {
|
2014-06-10 11:48:02 +02:00
|
|
|
r_config_set_i (core->config, "asm.bits", bits);
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2015-08-31 12:46:29 +02:00
|
|
|
|
2015-10-22 03:11:03 +02:00
|
|
|
//r_debug_set_arch (core->dbg, r_sys_arch_id (node->value), bits);
|
|
|
|
r_debug_set_arch (core->dbg, node->value, bits);
|
2013-12-07 14:25:15 +01:00
|
|
|
if (!r_config_set (core->config, "anal.arch", node->value)) {
|
2013-11-05 02:58:00 +01:00
|
|
|
char *p, *s = strdup (node->value);
|
2015-11-05 16:45:45 +01:00
|
|
|
if (s) {
|
|
|
|
p = strchr (s, '.');
|
2016-08-10 18:49:44 +02:00
|
|
|
if (p) {
|
|
|
|
*p = 0;
|
|
|
|
}
|
2015-11-05 16:45:45 +01:00
|
|
|
if (!r_config_set (core->config, "anal.arch", s)) {
|
|
|
|
/* fall back to the anal.null plugin */
|
|
|
|
r_config_set (core->config, "anal.arch", "null");
|
|
|
|
}
|
|
|
|
free (s);
|
2014-09-27 03:10:44 +02:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2015-11-02 18:57:01 +01:00
|
|
|
// set pcalign
|
|
|
|
{
|
|
|
|
int v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN);
|
2016-08-07 17:37:33 +02:00
|
|
|
if (v != -1) {
|
|
|
|
r_config_set_i (core->config, "asm.pcalign", v);
|
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "asm.pcalign", 0);
|
|
|
|
}
|
2015-11-02 18:57:01 +01:00
|
|
|
}
|
2016-08-07 17:37:33 +02:00
|
|
|
if (!r_syscall_setup (core->anal->syscall, node->value, asmos, core->anal->bits)) {
|
2013-11-05 02:58:00 +01:00
|
|
|
//eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n",
|
|
|
|
// node->value, asmos, R2_LIBDIR"/radare2/"R2_VERSION"/syscall");
|
|
|
|
}
|
|
|
|
//if (!strcmp (node->value, "bf"))
|
|
|
|
// r_config_set (core->config, "dbg.backend", "bf");
|
|
|
|
__setsegoff (core->config, node->value, core->assembler->bits);
|
2016-05-10 21:12:50 +01:00
|
|
|
|
2016-04-26 19:09:15 +10:00
|
|
|
// set a default endianness
|
|
|
|
int bigbin = r_bin_is_big_endian (core->bin);
|
|
|
|
if (bigbin == -1 /* error: no endianness detected in binary */) {
|
|
|
|
// try to set RAsm to LE
|
|
|
|
r_asm_set_big_endian (core->assembler, false);
|
|
|
|
// set endian of display to LE
|
|
|
|
core->print->big_endian = false;
|
|
|
|
} else {
|
|
|
|
// try to set endian of RAsm to match binary
|
|
|
|
r_asm_set_big_endian (core->assembler, bigbin);
|
|
|
|
// set endian of display to match binary
|
|
|
|
core->print->big_endian = bigbin;
|
|
|
|
}
|
2016-08-16 11:56:55 +02:00
|
|
|
/* reload types and cc info */
|
|
|
|
r_core_anal_type_init (core);
|
|
|
|
r_core_anal_cc_init (core);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2014-09-26 13:57:03 +02:00
|
|
|
static int cb_dbgbpsize(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->dbg->bpsize = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-09-26 13:57:03 +02:00
|
|
|
}
|
|
|
|
|
2015-08-22 20:19:33 +08:00
|
|
|
static int cb_dbgbtdepth(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->dbg->btdepth = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-08-22 20:19:33 +08:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_asmbits(void *user, void *data) {
|
|
|
|
const char *asmos, *asmarch;
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2016-04-08 13:36:15 +02:00
|
|
|
int ret = 0, bits;
|
2014-05-22 11:22:48 +02:00
|
|
|
if (!core) {
|
|
|
|
eprintf ("user can't be NULL\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2014-05-22 11:22:48 +02:00
|
|
|
}
|
|
|
|
|
2016-04-08 13:36:15 +02:00
|
|
|
bits = node->i_value;
|
|
|
|
|
|
|
|
if (bits > 0) {
|
|
|
|
ret = r_asm_set_bits (core->assembler, bits);
|
2016-08-10 18:49:44 +02:00
|
|
|
if (!ret) {
|
2016-04-08 13:36:15 +02:00
|
|
|
RAsmPlugin *h = core->assembler->cur;
|
|
|
|
if (h) {
|
|
|
|
eprintf ("Cannot set bits %d to '%s'\n", bits, h->name);
|
|
|
|
} else {
|
|
|
|
eprintf ("e asm.bits: Cannot set value, no plugins defined yet\n");
|
|
|
|
ret = true;
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2016-08-10 18:49:44 +02:00
|
|
|
if (!r_anal_set_bits (core->anal, bits)) {
|
2016-04-08 13:36:15 +02:00
|
|
|
eprintf ("asm.arch: Cannot setup '%d' bits analysis engine\n", bits);
|
|
|
|
}
|
|
|
|
core->print->bits = bits;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2015-09-22 01:49:14 +02:00
|
|
|
if (core->dbg && core->anal && core->anal->cur) {
|
2016-04-08 13:36:15 +02:00
|
|
|
bool load_from_debug = false;
|
|
|
|
r_debug_set_arch (core->dbg, core->anal->cur->arch, bits);
|
2015-05-21 02:26:54 +02:00
|
|
|
if (r_config_get_i (core->config, "cfg.debug")) {
|
2016-04-08 13:36:15 +02:00
|
|
|
load_from_debug = true;
|
2015-05-21 02:26:54 +02:00
|
|
|
} else {
|
2016-04-08 13:36:15 +02:00
|
|
|
(void)r_anal_set_reg_profile (core->anal);
|
2015-05-21 02:26:54 +02:00
|
|
|
}
|
|
|
|
if (load_from_debug) {
|
|
|
|
if (core->dbg->h && core->dbg->h->reg_profile) {
|
|
|
|
char *rp = core->dbg->h->reg_profile (core->dbg);
|
|
|
|
r_reg_set_profile_string (core->dbg->reg, rp);
|
|
|
|
r_reg_set_profile_string (core->anal->reg, rp);
|
|
|
|
free (rp);
|
|
|
|
}
|
2014-06-26 10:27:10 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
asmos = r_config_get (core->config, "asm.os");
|
|
|
|
asmarch = r_config_get (core->config, "asm.arch");
|
2014-06-25 03:07:54 +02:00
|
|
|
if (core->anal) {
|
2016-04-08 13:36:15 +02:00
|
|
|
if (!r_syscall_setup (core->anal->syscall, asmarch, asmos, bits)) {
|
2013-11-05 02:58:00 +01:00
|
|
|
//eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n",
|
|
|
|
// node->value, asmos, R2_LIBDIR"/radare2/"R2_VERSION"/syscall");
|
|
|
|
}
|
2014-06-25 03:07:54 +02:00
|
|
|
__setsegoff (core->config, asmarch, core->anal->bits);
|
2015-06-27 20:31:37 +03:00
|
|
|
if (core->dbg) {
|
|
|
|
r_bp_use (core->dbg->bp, asmarch, core->anal->bits);
|
|
|
|
}
|
2014-06-25 03:07:54 +02:00
|
|
|
}
|
2016-07-03 20:05:01 +02:00
|
|
|
/* set pcalign */
|
2015-10-14 03:19:42 +02:00
|
|
|
{
|
|
|
|
int v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN);
|
2016-08-10 18:49:44 +02:00
|
|
|
if (v != -1) {
|
|
|
|
r_config_set_i (core->config, "asm.pcalign", v);
|
|
|
|
} else {
|
|
|
|
r_config_set_i (core->config, "asm.pcalign", 0);
|
|
|
|
}
|
2015-10-14 03:19:42 +02:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-02-11 03:50:56 +01:00
|
|
|
static int cb_asmfeatures(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2015-02-18 13:04:59 +01:00
|
|
|
if (*node->value == '?') {
|
2015-02-11 03:50:56 +01:00
|
|
|
if (core && core->assembler && core->assembler->cur) {
|
|
|
|
if (core->assembler->cur->features) {
|
|
|
|
char *feat = strdup (core->assembler->cur->features);
|
|
|
|
r_str_replace_char (feat, ',','\n');
|
2016-06-26 00:51:17 -04:00
|
|
|
r_cons_println (feat);
|
2015-02-11 03:50:56 +01:00
|
|
|
free (feat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
free (core->assembler->features);
|
2015-02-18 13:04:59 +01:00
|
|
|
core->assembler->features = NULL;
|
2016-07-03 20:05:01 +02:00
|
|
|
if (node->value[0]) {
|
2015-02-11 03:50:56 +01:00
|
|
|
core->assembler->features = strdup (node->value);
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2015-02-11 03:50:56 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_asmcpu(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2014-04-11 02:22:41 +02:00
|
|
|
if (*node->value=='?') {
|
2016-05-19 00:38:33 +02:00
|
|
|
rasm2_list (core, r_config_get (core->config, "asm.arch"), node->value[1]);
|
2014-04-10 22:18:26 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
r_asm_set_cpu (core->assembler, node->value);
|
2014-08-07 01:57:10 +02:00
|
|
|
r_config_set (core->config, "anal.cpu", node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_asmlineswidth(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->anal->lineswidth = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2016-09-03 20:31:30 +02:00
|
|
|
static int cb_emustr(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (node->i_value) {
|
|
|
|
r_config_set (core->config, "asm.emu", "true");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-31 00:20:07 +02:00
|
|
|
static int cb_asm_invhex(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->assembler->invhex = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-08-31 00:20:07 +02:00
|
|
|
}
|
|
|
|
|
2015-10-14 02:11:53 +02:00
|
|
|
static int cb_asm_pcalign(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
int align = node->i_value;
|
2016-08-10 18:49:44 +02:00
|
|
|
if (align < 0) {
|
|
|
|
align = 0;
|
|
|
|
}
|
2015-10-14 02:11:53 +02:00
|
|
|
core->assembler->pcalign = align;
|
|
|
|
core->anal->pcalign = align;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_asmos(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
int asmbits = r_config_get_i (core->config, "asm.bits");
|
2014-11-04 11:47:42 +01:00
|
|
|
RConfigNode *asmarch, *node = (RConfigNode*) data;
|
|
|
|
|
2015-09-01 03:13:16 +02:00
|
|
|
if (*node->value == '?') {
|
2015-10-30 03:07:22 +01:00
|
|
|
r_cons_printf ("ios\ndos\ndarwin\nlinux\nfreebsd\nopenbsd\nnetbsd\nwindows\n");
|
2014-11-04 11:47:42 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-09-01 03:13:16 +02:00
|
|
|
if (!node->value[0]) {
|
|
|
|
free (node->value);
|
|
|
|
node->value = strdup (R_SYS_OS);
|
|
|
|
}
|
2014-11-04 11:47:42 +01:00
|
|
|
asmarch = r_config_node_get (core->config, "asm.arch");
|
2013-11-05 02:58:00 +01:00
|
|
|
if (asmarch) {
|
|
|
|
r_syscall_setup (core->anal->syscall, asmarch->value,
|
|
|
|
node->value, core->anal->bits);
|
|
|
|
__setsegoff (core->config, asmarch->value, asmbits);
|
|
|
|
}
|
2015-10-30 03:07:22 +01:00
|
|
|
r_anal_set_os (core->anal, node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_asmparser(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
return r_parse_use (core->parser, node->value);
|
|
|
|
}
|
|
|
|
|
2015-07-04 23:42:48 +02:00
|
|
|
static int cb_binfilter(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->bin->filter = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-07-04 23:42:48 +02:00
|
|
|
}
|
|
|
|
|
2016-05-03 04:31:36 +02:00
|
|
|
/* BinDemangleCmd */
|
|
|
|
static int cb_bdc(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->bin->demanglercmd = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-13 03:50:14 +02:00
|
|
|
static int cb_strpurge(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->bin->strpurge = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-17 20:18:50 +01:00
|
|
|
static int cb_midflags (void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *)data;
|
|
|
|
if (node->value[0] == '?') {
|
|
|
|
eprintf ("Valid values for asm.midflags:\n");
|
2016-07-03 20:05:01 +02:00
|
|
|
eprintf ("0 do not show middle flags\n");
|
|
|
|
eprintf ("1 print the middfle flag without realign instruction\n");
|
|
|
|
eprintf ("2 realign the instruction at the middfle flag\n");
|
2015-12-17 20:18:50 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-13 03:50:14 +02:00
|
|
|
static int cb_strfilter(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (node->value[0] == '?') {
|
|
|
|
eprintf ("Valid values for bin.strfilter:\n");
|
|
|
|
eprintf ("a only alphanumeric printable\n");
|
|
|
|
eprintf ("8 only strings with utf8 chars\n");
|
|
|
|
eprintf ("p file/directory paths\n");
|
|
|
|
eprintf ("e email-like addresses\n");
|
|
|
|
eprintf ("u urls\n");
|
2015-11-10 14:54:14 -06:00
|
|
|
eprintf ("i IPv4 address-like strings\n");
|
2015-10-29 13:55:03 +01:00
|
|
|
eprintf ("U only uppercase strings\n");
|
2015-10-13 03:50:14 +02:00
|
|
|
eprintf ("f format-strings\n");
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
core->bin->strfilter = node->value[0];
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-11 19:40:26 +01:00
|
|
|
static int cb_binforce(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
r_bin_force_plugin (core->bin, node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-01-11 19:40:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_asmsyntax(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2014-04-11 02:22:41 +02:00
|
|
|
if (*node->value == '?') {
|
2015-08-21 15:29:37 +02:00
|
|
|
r_cons_printf ("att\nintel\nmasm\njz\nregnum\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2014-06-25 15:44:03 +02:00
|
|
|
} else if (!strcmp (node->value, "regnum")) {
|
|
|
|
r_asm_set_syntax (core->assembler, R_ASM_SYNTAX_REGNUM);
|
2015-05-09 11:11:46 +02:00
|
|
|
} else if (!strcmp (node->value, "jz")) {
|
|
|
|
r_asm_set_syntax (core->assembler, R_ASM_SYNTAX_JZ);
|
2014-04-11 02:22:41 +02:00
|
|
|
} else if (!strcmp (node->value, "intel")) {
|
2013-11-05 02:58:00 +01:00
|
|
|
r_asm_set_syntax (core->assembler, R_ASM_SYNTAX_INTEL);
|
2015-08-21 15:29:37 +02:00
|
|
|
} else if (!strcmp (node->value, "masm")) {
|
|
|
|
r_asm_set_syntax (core->assembler, R_ASM_SYNTAX_MASM);
|
2014-04-11 02:22:41 +02:00
|
|
|
} else if (!strcmp (node->value, "att")) {
|
2013-11-05 02:58:00 +01:00
|
|
|
r_asm_set_syntax (core->assembler, R_ASM_SYNTAX_ATT);
|
2015-09-14 12:35:38 +02:00
|
|
|
} else return false;
|
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_bigendian(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2016-04-26 19:09:15 +10:00
|
|
|
// Try to set endian based on preference, restrict by RAsmPlugin
|
|
|
|
bool isbig = r_asm_set_big_endian (core->assembler, node->i_value);
|
|
|
|
// Set anal endianness the same as asm
|
|
|
|
r_anal_set_big_endian (core->anal, isbig);
|
2016-09-06 12:02:38 +02:00
|
|
|
// the big endian should also be assigned to dbg->bp->endian
|
|
|
|
core->dbg->bp->endian = isbig;
|
2016-04-26 19:09:15 +10:00
|
|
|
// Set printing endian to user's choice
|
2013-11-05 02:58:00 +01:00
|
|
|
core->print->big_endian = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_cfgdatefmt(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2014-04-22 18:39:17 -05:00
|
|
|
snprintf (core->print->datefmt, 32, "%s", node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 23:24:09 +02:00
|
|
|
static int cb_timezone(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->print->datezone = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-04-03 23:24:09 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_cfgdebug(void *user, void *data) {
|
2015-08-24 16:44:09 +02:00
|
|
|
int ioraw = 1;
|
2013-11-05 02:58:00 +01:00
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-09-14 12:35:38 +02:00
|
|
|
if (!core) return false;
|
2015-08-24 16:44:09 +02:00
|
|
|
if (core->io) {
|
2013-11-05 02:58:00 +01:00
|
|
|
core->io->debug = node->i_value;
|
2015-08-24 16:44:09 +02:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
if (core->dbg && node->i_value) {
|
|
|
|
const char *dbgbackend = r_config_get (core->config, "dbg.backend");
|
2015-09-14 12:35:38 +02:00
|
|
|
core->bin->is_debugger = true;
|
2013-11-05 02:58:00 +01:00
|
|
|
r_debug_use (core->dbg, dbgbackend);
|
2015-08-24 04:45:04 +02:00
|
|
|
if (!strcmp (r_config_get (core->config, "cmd.prompt"), "")) {
|
|
|
|
r_config_set (core->config, "cmd.prompt", ".dr*");
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
if (!strcmp (dbgbackend, "bf"))
|
|
|
|
r_config_set (core->config, "asm.arch", "bf");
|
|
|
|
if (core->file) {
|
2015-11-24 23:28:50 +01:00
|
|
|
#if __WINDOWS__
|
|
|
|
r_debug_select (core->dbg, core->dbg->pid,
|
|
|
|
core->dbg->tid);
|
|
|
|
#else
|
2014-05-28 04:34:12 +02:00
|
|
|
r_debug_select (core->dbg, core->file->desc->fd,
|
|
|
|
core->file->desc->fd);
|
2015-11-24 23:28:50 +01:00
|
|
|
#endif
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2015-01-29 01:45:39 +01:00
|
|
|
} else {
|
|
|
|
if (core->dbg) r_debug_use (core->dbg, NULL);
|
2015-09-14 12:35:38 +02:00
|
|
|
core->bin->is_debugger = false;
|
2015-01-29 01:45:39 +01:00
|
|
|
}
|
2015-08-24 16:44:09 +02:00
|
|
|
if (core->io) {
|
2016-02-03 12:53:35 +01:00
|
|
|
r_config_set (core->config, "io.va", "true");
|
2015-08-24 16:44:09 +02:00
|
|
|
if (core->dbg && core->dbg->h) {
|
|
|
|
ioraw = core->dbg->h->keepio? 0: 1;
|
|
|
|
} else {
|
|
|
|
ioraw = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r_config_set (core->config, "io.raw", ioraw? "true": "false");
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2015-10-29 12:37:14 +01:00
|
|
|
static int cb_dirsrc(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
RCore *core = (RCore *)user;
|
|
|
|
free (core->bin->srcdir);
|
|
|
|
core->bin->srcdir = strdup (node->value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_cfgsanbox(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
int ret = r_sandbox_enable (node->i_value);
|
2016-07-03 20:05:01 +02:00
|
|
|
if (node->i_value != ret) {
|
2014-06-14 02:52:56 +02:00
|
|
|
eprintf ("Cannot disable sandbox\n");
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
return (!node->i_value && ret)? 0: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_cmdrepeat(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->cmdrepeat = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2014-01-08 23:44:05 +01:00
|
|
|
static int cb_scrnull(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->cons->null = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-01-08 23:44:05 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_color(void *user, void *data) {
|
2010-03-11 00:51:32 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
if (node->i_value) {
|
|
|
|
core->print->flags |= R_PRINT_FLAGS_COLOR;
|
|
|
|
} else {
|
|
|
|
//c:core->print->flags ^= R_PRINT_FLAGS_COLOR;
|
|
|
|
core->print->flags &= (~R_PRINT_FLAGS_COLOR);
|
|
|
|
}
|
|
|
|
r_print_set_flags (core->print, core->print->flags);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2010-03-11 00:51:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-07 23:21:34 +02:00
|
|
|
static int cb_dbgbep(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (*node->value == '?') {
|
|
|
|
r_cons_printf ("loader\nentry\nconstructor\nmain\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2014-05-07 23:21:34 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-05-07 23:21:34 +02:00
|
|
|
}
|
2014-10-09 01:21:49 +02:00
|
|
|
|
2015-06-25 16:40:39 +02:00
|
|
|
static int cb_dbg_btalgo(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (*node->value == '?') {
|
2015-06-29 22:23:04 +02:00
|
|
|
r_cons_printf ("default\nfuzzy\nanal\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2015-06-25 16:40:39 +02:00
|
|
|
}
|
|
|
|
free (core->dbg->btalgo);
|
|
|
|
core->dbg->btalgo = strdup (node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-06-25 16:40:39 +02:00
|
|
|
}
|
|
|
|
|
2015-10-13 02:18:14 +02:00
|
|
|
static int cb_dbg_libs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
free (core->dbg->glob_libs);
|
|
|
|
core->dbg->glob_libs = strdup (node->value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_dbg_unlibs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
free (core->dbg->glob_unlibs);
|
|
|
|
core->dbg->glob_unlibs = strdup (node->value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-09 01:21:49 +02:00
|
|
|
static int cb_dbg_forks(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->dbg->trace_forks = node->i_value;
|
2015-12-14 00:43:16 +01:00
|
|
|
if (core->io->debug) {
|
|
|
|
r_debug_attach (core->dbg, core->dbg->pid);
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-09 01:21:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_dbg_execs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->dbg->trace_execs = node->i_value;
|
2015-12-14 00:43:16 +01:00
|
|
|
if (core->io->debug) {
|
|
|
|
r_debug_attach (core->dbg, core->dbg->pid);
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-09 01:21:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_dbg_clone(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->dbg->trace_clone = node->i_value;
|
2015-12-14 00:43:16 +01:00
|
|
|
if (core->io->debug) {
|
|
|
|
r_debug_attach (core->dbg, core->dbg->pid);
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-09 01:21:49 +02:00
|
|
|
}
|
|
|
|
|
2014-08-11 16:07:17 +02:00
|
|
|
static int cb_runprofile(void *user, void *data) {
|
2014-07-09 02:24:31 +02:00
|
|
|
RCore *r = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
free ((void*)r->io->runprofile);
|
2016-07-03 20:05:01 +02:00
|
|
|
if (!node || !*(node->value)) {
|
|
|
|
r->io->runprofile = NULL;
|
|
|
|
} else {
|
|
|
|
r->io->runprofile = strdup (node->value);
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-07-09 02:24:31 +02:00
|
|
|
}
|
2014-05-07 23:21:34 +02:00
|
|
|
|
2015-09-30 13:10:49 +02:00
|
|
|
static int cb_dbg_args(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *)user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2016-07-03 20:05:01 +02:00
|
|
|
if (!node || !*(node->value)) {
|
|
|
|
core->io->args = NULL;
|
|
|
|
} else {
|
|
|
|
core->io->args = strdup (node->value);
|
|
|
|
}
|
2015-09-30 13:10:49 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-02 02:36:41 +02:00
|
|
|
static int cb_dbgstatus(void *user, void *data) {
|
|
|
|
RCore *r = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (r_config_get_i (r->config, "cfg.debug")) {
|
2016-07-03 20:05:01 +02:00
|
|
|
if (node->i_value) {
|
2014-07-02 02:36:41 +02:00
|
|
|
r_config_set (r->config, "cmd.prompt",
|
2015-10-31 01:57:52 +01:00
|
|
|
".dr*; drd; sr PC;pi 1;s-");
|
2016-07-03 20:05:01 +02:00
|
|
|
} else {
|
|
|
|
r_config_set (r->config, "cmd.prompt", ".dr*");
|
|
|
|
}
|
2014-07-02 02:36:41 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-07-02 02:36:41 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_dbgbackend(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
// XXX: remove this spagetti
|
2016-07-03 20:05:01 +02:00
|
|
|
if (!strcmp (node->value, "bf")) {
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_set (core->config, "asm.arch", "bf");
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
r_debug_use (core->dbg, node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2010-03-12 18:46:11 +01:00
|
|
|
}
|
|
|
|
|
2015-04-01 00:38:24 +02:00
|
|
|
static int cb_gotolimit(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (r_sandbox_enable (0)) {
|
|
|
|
eprintf ("Cannot change gotolimit\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2015-04-01 00:38:24 +02:00
|
|
|
}
|
2016-07-03 20:05:01 +02:00
|
|
|
if (core->anal->esil) {
|
2015-04-01 00:38:24 +02:00
|
|
|
core->anal->esil_goto_limit = node->i_value;
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-04-01 00:38:24 +02:00
|
|
|
}
|
|
|
|
|
2015-03-12 16:45:23 +01:00
|
|
|
static int cb_esildebug (void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (core->anal->esil)
|
|
|
|
core->anal->esil->debug = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-03-12 16:45:23 +01:00
|
|
|
}
|
|
|
|
|
2016-01-19 23:36:21 +00:00
|
|
|
static int cb_esilstacksize (void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (node->i_value < 3) {
|
|
|
|
eprintf ("esil.stacksize must be greater than 2\n");
|
|
|
|
node->i_value = 32;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-09 00:29:00 +01:00
|
|
|
static int cb_fixrows(void *user, void *data) {
|
2010-03-12 18:46:11 +01:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2016-01-14 23:41:01 +01:00
|
|
|
r_cons_singleton ()->fix_rows = (int)node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2010-03-12 18:46:11 +01:00
|
|
|
}
|
|
|
|
|
2014-01-09 00:29:00 +01:00
|
|
|
static int cb_fixcolumns(void *user, void *data) {
|
2011-08-27 20:25:37 +02:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2016-01-14 23:41:01 +01:00
|
|
|
r_cons_singleton ()->fix_columns = atoi (node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-01-09 00:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_rows(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_singleton ()->force_rows = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2011-08-27 20:25:37 +02:00
|
|
|
}
|
|
|
|
|
2014-04-10 22:18:26 +02:00
|
|
|
static int cb_hexpairs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->print->pairs = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-04-10 22:18:26 +02:00
|
|
|
}
|
|
|
|
|
2015-09-19 19:39:25 +02:00
|
|
|
static int r_core_esil_cmd(RAnalEsil *esil, const char *cmd, int a1, int a2) {
|
2015-09-08 02:53:33 +02:00
|
|
|
if (cmd && *cmd) {
|
|
|
|
RCore *core = esil->anal->user;
|
2015-09-19 19:39:25 +02:00
|
|
|
r_core_cmdf (core, "%s %d %d", cmd, a1, a2);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-09-08 02:53:33 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2015-09-08 02:53:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_cmd_esil_intr(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (core && core->anal && core->anal->esil) {
|
|
|
|
core->anal->esil->cmd = r_core_esil_cmd;
|
|
|
|
core->anal->esil->cmd_intr = node->value;
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-09-08 02:53:33 +02:00
|
|
|
}
|
|
|
|
|
2015-09-19 19:39:25 +02:00
|
|
|
static int cb_cmd_esil_trap(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (core && core->anal && core->anal->esil) {
|
|
|
|
core->anal->esil->cmd = r_core_esil_cmd;
|
|
|
|
core->anal->esil->cmd_trap = node->value;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_fsview(void *user, void *data) {
|
2011-05-13 02:31:18 +02:00
|
|
|
int type = R_FS_VIEW_NORMAL;
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2014-04-11 02:22:41 +02:00
|
|
|
if (*node->value == '?') {
|
2011-05-13 02:31:18 +02:00
|
|
|
eprintf ("Values: all|deleted|special\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2011-05-13 02:31:18 +02:00
|
|
|
}
|
2016-07-03 20:05:01 +02:00
|
|
|
if (!strcmp (node->value, "all")) {
|
2011-05-13 02:31:18 +02:00
|
|
|
type = R_FS_VIEW_ALL;
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
|
|
|
if (!strstr (node->value, "del")) {
|
2011-05-13 02:31:18 +02:00
|
|
|
type |= R_FS_VIEW_DELETED;
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
|
|
|
if (!strstr (node->value, "spe")) {
|
2011-05-13 02:31:18 +02:00
|
|
|
type |= R_FS_VIEW_SPECIAL;
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2011-05-13 02:31:18 +02:00
|
|
|
r_fs_view (core->fs, type);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2011-05-13 02:31:18 +02:00
|
|
|
}
|
|
|
|
|
2013-12-22 01:53:15 +01:00
|
|
|
static int cb_cmddepth(void *user, void *data) {
|
|
|
|
int c = R_MAX (((RConfigNode*)data)->i_value, 0);
|
|
|
|
((RCore *)user)->cmd_depth = c;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-12-22 01:53:15 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_hexcols(void *user, void *data) {
|
2015-10-03 13:33:08 +02:00
|
|
|
RCore *core = (RCore *)user;
|
2013-11-05 02:58:00 +01:00
|
|
|
int c = R_MIN (128, R_MAX (((RConfigNode*)data)->i_value, 0));
|
2015-10-03 13:33:08 +02:00
|
|
|
core->print->cols = c & ~1;
|
2016-02-25 11:35:59 +01:00
|
|
|
core->dbg->regcols = c/4;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2010-10-27 17:45:53 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_hexstride(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
((RCore *)user)->print->stride = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2012-07-06 02:17:44 +02:00
|
|
|
}
|
|
|
|
|
2015-02-03 00:46:44 +01:00
|
|
|
static int cb_search_kwidx(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->search->n_kws = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-02-03 00:46:44 +01:00
|
|
|
}
|
|
|
|
|
2014-05-18 02:19:11 +02:00
|
|
|
static int cb_ioenforce(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
int perm = node->i_value;
|
|
|
|
core->io->enforce_rwx = 0;
|
2016-07-03 20:05:01 +02:00
|
|
|
if (perm & 1) {
|
|
|
|
core->io->enforce_rwx |= R_IO_READ;
|
|
|
|
}
|
|
|
|
if (perm & 2) {
|
|
|
|
core->io->enforce_rwx |= R_IO_WRITE;
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-05-18 02:19:11 +02:00
|
|
|
}
|
|
|
|
|
2014-11-24 00:41:20 +01:00
|
|
|
static int cb_iosectonly(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->io->sectonly = node->i_value? 1: 0;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-11-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_iobuffer(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
2011-08-27 03:31:55 +02:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
if (node->i_value) {
|
|
|
|
ut64 from, to;
|
|
|
|
from = r_config_get_i (core->config, "io.buffer.from");
|
|
|
|
to = r_config_get_i (core->config, "io.buffer.to");
|
|
|
|
if (from>=to) {
|
|
|
|
eprintf ("ERROR: io.buffer.from >= io.buffer.to"
|
|
|
|
" (0x%"PFMT64x" >= 0x%"PFMT64x")\n", from, to);
|
|
|
|
} else r_io_buffer_load (core->io, from, (int)(to-from));
|
2016-07-03 20:05:01 +02:00
|
|
|
} else {
|
|
|
|
r_io_buffer_close (core->io);
|
|
|
|
}
|
2016-08-15 13:56:23 -05:00
|
|
|
r_core_block_read (core);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2011-08-27 03:31:55 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_iocache(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
2011-02-28 00:03:26 +01:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2015-12-08 17:56:35 +01:00
|
|
|
if ((int)node->i_value < 0) {
|
2015-12-08 14:59:30 +01:00
|
|
|
r_io_cache_reset (core->io, node->i_value);
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
r_io_cache_enable (core->io, node->i_value, node->i_value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2011-02-28 00:03:26 +01:00
|
|
|
}
|
|
|
|
|
2015-08-16 17:45:23 +02:00
|
|
|
static int cb_ioaslr(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (node->i_value != core->io->aslr) {
|
|
|
|
core->io->aslr = node->i_value;
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-08-16 17:45:23 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_iova(void *user, void *data) {
|
2010-03-04 01:46:25 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
if (node->i_value != core->io->va) {
|
|
|
|
core->io->va = node->i_value;
|
2016-07-03 20:05:01 +02:00
|
|
|
/* ugly fix for r2 -d ... "r2 is going to die soon ..." */
|
|
|
|
if (r_io_desc_get (core->io, core->io->raised)) {
|
2016-08-15 13:56:23 -05:00
|
|
|
r_core_block_read (core);
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
|
|
|
/* reload symbol information */
|
|
|
|
if (r_list_length (r_bin_get_sections (core->bin)) > 0) {
|
2013-11-05 02:58:00 +01:00
|
|
|
r_core_cmd0 (core, ".ia*");
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2010-02-28 22:58:21 +01:00
|
|
|
}
|
|
|
|
|
2014-05-25 02:23:33 +02:00
|
|
|
static int cb_ioraw(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_io_set_raw (core->io, node->i_value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-05-25 02:23:33 +02:00
|
|
|
}
|
|
|
|
|
2014-06-10 11:20:17 +02:00
|
|
|
static int cb_ioff(void *user, void *data) {
|
2011-02-03 09:31:50 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2014-05-28 19:32:29 +02:00
|
|
|
core->io->ff = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2011-02-03 09:31:50 +01:00
|
|
|
}
|
|
|
|
|
2016-05-03 23:09:00 +02:00
|
|
|
static int cb_io_oxff(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->io->Oxff = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-03 15:55:56 +02:00
|
|
|
static int cb_ioautofd(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->io->autofd = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-06-03 15:55:56 +02:00
|
|
|
}
|
|
|
|
|
2015-02-09 23:13:49 +01:00
|
|
|
static int cb_iovio(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->io->vio = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-02-09 23:13:49 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_pager(void *user, void *data) {
|
2013-06-17 03:26:48 +02:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* Let cons know we have a new pager. */
|
|
|
|
core->cons->pager = node->value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-06-17 03:26:48 +02:00
|
|
|
}
|
|
|
|
|
2014-02-24 16:10:12 +01:00
|
|
|
static int cb_fps(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_singleton ()->fps = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-02-24 16:10:12 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_rgbcolors(void *user, void *data) {
|
2010-03-04 01:46:25 +01:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
if (node->i_value) {
|
|
|
|
r_cons_singleton()->truecolor =
|
|
|
|
(r_config_get_i (core->config, "scr.truecolor"))?2:1;
|
|
|
|
} else {
|
|
|
|
r_cons_singleton()->truecolor = 0;
|
2011-10-24 12:07:12 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2010-10-23 14:27:13 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_scrcolumns(void* user, void* data) {
|
2010-03-04 01:46:25 +01:00
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2015-10-03 13:33:08 +02:00
|
|
|
RCore *core = (RCore*) user;
|
2013-11-05 02:58:00 +01:00
|
|
|
int n = atoi (node->value);
|
2015-10-03 13:33:08 +02:00
|
|
|
core->cons->force_columns = n;
|
2016-07-03 20:05:01 +02:00
|
|
|
core->dbg->regcols = n / 20;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2009-03-17 22:06:50 +00:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_scrfgets(void* user, void* data) {
|
2010-02-28 22:58:21 +01:00
|
|
|
RCore *core = (RCore *) user;
|
2013-11-05 02:58:00 +01:00
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
2016-07-03 20:05:01 +02:00
|
|
|
core->cons->user_fgets = node->i_value
|
|
|
|
? NULL : (void *)r_core_fgets;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_scrhtml(void *user, void *data) {
|
2010-02-28 22:58:21 +01:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
r_cons_singleton ()->is_html = node->i_value;
|
|
|
|
// TODO: control error and restore old value (return false?) show errormsg?
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2012-08-19 03:28:17 +02:00
|
|
|
|
2014-09-27 03:48:54 +02:00
|
|
|
static int cb_scrhighlight(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_highlight (node->value);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-09-27 03:48:54 +02:00
|
|
|
}
|
|
|
|
|
2015-11-01 05:10:49 +01:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
|
|
|
static int scr_ansicon(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_singleton()->ansicon = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-30 22:58:51 +01:00
|
|
|
static int cb_screcho(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_singleton()->echo = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-30 22:58:51 +01:00
|
|
|
}
|
|
|
|
|
2016-09-20 00:11:59 +02:00
|
|
|
static int cb_scrflush(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_singleton()->flush = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-23 12:46:22 +02:00
|
|
|
static int cb_exectrap(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
if (core->anal && core->anal->esil) {
|
|
|
|
core->anal->esil->exectrap = node->i_value;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-09 01:17:55 +02:00
|
|
|
static int cb_iotrap(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
if (core->anal && core->anal->esil) {
|
|
|
|
core->anal->esil->iotrap = node->i_value;
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-09-09 01:17:55 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_scrint(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2015-02-12 21:48:04 +01:00
|
|
|
if (node->i_value && r_sandbox_enable (0)) {
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2015-02-12 17:23:30 +01:00
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
r_cons_singleton()->is_interactive = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_scrnkey(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (!strcmp (node->value, "help") || *node->value == '?') {
|
|
|
|
r_cons_printf ("scr.nkey = fun, hit, flag\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2011-11-15 23:26:45 +01:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_scrprompt(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_line_singleton()->echo = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_scrrows(void* user, void* data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
int n = atoi (node->value);
|
|
|
|
((RCore *)user)->cons->force_rows = n;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2009-04-11 21:22:20 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 13:44:52 +02:00
|
|
|
static int cb_contiguous(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *)user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->search->contiguous = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-05-31 13:44:52 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_searchalign(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *)user;
|
2013-07-17 22:12:14 +02:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
core->search->align = node->i_value;
|
|
|
|
core->print->addrmod = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_segoff(void *user, void *data) {
|
2013-07-17 22:12:14 +02:00
|
|
|
RCore *core = (RCore *) user;
|
2013-11-05 02:58:00 +01:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (node->i_value)
|
|
|
|
core->print->flags |= R_PRINT_FLAGS_SEGOFF;
|
|
|
|
else core->print->flags &= (((ut32)-1) & (~R_PRINT_FLAGS_SEGOFF));
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-07-17 22:12:14 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_stopthreads(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
2013-07-17 19:34:27 +02:00
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
core->dbg->stop_all_threads = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-07-17 19:34:27 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_swstep(void *user, void *data) {
|
2010-02-28 22:58:21 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
core->dbg->swstep = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_teefile(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
r_cons_singleton()->teefile = node->value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2015-02-22 11:18:40 +01:00
|
|
|
static int cb_anal_trace(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (core->anal) {
|
|
|
|
if (node->i_value && !core->anal->esil) {
|
|
|
|
r_core_cmd0 (core, "aei");
|
|
|
|
}
|
|
|
|
core->anal->trace = node->i_value;
|
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2015-02-22 11:18:40 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_trace(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->dbg->trace->enabled = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2009-03-12 01:42:35 +00:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_tracetag(void *user, void *data) {
|
2012-02-05 02:39:04 +01:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
2013-11-05 02:58:00 +01:00
|
|
|
core->dbg->trace->tag = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2012-02-05 02:39:04 +01:00
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_truecolor(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (r_cons_singleton()->truecolor)
|
|
|
|
r_cons_singleton()->truecolor = (node->i_value)? 2: 1;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2012-02-05 02:39:04 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_utf8(void *user, void *data) {
|
2013-07-19 00:20:23 +04:00
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->utf8 = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-07-19 00:20:23 +04:00
|
|
|
}
|
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
static int cb_zoombyte(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
switch (*node->value) {
|
|
|
|
case 'p': case 'f': case 's': case '0':
|
|
|
|
case 'F': case 'e': case 'h':
|
|
|
|
core->print->zoom->mode = *node->value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
eprintf ("Invalid zoom.byte value. See pz? for help\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-11-05 02:58:00 +01:00
|
|
|
}
|
|
|
|
|
2014-05-19 02:41:53 +02:00
|
|
|
static int cb_rawstr(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
core->bin->rawstr = node->i_value;
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-05-19 02:41:53 +02:00
|
|
|
}
|
|
|
|
|
2015-10-22 20:26:24 +02:00
|
|
|
static int cb_binprefix(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
free (core->bin->prefix);
|
|
|
|
if (node->value && *node->value) {
|
|
|
|
if (!strcmp (node->value, "auto")) {
|
2015-10-23 12:07:07 +02:00
|
|
|
if (!core->bin || !core->bin->file) {
|
2015-10-22 20:26:24 +02:00
|
|
|
//eprintf ("core->bin->file is null\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
char *name = (char *)r_file_basename (core->bin->file);
|
2015-10-23 14:56:30 +02:00
|
|
|
r_name_filter (name, strlen (name));
|
2015-10-22 20:26:24 +02:00
|
|
|
r_str_filter (name, strlen (name));
|
2015-10-23 16:55:38 +02:00
|
|
|
core->bin->prefix = strdup (name);
|
2015-10-22 20:26:24 +02:00
|
|
|
} else {
|
|
|
|
core->bin->prefix = node->value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
core->bin->prefix = NULL;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-06 20:52:50 -04:00
|
|
|
static int cb_binmaxstrbuf(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (core->bin) {
|
|
|
|
int v = node->i_value;
|
|
|
|
ut64 old_v = core->bin->maxstrbuf;
|
2015-10-22 20:26:24 +02:00
|
|
|
if (v < 1) v = 4; // HACK
|
2015-10-06 20:52:50 -04:00
|
|
|
core->bin->maxstrbuf = v;
|
2016-07-03 20:05:01 +02:00
|
|
|
if (v>old_v) {
|
2015-10-06 20:52:50 -04:00
|
|
|
r_core_bin_refresh_strings (core);
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2015-10-06 20:52:50 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-21 04:39:37 +02:00
|
|
|
static int cb_binmaxstr(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (core->bin) {
|
|
|
|
int v = node->i_value;
|
|
|
|
if (v<1) v = 4; // HACK
|
|
|
|
core->bin->maxstrlen = v;
|
|
|
|
// TODO: Do not refresh if nothing changed (minstrlen ?)
|
|
|
|
r_core_bin_refresh_strings (core);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-21 04:39:37 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-10-21 04:39:37 +02:00
|
|
|
}
|
|
|
|
|
2013-12-05 23:51:17 -06:00
|
|
|
static int cb_binminstr(void *user, void *data) {
|
|
|
|
RCore *core = (RCore *) user;
|
|
|
|
RConfigNode *node = (RConfigNode *) data;
|
|
|
|
if (core->bin) {
|
2013-12-29 03:42:18 +01:00
|
|
|
int v = node->i_value;
|
|
|
|
if (v<1) v = 4; // HACK
|
|
|
|
core->bin->minstrlen = v;
|
|
|
|
// TODO: Do not refresh if nothing changed (minstrlen ?)
|
|
|
|
r_core_bin_refresh_strings (core);
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-12-05 23:51:17 -06:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2013-12-05 23:51:17 -06:00
|
|
|
}
|
|
|
|
|
2014-04-27 04:25:51 +02:00
|
|
|
static int cb_searchin(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (*node->value == '?') {
|
2014-10-15 12:08:34 +02:00
|
|
|
r_cons_printf ("raw\nblock\nfile\nio.maps\nio.maprange\nio.section\n" \
|
2015-09-28 02:04:08 +02:00
|
|
|
"io.sections\nio.sections.write\nio.sections.exec\n" \
|
|
|
|
"dbg.stack\ndbg.heap\ndbg.map\ndbg.maps\n"\
|
|
|
|
"dbg.maps.exec\ndbg.maps.write\nanal.fcn\nanal.bb\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2014-04-27 04:25:51 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-04-27 04:25:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_fileloadmethod(void *user, void *data) {
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
if (*node->value == '?') {
|
|
|
|
r_cons_printf ("fail\noverwrite\nappend\n");
|
2015-09-14 12:35:38 +02:00
|
|
|
return false;
|
2014-04-27 04:25:51 +02:00
|
|
|
}
|
2015-09-14 12:35:38 +02:00
|
|
|
return true;
|
2014-04-27 04:25:51 +02:00
|
|
|
}
|
|
|
|
|
2014-10-26 01:26:41 +02:00
|
|
|
static int __dbg_swstep_getter(void *user, RConfigNode *node) {
|
|
|
|
RCore *core = (RCore*)user;
|
|
|
|
node->i_value = core->dbg->swstep;
|
2016-07-03 20:05:01 +02:00
|
|
|
return true;
|
2014-10-26 01:26:41 +02:00
|
|
|
}
|
|
|
|
|
2014-11-07 03:48:27 +01:00
|
|
|
static int cb_anal_gp(RCore *core, RConfigNode *node) {
|
|
|
|
core->anal->gp = node->i_value;
|
2016-07-03 20:05:01 +02:00
|
|
|
return true;
|
2014-11-07 03:48:27 +01:00
|
|
|
}
|
2014-11-24 00:41:20 +01:00
|
|
|
|
2014-11-03 04:05:19 +01:00
|
|
|
static int cb_anal_from(RCore *core, RConfigNode *node) {
|
|
|
|
if (r_config_get_i (core->config, "anal.limits")) {
|
2015-04-11 18:54:35 +02:00
|
|
|
r_anal_set_limits (core->anal,
|
2014-11-03 04:05:19 +01:00
|
|
|
r_config_get_i (core->config, "anal.from"),
|
|
|
|
r_config_get_i (core->config, "anal.to"));
|
|
|
|
}
|
2016-07-03 20:05:01 +02:00
|
|
|
return true;
|
2014-11-03 04:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_anal_limits(void *user, RConfigNode *node) {
|
|
|
|
RCore *core = (RCore*)user;
|
|
|
|
if (node->i_value) {
|
2015-04-11 18:54:35 +02:00
|
|
|
r_anal_set_limits (core->anal,
|
2014-11-03 04:05:19 +01:00
|
|
|
r_config_get_i (core->config, "anal.from"),
|
|
|
|
r_config_get_i (core->config, "anal.to"));
|
|
|
|
} else {
|
|
|
|
r_anal_unset_limits (core->anal);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-11-20 11:33:48 +03:00
|
|
|
static int cb_anal_jmptbl(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.jmptbl = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-30 13:10:49 +02:00
|
|
|
|
2015-11-23 18:00:11 +03:00
|
|
|
static int cb_anal_cjmpref(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.cjmpref = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cb_anal_jmpref(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.jmpref = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-24 15:01:26 +03:00
|
|
|
static int cb_anal_jmpabove(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.jmpabove = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-24 16:49:44 +03:00
|
|
|
static int cb_anal_followdatarefs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.followdatarefs = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-25 14:14:40 +03:00
|
|
|
static int cb_anal_searchstringrefs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.searchstringrefs = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-14 14:27:44 +02:00
|
|
|
static int cb_anal_pushret(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.pushret = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-03 13:41:26 +03:00
|
|
|
static int cb_anal_followbrokenfcnsrefs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.followbrokenfcnsrefs = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-10 17:46:10 +03:00
|
|
|
static int cb_anal_bbs_alignment(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.bbs_alignment = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-10 18:22:24 +03:00
|
|
|
static int cb_anal_bb_max_size(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->anal->opt.bb_max_size = node->i_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-21 22:27:05 +01:00
|
|
|
static int cb_linesto(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
ut64 from = (ut64)r_config_get_i (core->config, "lines.from");
|
|
|
|
int io_sz = r_io_size (core->io);
|
2015-12-22 02:30:34 +01:00
|
|
|
ut64 to = r_num_math (core->num, node->value);
|
|
|
|
if (to == 0) {
|
2015-12-22 20:51:06 +01:00
|
|
|
core->print->lines_cache_sz = -1; //r_core_lines_initcache (core, from, to);
|
2015-12-22 02:30:34 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-02 18:18:48 +01:00
|
|
|
if (to > from+io_sz) {
|
2015-12-22 02:30:34 +01:00
|
|
|
eprintf ("ERROR: \"lines.to\" can't exceed addr 0x%08"PFMT64x
|
|
|
|
" 0x%08"PFMT64x" %d\n", from, to, io_sz);
|
2015-12-21 22:27:05 +01:00
|
|
|
return true;
|
|
|
|
}
|
2015-12-22 02:30:34 +01:00
|
|
|
if (to > from) {
|
2015-12-22 20:51:06 +01:00
|
|
|
core->print->lines_cache_sz = r_core_lines_initcache (core, from, to);
|
|
|
|
//if (core->print->lines_cache_sz == -1) { eprintf ("ERROR: Can't allocate memory\n"); }
|
2015-12-22 02:30:34 +01:00
|
|
|
} else {
|
|
|
|
eprintf ("Invalid range 0x%08"PFMT64x" .. 0x%08"PFMT64x"\n", from, to);
|
2015-12-21 22:27:05 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-28 12:49:50 +01:00
|
|
|
static int cb_linesabs(void *user, void *data) {
|
|
|
|
RCore *core = (RCore*) user;
|
|
|
|
RConfigNode *node = (RConfigNode*) data;
|
|
|
|
core->print->lines_abs = node->i_value;
|
|
|
|
if (core->print->lines_abs && core->print->lines_cache_sz <= 0) {
|
|
|
|
ut64 from = (ut64)r_config_get_i (core->config, "lines.from");
|
|
|
|
ut64 to = (ut64)r_config_get_i (core->config, "lines.to");
|
|
|
|
core->print->lines_cache_sz = r_core_lines_initcache (core, from, to);
|
|
|
|
if (core->print->lines_cache_sz == -1) {
|
|
|
|
eprintf ("ERROR: \"lines.from\" and \"lines.to\" must be set\n");
|
|
|
|
} else {
|
|
|
|
eprintf ("Found %d lines\n", core->print->lines_cache_sz-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-09-04 13:31:25 +02:00
|
|
|
static char *getViewerPath() {
|
|
|
|
int i;
|
|
|
|
const char *viewers[] = {
|
|
|
|
"open",
|
|
|
|
"geeqie",
|
|
|
|
"gqview",
|
|
|
|
"eog",
|
|
|
|
"xdg-open"
|
|
|
|
};
|
|
|
|
for (i = 0; viewers[i]; i++) {
|
|
|
|
char *dotPath = r_file_path (viewers[i]);
|
2016-09-04 13:43:31 +02:00
|
|
|
if (dotPath && strcmp (dotPath, viewers[i])) {
|
2016-09-04 13:31:25 +02:00
|
|
|
return dotPath;
|
|
|
|
}
|
|
|
|
free (dotPath);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-13 17:41:26 +02:00
|
|
|
#define SLURP_LIMIT (10*1024*1024)
|
2010-03-04 01:46:25 +01:00
|
|
|
R_API int r_core_config_init(RCore *core) {
|
2012-08-19 03:28:17 +02:00
|
|
|
int i;
|
2013-01-03 00:47:58 +01:00
|
|
|
char buf[128], *p, *tmpdir;
|
2014-02-01 16:13:35 +00:00
|
|
|
RConfig *cfg = core->config = r_config_new (core);
|
2016-07-03 20:05:01 +02:00
|
|
|
if (!cfg) {
|
|
|
|
return 0;
|
|
|
|
}
|
2015-08-08 14:15:13 -04:00
|
|
|
cfg->cb_printf = r_cons_printf;
|
2012-08-13 04:33:01 +02:00
|
|
|
cfg->num = core->num;
|
2014-12-11 16:33:32 +02:00
|
|
|
/* pdb */
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("pdb.user_agent", "Microsoft-Symbol-Server/6.11.0001.402", "User agent for Microsoft symbol server");
|
|
|
|
SETPREF("pdb.server", "http://msdl.microsoft.com/download/symbols", "Base URL for Microsoft symbol server");
|
2015-05-25 17:48:43 +03:00
|
|
|
SETI("pdb.extract", 1, "Avoid extract of the pdb file, just download");
|
2014-12-11 16:33:32 +02:00
|
|
|
|
2010-02-28 22:58:21 +01:00
|
|
|
/* anal */
|
2015-01-12 02:33:57 +01:00
|
|
|
SETPREF("anal.a2f", "false", "Use the new WIP analysis algorithm (core/p/a2f), anal.depth ignored atm");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("anal.gp", 0, (RConfigCallback)&cb_anal_gp, "Set the value of the GP register (MIPS)");
|
|
|
|
SETCB("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "Restrict analysis to address range [anal.from:anal.to]");
|
|
|
|
SETICB("anal.from", -1, (RConfigCallback)&cb_anal_from, "Lower limit on the address range for analysis");
|
|
|
|
SETICB("anal.to", -1, (RConfigCallback)&cb_anal_from, "Upper limit on the address range for analysis");
|
2014-11-03 04:05:19 +01:00
|
|
|
|
2014-11-25 02:07:01 +01:00
|
|
|
SETCB("anal.eobjmp", "false", &cb_analeobjmp, "jmp is end of block mode (option)");
|
2015-12-14 11:18:26 +01:00
|
|
|
SETCB("anal.afterjmp", "true", &cb_analafterjmp, "Continue analysis after jmp/ujmp");
|
2014-10-09 18:43:57 +02:00
|
|
|
SETI("anal.depth", 16, "Max depth at code analysis"); // XXX: warn if depth is > 50 .. can be problematic
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("anal.sleep", 0, &cb_analsleep, "Sleep N usecs every so often during analysis. Avoid 100% CPU usage");
|
2015-07-27 23:56:11 +02:00
|
|
|
SETPREF("anal.calls", "false", "Make basic af analysis walk into calls");
|
2016-03-22 02:00:42 +01:00
|
|
|
SETPREF("anal.autoname", "true", "Automatically set a name for the functions, may result in some false positives");
|
2015-07-27 18:54:21 +02:00
|
|
|
SETPREF("anal.hasnext", "false", "Continue analysis after each function");
|
2014-09-12 02:37:49 +02:00
|
|
|
SETPREF("anal.esil", "false", "Use the new ESIL code analysis");
|
2016-03-14 09:42:54 +01:00
|
|
|
SETPREF("anal.strings", "false", "Identify and register strings during analysis (aar only)");
|
2016-06-26 01:52:53 +02:00
|
|
|
SETPREF("anal.vars", "true", "Analyze local variables and arguments");
|
2016-06-09 21:52:25 +02:00
|
|
|
SETPREF("anal.vinfun", "false", "Search values in functions (aav) (false by default to only find on non-code)");
|
2016-06-10 15:31:38 +02:00
|
|
|
SETPREF("anal.vinfunrange", "false", "Search values outside function ranges (requires anal.vinfun=false)\n");
|
2014-12-05 18:31:28 -05:00
|
|
|
SETCB("anal.nopskip", "true", &cb_analnopskip, "Skip nops at the beginning of functions");
|
2016-09-05 20:42:04 +02:00
|
|
|
SETCB("anal.hpskip", "false", &cb_analhpskip, "Skip `mov reg, reg` and `lea reg, [reg] at the beginning of functions");
|
2015-01-29 23:27:18 +01:00
|
|
|
SETCB("anal.bbsplit", "true", &cb_analbbsplit, "Use the experimental basic block split for JMPs");
|
2015-07-05 01:44:45 +02:00
|
|
|
SETCB("anal.noncode", "false", &cb_analnoncode, "Analyze data as code");
|
2014-02-06 00:08:46 +04:00
|
|
|
SETCB("anal.arch", R_SYS_ARCH, &cb_analarch, "Specify the anal.arch to use");
|
|
|
|
SETCB("anal.cpu", R_SYS_ARCH, &cb_analcpu, "Specify the anal.cpu to use");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("anal.prelude", "", "Specify an hexpair to find preludes in code");
|
2015-05-13 23:30:58 +02:00
|
|
|
SETCB("anal.split", "true", &cb_analsplit, "Split functions into basic blocks in analysis");
|
|
|
|
SETCB("anal.recont", "false", &cb_analrecont, "End block after splitting a basic block instead of error"); // testing
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("anal.trace", "false", &cb_anal_trace, "Record ESIL trace in log database");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETI("anal.ptrdepth", 3, "Maximum number of nested pointers to follow in analysis");
|
2014-11-26 01:12:54 +01:00
|
|
|
SETICB("anal.maxreflines", 0, &cb_analmaxrefs, "Maximum number of reflines to be analyzed and displayed in asm.lines with pd");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
2015-11-20 11:33:48 +03:00
|
|
|
SETCB("anal.jmptbl", "false", &cb_anal_jmptbl, "Analyze jump tables in switch statements");
|
|
|
|
|
2015-11-23 18:00:11 +03:00
|
|
|
SETCB("anal.cjmpref", "false", &cb_anal_cjmpref, "Create references for conditional jumps");
|
|
|
|
SETCB("anal.jmpref", "true", &cb_anal_jmpref, "Create references for unconditional jumps");
|
|
|
|
|
2015-11-24 15:01:26 +03:00
|
|
|
SETCB("anal.jmpabove", "true", &cb_anal_jmpabove, "Jump above function pointer");
|
2015-11-24 18:29:42 +03:00
|
|
|
SETCB("anal.followdatarefs", "false", &cb_anal_followdatarefs, "Follow data references for code coverage");
|
2015-12-03 13:41:26 +03:00
|
|
|
SETCB("anal.followbrokenfcnsrefs", "false", &cb_anal_followbrokenfcnsrefs, "Follow function references as well if function analysis was failed");
|
2015-11-24 15:01:26 +03:00
|
|
|
|
2015-11-25 14:14:40 +03:00
|
|
|
SETCB("anal.searchstringrefs", "false", &cb_anal_searchstringrefs, "Search string references in data references");
|
2015-12-10 17:46:10 +03:00
|
|
|
SETCB("anal.bbs_alignment", "0x10", &cb_anal_bbs_alignment, "Possible space between basic blocks");
|
2015-12-10 18:22:24 +03:00
|
|
|
SETCB("anal.bb_max_size", "1024", &cb_anal_bb_max_size, "Maximum basic block size");
|
2016-04-14 14:27:44 +02:00
|
|
|
SETCB("anal.pushret", "false", &cb_anal_pushret, "Analyze push+ret as jmp");
|
2015-11-25 14:14:40 +03:00
|
|
|
|
2015-07-21 06:06:00 +02:00
|
|
|
SETPREF("esil.prestep", "true", "Step before esil evaluation in `de` commands");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("esil.debug", "false", &cb_esildebug, "Show ESIL debug info");
|
|
|
|
SETICB("esil.gotolimit", core->anal->esil_goto_limit, &cb_gotolimit, "Maximum number of gotos per ESIL expression");
|
2016-01-19 23:36:21 +00:00
|
|
|
SETICB("esil.stacksize", 32, &cb_esilstacksize, "Number of elements that can be pushed on the esilstack");
|
2015-03-12 16:45:23 +01:00
|
|
|
|
2010-06-02 19:17:47 +02:00
|
|
|
/* asm */
|
2013-11-05 02:58:00 +01:00
|
|
|
//asm.os needs to be first, since other asm.* depend on it
|
|
|
|
SETCB("asm.os", R_SYS_OS, &cb_asmos, "Select operating system (kernel) (linux, darwin, w32,..)");
|
2014-09-23 10:15:19 +02:00
|
|
|
SETI("asm.maxrefs", 5, "Maximum number of xrefs to be displayed as list (use columns above)");
|
2015-08-31 00:20:07 +02:00
|
|
|
SETCB("asm.invhex", "false", &cb_asm_invhex, "Show invalid instructions as hexadecimal numbers");
|
|
|
|
SETPREF("asm.bytes", "true", "Display the bytes of each instruction");
|
2014-10-16 02:16:52 +02:00
|
|
|
SETPREF("asm.flagsinbytes", "false", "Display flags inside the bytes space");
|
2015-12-17 20:18:50 +01:00
|
|
|
SETICB("asm.midflags", 1, &cb_midflags, "Realign disassembly if there is a flag in the middle of an instruction");
|
2015-08-21 22:58:21 -07:00
|
|
|
SETPREF("asm.cmtflgrefs", "true", "Show comment flags associated to branch reference");
|
2014-11-13 03:36:48 +01:00
|
|
|
SETPREF("asm.cmtright", "true", "Show comments at right of disassembly if they fit in screen");
|
2014-11-14 15:49:34 +01:00
|
|
|
SETI("asm.cmtcol", 70, "Align comments at column 60");
|
2015-10-14 02:11:53 +02:00
|
|
|
SETICB("asm.pcalign", 0, &cb_asm_pcalign, "Only recognize as valid instructions aligned to this value");
|
2016-09-14 19:23:11 +03:00
|
|
|
SETPREF("asm.calls", "true", "Show callee function related info as comments in disasm");
|
2015-11-23 01:40:35 +01:00
|
|
|
SETPREF("asm.bbline", "false", "Show empty line after every basic block");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.comments", "true", "Show comments in disassembly view");
|
2016-01-27 02:25:25 +01:00
|
|
|
SETPREF("asm.jmphints", "true", "Show jump hints [numbers] in disasm");
|
2016-09-06 02:48:01 +02:00
|
|
|
SETPREF("asm.leahints", "false", "Show LEA hints [numbers] in disasm");
|
2015-08-26 03:27:34 +02:00
|
|
|
SETPREF("asm.slow", "true", "Perform slow analysis operations in disasm");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.decode", "false", "Use code analysis as a disassembler");
|
2016-03-04 00:33:24 +01:00
|
|
|
SETPREF("asm.flgoff", "false", "Show offset in flags");
|
2014-08-05 05:37:48 +02:00
|
|
|
SETPREF("asm.indent", "false", "Indent disassembly based on reflines depth");
|
2015-08-12 10:40:24 +02:00
|
|
|
SETI("asm.indentspace", 2, "How many spaces to indent the code");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.dwarf", "false", "Show dwarf comment at disassembly");
|
2013-11-13 01:51:15 +01:00
|
|
|
SETPREF("asm.esil", "false", "Show ESIL instead of mnemonic");
|
2016-01-10 22:30:10 +01:00
|
|
|
SETPREF("asm.nodup", "false", "Do not show dupped instructions (collapse disasm)");
|
2015-09-11 23:46:09 +02:00
|
|
|
SETPREF("asm.emu", "false", "Run ESIL emulation analysis on disasm");
|
2016-09-03 20:31:30 +02:00
|
|
|
SETCB("asm.emustr", "false", &cb_emustr, "Show only strings if any in the asm.emu output");
|
2015-10-29 23:37:51 +01:00
|
|
|
SETPREF("asm.emuwrite", "false", "Allow asm.emu to modify memory (WARNING)");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.filter", "true", "Replace numeric values by flags (e.g. 0x4003e0 -> sym.imp.printf)");
|
2014-07-21 04:18:27 +02:00
|
|
|
SETPREF("asm.fcnlines", "true", "Show function boundary lines");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.flags", "true", "Show flags");
|
|
|
|
SETPREF("asm.lbytes", "true", "Align disasm bytes to left");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.lines", "true", "Show ASCII-art lines at disassembly");
|
2015-08-31 00:20:07 +02:00
|
|
|
SETPREF("asm.lines.call", "false", "Enable call lines");
|
|
|
|
SETPREF("asm.lines.ret", "false", "Show separator lines after ret");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.linesout", "true", "Show out of block lines");
|
|
|
|
SETPREF("asm.linesright", "false", "Show lines before opcode instead of offset");
|
|
|
|
SETPREF("asm.lineswide", "false", "Put a space between lines");
|
2014-09-17 11:01:36 +02:00
|
|
|
SETICB("asm.lineswidth", 7, &cb_asmlineswidth, "Number of columns for program flow arrows");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.middle", "false", "Allow disassembling jumps in the middle of an instruction");
|
|
|
|
SETPREF("asm.offset", "true", "Show offsets at disassembly");
|
2016-03-04 00:33:24 +01:00
|
|
|
SETPREF("asm.spacy", "false", "Spacy disasm after calls and before flags");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.reloff", "false", "Show relative offsets instead of absolute address in disasm");
|
2016-08-25 20:27:52 +02:00
|
|
|
SETPREF("asm.reloff.flags", "false", "Show relative offsets to flags (not only functions)");
|
2014-11-22 05:39:52 +01:00
|
|
|
SETPREF("asm.section", "false", "Show section name before offset");
|
2016-04-08 02:56:42 +02:00
|
|
|
SETI("asm.section.col", 20, "Columns width to show asm.section");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.pseudo", "false", "Enable pseudo syntax");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.size", "false", "Show size of opcodes in disassembly (pd)");
|
|
|
|
SETPREF("asm.stackptr", "false", "Show stack pointer at disassembly");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.cyclespace", "false", "Indent instructions depending on CPU-cycles");
|
|
|
|
SETPREF("asm.cycles", "false", "Show CPU-cycles taken by instruction at disassembly");
|
2013-12-04 00:47:34 +01:00
|
|
|
SETI("asm.tabs", 0, "Use tabs in disassembly");
|
2015-07-15 15:14:51 +02:00
|
|
|
SETPREF("asm.tabsonce", "false", "Only tabulate the opcode, not the arguments");
|
2015-07-15 17:30:34 +02:00
|
|
|
SETI("asm.tabsoff", 0, "tabulate spaces after the offset");
|
2014-07-02 18:12:07 +02:00
|
|
|
SETPREF("asm.trace", "false", "Show execution traces for each opcode");
|
2014-11-02 02:19:31 +01:00
|
|
|
SETPREF("asm.tracespace", "false", "Indent disassembly with trace.count information");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.ucase", "false", "Use uppercase syntax at disassembly");
|
2015-01-11 04:29:15 +01:00
|
|
|
SETPREF("asm.vars", "true", "Show local function variables in disassembly");
|
|
|
|
SETPREF("asm.varxs", "false", "Show accesses of local variables");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.varsub", "true", "Substitute variables in disassembly");
|
2016-09-06 10:22:57 +02:00
|
|
|
SETPREF("asm.relsub", "true", "Substitute pc relative expressions in disasm");
|
2015-06-02 01:04:10 +02:00
|
|
|
SETPREF("asm.cmtfold", "false", "Fold comments, toggle with Vz");
|
2015-10-03 13:52:52 +02:00
|
|
|
SETPREF("asm.family", "false", "Show family name in disasm");
|
2016-03-29 02:03:17 +02:00
|
|
|
SETPREF("asm.symbol", "false", "Show symbol+delta instead of absolute offset");
|
2016-04-08 02:56:42 +02:00
|
|
|
SETI("asm.symbol.col", 40, "Columns width to show asm.section");
|
2016-05-30 18:53:32 +02:00
|
|
|
SETCB("asm.assembler", "", &cb_asmassembler, "Set the plugin name to use when assembling");
|
2015-03-23 10:19:53 +01:00
|
|
|
SETCB("asm.arch", R_SYS_ARCH, &cb_asmarch, "Set the arch to be used by asm");
|
2015-02-11 03:50:56 +01:00
|
|
|
SETCB("asm.features", "", &cb_asmfeatures, "Specify supported features by the target CPU (=? for help)");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("asm.cpu", R_SYS_ARCH, &cb_asmcpu, "Set the kind of asm.arch cpu");
|
|
|
|
SETCB("asm.parser", "x86.pseudo", &cb_asmparser, "Set the asm parser to use");
|
|
|
|
SETCB("asm.segoff", "false", &cb_segoff, "Show segmented address in prompt (x86-16)");
|
|
|
|
SETCB("asm.syntax", "intel", &cb_asmsyntax, "Select assembly syntax");
|
|
|
|
SETI("asm.nbytes", 6, "Number of bytes for each opcode at disassembly");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("asm.bytespace", "false", "Separate hexadecimal bytes with a whitespace");
|
2015-09-01 03:13:16 +02:00
|
|
|
#if R_SYS_BITS == R_SYS_BITS_64
|
|
|
|
SETICB("asm.bits", 64, &cb_asmbits, "Word size in bits at assembler");
|
|
|
|
#else
|
2013-11-05 02:58:00 +01:00
|
|
|
SETICB("asm.bits", 32, &cb_asmbits, "Word size in bits at assembler");
|
2015-09-01 03:13:16 +02:00
|
|
|
#endif
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.functions", "true", "Show functions in disassembly");
|
2015-01-28 17:05:18 +01:00
|
|
|
SETPREF("asm.fcncalls", "true", "Show functions calls");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("asm.xrefs", "true", "Show xrefs in disassembly");
|
2014-09-24 03:01:18 +02:00
|
|
|
SETPREF("asm.demangle", "true", "Show demangled symbols in disasm");
|
2015-03-08 02:27:39 +01:00
|
|
|
SETPREF("asm.describe", "false", "Show opcode description");
|
Add asm.hints and handle CDOV deoptimization
CDIV deoptimization
===================
This patch implements hints in the disassembler that
aim to assist the user in reading compiler-optimized divisions
by analysing the involved magic number.
Background
==========
Since integer divisions are usually very expensive on most architectures,
compilers try very hard to substitute them with cheaper operations.
One of the more advanced substitutions is described in the book __Hacker's Delight__,
chapter 10.
An actual implementation of the described algorithm in LLVM can be found in the
functions: `TargetLowering::BuildSDIV()` and `APInt::magic()`.
The optimization approximately transforms e.g.
```asm
xor edx, edx
idiv 39
```
into
```asm
mov eax, edi
mov edx, 0xd20d20d3
imul edx
lea eax, [rdx + rdi]
sar edi, 0x1f
sar eax, 5
sub eax, edi
```
Reading the optimized version and __seeing__ the constant 39 seems difficult.
Therefore I try to provide a small hint to the user.
Limitations
===========
* The current implementation only takes the magic number into account,
therefore it may result in false positives.
* Due to the nature of the optimization, the given hint may be off by a power of two.
Fixing this would require to analyse the following shift instructions.
* The hint is only shown in the line containing the magic number.
The user still has to know which of the following instructions belong to the optimization.
TODO
====
* Implement the corresponding analysis for unsigned integers
* Implement the corresponding analysis for 64-bit integers.
* Improve the heuristic by also looking at the next few instructions.
( I don't really know how to iterate over the instructions in the disassember
in a non-deprecated way. Maybe someone can drop me a hint? )
* Implement an exact analysis using the actual dataflow in radeco and use it
to revert the optimization. ( I suppose this is outside the scope of radare )
2016-06-15 15:18:04 +02:00
|
|
|
SETPREF("asm.hints", "false", "Show hints for magic numbers in disasm");
|
2015-07-15 00:22:20 +02:00
|
|
|
SETPREF("asm.marks", "true", "Show marks before the disassembly");
|
2016-08-25 18:41:49 +02:00
|
|
|
SETPREF("asm.cmtrefs", "false", "Show flag and comments from refs in disasm");
|
2015-10-13 03:50:14 +02:00
|
|
|
SETCB("bin.strpurge", "false", &cb_strpurge, "Try to purge false positive strings");
|
2016-05-09 17:24:12 +02:00
|
|
|
SETPREF("bin.libs", "false", "Try to load libraries after loading main binary");
|
2015-10-13 03:50:14 +02:00
|
|
|
SETCB("bin.strfilter", "", &cb_strfilter, "Filter strings (?:help, a:scii, e:mail, p:ath, u:rl, 8:utf8)");
|
2015-07-04 23:42:48 +02:00
|
|
|
SETCB("bin.filter", "true", &cb_binfilter, "Filter symbol names to fix dupped names");
|
2015-01-11 19:40:26 +01:00
|
|
|
SETCB("bin.force", "", &cb_binforce, "Force that rbin plugin");
|
2015-01-10 01:00:01 +01:00
|
|
|
SETPREF("bin.lang", "", "Language for bin.demangle");
|
2016-03-12 18:01:12 +01:00
|
|
|
SETPREF("bin.demangle", "true", "Import demangled symbols from RBin");
|
2016-05-03 04:31:36 +02:00
|
|
|
SETCB("bin.demanglecmd", "false", &cb_bdc, "run xcrun swift-demangle and similar if available (SLOW)");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
2012-12-13 09:22:17 +01:00
|
|
|
/* bin */
|
2015-09-09 23:40:09 +02:00
|
|
|
SETI("bin.baddr", -1, "Base address of the binary");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("bin.laddr", 0, "Base address for loading library ('*.so')");
|
2016-04-25 17:07:18 +04:00
|
|
|
SETPREF("bin.dbginfo", "true", "Load debug information on startup if available");
|
2013-12-05 23:51:17 -06:00
|
|
|
SETICB("bin.minstr", 0, &cb_binminstr, "Minimum string length for r_bin");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("bin.maxstr", 0, &cb_binmaxstr, "Maximum string length for r_bin");
|
2015-10-13 03:50:14 +02:00
|
|
|
SETICB("bin.maxstrbuf", 1024*1024*10, & cb_binmaxstrbuf, "Maximum size of range to load strings from");
|
2015-10-22 20:26:24 +02:00
|
|
|
SETCB("bin.prefix", NULL, &cb_binprefix, "Prefix all symbols/sections/relocs with a specific string");
|
2014-05-19 02:41:53 +02:00
|
|
|
SETCB("bin.rawstr", "false", &cb_rawstr, "Load strings from raw binaries");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("bin.strings", "true", "Load strings from rbin on startup");
|
2015-08-11 15:58:01 +02:00
|
|
|
SETPREF("bin.classes", "true", "Load classes from rbin on startup");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* cfg */
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cfg.plugins", "true", "Load plugins at startup");
|
2015-04-03 23:24:09 +02:00
|
|
|
SETCB("time.fmt", "%Y-%m-%d %H:%M:%S %z", &cb_cfgdatefmt, "Date format (%Y-%m-%d %H:%M:%S %z)");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("time.zone", 0, &cb_timezone, "Time zone, in hours relative to GMT: +2, -1,..");
|
|
|
|
SETCB("cfg.debug", "false", &cb_cfgdebug, "Debugger mode");
|
2011-05-21 14:27:46 +02:00
|
|
|
p = r_sys_getenv ("EDITOR");
|
2015-01-26 21:41:57 +03:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
2011-11-23 02:29:09 +01:00
|
|
|
r_config_set (cfg, "cfg.editor", p? p: "notepad");
|
|
|
|
#else
|
2011-05-21 14:27:46 +02:00
|
|
|
r_config_set (cfg, "cfg.editor", p? p: "vi");
|
2011-11-23 02:29:09 +01:00
|
|
|
#endif
|
2011-08-27 20:25:37 +02:00
|
|
|
free (p);
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_desc (cfg, "cfg.editor", "Select default editor program");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cfg.user", r_sys_whoami (buf), "Set current username/pid");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("cfg.fortunes", "true", "If enabled show tips at start");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cfg.fortunetype", "tips,fun", "Type of fortunes to show (tips, fun, nsfw)");
|
|
|
|
SETI("cfg.hashlimit", SLURP_LIMIT, "If the file is bigger than hashlimit, do not compute hashes");
|
|
|
|
SETPREF("cfg.prefixdump", "dump", "Filename prefix for automated dumps");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("cfg.sandbox", "false", &cb_cfgsanbox, "Sandbox mode disables systems and open on upper directories");
|
|
|
|
SETPREF("cfg.wseek", "false", "Seek after write");
|
2016-04-26 19:09:15 +10:00
|
|
|
SETCB("cfg.bigendian", "false", &cb_bigendian, "Use little (false) or big (true) endianness");
|
2016-09-04 14:02:27 +02:00
|
|
|
SETI("cfg.minzlen", 2, "Minimum zignature length to filter in 'zg'");
|
2016-09-18 23:07:48 +02:00
|
|
|
SETI("cfg.maxzlen", 500, "Maximum zignature length to filter in 'zg'");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* diff */
|
|
|
|
SETI("diff.from", 0, "Set source diffing address for px (uses cc command)");
|
|
|
|
SETI("diff.to", 0, "Set destination diffing address for px (uses cc command)");
|
2014-12-26 11:24:49 +10:30
|
|
|
SETPREF("diff.bare", "false", "Never show function names in diff output");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* dir */
|
|
|
|
SETPREF("dir.magic", R_MAGIC_PATH, "Path to r_magic files");
|
2015-10-23 02:58:48 +02:00
|
|
|
#if __WINDOWS__
|
|
|
|
SETPREF("dir.plugins", "plugins", "Path to plugin files to be loaded at startup");
|
|
|
|
#else
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("dir.plugins", R2_LIBDIR"/radare2/"R2_VERSION"/", "Path to plugin files to be loaded at startup");
|
2015-10-23 02:58:48 +02:00
|
|
|
#endif
|
2015-10-29 12:37:14 +01:00
|
|
|
SETCB("dir.source", "", &cb_dirsrc, "Path to find source files");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("dir.types", "/usr/include", "Default path to look for cparse type files");
|
2015-01-24 21:18:26 +01:00
|
|
|
#if __ANDROID__
|
2015-04-22 04:50:37 +02:00
|
|
|
SETPREF("dir.projects", "/data/data/org.radare2.installer/radare2/projects", "Default path for projects");
|
2015-06-11 12:12:22 +02:00
|
|
|
#elif __WINDOWS__
|
|
|
|
SETPREF("dir.projects", "~\\"R2_HOMEDIR"\\projects", "Default path for projects");
|
2015-01-24 21:18:26 +01:00
|
|
|
#else
|
2014-02-22 02:36:24 +01:00
|
|
|
SETPREF("dir.projects", "~/"R2_HOMEDIR"/projects", "Default path for projects");
|
2015-01-24 21:18:26 +01:00
|
|
|
#endif
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("stack.bytes", "true", "Show bytes instead of words in stack");
|
2014-09-27 03:48:54 +02:00
|
|
|
SETPREF("stack.anotated", "false", "Show anotated hexdump in visual debug");
|
2016-08-17 09:09:19 -04:00
|
|
|
SETI("stack.size", 64, "Size in bytes of stack hexdump in visual debug");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("stack.delta", 0, "Delta for the stack dump");
|
2014-09-27 03:48:54 +02:00
|
|
|
|
2015-10-13 02:18:14 +02:00
|
|
|
SETCB("dbg.libs", "", &cb_dbg_libs, "If set stop when loading matching libname");
|
2016-01-22 10:53:58 +01:00
|
|
|
SETI("dbg.hwbp", 0, "Set HW or SW breakpoints");
|
2015-10-13 02:18:14 +02:00
|
|
|
SETCB("dbg.unlibs", "", &cb_dbg_unlibs, "If set stop when unloading matching libname");
|
2015-09-28 02:04:08 +02:00
|
|
|
SETPREF("dbg.slow", "false", "Show stack and regs in visual mode in a slow but verbose mode");
|
|
|
|
|
2015-07-09 02:24:48 +02:00
|
|
|
SETPREF("dbg.bpinmaps", "true", "Force breakpoints to be inside a valid map");
|
2014-10-17 00:38:37 +02:00
|
|
|
SETCB("dbg.forks", "false", &cb_dbg_forks, "Stop execution if fork() is done (see dbg.threads)");
|
2015-06-29 22:23:04 +02:00
|
|
|
SETCB("dbg.btalgo", "fuzzy", &cb_dbg_btalgo, "Select backtrace algorithm");
|
2014-10-17 00:38:37 +02:00
|
|
|
SETCB("dbg.threads", "false", &cb_stopthreads, "Stop all threads when debugger breaks (see dbg.forks)");
|
2014-10-09 01:21:49 +02:00
|
|
|
SETCB("dbg.clone", "false", &cb_dbg_clone, "Stop execution if new thread is created");
|
|
|
|
SETCB("dbg.execs", "false", &cb_dbg_execs, "Stop execution if new thread is created");
|
2014-07-09 02:24:31 +02:00
|
|
|
SETCB("dbg.profile", "", &cb_runprofile, "Path to RRunProfile file");
|
2015-09-30 13:10:49 +02:00
|
|
|
SETCB("dbg.args", "", &cb_dbg_args, "Set the args of the program to debug");
|
2013-11-05 02:58:00 +01:00
|
|
|
/* debug */
|
2015-10-31 01:57:52 +01:00
|
|
|
SETCB("dbg.status", "false", &cb_dbgstatus, "Set cmd.prompt to '.dr*' or '.dr*;drd;sr PC;pi 1;s-'");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("dbg.backend", "native", &cb_dbgbackend, "Select the debugger backend");
|
2014-05-07 23:21:34 +02:00
|
|
|
SETCB("dbg.bep", "loader", &cb_dbgbep, "break on entrypoint (loader, entry, constructor, main)");
|
2016-07-03 20:05:01 +02:00
|
|
|
if (core->cons->rows > 30) { // HACKY
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_set_i (cfg, "dbg.follow", 64);
|
2016-07-03 20:05:01 +02:00
|
|
|
} else {
|
|
|
|
r_config_set_i (cfg, "dbg.follow", 32);
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_desc (cfg, "dbg.follow", "Follow program counter when pc > core->offset + dbg.follow");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("dbg.swstep", "false", &cb_swstep, "Force use of software steps (code analysis+breakpoint)");
|
2015-06-12 00:56:43 +02:00
|
|
|
SETPREF("dbg.shallow_trace", "false", "While tracing, avoid following calls outside specified range");
|
2016-04-22 16:18:33 +03:00
|
|
|
SETPREF("dbg.exitkills", "true", "Kill process on exit");
|
2014-10-26 01:26:41 +02:00
|
|
|
|
|
|
|
r_config_set_getter (cfg, "dbg.swstep", (RConfigCallback)__dbg_swstep_getter);
|
|
|
|
|
2014-09-26 13:57:03 +02:00
|
|
|
// TODO: This should be specified at first by the debug backend when attaching
|
|
|
|
#if __arm__ || __mips__
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("dbg.bpsize", 4, &cb_dbgbpsize, "Size of software breakpoints");
|
2014-09-26 13:57:03 +02:00
|
|
|
#else
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("dbg.bpsize", 1, &cb_dbgbpsize, "Size of software breakpoints");
|
2014-09-26 13:57:03 +02:00
|
|
|
#endif
|
2015-08-22 20:19:33 +08:00
|
|
|
SETICB("dbg.btdepth", 128, &cb_dbgbtdepth, "Depth of backtrace");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("dbg.trace", "false", &cb_trace, "Trace program execution (see asm.trace)");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("dbg.trace.tag", 0, &cb_tracetag, "Trace tag");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* cmd */
|
2016-09-04 13:31:25 +02:00
|
|
|
char *xdotPath = r_file_path ("xdot");
|
|
|
|
if (r_file_exists (xdotPath)) {
|
2016-09-03 17:57:30 +02:00
|
|
|
r_config_set (cfg, "cmd.graph", "ag $$ > a.dot;!xdot a.dot");
|
2016-07-03 20:05:01 +02:00
|
|
|
} else {
|
2016-09-03 17:57:30 +02:00
|
|
|
char *dotPath = r_file_path ("dot");
|
2016-09-04 13:31:25 +02:00
|
|
|
if (r_file_exists (dotPath)) {
|
2016-09-03 17:57:30 +02:00
|
|
|
R_FREE (dotPath);
|
2016-09-04 13:31:25 +02:00
|
|
|
char *viewer = getViewerPath();
|
|
|
|
if (viewer) {
|
|
|
|
char *cmd = r_str_newf ("ag $$>a.dot;!dot -Tgif -oa.gif a.dot;!%s a.gif", viewer);
|
|
|
|
r_config_set (cfg, "cmd.graph", cmd);
|
|
|
|
free (viewer);
|
|
|
|
free (cmd);
|
2016-09-03 17:57:30 +02:00
|
|
|
} else {
|
|
|
|
r_config_set (cfg, "cmd.graph", "?e cannot find a valid picture viewer");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
r_config_set (cfg, "cmd.graph", "agf");
|
|
|
|
}
|
2016-09-04 13:31:25 +02:00
|
|
|
free (dotPath);
|
2016-07-03 20:05:01 +02:00
|
|
|
}
|
2016-09-04 13:31:25 +02:00
|
|
|
free (xdotPath);
|
2016-09-02 17:14:52 +02:00
|
|
|
r_config_desc (cfg, "cmd.graph", "Command executed by 'agv' command to view graphs");
|
2014-10-07 00:56:39 +02:00
|
|
|
SETPREF("cmd.xterm", "xterm -bg black -fg gray -e", "xterm command to spawn with V@");
|
2013-12-22 01:53:15 +01:00
|
|
|
SETICB("cmd.depth", 10, &cb_cmddepth, "Maximum command depth");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cmd.bp", "", "Run when a breakpoint is hit");
|
2016-09-01 19:11:46 +02:00
|
|
|
SETICB("cmd.hitinfo", 1, &cb_debug_hitinfo, "Show info when a tracepoint/breakpoint is hit");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cmd.times", "", "Run when a command is repeated (number prefix)");
|
2014-09-27 03:48:54 +02:00
|
|
|
SETPREF("cmd.stack", "", "Command to display the stack in visual debug mode");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("cmd.cprompt", "", "Column visual prompt commands");
|
2014-10-23 03:29:05 +02:00
|
|
|
SETPREF("cmd.gprompt", "", "Graph visual prompt commands");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cmd.hit", "", "Run when a search hit is found");
|
|
|
|
SETPREF("cmd.open", "", "Run when file is opened");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("cmd.prompt", "", "Prompt commands");
|
|
|
|
SETCB("cmd.repeat", "true", &cb_cmdrepeat, "Alias newline (empty command) as '..'");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("cmd.fcn.new", "", "Run when new function is analyzed");
|
|
|
|
SETPREF("cmd.fcn.delete", "", "Run when a function is deleted");
|
|
|
|
SETPREF("cmd.fcn.rename", "", "Run when a function is renamed");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("cmd.visual", "", "Replace current print mode");
|
|
|
|
SETPREF("cmd.vprompt", "", "Visual prompt commands");
|
|
|
|
|
2015-09-08 02:53:33 +02:00
|
|
|
SETCB("cmd.esil.intr", "", &cb_cmd_esil_intr, "Command to run when an esil interrupt happens");
|
2015-09-19 19:39:25 +02:00
|
|
|
SETCB("cmd.esil.trap", "", &cb_cmd_esil_trap, "Command to run when an esil trap happens");
|
2015-09-08 02:53:33 +02:00
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
/* filesystem */
|
|
|
|
SETCB("fs.view", "normal", &cb_fsview, "Set visibility options for filesystems");
|
|
|
|
|
|
|
|
/* hexdump */
|
2014-04-10 22:18:26 +02:00
|
|
|
SETCB("hex.pairs", "true", &cb_hexpairs, "Show bytes paired in 'px' hexdump");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("hex.flagsz", 0, "If non zero, overrides the flag size in pxa");
|
|
|
|
SETICB("hex.cols", 16, &cb_hexcols, "Number of columns in hexdump");
|
2016-01-09 01:58:57 +01:00
|
|
|
SETI("hex.depth", 5, "Maximal level of recurrence while telescoping memory");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("hex.onechar", "false", "Number of columns in hexdump");
|
|
|
|
SETICB("hex.stride", 0, &cb_hexstride, "Line stride in hexdump (default is 0)");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* http */
|
2015-04-11 18:54:35 +02:00
|
|
|
SETPREF("http.cors", "false", "Enable CORS");
|
2016-03-28 23:38:45 +02:00
|
|
|
SETPREF("http.referer", "", "CSFR protection if set");
|
2014-06-22 14:57:54 +02:00
|
|
|
SETPREF("http.dirlist", "false", "Enable directory listing");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("http.allow", "", "Only accept clients from the comma separated IP list");
|
2012-09-06 03:12:54 +02:00
|
|
|
#if __WINDOWS__
|
|
|
|
r_config_set (cfg, "http.browser", "start");
|
|
|
|
#else
|
2016-07-03 20:05:01 +02:00
|
|
|
if (r_file_exists ("/usr/bin/openURL")) { // iOS ericautils
|
2014-01-20 03:03:45 +01:00
|
|
|
r_config_set (cfg, "http.browser", "/usr/bin/openURL");
|
2016-07-03 20:05:01 +02:00
|
|
|
} else if (r_file_exists ("/system/bin/toolbox")) {
|
2012-09-06 03:12:54 +02:00
|
|
|
r_config_set (cfg, "http.browser",
|
2013-11-05 02:58:00 +01:00
|
|
|
"LD_LIBRARY_PATH=/system/lib am start -a android.intent.action.VIEW -d");
|
2016-07-03 20:05:01 +02:00
|
|
|
} else if (r_file_exists ("/usr/bin/xdg-open")) {
|
2012-09-06 03:12:54 +02:00
|
|
|
r_config_set (cfg, "http.browser", "xdg-open");
|
2016-07-03 20:05:01 +02:00
|
|
|
} else if (r_file_exists ("/usr/bin/open")) {
|
2012-09-06 03:12:54 +02:00
|
|
|
r_config_set (cfg, "http.browser", "open");
|
2016-07-03 20:05:01 +02:00
|
|
|
} else {
|
|
|
|
r_config_set (cfg, "http.browser", "firefox");
|
|
|
|
}
|
2015-05-07 15:49:25 +02:00
|
|
|
r_config_desc (cfg, "http.browser", "Command to open HTTP URLs");
|
2013-11-05 02:58:00 +01:00
|
|
|
#endif
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("http.maxsize", 0, "Maximum file size for upload");
|
|
|
|
SETPREF("http.bind", "localhost", "Server address");
|
2016-05-16 00:59:29 +02:00
|
|
|
SETPREF("http.homeroot", "~/.config/radare2/www", "http home root directory");
|
2016-04-26 03:13:00 +02:00
|
|
|
#if __ANDROID__
|
|
|
|
SETPREF("http.root", "/data/data/org.radare2.installer/www", "http root directory");
|
|
|
|
#elif __WINDOWS__
|
|
|
|
SETPREF("http.root", "www", "http root directory");
|
2014-04-21 12:55:34 +02:00
|
|
|
#else
|
2016-04-26 03:13:00 +02:00
|
|
|
SETPREF("http.root", R2_WWWROOT, "http root directory");
|
2014-04-21 12:55:34 +02:00
|
|
|
#endif
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("http.port", "9090", "Server port");
|
2015-07-10 00:02:26 +02:00
|
|
|
SETPREF("http.ui", "m", "Default webui (enyo, m, p, t)");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("http.sandbox", "false", "Sandbox the HTTP server");
|
|
|
|
SETI("http.timeout", 3, "Disconnect clients after N seconds of inactivity");
|
|
|
|
SETI("http.dietime", 0, "Kill server after N seconds with no client");
|
|
|
|
SETPREF("http.verbose", "true", "Output server logs to stdout");
|
|
|
|
SETPREF("http.upget", "false", "/up/ answers GET requests, in addition to POST");
|
|
|
|
SETPREF("http.upload", "false", "Enable file uploads to /up/<filename>");
|
|
|
|
SETPREF("http.uri", "", "Address of HTTP proxy");
|
2013-01-03 00:47:58 +01:00
|
|
|
tmpdir = r_file_tmpdir ();
|
|
|
|
r_config_set (cfg, "http.uproot", tmpdir);
|
|
|
|
free (tmpdir);
|
2016-07-03 20:05:01 +02:00
|
|
|
r_config_desc (cfg, "http.uproot", "Path where files are uploaded");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* graph */
|
2016-05-04 00:11:28 +02:00
|
|
|
SETPREF("graph.refs", "false", "Graph references in callgraphs (.agc*;aggi)");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("graph.font", "Courier", "Font for dot graphs");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("graph.offset", "false", "Show offsets in graphs");
|
2016-09-02 17:14:52 +02:00
|
|
|
SETPREF("graph.web", "false", "Display graph in web browser (VV)");
|
2014-12-22 04:16:50 +01:00
|
|
|
SETI("graph.from", UT64_MAX, "");
|
|
|
|
SETI("graph.to", UT64_MAX, "");
|
2015-06-29 23:49:38 +02:00
|
|
|
SETI("graph.scroll", 5, "Scroll speed in ascii-art graph");
|
2015-07-16 18:02:14 +01:00
|
|
|
SETPREF("graph.invscroll", "false", "Invert scroll direction in ascii-art graph");
|
2015-07-18 12:49:09 +02:00
|
|
|
SETPREF("graph.title", "", "Title of the graph");
|
2016-05-10 21:12:50 +01:00
|
|
|
SETPREF("graph.gv.node", "", "Graphviz node style. (color=gray, style=filled shape=box)");
|
|
|
|
SETPREF("graph.gv.edge", "", "Graphviz edge style. (arrowhead=\"vee\")");
|
|
|
|
SETPREF("graph.gv.graph", "", "Graphviz global style attributes. (bgcolor=white)");
|
|
|
|
SETPREF("graph.gv.current", "false", "Highlight the current node in graphviz graph.");
|
2016-05-12 12:29:00 +02:00
|
|
|
SETPREF("graph.nodejmps", "false", "Enables shortcuts for every node.");
|
2013-11-05 02:58:00 +01:00
|
|
|
/* hud */
|
2014-08-30 01:22:34 +02:00
|
|
|
SETPREF("hud.path", "", "Set a custom path for the HUD file");
|
2013-09-16 04:08:08 +02:00
|
|
|
|
2015-09-23 12:46:22 +02:00
|
|
|
SETCB("esil.exectrap", "false", &cb_exectrap, "trap when executing code in non-executable memory");
|
2015-09-09 01:17:55 +02:00
|
|
|
SETCB("esil.iotrap", "true", &cb_iotrap, "invalid read or writes produce a trap exception");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("esil.romem", "false", "Set memory as read-only for ESIL");
|
|
|
|
SETPREF("esil.stats", "false", "Statistics from ESIL emulation stored in sdb");
|
2016-08-05 14:35:44 +03:00
|
|
|
SETPREF("esil.nonull", "false", "Prevent memory read, memory write at null pointer");
|
2014-09-11 04:18:23 +02:00
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
/* scr */
|
2013-09-16 04:08:08 +02:00
|
|
|
#if __EMSCRIPTEN__
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_set_cb (cfg, "scr.fgets", "true", cb_scrfgets);
|
2013-09-16 04:08:08 +02:00
|
|
|
#else
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_set_cb (cfg, "scr.fgets", "false", cb_scrfgets);
|
2013-09-16 04:08:08 +02:00
|
|
|
#endif
|
2015-05-07 15:49:25 +02:00
|
|
|
r_config_desc (cfg, "scr.fgets", "Use fgets() instead of dietline for prompt input");
|
2014-10-30 22:58:51 +01:00
|
|
|
SETCB("scr.echo", "false", &cb_screcho, "Show rcons output in realtime to stderr and buffer");
|
2016-09-20 00:11:59 +02:00
|
|
|
SETCB("scr.flush", "false", &cb_scrflush, "Force flush to console in realtime (breaks scripting)");
|
2016-08-25 20:27:52 +02:00
|
|
|
/* TODO: rename to asm.color.ops ? */
|
|
|
|
SETPREF("scr.color.ops", "true", "Colorize numbers and registers in opcodes");
|
|
|
|
SETPREF("scr.color.bytes", "true", "Colorize bytes that represent the opcodes of the instruction");
|
2015-11-01 05:10:49 +01:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
|
|
|
SETCB("scr.ansicon", r_str_bool (r_cons_singleton()->ansicon),
|
|
|
|
&scr_ansicon, "Use ANSICON mode or not on Windows");
|
|
|
|
#endif
|
2014-09-22 15:00:41 +02:00
|
|
|
#if __ANDROID__
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("scr.responsive", "true", "Auto-adjust Visual depending on screen (e.g. unset asm.bytes)");
|
2014-09-22 15:00:41 +02:00
|
|
|
#else
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("scr.responsive", "false", "Auto-adjust Visual depending on screen (e.g. unset asm.bytes)");
|
2014-09-22 15:00:41 +02:00
|
|
|
#endif
|
2016-02-21 01:56:50 +01:00
|
|
|
SETPREF("scr.wheelnkey", "false", "Use sn/sp and scr.nkey on wheel instead of scroll");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("scr.wheel", "true", "Mouse wheel in Visual; temporaryly disable/reenable by right click/Enter)");
|
2015-05-19 00:18:14 +02:00
|
|
|
SETPREF("scr.atport", "false", "V@ starts a background http server and spawns an r2 -C");
|
2015-09-14 16:22:57 +02:00
|
|
|
SETI("scr.wheelspeed", 4, "Mouse wheel speed");
|
2014-10-06 02:36:22 +02:00
|
|
|
// DEPRECATED: USES hex.cols now SETI("scr.colpos", 80, "Column position of cmd.cprompt in visual");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("scr.columns", 0, &cb_scrcolumns, "Force console column count (width)");
|
|
|
|
SETCB("scr.rows", "0", &cb_scrrows, "Force console row count (height) ");
|
|
|
|
SETICB("scr.rows", 0, &cb_rows, "Force console row count (height) (duplicate?)");
|
|
|
|
SETCB("scr.fps", "false", &cb_fps, "Show FPS in Visual");
|
2014-01-09 00:29:00 +01:00
|
|
|
SETICB("scr.fix_rows", 0, &cb_fixrows, "Workaround for Linux TTY");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETICB("scr.fix_columns", 0, &cb_fixcolumns, "Workaround for Prompt iOS SSH client");
|
|
|
|
SETCB("scr.highlight", "", &cb_scrhighlight, "Highlight that word at RCons level");
|
|
|
|
SETCB("scr.interactive", "true", &cb_scrint, "Start in interactive mode");
|
2014-09-28 03:27:22 +02:00
|
|
|
SETI("scr.feedback", 1, "Set visual feedback level (1=arrow on jump, 2=every key (useful for videos))");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("scr.html", "false", &cb_scrhtml, "Disassembly uses HTML syntax");
|
2016-02-21 01:56:50 +01:00
|
|
|
SETCB("scr.nkey", "flag", &cb_scrnkey, "Select the seek mode in visual");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("scr.pager", "", &cb_pager, "Select pager program (when output overflows the window)");
|
2016-03-06 12:35:07 +01:00
|
|
|
SETPREF("scr.randpal", "false", "Random color palete or just get the next one from 'eco'");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("scr.pipecolor", "false", "Enable colors when using pipes");
|
|
|
|
SETPREF("scr.promptfile", "false", "Show user prompt file (used by r2 -q)");
|
2015-08-11 11:49:56 +02:00
|
|
|
SETPREF("scr.promptflag", "false", "Show flag name in the prompt");
|
2015-08-11 19:42:12 +02:00
|
|
|
SETPREF("scr.promptsect", "false", "Show section name in the prompt");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("scr.prompt", "true", &cb_scrprompt, "Show user prompt (used by r2 -q)");
|
|
|
|
SETCB("scr.tee", "", &cb_teefile, "Pipe output to file of this name");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("scr.seek", "", "Seek to the specified address on startup");
|
2015-01-26 21:41:57 +03:00
|
|
|
#if __WINDOWS__ && !__CYGWIN__
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_set_cb (cfg, "scr.rgbcolor", "false", &cb_rgbcolors);
|
2013-07-17 22:12:14 +02:00
|
|
|
#else
|
2013-11-05 02:58:00 +01:00
|
|
|
r_config_set_cb (cfg, "scr.rgbcolor", "true", &cb_rgbcolors);
|
2013-07-17 22:12:14 +02:00
|
|
|
#endif
|
2015-05-07 15:49:25 +02:00
|
|
|
r_config_desc (cfg, "scr.rgbcolor", "Use RGB colors (not available on Windows)");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("scr.truecolor", "false", &cb_truecolor, "Manage color palette (0: ansi 16, 1: 256, 2: 16M)");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("scr.color", (core->print->flags&R_PRINT_FLAGS_COLOR)?"true":"false", &cb_color, "Enable colors");
|
|
|
|
SETCB("scr.null", "false", &cb_scrnull, "Show no output");
|
2015-04-20 14:44:54 +02:00
|
|
|
SETCB("scr.utf8", r_cons_is_utf8()?"true":"false",
|
|
|
|
&cb_utf8, "Show UTF-8 characters instead of ANSI");
|
2015-01-17 19:32:19 +01:00
|
|
|
SETPREF("scr.histsave", "true", "Always save history on exit");
|
2013-11-05 02:58:00 +01:00
|
|
|
/* search */
|
2014-05-31 13:44:52 +02:00
|
|
|
SETCB("search.contiguous", "true", &cb_contiguous, "Accept contiguous/adjacent search hits");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETICB("search.align", 0, &cb_searchalign, "Only catch aligned search hits");
|
2014-10-06 02:36:22 +02:00
|
|
|
SETI("search.chunk", 0, "Chunk size for /+ (default size is asm.bits/8");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("search.esilcombo", 8, "Stop search after N consecutive hits");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETI("search.count", 0, "Start index number at search hits");
|
|
|
|
SETI("search.distance", 0, "Search string distance");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("search.flags", "true", "All search results are flagged, otherwise only printed");
|
2016-02-12 11:37:48 -06:00
|
|
|
SETPREF("search.overlap", "false", "Look for overlapped search hits");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("search.maxhits", 0, "Maximum number of hits (0: no limit)");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETI("search.from", -1, "Search start address");
|
2015-10-02 02:20:09 -04:00
|
|
|
SETCB("search.in", "file", &cb_searchin, "Specify search boundaries (raw, block, file, section, range)");
|
2015-02-03 00:46:44 +01:00
|
|
|
SETICB("search.kwidx", 0, &cb_search_kwidx, "Store last search index count");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("search.prefix", "hit", "Prefix name in search hits label");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("search.show", "true", "Show search results");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETI("search.to", -1, "Search end address");
|
2014-12-14 18:19:10 -05:00
|
|
|
|
|
|
|
/* rop */
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("rop.len", 5, "Maximum ROP gadget length");
|
2016-07-05 23:41:29 +02:00
|
|
|
SETPREF("rop.db", "true", "Store rop search results in sdb");
|
2015-05-28 21:27:36 +02:00
|
|
|
SETPREF("rop.subchains", "false", "Display every length gadget from rop.len=X to 2 in /Rl");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("rop.conditional", "false", "Include conditional jump, calls and returns in ropsearch");
|
2015-05-22 01:05:00 -04:00
|
|
|
SETPREF("rop.nx", "false", "Include NX/XN/XD sections in ropsearch");
|
2015-09-30 23:47:23 -04:00
|
|
|
SETPREF("rop.comments", "false", "Display comments in rop search output");
|
2013-11-05 02:58:00 +01:00
|
|
|
|
|
|
|
/* io */
|
2014-05-18 02:19:11 +02:00
|
|
|
SETICB("io.enforce", 0, &cb_ioenforce, "Honor IO section permissions for 1=read , 2=write, 0=none");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("io.buffer", "false", &cb_iobuffer, "Load and use buffer cache if enabled");
|
2014-11-24 00:41:20 +01:00
|
|
|
SETCB("io.sectonly", "false", &cb_iosectonly, "Only read from sections (if any)");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETI("io.buffer.from", 0, "Lower address of buffered cache");
|
|
|
|
SETI("io.buffer.to", 0, "Higher address of buffered cache");
|
|
|
|
SETCB("io.cache", "false", &cb_iocache, "Enable cache for io changes");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("io.raw", "false", &cb_ioraw, "Ignore maps/sections and use raw io");
|
2014-06-10 11:20:17 +02:00
|
|
|
SETCB("io.ff", "true", &cb_ioff, "Fill invalid buffers with 0xff instead of returning error");
|
2016-05-03 23:09:00 +02:00
|
|
|
SETICB("io.0xff", 0xff, &cb_io_oxff, "Use this value instead of 0xff to fill unallocated areas");
|
2015-08-16 17:45:23 +02:00
|
|
|
SETCB("io.aslr", "false", &cb_ioaslr, "Disable ASLR for spawn and such");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETCB("io.va", "true", &cb_iova, "Use virtual address layout");
|
|
|
|
SETCB("io.autofd", "true", &cb_ioautofd, "Change fd when opening a new file");
|
|
|
|
SETCB("io.vio", "false", &cb_iovio, "Enable the new vio (reading only) (WIP)");
|
2014-10-07 19:35:15 +02:00
|
|
|
|
2013-11-05 02:58:00 +01:00
|
|
|
/* file */
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("file.desc", "", "User defined file description (used by projects)");
|
|
|
|
SETPREF("file.md5", "", "MD5 sum of current file");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("file.path", "", "Path of current file");
|
|
|
|
SETPREF("file.project", "", "Name of current project");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETPREF("file.sha1", "", "SHA1 hash of current file");
|
2013-11-05 02:58:00 +01:00
|
|
|
SETPREF("file.type", "", "Type of current file");
|
2014-04-28 11:37:48 +02:00
|
|
|
SETCB("file.loadmethod", "fail", &cb_fileloadmethod, "What to do when load addresses overlap: fail, overwrite, or append (next available)");
|
2014-01-25 18:06:17 -06:00
|
|
|
SETI("file.loadalign", 1024, "Alignment of load addresses");
|
2015-05-07 15:49:25 +02:00
|
|
|
SETI("file.openmany", 1, "Maximum number of files opened at once");
|
|
|
|
SETPREF("file.nowarn", "true", "Suppress file loading warning messages");
|
2014-04-23 18:04:25 -05:00
|
|
|
SETPREF("file.location", "", "Is the file 'local', 'remote', or 'memory'");
|
2013-11-05 02:58:00 +01:00
|
|
|
/* magic */
|
|
|
|
SETI("magic.depth", 100, "Recursivity depth in magic description strings");
|
|
|
|
|
|
|
|
/* rap */
|
|
|
|
SETPREF("rap.loop", "true", "Run rap as a forever-listening daemon");
|
|
|
|
|
2012-09-28 02:20:52 +02:00
|
|
|
/* nkeys */
|
2015-06-12 02:19:58 +02:00
|
|
|
SETPREF("key.s", "", "override step into action");
|
|
|
|
SETPREF("key.S", "", "override step over action");
|
2016-07-03 20:05:01 +02:00
|
|
|
for (i = 1; i < 13; i++) {
|
2012-08-19 03:28:17 +02:00
|
|
|
snprintf (buf, sizeof (buf), "key.f%d", i);
|
2016-07-03 20:05:01 +02:00
|
|
|
snprintf (buf + 10, sizeof (buf) - 10,
|
2013-11-05 02:58:00 +01:00
|
|
|
"Run this when F%d key is pressed in visual mode", i);
|
2012-08-19 03:28:17 +02:00
|
|
|
switch (i) {
|
2013-11-05 02:58:00 +01:00
|
|
|
case 2: p = "dbs $$"; break;
|
|
|
|
case 7: p = "ds"; break;
|
|
|
|
case 8: p = "dso"; break;
|
|
|
|
case 9: p = "dc"; break;
|
|
|
|
default: p = ""; break;
|
2012-08-19 03:28:17 +02:00
|
|
|
}
|
|
|
|
r_config_set (cfg, buf, p);
|
|
|
|
r_config_desc (cfg, buf, buf+10);
|
|
|
|
}
|
2013-11-05 02:58:00 +01:00
|
|
|
|
2011-02-17 00:58:54 +01:00
|
|
|
/* zoom */
|
2013-11-05 02:58:00 +01:00
|
|
|
SETCB("zoom.byte", "h", &cb_zoombyte, "Zoom callback to calculate each byte (See pz? for help)");
|
|
|
|
SETI("zoom.from", 0, "Zoom start address");
|
|
|
|
SETI("zoom.maxsz", 512, "Zoom max size of block");
|
|
|
|
SETI("zoom.to", 0, "Zoom end address");
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2015-12-21 22:27:05 +01:00
|
|
|
/* lines */
|
2015-12-22 02:30:34 +01:00
|
|
|
SETI("lines.from", 0, "Start address for line seek");
|
|
|
|
SETCB("lines.to", "$s", &cb_linesto, "End address for line seek");
|
2015-12-28 12:49:50 +01:00
|
|
|
SETCB("lines.abs", "false", &cb_linesabs, "Enable absolute line numbers");
|
2015-12-21 22:27:05 +01:00
|
|
|
|
2015-09-14 12:35:38 +02:00
|
|
|
r_config_lock (cfg, true);
|
|
|
|
return true;
|
2009-02-05 22:08:46 +01:00
|
|
|
}
|