This commit is contained in:
pancake 2024-03-18 11:28:03 +01:00
parent 35244929a9
commit b25f2a724f
3 changed files with 28 additions and 16 deletions

View File

@ -5615,8 +5615,8 @@ static void core_print_decompile(RCore *core, const char *input) {
}
ut64 addr = core->offset;
int minopsize = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE);
//int bits = r_config_get_i (core->config, "asm.bits");
REsilC *ec = r_esil_toc_new ();
const int bits = r_config_get_i (core->config, "asm.bits");
REsilC *ec = r_esil_toc_new (core->anal, bits);
for (i = 0; i < count; i++) {
RAnalOp *op = r_core_anal_op (core, addr, R_ARCH_OP_MASK_BASIC | R_ARCH_OP_MASK_ESIL);
if (!op) {

View File

@ -195,6 +195,7 @@ static bool esil2c_mr(REsil *esil, ut64 addr, ut8 *buf, int len) {
}
static void esil2c_setup(REsil *esil) {
R_RETURN_IF_FAIL (esil);
REsilC *user = R_NEW (REsilC);
esil->user = user;
esil->verbose = true; // r_config_get_b (core->config, "esil.verbose");
@ -218,21 +219,31 @@ static void esil2c_setup(REsil *esil) {
// r_esil_set_op (esil, "+=", esil2c_set, 0, 2, R_ESIL_OP_TYPE_REG_WRITE);
}
R_API REsilC *r_esil_toc_new() {
R_API REsilC *r_esil_toc_new(struct r_anal_t *anal, const int bits) {
REsilC *ec = R_NEW0 (REsilC);
int ss = 16 * 1024;
const int bits = 64;
REsil *esil = r_esil_new (ss, 0, bits);
esil2c_setup (esil);
ec->esil = esil;
if (ec) {
int ss = 16 * 1024;
REsil *esil = r_esil_new (ss, 0, bits);
if (esil) {
esil2c_setup (esil);
ec->anal = anal;
ec->esil = esil;
} else {
R_FREE (ec);
}
}
return ec;
}
R_API void r_esil_toc_free (REsilC *ec) {
esil2c_free (ec->esil->user);
ec->esil->user = NULL;
r_esil_free (ec->esil);
free (ec);
R_API void r_esil_toc_free(REsilC *ec) {
if (ec) {
if (ec->esil) {
esil2c_free (ec->esil->user);
ec->esil->user = NULL;
r_esil_free (ec->esil);
}
free (ec);
}
}
R_API char *r_esil_toc(REsilC *ec, const char *expr) {

View File

@ -1,4 +1,4 @@
/* radare2 - LGPL - Copyright 2022-2023 - pancake */
/* radare2 - LGPL - Copyright 2022-2024 - pancake */
#ifndef R_ESIL_H
#define R_ESIL_H
@ -351,9 +351,10 @@ typedef struct r_esil_operation_t {
typedef struct {
REsil *esil;
RStrBuf *sb;
void *anal; // RAnal*
} REsilC;
R_API REsilC *r_esil_toc_new();
R_API void r_esil_toc_free (REsilC *ec);
R_API REsilC *r_esil_toc_new(struct r_anal_t *anal, int bits);
R_API void r_esil_toc_free(REsilC *ec);
R_API char *r_esil_toc(REsilC *esil, const char *expr);
R_API bool r_esil_set_op(REsil *esil, const char *op, REsilOpCb code, ut32 push, ut32 pop, ut32 type);