Skip to content

Commit

Permalink
Add minor tweaks for r2wars from @skuater and the cfg.r2wars option
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Sep 5, 2018
1 parent 8ddd542 commit be913de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions libr/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("prj.simple", "false", "Use simple project saving style (functions, comments, options)");

/* cfg */
SETPREF ("cfg.r2wars", "false", "Enable some tweaks for the r2wars game");
SETPREF ("cfg.plugins", "true", "Load plugins at startup");
SETCB ("time.fmt", "%Y-%m-%d %H:%M:%S %z", &cb_cfgdatefmt, "Date format (%Y-%m-%d %H:%M:%S %z)");
SETICB ("time.zone", 0, &cb_timezone, "Time zone, in hours relative to GMT: +2, -1,..");
Expand Down
24 changes: 23 additions & 1 deletion libr/core/cmd_anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3463,7 +3463,21 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
r_anal_op_hint (&op, hint);
r_anal_hint_free (hint);
}
r_reg_setv (core->anal->reg, name, addr + op.size);
if (r_config_get_i (core->config, "cfg.r2wars")) {
// this is x86 and r2wars specific, shouldnt hurt outside x86
ut64 vECX = r_reg_getv (core->anal->reg, "ecx");
if (op.prefix & R_ANAL_OP_PREFIX_REP && vECX > 1) {
char *tmp = strstr (op.esil.ptr, ",ecx,?{,5,GOTO,}");
if (tmp) {
tmp[0] = 0;
}
op.esil.len -= 16;
} else {
r_reg_setv (core->anal->reg, name, addr + op.size);
}
} else {
r_reg_setv (core->anal->reg, name, addr + op.size);
}
if (ret) {
r_anal_esil_set_pc (esil, addr);
if (core->dbg->trace->enabled) {
Expand Down Expand Up @@ -4100,6 +4114,14 @@ static bool cmd_aea(RCore* core, int mode, ut64 addr, int length) {
addr + ptr, buf[ptr], buf[ptr + 1]);
break;
}
if (r_config_get_i (core->config, "cfg.r2wars")) {
if (aop.prefix & R_ANAL_OP_PREFIX_REP) {
char * tmp = strstr (esilstr, ",ecx,?{,5,GOTO,}");
if (tmp) {
tmp[0] = 0;
}
}
}
r_anal_esil_parse (esil, esilstr);
r_anal_esil_stack_free (esil);
}
Expand Down

0 comments on commit be913de

Please sign in to comment.