Skip to content

Commit 093c5a1

Browse files
authored
Merge pull request #618 from learn-more/runtime_loglevel
Allow enabling disassembly output at runtime
2 parents 7ae14c3 + 00d99b0 commit 093c5a1

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

CREDITS.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ iamyeh
4949
alfink
5050
bambu
5151
bkerler (viperbjk)
52-
learn-more
52+
Mark Jansen (learn-more)
5353
cq674350529
5454

5555
Alpha testers (in no particular order, named by github id)

qiling/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ def output(self, op):
553553
else:
554554
self._output = op
555555
ql_resolve_logger_level(self._output, self._verbose)
556+
self.os.setup_output()
556557

557558
@property
558559
def verbose(self):
@@ -575,6 +576,7 @@ def verbose(self):
575576
def verbose(self, v):
576577
self._verbose = v
577578
ql_resolve_logger_level(self._output, self._verbose)
579+
self.os.setup_output()
578580

579581
@property
580582
def patch_bin(self) -> list:

qiling/os/utils.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ class QlOsUtils:
123123
def __init__(self, ql):
124124
self.ql = ql
125125
self.path = None
126-
self.output_ready = False
127126
self.md = None
127+
self._disasm_hook = None
128+
self._block_hook = None
128129

129130
def lsbmsb_convert(self, sc, size=4):
130131
split_bytes = []
@@ -267,16 +268,20 @@ def disassembler(self, ql, address, size):
267268
logging.debug("%s\t:\t 0x%x" % (REG_NAME, REG_VAL))
268269

269270
def setup_output(self):
270-
if self.output_ready:
271-
return
272-
self.output_ready = True
273271
def ql_hook_block_disasm(ql, address, size):
274272
logging.info("\n[+] Tracing basic block at 0x%x" % (address))
275273

274+
if self._disasm_hook:
275+
self._disasm_hook.remove()
276+
self._disasm_hook = None
277+
if self._block_hook:
278+
self._block_hook.remove()
279+
self._block_hook = None
280+
276281
if self.ql.output in (QL_OUTPUT.DISASM, QL_OUTPUT.DUMP):
277282
if self.ql.output == QL_OUTPUT.DUMP:
278-
self.ql.hook_block(ql_hook_block_disasm)
279-
self.ql.hook_code(self.disassembler)
283+
self._block_hook = self.ql.hook_block(ql_hook_block_disasm)
284+
self._disasm_hook = self.ql.hook_code(self.disassembler)
280285

281286
def stop(self):
282287
if self.ql.multithread:

0 commit comments

Comments
 (0)