本文整理汇总了C++中r_config_get_i函数的典型用法代码示例。如果您正苦于以下问题:C++ r_config_get_i函数的具体用法?C++ r_config_get_i怎么用?C++ r_config_get_i使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_config_get_i函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visual_repeat
static void visual_repeat(RCore *core) {
int atport = r_config_get_i (core->config, "scr.atport");
if (atport) {
#if __UNIX__ && !__APPLE__
int port = r_config_get_i (core->config, "http.port");
if (!r_core_rtr_http (core, '&', NULL)) {
const char *xterm = r_config_get (core->config, "cmd.xterm");
// TODO: this must be configurable
r_sys_cmdf ("%s 'r2 -C http://localhost:%d/cmd/V;sleep 1' &", xterm, port);
//xterm -bg black -fg gray -e 'r2 -C http://localhost:%d/cmd/;sleep 1' &", port);
} else {
r_cons_any_key (NULL);
}
#else
eprintf ("Unsupported on this platform\n");
r_cons_any_key (NULL);
#endif
} else {
RThread *th = r_th_new (visual_repeat_thread, core, 0);
r_th_start (th, 1);
r_cons_break (NULL, NULL);
r_cons_any_key (NULL);
eprintf ("^C \n");
core->cons->breaked = true;
r_th_wait (th);
r_cons_break_end ();
}
}
示例2: __init_seek_line
static void __init_seek_line(RCore *core) {
ut64 from, to;
r_config_bump (core->config, "lines.to");
from = r_config_get_i (core->config, "lines.from");
to = r_config_get_i (core->config, "lines.to");
if (r_core_lines_initcache (core, from, to) == -1) {
eprintf ("ERROR: \"lines.from\" and \"lines.to\" must be set\n");
}
}
示例3: bin_strings
static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
char *p, *q, str[R_FLAG_NAME_SIZE];
RBinSection *section;
int hasstr, minstr, rawstr;
RBinString *string;
RListIter *iter;
RList *list;
RBin *bin = r->bin;
RBinFile * binfile = r_core_bin_cur (r);
RBinPlugin *plugin = r_bin_file_cur_plugin (binfile);
if (!binfile) return R_FALSE;
minstr = r_config_get_i (r->config, "bin.minstr");
rawstr = r_config_get_i (r->config, "bin.rawstr");
binfile->rawstr = rawstr;
if (!(hasstr = r_config_get_i (r->config, "bin.strings")))
return 0;
if (!plugin) return 0;
if (!plugin->info) {
if (!rawstr) {
eprintf ("WARN: Use '-e bin.rawstr=true' or 'rabin2 -zz'"
" to find strings on unknown file types\n");
return R_FALSE;
}
}
if (bin->minstrlen == 0)
bin->minstrlen = plugin->minstrlen? plugin->minstrlen: 4;
if (minstr > 0 || bin->minstrlen <= 0)
bin->minstrlen = R_MIN (minstr, 4);
if ((list = r_bin_get_strings (bin)) == NULL)
return R_FALSE;
if ((mode & R_CORE_BIN_JSON)) {
r_cons_printf ("[");
r_list_foreach (list, iter, string) {
ut64 vaddr = r_bin_get_vaddr (bin, baddr,
string->vaddr, string->paddr);
ut64 paddr = string->paddr;
q = strdup (string->string);
for (p=q; *p; p++) {
if (*p=='"') *p = '\'';
if (*p=='\\') *p = '/';
}
r_cons_printf ("%s{\"vaddr\":%"PFMT64d
",\"paddr\":%"PFMT64d
",\"length\":%d,\"size\":%d,"
"\"type\":\"%s\",\"string\":\"%s\"}",
iter->p? ",": "", vaddr, paddr,
string->length, string->size,
string->type=='w'?"wide":"ascii", q);
free (q);
}
示例4: r_core_bin_set_env
R_API int r_core_bin_set_env (RCore *r, RBinFile *binfile) {
RBinObject *binobj = binfile ? binfile->o: NULL;
RBinInfo *info = binobj ? binobj->info: NULL;
if (info) {
int va = info->has_va;
const char * arch = info->arch;
ut16 bits = info->bits;
ut64 loadaddr = r_config_get_i (r->config, "bin.laddr");
ut64 baseaddr = binobj->baddr;
/* Hack to make baddr work on some corner */
r_config_set_i (r->config, "io.va",
(binobj->info)? binobj->info->has_va: 0);
r_config_set_i (r->config, "bin.laddr", loadaddr);
r_config_set_i (r->config, "bin.baddr", baseaddr);
r_config_set (r->config, "asm.arch", arch);
r_config_set_i (r->config, "asm.bits", bits);
r_config_set (r->config, "anal.arch", arch);
if (strlen(info->cpu))
r_config_set (r->config, "anal.cpu", info->cpu);
else r_config_set (r->config, "anal.cpu", arch);
r_asm_use (r->assembler, arch);
r_core_bin_info (r, R_CORE_BIN_ACC_ALL, R_CORE_BIN_SET,
va, NULL, loadaddr, NULL);
r_core_bin_set_cur (r, binfile);
return R_TRUE;
}
return R_FALSE;
}
示例5: r_core_magic
static void r_core_magic(RCore *core, const char *file, int v) {
ut64 addr = core->offset;
magicdepth = r_config_get_i (core->config, "magic.depth"); // TODO: do not use global var here
r_core_magic_at (core, file, addr, magicdepth, v);
if (addr != core->offset)
r_core_seek (core, addr, R_TRUE);
}
示例6: readline_callback
static int readline_callback(void *_a, const char *str) {
RCoreVisualAsm *a = _a;
int xlen;
r_cons_clear00 ();
r_cons_printf ("Write your favourite %s-%d opcode...\n\n",
r_config_get (a->core->config, "asm.arch"),
r_config_get_i (a->core->config, "asm.bits"));
if (*str == '?') {
r_cons_printf ("0> ?\n\n"
"Visual assembler help:\n\n"
" assemble input while typing using asm.arch, asm.bits and cfg.bigendian\n"
" press enter to quit (prompt if there are bytes to be written)\n"
" this assembler supports various directives like .hex ...\n"
);
} else {
r_asm_code_free (a->acode);
a->acode = r_asm_massemble (a->core->assembler, str);
r_cons_printf ("%d> %s\n", a->acode? a->acode->len: 0, str);
if (a->acode && a->acode->len)
r_cons_printf ("* %s\n\n", a->acode->buf_hex);
else r_cons_printf ("\n\n");
if (a->acode) {
xlen = strlen (a->acode->buf_hex);
strcpy (a->codebuf, a->blockbuf);
memcpy (a->codebuf, a->acode->buf_hex, xlen);
}
r_core_cmdf (a->core, "pd [email protected]:%s @0x%"PFMT64x, a->codebuf, a->off);
}
r_cons_flush ();
return 1;
}
示例7: r_core_visual_seek_animation
R_API void r_core_visual_seek_animation (RCore *core, ut64 addr) {
if (r_config_get_i (core->config, "scr.feedback")<1)
return;
#if 0
int i, ns = 90000;
const char *scmd = (addr > core->offset)? "so": "s-4";
for (i=0;i<5;i++) {
r_core_cmd0 (core, scmd);
r_core_visual_refresh (core);
r_cons_flush();
r_sys_usleep (ns);
ns -= 1000;
}
r_core_seek (core, addr, 1);
#else
if (core->offset == addr)
return;
r_cons_gotoxy (1, 2);
if (addr>core->offset) {
r_cons_printf (".----.\n");
r_cons_printf ("| \\/ |\n");
r_cons_printf ("'----'\n");
} else {
r_cons_printf (".----.\n");
r_cons_printf ("| /\\ |\n");
r_cons_printf ("'----'\n");
}
r_cons_flush();
r_sys_usleep (90000);
#endif
r_core_seek (core, addr, 1);
}
示例8: r_anal_hint_free
R_API RAnalHint *r_core_hint_begin (RCore *core, RAnalHint* hint, ut64 at) {
// XXX not here
static char *hint_arch = NULL;
static int hint_bits = 0;
if (hint) {
r_anal_hint_free (hint);
hint = NULL;
}
hint = r_anal_hint_get (core->anal, at);
if (hint_arch) {
r_config_set (core->config, "asm.arch", hint_arch);
hint_arch = NULL;
}
if (hint_bits) {
r_config_set_i (core->config, "asm.bits", hint_bits);
hint_bits = 0;
}
if (hint) {
/* arch */
if (hint->arch) {
if (!hint_arch) hint_arch = strdup (
r_config_get (core->config, "asm.arch"));
r_config_set (core->config, "asm.arch", hint->arch);
}
/* bits */
if (hint->bits) {
if (!hint_bits) hint_bits =
r_config_get_i (core->config, "asm.bits");
r_config_set_i (core->config, "asm.bits", hint->bits);
}
}
return hint;
}
示例9: r_core_lines_initcache
R_API int r_core_lines_initcache(RCore *core, ut64 start_addr, ut64 end_addr) {
int i, line_count;
int bsz = core->blocksize;
char *buf;
ut64 off = start_addr;
ut64 baddr;
if (start_addr == UT64_MAX || end_addr == UT64_MAX) {
return -1;
}
free (core->print->lines_cache);
core->print->lines_cache = R_NEWS0 (ut64, bsz);
if (!core->print->lines_cache) {
return -1;
}
{
RIOSection *s = r_io_section_mget_in (core->io, core->offset);
baddr = s? s->paddr: r_config_get_i (core->config, "bin.baddr");
}
line_count = start_addr? 0: 1;
core->print->lines_cache[0] = start_addr? 0: baddr;
buf = malloc (bsz);
if (!buf) {
return -1;
}
r_cons_break_push (NULL, NULL);
while (off < end_addr) {
if (r_cons_is_breaked ()) {
break;
}
r_io_read_at (core->io, off, (ut8 *) buf, bsz);
for (i = 0; i < bsz; i++) {
if (buf[i] == '\n') {
core->print->lines_cache[line_count] = start_addr? off + i + 1: off + i + 1 + baddr;
line_count++;
if (line_count % bsz == 0) {
ut64 *tmp = realloc (core->print->lines_cache,
(line_count + bsz) * sizeof (ut64));
if (tmp) {
core->print->lines_cache = tmp;
} else {
R_FREE (core->print->lines_cache);
goto beach;
}
}
}
}
off += bsz;
}
free (buf);
r_cons_break_pop ();
return line_count;
beach:
free (buf);
r_cons_break_pop ();
return -1;
}
示例10: r_core_fortune_print_random
R_API void r_core_fortune_print_random(RCore *core) {
// TODO: use file.fortunes // can be dangerous in sandbox mode
char *line = getrandomline (core);
if (!line) {
line = getrandomline (core);
}
if (line) {
if (r_config_get_i (core->config, "cfg.fortunes.clippy")) {
r_core_clippy (line);
} else {
r_cons_printf (" -- %s\n", line);
}
if (r_config_get_i (core->config, "cfg.fortunes.tts")) {
r_sys_tts (line, true);
}
free (line);
}
}
示例11: objc_analyze
static void objc_analyze(RCore *core) {
eprintf ("[+] Analyzing searching references to selref\n");
r_core_cmd0 (core, "aar");
if (!strcmp ("arm", r_config_get (core->config, "asm.arch"))) {
bool emu_lazy = r_config_get_i (core->config, "emu.lazy");
r_config_set_i (core->config, "emu.lazy", true);
r_core_cmd0 (core, "aae");
r_config_set_i (core->config, "emu.lazy", emu_lazy);
}
}
示例12: r_anal_emul_init
static bool r_anal_emul_init(RCore *core, bool *state) {
state[ROMEM] = r_config_get_i (core->config, "esil.romem");
r_config_set (core->config, "esil.romem", "true");
state[ASM_TRACE] = r_config_get_i (core->config, "asm.trace");
r_config_set (core->config, "asm.trace", "true");
state[ANAL_TRACE] = r_config_get_i (core->config, "anal.trace");
r_config_set (core->config, "anal.trace", "true");
state[DBG_TRACE] = r_config_get_i (core->config, "dbg.trace");
r_config_set (core->config, "dbg.trace", "true");
state[NONULL] = r_config_get_i (core->config, "esil.nonull");
r_config_set (core->config, "esil.nonull", "true");
const char *bp = r_reg_get_name (core->anal->reg, R_REG_NAME_BP);
const char *sp = r_reg_get_name (core->anal->reg, R_REG_NAME_SP);
if ((bp && !r_reg_getv (core->anal->reg, bp)) || (sp && !r_reg_getv (core->anal->reg, sp))) {
eprintf ("Stack isn't initiatized.\n");
eprintf ("Try running aei and aeim commands before aftm for default stack initialization\n");
return false;
}
return (core->anal->esil != NULL);
}
示例13: bin_dwarf
static int bin_dwarf(RCore *core, int mode) {
RBinDwarfRow *row;
RListIter *iter;
RList *list = NULL;
RBinFile *binfile = r_core_bin_cur (core);
RBinPlugin * plugin = r_bin_file_cur_plugin (binfile);
if (!binfile) return false;
if (plugin && plugin->lines) {
list = plugin->lines (binfile);
} else if (core->bin) {
// TODO: complete and speed-up support for dwarf
if (r_config_get_i (core->config, "bin.dwarf")) {
RBinDwarfDebugAbbrev *da = NULL;
da = r_bin_dwarf_parse_abbrev (core->bin, mode);
r_bin_dwarf_parse_info (da, core->bin, mode);
r_bin_dwarf_parse_aranges (core->bin, mode);
list = r_bin_dwarf_parse_line (core->bin, mode);
r_bin_dwarf_free_debug_abbrev (da);
free (da);
}
}
if (!list) return false;
r_cons_break (NULL, NULL);
r_list_foreach (list, iter, row) {
if (r_cons_singleton()->breaked) break;
if (mode) {
// TODO: use 'Cl' instead of CC
const char *path = row->file;
char *line = r_file_slurp_line (path, row->line-1, 0);
if (line) {
r_str_filter (line, strlen (line));
line = r_str_replace (line, "\"", "\\\"", 1);
line = r_str_replace (line, "\\\\", "\\", 1);
}
// TODO: implement internal : if ((mode & R_CORE_BIN_SET))
if ((mode & R_CORE_BIN_SET)) {
char *cmt = r_str_newf ("%s:%d %s", row->file, row->line, line?line:"");
r_meta_set_string (core->anal, R_META_TYPE_COMMENT,
row->address, cmt);
free (cmt);
} else {
r_cons_printf ("\"CC %s:%d %s\"@0x%"PFMT64x"\n",
row->file, row->line, line?line:"", row->address);
}
free (line);
} else {
r_cons_printf ("0x%08"PFMT64x"\t%s\t%d\n", row->address, row->file, row->line);
}
}
r_cons_break_end ();
r_list_free (list);
return true;
}
示例14: bin_strings
static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
char *p, *q, str[R_FLAG_NAME_SIZE];
RBinSection *section;
int hasstr, minstr;
RBinString *string;
RListIter *iter;
RList *list;
int i = 0;
if (!(hasstr = r_config_get_i (r->config, "bin.strings")))
return 0;
if (!r->bin->cur.curplugin) return 0;
if (!r->bin->cur.curplugin->info) {
if (!r_config_get_i (r->config, "bin.rawstr")) {
eprintf ("WARN: Use '-e bin.rawstr=true' or 'rabin2 -zz'"
" to find strings on unknown file types\n");
return 0;
}
}
minstr = r_config_get_i (r->config, "bin.minstr");
//if (r->bin->minstrlen == 0 && minstr>0) r->bin->minstrlen = minstr;
//else if (r->bin->minstrlen > 0) r_config_set_i (r->config, "bin.minstr", r->bin->minstrlen);
if (r->bin->minstrlen <=0) return -1;
/* code */
if ((list = r_bin_get_strings (r->bin)) == NULL)
return R_FALSE;
if ((mode & R_CORE_BIN_JSON)) {
r_cons_printf ("[");
r_list_foreach (list, iter, string) {
ut64 addr = va? r_bin_get_vaddr (r->bin, baddr, string->rva,
string->offset): string->offset;
q = strdup (string->string);
//r_name_filter (str, 128);
for (p=q; *p; p++) if(*p=='"')*p='\'';
r_cons_printf ("%s{\"offset\":%"PFMT64d
",\"length\":%d,\"string\":\"%s\"}",
iter->p? ",": "", addr, string->size, q);
free (q);
}
示例15: r_core_visual_show_char
R_API void r_core_visual_show_char (RCore *core, char ch) {
if (r_config_get_i (core->config, "scr.feedback")<2)
return;
if (!IS_PRINTABLE (ch))
return;
r_cons_gotoxy (1, 2);
r_cons_printf (".---.\n");
r_cons_printf ("| %c |\n", ch);
r_cons_printf ("'---'\n");
r_cons_flush ();
r_sys_sleep (1);
}