Skip to content

Commit

Permalink
0.2.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dc3-tsd committed Nov 4, 2022
1 parent a49a6fb commit cbebd8f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyhidra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

__version__ = "0.2.0"
__version__ = "0.2.1"

# Expose API
from .ghidra import run_script, start, open_program
Expand Down
36 changes: 33 additions & 3 deletions pyhidra/java/plugin/PyScriptProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ public final class PyScriptProvider extends PythonScriptProvider {
private static Consumer<GhidraScript> 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()
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit cbebd8f

Please sign in to comment.