diff options
Diffstat (limited to 'miasm2')
| -rw-r--r-- | miasm2/ir/ir.py | 14 | ||||
| -rw-r--r-- | miasm2/ir/symbexec.py | 12 |
2 files changed, 20 insertions, 6 deletions
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index 603d3fd0..afb6b382 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -469,13 +469,15 @@ class IntermediateRepresentation(object): if (isinstance(addr, m2_expr.ExprId) and isinstance(addr.name, AsmLabel)): addr = addr.name - if isinstance(addr, m2_expr.ExprInt): + if isinstance(addr, AsmLabel): + return addr + + try: addr = int(addr) - if isinstance(addr, (int, long)): - addr = self.symbol_pool.getby_offset_create(addr) - elif isinstance(addr, AsmLabel): - addr = self.symbol_pool.getby_name_create(addr.name) - return addr + except (ValueError, TypeError): + return None + + return self.symbol_pool.getby_offset_create(addr) def get_block(self, addr): """Returns the irbloc associated to an ExprId/ExprInt/label/int diff --git a/miasm2/ir/symbexec.py b/miasm2/ir/symbexec.py index 6d6ba630..593ab49a 100644 --- a/miasm2/ir/symbexec.py +++ b/miasm2/ir/symbexec.py @@ -16,6 +16,18 @@ log.addHandler(console_handler) log.setLevel(logging.INFO) +def get_block(ir_arch, mdis, addr): + """Get IRBlock at address @addr""" + lbl = ir_arch.get_label(addr) + if not lbl in ir_arch.blocks: + block = mdis.dis_block(lbl.offset) + ir_arch.add_block(block) + irblock = ir_arch.get_block(lbl) + if irblock is None: + raise LookupError('No block found at that address: %s' % lbl) + return irblock + + class SymbolMngr(object): """ Store registers and memory symbolic values |