本文整理汇总了C++中r_core_cmd0函数的典型用法代码示例。如果您正苦于以下问题:C++ r_core_cmd0函数的具体用法?C++ r_core_cmd0怎么用?C++ r_core_cmd0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_core_cmd0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: r_core_debug_breakpoint_hit
static void r_core_debug_breakpoint_hit(RCore *core, RBreakpointItem *bpi) {
const char *cmdbp;
int oecho = core->cons->echo; // should be configurable by user?
core->cons->echo = 1; // should be configurable by user?
cmdbp = r_config_get (core->config, "cmd.bp");
if (cmdbp && *cmdbp)
r_core_cmd0 (core, cmdbp);
r_core_cmd0 (core, bpi->data);
core->cons->echo = oecho;
}
示例3: objc_analyze
static void objc_analyze(RCore *core) {
static const char *oldstr = NULL;
oldstr = r_print_rowlog (core->print, "Analyzing searching references to selref");
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);
}
r_print_rowlog_done (core->print, oldstr);
}
示例4: opencore
static RCore* opencore(const char *f) {
const ut64 baddr = UT64_MAX;
RCore *c = r_core_new ();
if (!c) return NULL;
r_core_loadlibs (c, R_CORE_LOADLIBS_ALL, NULL);
r_config_set_i (c->config, "io.va", useva);
r_config_set_i (c->config, "anal.split", true);
if (f) {
if (!r_core_file_open (c, f, 0, 0)) {
r_core_free (c);
return NULL;
}
r_core_bin_load (c, NULL, baddr);
}
// TODO: must enable io.va here if wanted .. r_config_set_i (c->config, "io.va", va);
if (f && anal_all) {
const char *cmd = "aac";
switch (anal_all) {
case 1: cmd = "aaa"; break;
case 2: cmd = "aaaa"; break;
}
r_core_cmd0 (c, cmd);
}
return c;
}
示例5: run_commands
static bool run_commands(RList *cmds, RList *files, bool quiet) {
RListIter *iter;
const char *cmdn;
const char *file;
int ret;
/* -i */
r_list_foreach (files, iter, file) {
if (!r_file_exists (file)) {
eprintf ("Script '%s' not found.\n", file);
return false;
}
ret = r_core_run_script (&r, file);
if (ret == -2) {
eprintf ("Cannot open '%s'\n", file);
}
if (ret < 0 || (ret == 0 && quiet)) {
r_cons_flush ();
return false;
}
}
/* -c */
r_list_foreach (cmds, iter, cmdn) {
r_core_cmd0 (&r, cmdn);
r_cons_flush ();
}
示例6: r_core_visual_hud
static int r_core_visual_hud(RCore *core) {
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
char *homehud = r_str_home (R2_HOMEDIR"/hud");
char *res = NULL;
char *p = 0;
showcursor (core, R_TRUE);
if (homehud)
res = r_cons_hud_file (homehud);
if (!res) {
if (r_file_exists (f))
res = r_cons_hud_file (f);
else r_cons_message ("Cannot find hud file");
}
r_cons_clear ();
if (res) {
p = strchr (res, '\t');
core->printidx = 1;
r_cons_printf ("%s\n", res);
r_cons_flush ();
if (p) r_core_cmd0 (core, p+1);
free (res);
}
showcursor (core, R_FALSE);
r_cons_flush ();
free (homehud);
return (int)(size_t)p;
}
示例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_core_visual_hud
R_API int r_core_visual_hud(RCore *core) {
const char *c = r_config_get (core->config, "hud.path");
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
char *homehud = r_str_home (R2_HOMEDIR"/hud");
char *res = NULL;
char *p = 0;
showcursor (core, true);
if (c && *c && r_file_exists (c))
res = r_cons_hud_file (c);
if (!res && homehud)
res = r_cons_hud_file (homehud);
if (!res && r_file_exists (f))
res = r_cons_hud_file (f);
if (!res)
r_cons_message ("Cannot find hud file");
r_cons_clear ();
if (res) {
p = strchr (res, '\t');
r_cons_printf ("%s\n", res);
r_cons_flush ();
if (p) r_core_cmd0 (core, p+1);
free (res);
}
showcursor (core, false);
r_cons_flush ();
free (homehud);
return (int)(size_t)p;
}
示例9: r_core_patch
R_API int r_core_patch (RCore *core, const char *patch) {
char *p, *p0, *str;
ut64 noff = 0LL;
p = p0 = str = strdup (patch);
if (!p) {
return 0;
}
for (; *p; p++) {
/* read until newline */
if (!*p || *p == '\n') {
*p++ = 0;
} else {
continue;
}
switch (*str) {
case '#':
case '\n':
case '\r':
case '\0':
break;
case ':':
r_core_cmd0 (core, str+1);
break;
case '.':
case '!':
r_core_cmd0 (core, str);
break;
case '{':
(void)__core_patch_bracket (core, str, &noff);
break;
default:
r_core_patch_line (core, str);
break;
}
if (!*p) {
break;
}
str = p;
}
// eprintf ("%d\n", *p);
// eprintf ("Missing newline\n");
free (p0);
return 0;
}
示例10: r_anal_type_match
R_API void r_anal_type_match(RCore *core, RAnalFunction *fcn) {
bool esil_var[STATES_SIZE] = {false};
if (!core ) {
return;
}
if (!r_anal_emul_init (core, esil_var) || !fcn ) {
r_anal_emul_restore (core, esil_var);
return;
}
const char *pc = r_reg_get_name (core->anal->reg, R_REG_NAME_PC);
ut64 addr = fcn->addr;
r_reg_setv (core->dbg->reg, pc, fcn->addr);
r_debug_reg_sync (core->dbg, -1, true);
r_cons_break (NULL, NULL);
while (!r_cons_is_breaked ()) {
RAnalOp *op = r_core_anal_op (core, addr);
int loop_count = sdb_num_get ( core->anal->esil->db_trace, sdb_fmt (-1, "0x%"PFMT64x".count", addr), 0);
if (loop_count > LOOP_MAX) {
eprintf ("Unfortunately your evilly engineered %s function trapped my most innocent `aftm` in an infinite loop.\n", fcn->name);
eprintf ("I kept trace log for you to review and find out how bad things were going to happen by yourself.\n");
eprintf ("You can view this log by `ate`. Meanwhile, I will train on how to behave with such behaviour without bothering you.\n");
return;
}
sdb_num_set (core->anal->esil->db_trace, sdb_fmt (-1, "0x%"PFMT64x".count", addr), loop_count + 1, 0);
if (!op || op->type == R_ANAL_OP_TYPE_RET) {
r_anal_emul_restore (core, esil_var);
return;
}
if (op->type == R_ANAL_OP_TYPE_CALL) {
RAnalFunction *fcn_call = r_anal_get_fcn_in (core->anal, op->jump, -1);
//eprintf ("in the middle of %s\n", fcn_call->name);
if (fcn_call) {
type_match (core, addr, fcn_call->name);
} else {
eprintf ("Cannot find function at 0x%08"PFMT64x"\n", op->jump);
}
addr += op->size;
r_anal_op_free (op);
r_reg_setv (core->dbg->reg, pc, addr);
r_debug_reg_sync (core->dbg, -1, true);
r_anal_esil_set_pc (core->anal->esil, addr);
addr += stack_clean (core, addr, fcn);
r_reg_setv (core->dbg->reg, pc, addr);
r_debug_reg_sync (core->dbg, -1, true);
r_anal_esil_set_pc (core->anal->esil, addr);
continue;
} else {
r_core_esil_step (core, UT64_MAX, NULL);
r_anal_op_free (op);
}
r_core_cmd0 (core, ".ar*");
addr = r_reg_getv (core->anal->reg, pc);
}
r_cons_break_end ();
r_anal_emul_restore (core, esil_var);
}
示例11: visual_offset
static void visual_offset (RCore *core) {
char buf[256];
r_line_set_prompt ("[offset]> ");
strcpy (buf, "s ");
if (r_cons_fgets (buf+2, sizeof (buf)-3, 0, NULL) >0) {
if (buf[2]=='.')buf[1]='.';
r_core_cmd0 (core, buf);
}
}
示例12: config_iova_callback
static int config_iova_callback(void *user, void *data) {
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
if (node->i_value != core->io->va) {
core->io->va = node->i_value;
r_core_block_read (core, 0);
// reload symbol information
r_core_cmd0 (core, ".ia*");
}
return R_TRUE;
}
示例13: on_fcn_delete
static int on_fcn_delete (void *_anal, void* _user, RAnalFunction *fcn) {
RCore *core = (RCore*)_user;
const char *cmd = r_config_get (core->config, "cmd.fcn.delete");
if (cmd && *cmd) {
ut64 oaddr = core->offset;
ut64 addr = fcn->addr;
r_core_seek (core, addr, 1);
r_core_cmd0 (core, cmd);
r_core_seek (core, oaddr, 1);
}
return 0;
}
示例14: r_core_hack_x86
R_API int r_core_hack_x86(RCore *core, const char *op, const RAnalOp *analop) {
const ut8 *b = core->block;
const int size = analop->size;
if (!strcmp (op, "nop")) {
if (size * 2 + 1 < size) return false;
char *str = malloc (size * 2 + 1);
if (!str) return false;
int i;
for (i = 0; i < size; i++)
memcpy(str + (i * 2), "90", 2);
str[size*2] = '\0';
r_core_cmdf(core, "wx %s\n", str);
free(str);
} else if (!strcmp (op, "trap")) {
r_core_cmd0 (core, "wx cc\n");
} else if (!strcmp (op, "jz")) {
if (b[0] == 0x75) {
r_core_cmd0 (core, "wx 74\n");
} else {
eprintf ("Current opcode is not conditional\n");
return false;
}
} else if (!strcmp (op, "jnz")) {
if (b[0] == 0x74) {
r_core_cmd0 (core, "wx 75\n");
} else {
eprintf ("Current opcode is not conditional\n");
return false;
}
} else if (!strcmp (op, "un-cjmp")) {
if (b[0] >= 0x70 && b[0] <= 0x7f) {
r_core_cmd0 (core, "wx eb\n");
} else {
eprintf ("Current opcode is not conditional\n");
return false;
}
} else if (!strcmp (op, "swap-cjmp")) {
if (b[0] < 0x80 && b[0] >= 0x70){ // jo, jno, jb, jae, je, jne, jbe, ja, js, jns
r_core_cmdf (core, "wx %x\n", (b[0]%2)? b[0] - 1: b[0] + 1);
} else {
eprintf ("Invalid opcode\n");
return false;
}
} else if (!strcmp (op, "ret1")) {
r_core_cmd0 (core, "wx c20100\n");
} else if (!strcmp (op, "ret0")) {
r_core_cmd0 (core, "wx c20000\n");
} else if (!strcmp (op, "retn")) {
r_core_cmd0 (core, "wx c2ffff\n");
} else {
eprintf ("Invalid operation\n");
return false;
}
return true;
}
示例15: on_fcn_rename
static int on_fcn_rename(void *_anal, void* _user, RAnalFunction *fcn, const char *oname) {
RCore *core = (RCore*)_user;
const char *cmd = r_config_get (core->config, "cmd.fcn.rename");
if (cmd && *cmd) {
// XXX: wat do with old name here?
ut64 oaddr = core->offset;
ut64 addr = fcn->addr;
r_core_seek (core, addr, 1);
r_core_cmd0 (core, cmd);
r_core_seek (core, oaddr, 1);
}
return 0;
}