Let EVM patch ql.run

This commit is contained in:
elicn
2022-05-31 23:03:42 +03:00
committed by Eli
parent 1f0755d877
commit 2062a72754
2 changed files with 15 additions and 4 deletions
+14
View File
@@ -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)
+1 -4
View File
@@ -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)