mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-17 04:39:36 +00:00
Implement soft esil pins, only executed in the disasm loop ##disasm
This commit is contained in:
parent
354b17c87b
commit
3db7d62b4e
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2015-2023 - pancake, nibble */
|
||||
/* radare - LGPL - Copyright 2015-2024 - pancake */
|
||||
|
||||
#include <r_anal.h>
|
||||
|
||||
@ -107,6 +107,13 @@ R_API const char *r_anal_pin_call(RAnal *a, ut64 addr) {
|
||||
if (key) {
|
||||
r_strf_buffer (128);
|
||||
const char *name = sdb_const_get (DB, key, NULL);
|
||||
if (!name) {
|
||||
return NULL;
|
||||
}
|
||||
if (r_str_startswith (name, "soft.")) {
|
||||
// do not call soft esil pins from here
|
||||
return NULL;
|
||||
}
|
||||
char *ckey = r_strf ("cmd.%s", name);
|
||||
const char *cmd = sdb_const_get (DB, ckey, NULL);
|
||||
if (R_STR_ISNOTEMPTY (cmd)) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const char * const SPECIAL_CHARS_REGULAR = "@;~$#|`\"'()<>";
|
||||
#define SPECIAL_CHARS "@;~$#|`\"'()<>"
|
||||
|
||||
static bool isAnExport(RBinSymbol *s) {
|
||||
/* workaround for some bin plugs */
|
||||
@ -5115,7 +5115,7 @@ fuji:
|
||||
beach:
|
||||
if (grep) {
|
||||
char *old_grep = grep;
|
||||
grep = unescape_special_chars (old_grep, SPECIAL_CHARS_REGULAR);
|
||||
grep = unescape_special_chars (old_grep, SPECIAL_CHARS);
|
||||
free (old_grep);
|
||||
r_cons_grep_expression (grep);
|
||||
free (grep);
|
||||
|
@ -521,6 +521,7 @@ static RCoreHelpMessage help_msg_aep = {
|
||||
"aepa", " ([addr])", "auto set pin in current or given address by flag name (see aaep)",
|
||||
"aep", " [name] @ [addr]", "set pin",
|
||||
"aep ", "memcpy=wf `dr?A1` `dr?A2` @r:A0", "override esil.cmd.pin for this pin name",
|
||||
"aep ", "soft.show.r9=dr?r9", "set a 'soft.' esil pin, only executed in the disasm loop",
|
||||
"aep", "", "list pins",
|
||||
"aep.", "", "show pin name in current address if any",
|
||||
"aepk", " [query]", "kuery the sdb of pins",
|
||||
|
@ -1392,10 +1392,18 @@ static void ds_begin_comment(RDisasmState *ds) {
|
||||
}
|
||||
|
||||
static void ds_print_pins(RDisasmState *ds) {
|
||||
const char *lepin = r_anal_pin_at (ds->core->anal, ds->at);
|
||||
RCore *core = ds->core;
|
||||
const char *lepin = r_anal_pin_at (core->anal, ds->at);
|
||||
if (R_STR_ISNOTEMPTY (lepin)) {
|
||||
ds_begin_comment (ds);
|
||||
ds_comment (ds, true, "%s [aep: %s]", ds->cmtoken, lepin);
|
||||
if (r_str_startswith (lepin, "soft.")) {
|
||||
const char *cmd = r_anal_pin_get (core->anal, lepin);
|
||||
if (cmd) {
|
||||
r_cons_newline ();
|
||||
r_core_cmd0 (core, cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,3 +132,36 @@ INFO: esil.dummy: Activated
|
||||
INFO: Dummy: Operation executed
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=esil soft pins
|
||||
FILE=bins/elf/ls
|
||||
ARGS=-e bin.relocs.apply=true -e asm.lines=0 -e asm.bytes=0 -e asm.cmt.col=40
|
||||
CMDS=<<EOF
|
||||
'aep soft.dr9=dr?r9
|
||||
aep hard.rbp=dr?rbp
|
||||
pd 3
|
||||
aep hard.rbp @ 0x5ae4
|
||||
aep soft.dr9 @ 0x5ae6
|
||||
e emu.str=1
|
||||
dr r9=0x666
|
||||
pd 3
|
||||
aeim
|
||||
dr PC=$$
|
||||
3ds
|
||||
dr?rbp
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
;-- entry0:
|
||||
0x00005ae0 endbr64
|
||||
0x00005ae4 xor ebp, ebp
|
||||
0x00005ae6 mov r9, rdx
|
||||
;-- entry0:
|
||||
0x00005ae0 endbr64
|
||||
0x00005ae4 xor ebp, ebp ; [aep: hard.rbp]
|
||||
0x00005ae6 mov r9, rdx ; [aep: soft.dr9]
|
||||
0x00000666
|
||||
|
||||
0x00178000
|
||||
0x00178000
|
||||
EOF
|
||||
RUN
|
||||
|
Loading…
x
Reference in New Issue
Block a user