From 1e4882d82d9d5ca367228a8fd0ab999b998ae3d2 Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Thu, 6 Jun 2024 21:33:03 +0000 Subject: [PATCH] GP-0: fix for opinion failures in dbgeng --- .../Debugger-agent-dbgeng/data/support/local-dbgeng.py | 9 ++++++--- .../src/main/py/src/ghidradbg/arch.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/data/support/local-dbgeng.py b/Ghidra/Debug/Debugger-agent-dbgeng/data/support/local-dbgeng.py index bf32012a3c..6d95b403c1 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/data/support/local-dbgeng.py +++ b/Ghidra/Debug/Debugger-agent-dbgeng/data/support/local-dbgeng.py @@ -39,6 +39,7 @@ else: def main(): # Delay these imports until sys.path is patched from ghidradbg import commands as cmd + from ghidradbg.hooks import on_stop from ghidradbg.util import dbg # So that the user can re-enter by typing repl() @@ -51,15 +52,17 @@ def main(): args = ' ' + args cmd.ghidra_trace_create( os.getenv('OPT_TARGET_IMG') + args, start_trace=False) - cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG')) - cmd.ghidra_trace_sync_enable() - + # TODO: HACK try: dbg.wait() except KeyboardInterrupt as ki: dbg.interrupt() + cmd.ghidra_trace_start(os.getenv('OPT_TARGET_IMG')) + cmd.ghidra_trace_sync_enable() + + on_stop() cmd.repl() diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/arch.py b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/arch.py index a6722c2a95..0e40cdc420 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/arch.py +++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/arch.py @@ -20,7 +20,8 @@ from . import util language_map = { - 'ARM': ['AARCH64:BE:64:v8A', 'AARCH64:LE:64:AppleSilicon', 'AARCH64:LE:64:v8A', 'ARM:BE:64:v8', 'ARM:LE:64:v8'], + 'AARCH64': ['AARCH64:LE:64:AppleSilicon'], + 'ARM': ['ARM:LE:32:v8'], 'Itanium': [], 'x86': ['x86:LE:32:default'], 'x86_64': ['x86:LE:64:default'], @@ -37,7 +38,7 @@ x86_compiler_map = { } arm_compiler_map = { - 'windows': 'windows', + 'windows': 'default', } compiler_map = { @@ -57,12 +58,14 @@ def get_arch(): try: type = util.dbg.get_actual_processor_type() except Exception: - #print("Error getting actual processor type.") + print("Error getting actual processor type.") return "Unknown" if type is None: return "x86_64" if type == 0x8664: return "x86_64" + if type == 0xAA64: + return "AARCH64" if type == 0x014c: return "x86" if type == 0x01c0: