diff options
| author | Rusty Wagner <rusty@vector35.com> | 2017-12-26 17:14:16 -0500 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2017-12-26 17:14:16 -0500 |
| commit | 9fc4766a507d5299cd4de78170c5798b02bb9698 (patch) | |
| tree | a4589f36a46e662cc16613db88f1c83c69512181 /python/scriptingprovider.py | |
| parent | 06b97009b2a09dc7816f6ace2d6a4bff66cb3f26 (diff) | |
| parent | 26edabfdd7211012c7c8a03186d3025eea9aa345 (diff) | |
Merge branch 'dev' into fpu
Diffstat (limited to 'python/scriptingprovider.py')
| -rw-r--r-- | python/scriptingprovider.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index ed9688b9..c92c249a 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -42,14 +42,14 @@ class _ThreadActionContext(object): def __init__(self, func): self.func = func self.interpreter = None - if "value" in dir(PythonScriptingInstance._interpreter): + if hasattr(PythonScriptingInstance._interpreter, "value"): self.interpreter = PythonScriptingInstance._interpreter.value self.__class__._actions.append(self) self.callback = ctypes.CFUNCTYPE(None, ctypes.c_void_p)(lambda ctxt: self.execute()) def execute(self): old_interpreter = None - if "value" in dir(PythonScriptingInstance._interpreter): + if hasattr(PythonScriptingInstance._interpreter, "value"): old_interpreter = PythonScriptingInstance._interpreter.value PythonScriptingInstance._interpreter.value = self.interpreter try: @@ -380,7 +380,7 @@ class _PythonScriptingInstanceOutput(object): def write(self, data): interpreter = None - if "value" in dir(PythonScriptingInstance._interpreter): + if hasattr(PythonScriptingInstance._interpreter, "value"): interpreter = PythonScriptingInstance._interpreter.value if interpreter is None: @@ -419,7 +419,7 @@ class _PythonScriptingInstanceInput(object): def read(self, size): interpreter = None - if "value" in dir(PythonScriptingInstance._interpreter): + if hasattr(PythonScriptingInstance._interpreter, "value"): interpreter = PythonScriptingInstance._interpreter.value if interpreter is None: @@ -434,7 +434,7 @@ class _PythonScriptingInstanceInput(object): def readline(self): interpreter = None - if "value" in dir(PythonScriptingInstance._interpreter): + if hasattr(PythonScriptingInstance._interpreter, "value"): interpreter = PythonScriptingInstance._interpreter.value if interpreter is None: @@ -457,7 +457,7 @@ class PythonScriptingInstance(ScriptingInstance): super(PythonScriptingInstance.InterpreterThread, self).__init__() self.instance = instance self.locals = {"__name__": "__console__", "__doc__": None, "binaryninja": sys.modules[__name__]} - self.interpreter = code.InteractiveInterpreter(self.locals) + self.interpreter = code.InteractiveConsole(self.locals) self.event = threading.Event() self.daemon = True @@ -484,7 +484,7 @@ class PythonScriptingInstance(ScriptingInstance): self.code = None self.input = "" - self.interpreter.runsource("from binaryninja import *\n") + self.interpreter.push("from binaryninja import *\n") def execute(self, code): self.code = code @@ -540,8 +540,15 @@ class PythonScriptingInstance(ScriptingInstance): self.locals["current_address"] = self.active_addr self.locals["here"] = self.active_addr self.locals["current_selection"] = (self.active_selection_begin, self.active_selection_end) + if self.active_func == None: + self.locals["current_llil"] = None + self.locals["current_mlil"] = None + else: + self.locals["current_llil"] = self.active_func.low_level_il + self.locals["current_mlil"] = self.active_func.medium_level_il - self.interpreter.runsource(code) + for line in code.split("\n"): + self.interpreter.push(line) if self.locals["here"] != self.active_addr: if not self.active_view.file.navigate(self.active_view.file.view, self.locals["here"]): |
