From f1b32ba2b8db22a5f92a2734af55e9a5dba2271e Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Mon, 18 Jun 2018 09:27:45 +0200 Subject: Example/ida: use addr to guess arch Some arch like ARM depends on address in order to determine which attributes have to be used during analysis --- example/ida/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'example/ida/utils.py') diff --git a/example/ida/utils.py b/example/ida/utils.py index 481220a9..5620a881 100644 --- a/example/ida/utils.py +++ b/example/ida/utils.py @@ -5,7 +5,7 @@ from miasm2.analysis.machine import Machine from miasm2.ir.translators import Translator import miasm2.expression.expression as m2_expr -def guess_machine(): +def guess_machine(addr=None): "Return an instance of Machine corresponding to the IDA guessed processor" processor_name = GetLongPrm(INF_PROCNAME) @@ -39,7 +39,14 @@ def guess_machine(): (False, 64, True): "aarch64b", (False, 64, False): "aarch64l", } - is_armt = globals().get('armt', False) + + # Get T reg to detect arm/thumb function + # Default is arm + is_armt = False + if addr is not None: + t_reg = GetReg(addr, "T") + is_armt = t_reg == 1 + is_bigendian = info.is_be() infos = (is_armt, size, is_bigendian) if not infos in info2machine: -- cgit 1.4.1