Skip to content

Commit

Permalink
catch Python SystemExit exception to prevent Ghidra from closing (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hunhoff authored Jan 10, 2023
1 parent 8351555 commit fe5fcb1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data/python/jepeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def _jepeval(line):

try:
more_input_needed = _jepeval(line)
except SystemExit as err:
more_input_needed = False
except Exception as err:
# Python exceptions are printed in Python instead of Java to improve error messaging
# in the Ghidra console window
Expand Down
2 changes: 2 additions & 0 deletions data/python/jeprunscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def jep_runscript(path):

try:
exec(compile(source, path, "exec"), {**globals(), **additional_globals})
except SystemExit as err:
print(f"Script {path} called exit with code {err.code}")
except Exception as err:
# Python exceptions are printed in Python instead of Java to give us better error
# messages in the Ghidra console window
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ghidrathon/GhidrathonPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import ghidra.framework.plugintool.*;
import ghidra.util.task.TaskLauncher;
import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.ExamplesPluginPackage;
import ghidra.app.CorePluginPackage;
import ghidra.util.task.TaskMonitorAdapter;
import ghidra.framework.options.ToolOptions;
import ghidra.app.plugin.PluginCategoryNames;
Expand All @@ -32,7 +32,7 @@
//@formatter:off
@PluginInfo(
status = PluginStatus.STABLE,
packageName = ExamplesPluginPackage.NAME,
packageName = CorePluginPackage.NAME,
category = PluginCategoryNames.INTERPRETERS,
shortDescription = "Python 3 Interpreter",
description = "The FLARE team's open-source Python 3 interpreter console that is tightly integrated with a loaded Ghidra program.",
Expand Down

0 comments on commit fe5fcb1

Please sign in to comment.