diff options
| author | Camille Mougey <commial@gmail.com> | 2017-05-10 15:06:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 15:06:05 +0200 |
| commit | 3260f7867827195ea7c6ec37bc3a8687ce998f6d (patch) | |
| tree | eaba06d1e886a78c51cb342d635bfd083d252e3c | |
| parent | 0904a50a1d6735ad7ae6720b9b09c9feddfcd92f (diff) | |
| parent | 32508138302e608bed354f6c6bf5e105877b4dac (diff) | |
| download | miasm-3260f7867827195ea7c6ec37bc3a8687ce998f6d.tar.gz miasm-3260f7867827195ea7c6ec37bc3a8687ce998f6d.zip | |
Merge pull request #550 from serpilliere/add_rot_pytrans
Add rot pytrans
Diffstat (limited to '')
| -rw-r--r-- | example/ida/utils.py | 2 | ||||
| -rw-r--r-- | miasm2/ir/translators/python.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/example/ida/utils.py b/example/ida/utils.py index 9af98cc5..a7d2418a 100644 --- a/example/ida/utils.py +++ b/example/ida/utils.py @@ -113,7 +113,7 @@ def expr2colorstr(regs_ids, expr): s += ", ".join(["%s, %s, %s" % (expr2colorstr(regs_ids, subexpr), idaapi.COLSTR(str(idx), idaapi.SCOLOR_RPTCMT), - idaapi.COLSTR(str(idx + expr.size), + idaapi.COLSTR(str(idx + subexpr.size), idaapi.SCOLOR_RPTCMT)) for idx, subexpr in expr.iter_args()]) s += "}" diff --git a/miasm2/ir/translators/python.py b/miasm2/ir/translators/python.py index c06d865c..d7369e9e 100644 --- a/miasm2/ir/translators/python.py +++ b/miasm2/ir/translators/python.py @@ -1,3 +1,4 @@ +from miasm2.expression.expression import ExprInt from miasm2.ir.translators.translator import Translator @@ -55,6 +56,19 @@ class TranslatorPython(Translator): elif expr.op == "parity": return "(%s & 0x1)" % self.from_expr(expr.args[0]) + elif expr.op in ["<<<", ">>>"]: + amount_raw = expr.args[1] + amount = expr.args[1] % ExprInt(amount_raw.size, expr.size) + amount_inv = ExprInt(expr.size, expr.size) - amount + if expr.op == "<<<": + amount, amount_inv = amount_inv, amount + part1 = "(%s >> %s)"% (self.from_expr(expr.args[0]), + self.from_expr(amount)) + part2 = "(%s << %s)"% (self.from_expr(expr.args[0]), + self.from_expr(amount_inv)) + + return "((%s | %s) &0x%x)" % (part1, part2, int(expr.mask)) + raise NotImplementedError("Unknown operator: %s" % expr.op) def from_ExprAff(self, expr): |