This commit is contained in:
condret 2019-06-10 06:01:24 +00:00
parent 00245f3e97
commit cac76f2e7d
4 changed files with 279 additions and 279 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1577,7 +1577,7 @@ bad:
return result;
}
static int esil_addrinfo(RAnalEsil *esil) {
static bool esil_addrinfo(RAnalEsil *esil) {
RCore *core = (RCore *) esil->cb.user;
ut64 num = 0;
char *src = r_anal_esil_pop (esil);
@ -1586,10 +1586,10 @@ static int esil_addrinfo(RAnalEsil *esil) {
r_anal_esil_pushnum (esil, num);
} else {
// error. empty stack?
return 0;
return false;
}
free (src);
return 1;
return true;
}
static void do_esil_search(RCore *core, struct search_parameters *param, const char *input) {

View File

@ -5,7 +5,6 @@
#include <r_anal.h>
#include <sdb.h>
typedef struct esil_data_flow_t {
ut32 idx;
Sdb *latest_nodes;
@ -19,8 +18,8 @@ typedef struct esil_data_flow_node_t {
} EsilDataFlowNode;
EsilDataFlowNode *new_edf_node (EsilDataFlow *edf, const char *c) {
EsilDataFlowNode *ret = R_NEW(EsilDataFlowNode);
ret->content = r_strbuf_new(c);
EsilDataFlowNode *ret = R_NEW (EsilDataFlowNode);
ret->content = r_strbuf_new (c);
ret->idx = edf->idx++;
return ret;
}
@ -32,18 +31,18 @@ void edf_node_free (EsilDataFlowNode *free_me) {
free (free_me);
}
static bool edf_consume_2_set_reg (RAnalEsil *esil);
static bool edf_consume_2_push_1 (RAnalEsil *esil);
static bool edf_consume_1_push_1 (RAnalEsil *esil);
typedef void (*AddConstraintStringUseNewCB)(RStrBuf *result, const char *new_node_str);
static bool edf_use_new_push_1 (RAnalEsil *esil, const char *op_string, AddConstraintStringUseNewCB cb);
typedef void (*AddConstraintStringConsume1UseOldNewCB)(RStrBuf *result, const char *consume_str, const char *old_node_str, const char *new_node_str);
static bool edf_consume_1_use_old_new_push_1 (RAnalEsil *esil, const char *op_string, AddConstraintStringConsume1UseOldNewCB cb);
static bool edf_consume_2_set_reg(RAnalEsil *esil);
static bool edf_consume_2_push_1(RAnalEsil *esil);
static bool edf_consume_1_push_1(RAnalEsil *esil);
typedef void (*AddConstraintStringUseNewCB) (RStrBuf *result, const char *new_node_str);
static bool edf_use_new_push_1(RAnalEsil *esil, const char *op_string, AddConstraintStringUseNewCB cb);
typedef void (*AddConstraintStringConsume1UseOldNewCB) (RStrBuf *result, const char *consume_str, const char *old_node_str, const char *new_node_str);
static bool edf_consume_1_use_old_new_push_1(RAnalEsil *esil, const char *op_string, AddConstraintStringConsume1UseOldNewCB cb);
static bool edf_eq_weak (RAnalEsil *esil) {
static bool edf_eq_weak(RAnalEsil *esil) {
EsilDataFlow *edf = (EsilDataFlow *)esil->user;
RGraphNode *o_old = sdb_ptr_get (edf->latest_nodes, "old", 0); //node for esil->old
RGraphNode *o_new = sdb_ptr_get (edf->latest_nodes, "new", 0); //node for esil->cur
RGraphNode *o_old = sdb_ptr_get (edf->latest_nodes, "old", 0); //node for esil->old
RGraphNode *o_new = sdb_ptr_get (edf->latest_nodes, "new", 0); //node for esil->cur
if (!edf_consume_2_set_reg (esil)) {
return false;
}
@ -61,33 +60,33 @@ static bool edf_eq_weak (RAnalEsil *esil) {
return true;
}
static void edf_zf_constraint (RStrBuf *result, const char *new_node_str) {
static void edf_zf_constraint(RStrBuf *result, const char *new_node_str) {
r_strbuf_appendf (result, ":(%s==0)", new_node_str);
}
static int edf_zf (RAnalEsil *esil) {
static bool edf_zf(RAnalEsil *esil) {
return edf_use_new_push_1 (esil, "$z", edf_zf_constraint);
}
static void edf_cf_constraint (RStrBuf *result, const char *consume, const char *o, const char *n) {
static void edf_cf_constraint(RStrBuf *result, const char *consume, const char *o, const char *n) {
r_strbuf_appendf (result, ":((%s&mask(%s&0x3f))<(%s&mask(%s&0x3f)))",
n, consume, o, consume);
n, consume, o, consume);
}
static int edf_cf (RAnalEsil *esil) {
static bool edf_cf(RAnalEsil *esil) {
return edf_consume_1_use_old_new_push_1 (esil, "$c", edf_cf_constraint);
}
static void edf_bf_constraint (RStrBuf *result, const char *consume, const char *o, const char *n) {
static void edf_bf_constraint(RStrBuf *result, const char *consume, const char *o, const char *n) {
r_strbuf_appendf (result, ":((%s&mask((%s+0x3f)&0x3f))<(%s& mask((%s+0x3f)&0x3f)))",
o, consume, n, consume);
o, consume, n, consume);
}
static int edf_bf (RAnalEsil *esil) {
static bool edf_bf(RAnalEsil *esil) {
return edf_consume_1_use_old_new_push_1 (esil, "$b", edf_bf_constraint);
}
static bool edf_consume_2_set_reg (RAnalEsil *esil) {
static bool edf_consume_2_set_reg(RAnalEsil *esil) {
const char *op_string = esil->current_opstr;
EsilDataFlow *edf = (EsilDataFlow *)esil->user;
char *dst = r_anal_esil_pop (esil);
@ -105,7 +104,7 @@ static bool edf_consume_2_set_reg (RAnalEsil *esil) {
free (src);
return false;
}
// could be an abstract value
RGraphNode *src_node = sdb_ptr_get (edf->latest_nodes, src, 0);
if (!src_node) {
@ -115,18 +114,18 @@ static bool edf_consume_2_set_reg (RAnalEsil *esil) {
free (src);
return false;
}
if (src_type == R_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = r_graph_add_node (edf->flow, new_edf_node (edf, src));
EsilDataFlowNode *ec_node = new_edf_node (edf, src);
r_strbuf_appendf(ec_node->content, ":const_%d", edf->idx++);
r_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node = r_graph_add_node (edf->flow, ec_node);
r_graph_add_edge (edf->flow, n_value, src_node);
}
if (src_type == R_ANAL_ESIL_PARM_REG) {
RGraphNode *n_reg = r_graph_add_node (edf->flow, new_edf_node (edf, src));
EsilDataFlowNode *ev_node = new_edf_node (edf, src);
r_strbuf_appendf(ev_node->content, ":var_%d", edf->idx++);
r_strbuf_appendf (ev_node->content, ":var_%d", edf->idx++);
src_node = r_graph_add_node (edf->flow, ev_node);
sdb_ptr_set (edf->latest_nodes, src, src_node, 0);
r_graph_add_edge (edf->flow, n_reg, src_node);
@ -141,9 +140,9 @@ static bool edf_consume_2_set_reg (RAnalEsil *esil) {
if (dst_type == R_ANAL_ESIL_PARM_REG) {
RGraphNode *n_reg = r_graph_add_node (edf->flow, new_edf_node (edf, dst));
EsilDataFlowNode *ev_node = new_edf_node (edf, dst);
r_strbuf_appendf(ev_node->content, ":var_%d", edf->idx++);
r_strbuf_appendf (ev_node->content, ":var_%d", edf->idx++);
dst_node = r_graph_add_node (edf->flow, ev_node);
// sdb_ptr_set (edf->latest_nodes, dst, ev_node, 0);
// sdb_ptr_set (edf->latest_nodes, dst, ev_node, 0);
r_graph_add_edge (edf->flow, n_reg, dst_node);
}
}
@ -161,21 +160,21 @@ static bool edf_consume_2_set_reg (RAnalEsil *esil) {
RGraphNode *op_node = r_graph_add_node (edf->flow, eop_node);
r_graph_add_edge (edf->flow, dst_node, op_node);
r_graph_add_edge (edf->flow, src_node, op_node);
sdb_ptr_set (edf->latest_nodes, "old", dst_node, 0); //esil->old
sdb_ptr_set (edf->latest_nodes, "old", dst_node, 0); //esil->old
EsilDataFlowNode *result = new_edf_node (edf, dst);
r_strbuf_appendf(result->content, ":var_%d", edf->idx++);
r_strbuf_appendf (result->content, ":var_%d", edf->idx++);
dst_node = r_graph_add_node (edf->flow, result);
r_graph_add_edge (edf->flow, op_node, dst_node);
sdb_ptr_set (edf->latest_nodes, dst, dst_node, 0);
sdb_ptr_set (edf->latest_nodes, "new", dst_node, 0); //esil->new
sdb_ptr_set (edf->latest_nodes, "new", dst_node, 0); //esil->new
free (dst);
return true;
}
static bool edf_consume_2_push_1 (RAnalEsil *esil) {
static bool edf_consume_2_push_1(RAnalEsil *esil) {
const char *op_string = esil->current_opstr;
EsilDataFlow *edf = (EsilDataFlow *)esil->user;
char *src[2] = {r_anal_esil_pop (esil), r_anal_esil_pop (esil)};
char *src[2] = { r_anal_esil_pop (esil), r_anal_esil_pop (esil) };
if (!src[0] || !src[1]) {
free (src[0]);
@ -186,7 +185,7 @@ static bool edf_consume_2_push_1 (RAnalEsil *esil) {
r_strbuf_appendf (eop_node->content, ",%s,%s", src[1], op_string);
RGraphNode *op_node = r_graph_add_node (edf->flow, eop_node);
RGraphNode *src_node[2];
ut32 i;
ut32 i;
for (i = 0; i < 2; i++) {
src_node[i] = sdb_ptr_get (edf->latest_nodes, src[i], 0);
if (!src_node[i]) {
@ -203,14 +202,14 @@ static bool edf_consume_2_push_1 (RAnalEsil *esil) {
if (src_type == R_ANAL_ESIL_PARM_NUM) {
RGraphNode *n_value = r_graph_add_node (edf->flow, new_edf_node (edf, src[i]));
EsilDataFlowNode *ec_node = new_edf_node (edf, src[i]);
r_strbuf_appendf(ec_node->content, ":const_%d", edf->idx++);
r_strbuf_appendf (ec_node->content, ":const_%d", edf->idx++);
src_node[i] = r_graph_add_node (edf->flow, ec_node);
r_graph_add_edge (edf->flow, n_value, src_node[i]);
}
if (src_type == R_ANAL_ESIL_PARM_REG) {
RGraphNode *n_reg = r_graph_add_node (edf->flow, new_edf_node (edf, src[i]));
EsilDataFlowNode *ev_node = new_edf_node (edf, src[i]);
r_strbuf_appendf(ev_node->content, ":var_%d", edf->idx++);
r_strbuf_appendf (ev_node->content, ":var_%d", edf->idx++);
src_node[i] = r_graph_add_node (edf->flow, ev_node);
sdb_ptr_set (edf->latest_nodes, src[i], src_node[i], 0);
r_graph_add_edge (edf->flow, n_reg, src_node[i]);
@ -228,7 +227,7 @@ static bool edf_consume_2_push_1 (RAnalEsil *esil) {
RGraphNode *result_node = r_graph_add_node (edf->flow, result);
r_graph_add_edge (edf->flow, op_node, result_node);
sdb_ptr_set (edf->latest_nodes, r_strbuf_get (result->content), result_node, 0);
r_anal_esil_push (esil, r_strbuf_get(result->content));
r_anal_esil_push (esil, r_strbuf_get (result->content));
return true;
}
@ -263,14 +262,14 @@ static bool edf_consume_1_push_1(RAnalEsil *esil) {
if (src_type == R_ANAL_ESIL_PARM_REG) {
RGraphNode *n_reg = r_graph_add_node (edf->flow, new_edf_node (edf, src));
EsilDataFlowNode *ev_node = new_edf_node (edf, src);
r_strbuf_appendf(ev_node->content, ":var_%d", edf->idx++);
r_strbuf_appendf (ev_node->content, ":var_%d", edf->idx++);
src_node = r_graph_add_node (edf->flow, ev_node);
sdb_ptr_set (edf->latest_nodes, src, src_node, 0);
r_graph_add_edge (edf->flow, n_reg, src_node);
}
// ignore internal vars for now
}
free (src);
r_graph_add_edge (edf->flow, src_node, op_node);
@ -280,31 +279,31 @@ static bool edf_consume_1_push_1(RAnalEsil *esil) {
RGraphNode *result_node = r_graph_add_node (edf->flow, result);
r_graph_add_edge (edf->flow, op_node, result_node);
sdb_ptr_set (edf->latest_nodes, r_strbuf_get (result->content), result_node, 0);
r_anal_esil_push (esil, r_strbuf_get(result->content));
r_anal_esil_push (esil, r_strbuf_get (result->content));
return true;
}
static bool edf_use_new_push_1 (RAnalEsil *esil, const char *op_string, AddConstraintStringUseNewCB cb) {
static bool edf_use_new_push_1(RAnalEsil *esil, const char *op_string, AddConstraintStringUseNewCB cb) {
EsilDataFlow *edf = (EsilDataFlow *)esil->user;
RGraphNode *op_node = r_graph_add_node (edf->flow, new_edf_node (edf, op_string));
RGraphNode *latest_new = sdb_ptr_get (edf->latest_nodes, "new", 0); //node for esil->cur
RGraphNode *latest_new = sdb_ptr_get (edf->latest_nodes, "new", 0); //node for esil->cur
if (!latest_new) {
return 0;
}
EsilDataFlowNode *result = new_edf_node (edf, "result_");
r_strbuf_appendf(result->content, "%d", edf->idx++);
r_strbuf_appendf (result->content, "%d", edf->idx++);
if (cb) {
EsilDataFlowNode *e_new_node = (EsilDataFlowNode *)latest_new->data;
cb (result->content, r_strbuf_get (e_new_node->content));
}
RGraphNode *result_node = r_graph_add_node (edf->flow, result);
sdb_ptr_set (edf->latest_nodes, r_strbuf_get(result->content), result_node, 0);
sdb_ptr_set (edf->latest_nodes, r_strbuf_get (result->content), result_node, 0);
r_graph_add_edge (edf->flow, latest_new, op_node);
r_graph_add_edge (edf->flow, op_node, result_node);
return r_anal_esil_push (esil, r_strbuf_get(result->content));
return r_anal_esil_push (esil, r_strbuf_get (result->content));
}
static bool edf_consume_1_use_old_new_push_1 (RAnalEsil *esil, const char *op_string, AddConstraintStringConsume1UseOldNewCB cb) {
static bool edf_consume_1_use_old_new_push_1(RAnalEsil *esil, const char *op_string, AddConstraintStringConsume1UseOldNewCB cb) {
EsilDataFlow *edf = (EsilDataFlow *)esil->user;
char *src = r_anal_esil_pop (esil);
@ -335,7 +334,7 @@ static bool edf_consume_1_use_old_new_push_1 (RAnalEsil *esil, const char *op_st
if (src_type == R_ANAL_ESIL_PARM_REG) {
RGraphNode *n_reg = r_graph_add_node (edf->flow, new_edf_node (edf, src));
EsilDataFlowNode *ev_node = new_edf_node (edf, src);
r_strbuf_appendf(ev_node->content, ":var_%d", edf->idx++);
r_strbuf_appendf (ev_node->content, ":var_%d", edf->idx++);
src_node = r_graph_add_node (edf->flow, ev_node);
sdb_ptr_set (edf->latest_nodes, src, src_node, 0);
r_graph_add_edge (edf->flow, n_reg, src_node);
@ -347,23 +346,23 @@ static bool edf_consume_1_use_old_new_push_1 (RAnalEsil *esil, const char *op_st
r_graph_add_edge (edf->flow, src_node, op_node);
RGraphNode *latest_new = sdb_ptr_get(edf->latest_nodes, "new", 0);
RGraphNode *latest_old = sdb_ptr_get(edf->latest_nodes, "old", 0);
RGraphNode *latest_new = sdb_ptr_get (edf->latest_nodes, "new", 0);
RGraphNode *latest_old = sdb_ptr_get (edf->latest_nodes, "old", 0);
EsilDataFlowNode *result = new_edf_node (edf, "result_");
r_strbuf_appendf(result->content, "%d", edf->idx++);
r_strbuf_appendf (result->content, "%d", edf->idx++);
if (cb) {
EsilDataFlowNode *e_src_node = (EsilDataFlowNode *)src_node->data;
EsilDataFlowNode *e_new_node = (EsilDataFlowNode *)latest_new->data;
EsilDataFlowNode *e_old_node = (EsilDataFlowNode *)latest_old->data;
cb (result->content, r_strbuf_get (e_src_node->content),
r_strbuf_get (e_new_node->content), r_strbuf_get (e_old_node->content));
r_strbuf_get (e_new_node->content), r_strbuf_get (e_old_node->content));
}
RGraphNode *result_node = r_graph_add_node (edf->flow, result);
sdb_ptr_set (edf->latest_nodes, r_strbuf_get(result->content), result_node, 0);
sdb_ptr_set (edf->latest_nodes, r_strbuf_get (result->content), result_node, 0);
r_graph_add_edge (edf->flow, latest_new, op_node);
r_graph_add_edge (edf->flow, latest_old, op_node);
r_graph_add_edge (edf->flow, op_node, result_node);
return r_anal_esil_push (esil, r_strbuf_get(result->content));
return r_anal_esil_push (esil, r_strbuf_get (result->content));
}
R_API void r_core_anal_esil_graph(RCore *core, const char *expr) {
@ -380,39 +379,39 @@ R_API void r_core_anal_esil_graph(RCore *core, const char *expr) {
}
esil->anal = core->anal;
edf->latest_nodes = sdb_new0 ();
edf->flow = r_graph_new();
edf->flow = r_graph_new ();
r_anal_esil_set_op(esil, "=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, ":=", edf_eq_weak, 0, 2, R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "$z", edf_zf, 1, 0, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
r_anal_esil_set_op(esil, "$c", edf_cf, 1, 1, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
r_anal_esil_set_op(esil, "$b", edf_bf, 1, 1, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
r_anal_esil_set_op(esil, "^=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "-=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "+=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "*=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "/=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "&=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "|=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "^=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op(esil, "+", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "-", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "&", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "|", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "^", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "%", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "*", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "/", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, ">>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "<<", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, ">>>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, ">>>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "!", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op(esil, "[1]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op(esil, "[2]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op(esil, "[4]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op(esil, "[8]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op(esil, "[16]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op (esil, "=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, ":=", edf_eq_weak, 0, 2, R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "$z", edf_zf, 1, 0, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
r_anal_esil_set_op (esil, "$c", edf_cf, 1, 1, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
r_anal_esil_set_op (esil, "$b", edf_bf, 1, 1, R_ANAL_ESIL_OP_TYPE_UNKNOWN);
r_anal_esil_set_op (esil, "^=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "-=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "+=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "*=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "/=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "&=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "|=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "^=", edf_consume_2_set_reg, 0, 2, R_ANAL_ESIL_OP_TYPE_MATH | R_ANAL_ESIL_OP_TYPE_REG_WRITE);
r_anal_esil_set_op (esil, "+", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "-", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "&", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "|", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "^", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "%", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "*", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "/", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, ">>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "<<", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, ">>>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, ">>>", edf_consume_2_push_1, 1, 2, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "!", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MATH);
r_anal_esil_set_op (esil, "[1]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op (esil, "[2]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op (esil, "[4]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op (esil, "[8]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
r_anal_esil_set_op (esil, "[16]", edf_consume_1_push_1, 1, 1, R_ANAL_ESIL_OP_TYPE_MEM_READ);
esil->user = edf;
@ -422,15 +421,15 @@ R_API void r_core_anal_esil_graph(RCore *core, const char *expr) {
RGraphNode *node, *edon;
r_list_foreach (r_graph_get_nodes (edf->flow), iter, node) {
const EsilDataFlowNode *enode = (EsilDataFlowNode *)node->data;
char *esc_str = r_str_escape (r_strbuf_get(enode->content));
char *esc_str = r_str_escape (r_strbuf_get (enode->content));
r_cons_printf ("\"agn %d %s\"\n", enode->idx, esc_str);
node->free = (RListFree)edf_node_free;
free (esc_str);
}
r_list_foreach (r_graph_get_nodes(edf->flow), iter, node) {
r_list_foreach (r_graph_get_nodes (edf->flow), iter, node) {
const EsilDataFlowNode *enode = (EsilDataFlowNode *)node->data;
r_list_foreach (r_graph_get_neighbours(edf->flow, node), ator, edon) {
r_list_foreach (r_graph_get_neighbours (edf->flow, node), ator, edon) {
const EsilDataFlowNode *edone = (EsilDataFlowNode *)edon->data;
r_cons_printf ("age %d %d\n", enode->idx, edone->idx);
}

View File

@ -1209,8 +1209,8 @@ typedef bool (*RAnalEsilOpCb)(RAnalEsil *esil);
typedef struct r_anal_esil_operation_t {
RAnalEsilOpCb code;
ut32 push;
ut32 pop;
ut32 push; // amount of operands pushed
ut32 pop; // amount of operands popped
ut32 type;
} RAnalEsilOp;
@ -1426,7 +1426,7 @@ R_API int r_anal_esil_mem_read(RAnalEsil *esil, ut64 addr, ut8 *buf, int len);
R_API int r_anal_esil_mem_write(RAnalEsil *esil, ut64 addr, const ut8 *buf, int len);
R_API int r_anal_esil_reg_read(RAnalEsil *esil, const char *regname, ut64 *num, int *size);
R_API int r_anal_esil_reg_write(RAnalEsil *esil, const char *dst, ut64 num);
R_API int r_anal_esil_pushnum(RAnalEsil *esil, ut64 num);
R_API bool r_anal_esil_pushnum(RAnalEsil *esil, ut64 num);
R_API bool r_anal_esil_push(RAnalEsil *esil, const char *str);
R_API char *r_anal_esil_pop(RAnalEsil *esil);
R_API bool r_anal_esil_set_op(RAnalEsil *esil, const char *op, RAnalEsilOpCb code, ut32 push, ut32 pop, ut32 type);