Skip to main content

Crate re_ghidra_cc_hook

Crate re_ghidra_cc_hook 

Source
Expand description

re-ghidra-cc-hook — the plugin’s SessionStart preflight.

The four ways this plugin fails to start are all environmental: no GHIDRA_INSTALL_DIR, a directory that is not actually a Ghidra root, a JDK older than 21, and an unconfigured project. Without this hook each of them surfaces only on the first tool call, as an error from inside a JVM that never booted.

Two rules govern what it may do:

  1. Silent when healthy. It runs on every session start, so a clean environment must produce no output at all. Anything else is noise the user reads once and then learns to ignore.
  2. Never blocks. It always exits 0. A preflight that can stop a session is worse than the problem it reports — the user may not even intend to touch Ghidra this session.

Every check is filesystem-or-java -version cheap: no JVM boot, no Ghidra project open.

Functions§

detect_java_major 🔒
java -version writes to stderr, not stdout. Any spawn failure means “no usable java”, which is exactly what the preflight wants to hear.
event_cwd 🔒
Pull cwd out of the hook event without a full deserialization struct — the field is the only one we want and the schema may grow.
launcher_exists 🔒
A Ghidra install root is identified by its headless launcher, the same file the server’s own config validation looks for.
main 🔒
overlay_env 🔒
Layer the environment over the settings file, matching the server’s own precedence. Empty is treated as unset, as it is there.