about summary refs log tree commit diff stats
path: root/src/focaccia/lldb_target.py
diff options
context:
space:
mode:
authorTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-10-22 15:59:53 +0000
committerTheofilos Augoustis <theofilos.augoustis@gmail.com>2025-11-06 17:20:13 +0000
commitf5746bcbab5d1a3ff88a6e82d7721086fe4c5af2 (patch)
treeda7dfc9be90637d34b0750b47e2bc69d21b11b5a /src/focaccia/lldb_target.py
parentf762c35148bb69cb9ddcea4e95022750e9367e52 (diff)
downloadfocaccia-f5746bcbab5d1a3ff88a6e82d7721086fe4c5af2.tar.gz
focaccia-f5746bcbab5d1a3ff88a6e82d7721086fe4c5af2.zip
Make it possible to use the LLDB disassembly when the Miasm disassembly does not work
Diffstat (limited to 'src/focaccia/lldb_target.py')
-rw-r--r--src/focaccia/lldb_target.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/focaccia/lldb_target.py b/src/focaccia/lldb_target.py
index 6f0011f..b0d7dd6 100644
--- a/src/focaccia/lldb_target.py
+++ b/src/focaccia/lldb_target.py
@@ -315,8 +315,21 @@ class LLDBConcreteTarget:
         return addr
 
     def get_disassembly(self, addr: int) -> str:
-        inst = self.target.ReadInstructions(lldb.SBAddress(addr, self.target), 1)[0]
-        return f'{inst.GetMnemonic(self.target)} {inst.GetOperands(self.target)}'
+        inst: lldb.SBInstruction = self.target.ReadInstructions(lldb.SBAddress(addr, self.target), 1, 'intel')[0]
+        mnemonic: str = inst.GetMnemonic(self.target).upper()
+        operands: str = inst.GetOperands(self.target).upper()
+        operands = operands.replace("0X", "0x")
+        return f'{mnemonic} {operands}'
+
+    def get_disassembly_bytes(self, addr: int):
+        error = lldb.SBError()
+        buf = self.process.ReadMemory(addr, 64, error)
+        inst = self.target.GetInstructions(lldb.SBAddress(addr, self.target), buf)[0]
+        return inst.GetData(self.target).ReadRawData(error, 0, inst.GetByteSize())
+
+    def get_instruction_size(self, addr: int) -> int:
+        inst = self.target.ReadInstructions(lldb.SBAddress(addr, self.target), 1, 'intel')[0]
+        return inst.GetByteSize()
 
 class LLDBLocalTarget(LLDBConcreteTarget):
     def __init__(self,