Skip to content

Commit

Permalink
Implement 'wao jinf' to assemble infinite loop instruction ##asm
Browse files Browse the repository at this point in the history
* Done for x86, arm16, arm32 and arm64
  • Loading branch information
radare committed Jan 26, 2019
1 parent 18cb56c commit b7f0cf6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libr/core/hack.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2011-2012 - pancake */
/* radare - LGPL - Copyright 2011-2019 - pancake */

#include <r_core.h>

Expand All @@ -11,6 +11,7 @@ void r_core_hack_help(const RCore *core) {
const char* help_msg[] = {
"wao", " [op]", "performs a modification on current opcode",
"wao", " nop", "nop current opcode",
"wao", " jinf", "assemble an infinite loop",
"wao", " jz", "make current opcode conditional (zero)",
"wao", " jnz", "make current opcode conditional (not zero)",
"wao", " ret1", "make the current opcode return 1",
Expand All @@ -35,6 +36,8 @@ R_API bool r_core_hack_arm64(RCore *core, const char *op, const RAnalOp *analop)
} else if (!strcmp (op, "jz")) {
eprintf ("ARM jz hack not supported\n");
return false;
} else if (!strcmp (op, "jinf")) {
r_core_cmdf (core, "wx 00000014");
} else if (!strcmp (op, "jnz")) {
eprintf ("ARM jnz hack not supported\n");
return false;
Expand Down Expand Up @@ -82,6 +85,8 @@ R_API bool r_core_hack_arm(RCore *core, const char *op, const RAnalOp *analop) {
str[len*2] = '\0';
r_core_cmdf (core, "wx %s\n", str);
free (str);
} else if (!strcmp (op, "jinf")) {
r_core_cmdf (core, "wx %s\n", (bits==16)? "fee7": "feffffea");
} else if (!strcmp (op, "trap")) {
const char* trapcode = (bits==16)? "bebe": "fedeffe7";
r_core_cmdf (core, "wx %s\n", trapcode);
Expand Down Expand Up @@ -199,6 +204,8 @@ R_API bool r_core_hack_x86(RCore *core, const char *op, const RAnalOp *analop) {
eprintf ("Current opcode is not conditional\n");
return false;
}
} else if (!strcmp (op, "jinf")) {
r_core_cmd0 (core, "wx ebfe\n");
} else if (!strcmp (op, "jnz")) {
if (b[0] == 0x74) {
r_core_cmd0 (core, "wx 75\n");
Expand Down

0 comments on commit b7f0cf6

Please sign in to comment.