diff --git a/qiling/arch/evm/evm.py b/qiling/arch/evm/evm.py index 2d77956d..bd824517 100644 --- a/qiling/arch/evm/evm.py +++ b/qiling/arch/evm/evm.py @@ -3,6 +3,9 @@ # Cross Platform and Multi Architecture Advanced Binary Emulation Framework +import types + +from qiling.arch.evm.vm.message import Message from qiling.const import * from ..arch import QlArch from .vm.evm import QlArchEVMEmulator @@ -17,6 +20,7 @@ class QlArchEVM(QlArch): self.evm = QlArchEVMEmulator(self.ql) monkeypatch_core_hooks(self.ql) + monkeypatch_core_methods(self.ql) def run(self, msg): return self.evm.vm.execute_message(msg) @@ -40,3 +44,13 @@ class QlArchEVM(QlArch): @property def endian(self) -> QL_ENDIAN: return QL_ENDIAN.EL + + +def __evm_run(self, code: Message): + return self.arch.run(code) + +def monkeypatch_core_methods(ql): + """Monkeypatch core methods for evm + """ + + ql.run = types.MethodType(__evm_run, ql) diff --git a/qiling/core.py b/qiling/core.py index 0c5cb929..5dec0341 100644 --- a/qiling/core.py +++ b/qiling/core.py @@ -542,16 +542,13 @@ class Qiling(QlCoreHooks, QlCoreStructs): # Emulate the binary from begin until @end, with timeout in @timeout and # number of emulated instructions in @count - def run(self, begin=None, end=None, timeout=0, count=0, code=None): + def run(self, begin=None, end=None, timeout=0, count=0): # replace the original entry point, exit point, timeout and count self.entry_point = begin self.exit_point = end self.timeout = timeout self.count = count - if self.interpreter: - return self.arch.run(code) - # init debugger (if set) debugger = select_debugger(self._debugger)