From 352949f41ea0b66c833f272d2a2a1e5a77a9507c Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 6 Mar 2018 19:33:00 -0500 Subject: Automatically update analysis after commands in interactive Python --- python/scriptingprovider.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python/scriptingprovider.py') diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index c92c249a..e7838748 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -540,7 +540,7 @@ 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: + if self.active_func is None: self.locals["current_llil"] = None self.locals["current_mlil"] = None else: @@ -556,6 +556,8 @@ class PythonScriptingInstance(ScriptingInstance): elif self.locals["current_address"] != self.active_addr: if not self.active_view.file.navigate(self.active_view.file.view, self.locals["current_address"]): sys.stderr.write("Address 0x%x is not valid for the current view\n" % self.locals["current_address"]) + if self.active_view is not None: + self.active_view.update_analysis() except: traceback.print_exc() finally: -- cgit v1.3.1 From 8275894663c905b839e62c60f804c30e47584e5b Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Thu, 10 May 2018 13:05:48 -0400 Subject: change stdin/out hijacking to be triggered by pythonplugin shared library --- python/scriptingprovider.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'python/scriptingprovider.py') diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index e7838748..988f856d 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -650,6 +650,7 @@ original_stdin = sys.stdin original_stdout = sys.stdout original_stderr = sys.stderr -sys.stdin = _PythonScriptingInstanceInput(sys.stdin) -sys.stdout = _PythonScriptingInstanceOutput(sys.stdout, False) -sys.stderr = _PythonScriptingInstanceOutput(sys.stderr, True) +def redirect_stdio(): + sys.stdin = _PythonScriptingInstanceInput(sys.stdin) + sys.stdout = _PythonScriptingInstanceOutput(sys.stdout, False) + sys.stderr = _PythonScriptingInstanceOutput(sys.stderr, True) -- cgit v1.3.1 From 3b433195716732f63f352730d481a0a9415639a1 Mon Sep 17 00:00:00 2001 From: negasora Date: Mon, 11 Jun 2018 19:03:18 -0400 Subject: Add empty list properties to some classes to allow for visibility --- python/architecture.py | 5 +++++ python/binaryview.py | 4 ++++ python/platform.py | 5 +++++ python/plugin.py | 10 ++++++++++ python/scriptingprovider.py | 5 +++++ python/transform.py | 5 +++++ python/update.py | 4 ++++ 7 files changed, 38 insertions(+) (limited to 'python/scriptingprovider.py') diff --git a/python/architecture.py b/python/architecture.py index c5f87ec6..df22da7f 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -391,6 +391,11 @@ class Architecture(object): return True return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents) + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass + @property def full_width_regs(self): """List of full width register strings (read-only)""" diff --git a/python/binaryview.py b/python/binaryview.py index 0cf25e70..80298304 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -341,6 +341,10 @@ class BinaryViewType(object): if not isinstance(value, BinaryViewType): return True return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents) + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass @property def name(self): diff --git a/python/platform.py b/python/platform.py index a79e3b9a..dd756178 100644 --- a/python/platform.py +++ b/python/platform.py @@ -120,6 +120,11 @@ class Platform(object): return True return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents) + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass + @property def default_calling_convention(self): """ diff --git a/python/plugin.py b/python/plugin.py index 30a46412..13ca51af 100644 --- a/python/plugin.py +++ b/python/plugin.py @@ -83,6 +83,11 @@ class PluginCommand(object): self.description = str(cmd.description) self.type = PluginCommandType(cmd.type) + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass + @classmethod def _default_action(cls, view, action): try: @@ -587,6 +592,11 @@ class BackgroundTask(object): def __del__(self): core.BNFreeBackgroundTask(self.handle) + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass + @property def progress(self): """Text description of the progress of the background task (displayed in status bar of the UI)""" diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index 988f856d..1e2338d9 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -303,6 +303,11 @@ class ScriptingProvider(object): if handle is not None: self.handle = core.handle_of_type(handle, core.BNScriptingProvider) self.__dict__["name"] = core.BNGetScriptingProviderName(handle) + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass + def register(self): self._cb = core.BNScriptingProviderCallbacks() diff --git a/python/transform.py b/python/transform.py index 59d719e7..3284ed74 100644 --- a/python/transform.py +++ b/python/transform.py @@ -200,6 +200,11 @@ class Transform(object): log.log_error(traceback.format_exc()) return False + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass + @abc.abstractmethod def perform_decode(self, data, params): if self.type == TransformType.InvertingTransform: diff --git a/python/update.py b/python/update.py index 1eb8ea61..2f817595 100644 --- a/python/update.py +++ b/python/update.py @@ -115,6 +115,10 @@ class UpdateChannel(object): self.name = name self.description = desc self.latest_version_num = ver + @property + def list(self): + """Allow tab completion to discover metaclass list property""" + pass @property def versions(self): -- cgit v1.3.1 From 829917b3bb442d58dbd5f95dc13634ddb7a02a51 Mon Sep 17 00:00:00 2001 From: negasora Date: Mon, 11 Jun 2018 19:05:21 -0400 Subject: fix styling --- python/binaryview.py | 1 + python/scriptingprovider.py | 1 + python/update.py | 1 + 3 files changed, 3 insertions(+) (limited to 'python/scriptingprovider.py') diff --git a/python/binaryview.py b/python/binaryview.py index 80298304..81851c1f 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -341,6 +341,7 @@ class BinaryViewType(object): if not isinstance(value, BinaryViewType): return True return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents) + @property def list(self): """Allow tab completion to discover metaclass list property""" diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py index 1e2338d9..9cacc6ad 100644 --- a/python/scriptingprovider.py +++ b/python/scriptingprovider.py @@ -303,6 +303,7 @@ class ScriptingProvider(object): if handle is not None: self.handle = core.handle_of_type(handle, core.BNScriptingProvider) self.__dict__["name"] = core.BNGetScriptingProviderName(handle) + @property def list(self): """Allow tab completion to discover metaclass list property""" diff --git a/python/update.py b/python/update.py index 2f817595..a89c9348 100644 --- a/python/update.py +++ b/python/update.py @@ -115,6 +115,7 @@ class UpdateChannel(object): self.name = name self.description = desc self.latest_version_num = ver + @property def list(self): """Allow tab completion to discover metaclass list property""" -- cgit v1.3.1