diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af0175..43f1aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [0.2.1] - 2022-11-03 +- Adds compatibility for Ghidra 10.2. + ## [0.2.0] - 2022-09-27 - Fixed issue with terminal being taken over when running `pyhidraw` on Linux/Mac. - Added cancel and reset buttons to the pyhidra interpreter in the Ghidra plugin. @@ -42,7 +45,8 @@ ## 0.1.0 - 2021-06-14 - Initial release -[Unreleased]: https://github.com/dod-cyber-crime-center/pyhidra/compare/0.2.0...HEAD +[Unreleased]: https://github.com/dod-cyber-crime-center/pyhidra/compare/0.2.1...HEAD +[0.2.1]: https://github.com/dod-cyber-crime-center/pyhidra/compare/0.2.0...0.2.1 [0.2.0]: https://github.com/dod-cyber-crime-center/pyhidra/compare/0.1.5...0.2.0 [0.1.5]: https://github.com/dod-cyber-crime-center/pyhidra/compare/0.1.4...0.1.5 [0.1.4]: https://github.com/dod-cyber-crime-center/pyhidra/compare/0.1.3...0.1.4 diff --git a/pyhidra/__init__.py b/pyhidra/__init__.py index b889c21..ec08836 100644 --- a/pyhidra/__init__.py +++ b/pyhidra/__init__.py @@ -1,5 +1,5 @@ -__version__ = "0.2.0" +__version__ = "0.2.1" # Expose API from .ghidra import run_script, start, open_program diff --git a/pyhidra/java/plugin/PyScriptProvider.java b/pyhidra/java/plugin/PyScriptProvider.java index 81f0fb4..b72a4bc 100644 --- a/pyhidra/java/plugin/PyScriptProvider.java +++ b/pyhidra/java/plugin/PyScriptProvider.java @@ -28,11 +28,21 @@ public final class PyScriptProvider extends PythonScriptProvider { private static Consumer scriptRunner = null; @Override - public GhidraScript getScriptInstance(ResourceFile sourceFile, PrintWriter writer) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + public GhidraScript getScriptInstance(ResourceFile sourceFile, PrintWriter writer) { // check if python is running or not and if not let jython handle it if (scriptRunner == null || GhidraScriptUtil.isSystemScript(sourceFile)) { - return super.getScriptInstance(sourceFile, writer); + try { + return super.getScriptInstance(sourceFile, writer); + } + catch (Throwable t) { + // returning null isn't allowed + // instead return a dummy script instance to report the error + ErrorHandlingGhidraScript gs = new ErrorHandlingGhidraScript(); + gs.setException(t); + gs.setWriter(writer); + gs.setSourceFile(sourceFile); + return gs; + } } GhidraScript script = SystemUtilities.isInHeadlessMode() ? new PyhidraHeadlessScript() @@ -101,4 +111,24 @@ public _ExposedField(String name, Class type) { } } } + + private static class ErrorHandlingGhidraScript extends GhidraScript { + + private Throwable exception; + + private void setException(Throwable exception) { + this.exception = exception; + } + + private void setWriter(PrintWriter writer) { + this.writer = writer; + } + + @Override + public void run() { + writer.println("An exception occured while creating the script instance for " + + sourceFile.getName()); + exception.printStackTrace(writer); + } + } }