Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2504,7 +2504,8 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int
r_asm_set_pc (core->rasm, addr);
hint = r_anal_hint_get (core->anal, addr);
ret = r_anal_op (core->anal, &op, addr, buf + idx, len - idx,
R_ARCH_OP_MASK_ESIL | R_ARCH_OP_MASK_OPEX | R_ARCH_OP_MASK_HINT | R_ARCH_OP_MASK_DISASM);
R_ARCH_OP_MASK_ESIL | R_ARCH_OP_MASK_OPEX | R_ARCH_OP_MASK_HINT
| R_ARCH_OP_MASK_DISASM | R_ARCH_OP_MASK_VAL);
(void)r_asm_disassemble (core->rasm, &asmop, buf + idx, len - idx);
esilstr = R_STRBUF_SAFEGET (&op.esil);
opexstr = R_STRBUF_SAFEGET (&op.opex);
Expand Down
40 changes: 40 additions & 0 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7568,6 +7568,30 @@ R_API int r_core_print_disasm_instructions(RCore *core, int nb_bytes, int nb_opc
return ret;
}

static void anal_value_to_json(PJ *pj, RAnalValue *val) {
char *s = r_anal_value_tostring (val);
pj_o (pj);
pj_ks (pj, "name", s);
free (s);
pj_ks (pj, "type", r_anal_value_type_tostring (val));
if (val->access) {
pj_ks (pj, "access", (val->access & R_PERM_W)? "rw": "ro");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm i think that should be RWX not "rw" or "ro"

}
if (val->absolute) {
pj_kn (pj, "absolute", val->absolute);
}
if (val->imm) {
pj_kn (pj, "imm", val->imm);
}
if (val->delta) {
pj_kn (pj, "delta", val->delta);
}
if (val->mul) {
pj_kn (pj, "mul", val->mul);
}
pj_end (pj);
}


/* Disassemble `nb_opcodes` instructions, or bytes if `nb_bytes` is enabled (as JSON) */
R_IPI int r_core_print_disasm_json_ipi(RCore *core, ut64 addr, ut8 *buf, int nb_bytes, int nb_opcodes, PJ *pj, const void *pdu_condition) {
Expand Down Expand Up @@ -7790,6 +7814,22 @@ R_IPI int r_core_print_disasm_json_ipi(RCore *core, ut64 addr, ut8 *buf, int nb_
// wanted the numerical values of the type information
pj_kn (pj, "type_num", (ut64)(ds->analop.type & UT64_MAX));
pj_kn (pj, "type2_num", (ut64)(ds->analop.type2 & UT64_MAX));
if (RVecRArchValue_length (&ds->analop.srcs) > 0) {
pj_ka (pj, "srcs");
RAnalValue *val;
R_VEC_FOREACH (&ds->analop.srcs, val) {
anal_value_to_json (pj, val);
}
pj_end (pj);
}
if (RVecRArchValue_length (&ds->analop.dsts) > 0) {
pj_ka (pj, "dsts");
RAnalValue *val;
R_VEC_FOREACH (&ds->analop.dsts, val) {
anal_value_to_json (pj, val);
}
pj_end (pj);
}
// addr addrline info here
{
const RBinAddrline *al = r_bin_addrline_get (core->bin, at);
Expand Down
Loading