Skip to content

Commit

Permalink
updated README and fixed printer
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed May 20, 2019
1 parent 22efa79 commit 8b08d51
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"no-cond-assign": ["error", "except-parens"],
"no-constant-condition": ["error", {
"checkLoops": false
}]
}],
"no-control-regex": "warn"
},
"globals": {
"Global": true,
Expand All @@ -37,4 +38,4 @@
"___internal_load": true,
"___internal_require": true
}
}
}
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Converts asm to pseudo-C code.

# Software Requirements

Requires radare2 version 3.5.0 or newer.
Requires radare2 version 3.6.0 or newer.

# Install

Expand All @@ -32,42 +32,51 @@ Follow the following steps to install r2dec via r2pm
# Arguments

```
[0x00000000]> pdd?
Usage: pdd [args] - core plugin for r2dec
pdd - decompile current function
pdd? - show this help
pdda - decompile current function with side assembly
pddb - decompile current function but shows only scopes
pddu - install/upgrade r2dec via r2pm
pddi - generates the issue data
[0x00000000]> pdd?Usage: pdd [args] - core plugin for r2dec
pdd - decompile current function
pdd? - show this help
pdd* - the decompiled code is returned to r2 as comment (via CCu)
pdda - decompile current function side by side with assembly
pddb - decompile current function but shows only scopes
pddo - decompile current function side by side with offsets
pddu - install/upgrade r2dec via r2pm
pdds <branch> - switches r2dec branch
pddi - generates the issue data
Environment
R2DEC_HOME defaults to the root directory of the r2dec repo
[0x00000000]> pdd --help
r2dec [options]
--help | this help message
--assembly | shows pseudo next to the assembly
--blocks | shows only scopes blocks
--colors | enables syntax colors
--casts | shows all casts in the pseudo code
--colors | enables syntax colors
--debug | do not catch exceptions
--html | outputs html data instead of text
--issue | generates the json used for the test suite
--offsets | shows pseudo next to the assembly offset
--paddr | all xrefs uses physical addresses instead of virtual addresses
--xrefs | shows also instruction xrefs in the pseudo code
--as-comment | the decompiled code is returned to r2 as comment (via CCu)
--as-opcode | the decompiled code is returned to r2 as opcode (via aho)
```

# Radare2 Evaluable vars

You can use these in your `.radare2rc` file.

```
r2dec.casts | if false, hides all casts in the pseudo code.
r2dec.asm | if true, shows pseudo next to the assembly.
r2dec.blocks | if true, shows only scopes blocks.
r2dec.casts | if false, hides all casts in the pseudo code.
r2dec.debug | do not catch exceptions in r2dec.
r2dec.paddr | if true, all xrefs uses physical addresses compare.
r2dec.xrefs | if true, shows all xrefs in the pseudo code.
r2dec.slow | if true load all the data before to avoid multirequests to r2.
r2dec.theme | defines the color theme to be used on r2dec.
r2dec.xrefs | if true, shows all xrefs in the pseudo code.
e scr.html | outputs html data instead of text.
e scr.color | enables syntax colors.
```
Expand All @@ -81,15 +90,16 @@ e scr.color | enables syntax colors.

# Supported Arch

arm
arm 16/32/64 bit
avr
dalvik
m68k (experimental)
mips
ppc
ppc 32/64 bit (VLE included)
sparc
v850
wasm (partial)
x86-64 (intel syntax)
wasm (experimental)
x86/x64

# Developing on r2dec

Expand Down
5 changes: 4 additions & 1 deletion libdec/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
controlflow: /\bif\b|\belse\b|\bwhile\b|\bfor\b|\bdo\b|\breturn\b|\bthrow\b/g,
definebits: /[ui]+nt[123468]+_t|\bvoid\b|\bconst\b|\bsizeof\b|\bfloat\b|\bdouble\b|\bchar\b|\bwchar_t\b|\bextern\b|\bstruct\b|\bsize_t\b|\btime_t\b/g,
numbers: /0x[0-9a-fA-F]+|\b\d+\b/g,
string: /("[^"]+")/
string: /("[^"]+")/,
};

// const defaulttheme = JSON.parse(include('themes/default.json'));
Expand Down Expand Up @@ -135,6 +135,9 @@
if (!Global.evars.honor.color && !Global.evars.honor.html) {
return input;
}
if (input.indexOf("\u001b[") >= 0) {
input = input.replace(/\u001b\[[\d;]+m/, '');
}
/* control flow (if, else, while, do, etc..) */
var x = input.split(_autotheme.controlflow);
if (x.length > 1) {
Expand Down

0 comments on commit 8b08d51

Please sign in to comment.