Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added esil break on invalid instruction variable #10823

Merged
merged 3 commits into from Jul 27, 2018
Merged
Changes from all commits
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -2435,6 +2435,7 @@ R_API int r_core_config_init(RCore *core) {
SETI ("esil.stack.addr", 0x100000, "Number of elements that can be pushed on the esilstack");
SETPREF ("esil.stack.pattern", "0", "Specify fill pattern to initialize the stack (0, w, d, i)");
SETI ("esil.addr.size", 64, "Maximum address size in accessed by the ESIL VM");
SETPREF ("esil.breakoninvalid", "false", "Break esil execution when instruction is invalid");

This comment has been minimized.

@radare

radare Jul 27, 2018
Collaborator

Maybe good to try to have this enabled by default?

This comment has been minimized.

@fcasal

fcasal Jul 27, 2018
Author Contributor

We can try, but in r2 it's less important than in cutter since you can always ^C when it starts sledding on invalids.


/* asm */
//asm.os needs to be first, since other asm.* depend on it
@@ -3236,6 +3236,7 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
RAnalOp op = {0};
RAnalEsil *esil = core->anal->esil;
const char *name = r_reg_get_name (core->anal->reg, R_REG_NAME_PC);
bool breakoninvalid = r_config_get_i (core->config, "esil.breakoninvalid");
if (!esil) {
// TODO inititalizeEsil (core);

@@ -3310,6 +3311,10 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
// update the esil pointer because RAnal.op() can change it
esil = core->anal->esil;
if (op.size < 1 || ret < 0) {
if (breakoninvalid) {
r_cons_printf ("[ESIL] Stopped execution in an invalid instruction (see e??esil.breakoninvalid)\n");
return_tail (0);
}
if (esil->cmd && esil->cmd_todo) {
esil->cmd (esil, esil->cmd_todo, addr, 0);
}
ProTip! Use n and p to navigate between commits in a pull request.