mirror of
https://github.com/qilingframework/qiling.git
synced 2026-10-12 02:21:40 +00:00
Let EVM patch ql.run
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user