Skip to content

Commit 94aeb96

Browse files
committed
Use disasm_lite for faster DISASM output
1 parent 59ebfdd commit 94aeb96

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

qiling/arch/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def get_base_and_name(self, addr: int) -> Tuple[int, str]:
4848
return addr, '-'
4949

5050
def disassembler(self, ql: Qiling, address: int, size: int):
51-
data = ql.mem.read(address, size)
51+
data = memoryview(ql.mem.read(address, size))
5252

5353
# knowing that all binary sections are aligned to page boundary allows
5454
# us to 'cheat' and search for the containing image using the aligned
@@ -64,11 +64,14 @@ def disassembler(self, ql: Qiling, address: int, size: int):
6464
ba, name = self.get_base_and_name(ql.mem.align(address))
6565

6666
anibbles = ql.arch.bits // 4
67+
pos = 0
6768

68-
for insn in ql.arch.disassembler.disasm(data, address):
69-
offset = insn.address - ba
69+
for iaddr, isize, mnem, ops in ql.arch.disassembler.disasm_lite(data, address):
70+
offset = iaddr - ba
71+
ibytes = data[pos:pos + isize]
7072

71-
ql.log.info(f'{insn.address:0{anibbles}x} [{name:20s} + {offset:#08x}] {insn.bytes.hex(" "):20s} {insn.mnemonic:20s} {insn.op_str}')
73+
ql.log.info(f'{iaddr:0{anibbles}x} [{name:20s} + {offset:#08x}] {ibytes.hex():22s} {mnem:16s} {ops}')
74+
pos += isize
7275

7376
if ql.verbose >= QL_VERBOSE.DUMP:
7477
for reg in ql.arch.regs.register_mapping:

0 commit comments

Comments
 (0)