Skip to content

Commit

Permalink
initial work on annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Aug 27, 2020
1 parent bd50ec0 commit 7e288f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libdec/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
session.ascodeline();
Global.context.printLog('[r2dec] new code lines applied for "' + session.routine_name + '".');
return;
} else if (Global.evars.extra.ascodeline) {
session.ascodeline();
Global.context.printLog('[r2dec] new code lines applied for "' + session.routine_name + '".');
return;
}
if (!Global.evars.extra.allfunctions) {
var t = Global.printer.theme;
Expand Down
19 changes: 18 additions & 1 deletion libdec/r2util.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"--highlight-current": "highlights the current address.",
"--as-comment": "the decompiled code is returned to r2 as comment (via CCu)",
"--as-code-line": "the decompiled code is returned to r2 as 'file:line code' (via CL)",
"--as-json": "the decompiled code lines are returned as JSON"
"--as-json": "the decompiled code lines are returned as JSON",
"--annotation": "the decompiled code lines are returned with the annotation format"
};

function has_option(args, name) {
Expand Down Expand Up @@ -160,6 +161,7 @@
offset: Long.ZERO,
slow: true,
theme: 'default',
annotation: false,
};
},
dataTestSuite: function(x) {
Expand Down Expand Up @@ -221,6 +223,7 @@
offset: r2pipe.long('s'),
slow: r2pipe.bool('e r2dec.slow'),
theme: r2pipe.string('e r2dec.theme'),
annotation: has_option(args, '--annotation'),
};
this.add_comment = function(comment, offset) {
if (!comment || comment.length < 1) {
Expand All @@ -244,6 +247,7 @@
this.extra.json = false;
this.honor.color = false;
this.extra.highlights = false;
this.extra.annotation = false;
}

if (this.extra.allfunctions) {
Expand All @@ -254,6 +258,19 @@
this.honor.offsets = false;
this.extra.json = false;
this.extra.highlights = false;
this.extra.annotation = false;
}

if (this.extra.annotation) {
this.extra.ascodeline = false;
this.extra.ascomment = false;
this.extra.highlights = false;
this.extra.html = false;
this.extra.json = false;
this.honor.assembly = false;
this.honor.blocks = false;
this.honor.color = false;
this.honor.offsets = false;
}

if (this.sanitize.html || !this.honor.color) {
Expand Down
5 changes: 5 additions & 0 deletions p/core_pdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static void usage(const RCore* const core) {
"pddb", "", "decompile current function but show only scopes",
"pddo", "", "decompile current function side by side with offsets",
"pddj", "", "decompile current function as json",
"pddA", "", "decompile current function with annotation output",
"pddf", "", "decompile all functions",
"pddu", "", "upgrade r2dec via r2pm",
"pdds", " branch", "switch r2dec branch",
Expand Down Expand Up @@ -272,6 +273,10 @@ static void _cmd_pdd(RCore *core, const char *input) {
// --as-json
duk_r2dec (core, "--as-json");
break;
case 'A':
// --as-json
duk_r2dec (core, "--annotation");
break;
case '?':
default:
usage(core);
Expand Down

0 comments on commit 7e288f8

Please sign in to comment.