From e261756088883135dced8de6860f9382a1b9492e Mon Sep 17 00:00:00 2001 From: Eric Hennenfent Date: Thu, 9 Jul 2020 19:17:27 -0700 Subject: [PATCH] Handle failed jumps a little more loudly --- README.md | 8 -------- __init__.py | 4 ++-- instruction_state.py | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 26a7e66..3df9775 100644 --- a/README.md +++ b/README.md @@ -47,17 +47,9 @@ The Medium Level IL functions at a significantly higher level than the Lifted IL This plugin has only been tested on 64-bit Ubuntu 16.04. However, since it does not rely on any strictly os-dependent code, it will likely work on other platforms. -## Installation -If available, this plugin uses PyQt5 to display the explanation window. If no working PyQt5 installation is found, it will fall back to using the `show_message_box` feature of the Binary Ninja API, which displays a window that behaves more or less the same, but is not resizable, and blocks any other interaction with Binary Ninja. -1. [Optional]: Install PyQt5 for your platform (`apt install python-pyqt5` on Ubuntu. For other platforms, see [this guide](https://github.com/nbsdx/binja-ui-api/blob/master/HowToPyQt5.pdf).) -2. Clone this repository into your [Binary Ninja Plugins Folder](https://github.com/Vector35/binaryninja-api/tree/dev/python/examples#loading-plugins) - ## Contributing This plugin is designed to make it simple to add support for new LLIL instructions or additional architectures. See [CONTRIBUTING.md](https://github.com/ehennenfent/binja_explain_instruction/blob/master/CONTRIBUTING.md). If you come across any inaccuracies, feel free to file a pull request or create an issue. ## Open Source This plugin incorporates [code by Ryan Stortz (@withzombies)](https://gist.github.com/withzombies/d4f0502754407b22da02664d4eb2fbae) that is used to display information about the CPU state before the selected instruction is executed. See instruction_state.py -## Dependencies -* PyQt5 [Optional] -* Binary Ninja diff --git a/__init__.py b/__init__.py index a095e5d..f73c594 100644 --- a/__init__.py +++ b/__init__.py @@ -138,8 +138,8 @@ def explain_instruction(bv, addr): # Display what information we can calculate about the program state before the instruction is executed try: explain_window().state = get_state(bv, addr) - except AttributeError: - log_error("No instruction state support for this architecture") + except (AttributeError, TypeError) as e: + log_error("Failed to extract instruction state") explain_window().show() diff --git a/instruction_state.py b/instruction_state.py index 9dd43dd..8114422 100644 --- a/instruction_state.py +++ b/instruction_state.py @@ -57,7 +57,7 @@ def get_state(bv, addr): sp_max = func.get_reg_value_at(addr, sp).offset # TODO: What happens when sp_max is None? - for i in range(sp_max if sp_max is not None else 0, 1): + for i in range(sp_max, 1): out = func.get_stack_contents_at(addr, i, 1) if IsRegisterValueInteresting(out): output.append("[SP{:#x}] = {}".format(i, out))