mirror of
https://github.com/qilingframework/qiling.git
synced 2026-10-12 02:21:40 +00:00
The first line reads `from future import __annotations__`, with the module name and the imported symbol swapped. The intent was clearly the PEP 563 future statement `from __future__ import annotations`. As written, the line fails in both possible situations: - without the third-party `future` package installed (the common case), the import raises `ModuleNotFoundError`, so `QILING_IDA` is never defined; - with that package installed, the import silently succeeds but binds the module's empty `__annotations__` dict, so PEP 563 is *not* enabled — while the annotations in this file (`ql: Qiling`) rely on it, `Qiling` being imported under `TYPE_CHECKING` only. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pru9dwqPVrDakERYZwzjUx
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, List
|
|
|
|
if TYPE_CHECKING:
|
|
from qiling import Qiling
|
|
from qiling.core_hooks_types import HookRet
|
|
|
|
|
|
class QILING_IDA:
|
|
|
|
def _show_context(self, ql: Qiling):
|
|
registers = tuple(ql.arch.regs.register_mapping.keys())
|
|
grouping = 4
|
|
|
|
for idx in range(0, len(registers), grouping):
|
|
ql.log.info('\t'.join(f'{r:5s}: {ql.arch.regs.read(r):016x}' for r in registers[idx:idx + grouping]))
|
|
|
|
def custom_prepare(self, ql: Qiling) -> None:
|
|
ql.log.info('Context before starting emulation:')
|
|
self._show_context(ql)
|
|
|
|
def custom_continue(self, ql: Qiling) -> List[HookRet]:
|
|
ql.log.info('custom_continue hook')
|
|
self._show_context(ql)
|
|
|
|
return []
|
|
|
|
def custom_step(self, ql: Qiling) -> List[HookRet]:
|
|
def step_hook(ql: Qiling, addr: int, size: int):
|
|
ql.log.info(f'Executing: {addr:#x}')
|
|
self._show_context(ql)
|
|
|
|
ql.log.info('custom_step hook')
|
|
|
|
return [ql.hook_code(step_hook)]
|
|
|
|
def custom_execute_selection(self, ql: Qiling) -> List[HookRet]:
|
|
ql.log.info('custom_execute_selection hook')
|
|
|
|
return []
|