Skip to content

Add Ghidra 12.0 support and fix decompiler highlighting (broken since 11.2)#18

Open
nathan-casabieille wants to merge 2 commits into
nccgroup:mainfrom
nathan-casabieille:main
Open

Add Ghidra 12.0 support and fix decompiler highlighting (broken since 11.2)#18
nathan-casabieille wants to merge 2 commits into
nccgroup:mainfrom
nathan-casabieille:main

Conversation

@nathan-casabieille
Copy link
Copy Markdown

Problem

Since Ghidra 11.2, the plugin no longer highlights code in the decompiler view. The root cause is that `DecompilerController.callbackHandler` was made `final` in 11.2, which broke the approach of replacing it via reflection. With Java 21 (required by Ghidra 11.3+), this fails hard at runtime — `IllegalAccessException` is thrown when the plugin initialises, silently disabling decompiler highlighting entirely. Listing and function graph highlighting were unaffected.

Solution

Replace the reflection approach with `DecompilerHighlightService`, the official public API introduced in Ghidra 10.2 for exactly this use case. A `CTokenHighlightMatcher` is registered once via `createHighlighter()` and Ghidra calls it back for every token whenever a function is decompiled. The covered address set is built once per decompile pass in `start()` and looked up in O(log n) per token via `AddressSet`, which keeps things snappy even on large functions.

Changes

  • `CartographerPlugin.java`: Remove all reflection-based decompiler interception. Register a `DecompilerHighlighter` through `DecompilerHighlightService` instead. `colorizeDecompiler()` now simply calls `applyHighlights()` on the highlighter, and `dispose()` cleans it up properly.
  • `build.gradle`: Add support for building against both binary Ghidra releases and source tree checkouts. Add the transitive Maven dependencies that Ghidra's API signatures pull in (`guava`, `commons-lang3`, `jdom2`, etc.) as `compileOnly` so `javac` can resolve them without bundling anything extra. Fix a classpath isolation issue that caused `buildModuleHelp` to fail with a module collision error on source tree builds.
  • `MIGRATION.md`: Notes on what changed and why, for anyone upgrading from an older version.
  • CI: Added Ghidra 12.0 to the build matrix alongside 11.1.2.

Testing

Tested on Ghidra 12.0.4. Listing highlights, decompiler highlights, and color customisation all work as before. The `DecompilerHighlightService` API is available from Ghidra 10.2 onward, so this should not regress anything on older supported versions.

In Ghidra 11.2, the DecompilerController.callbackHandler field was made
final, which broke the existing approach of replacing it via reflection
to intercept decompilation results. Java 21 (required by Ghidra 11.3+)
enforces immutability of final fields even through reflection, making the
plugin non-functional on all current Ghidra versions.

Replace the reflection-based approach with the official
DecompilerHighlightService API, which was designed for exactly this use
case. A CTokenHighlightMatcher is registered via createHighlighter() and
called back by Ghidra for every token whenever a function is decompiled.
The covered address set is built once per decompile pass in start() and
checked in O(log n) per token using AddressSet.

The build system is also updated to support both binary Ghidra
installations and source tree checkouts, and to correctly resolve
transitive Maven dependencies needed to compile against the Ghidra API.
CI matrix extended to cover Ghidra 12.0.
@nathan-casabieille nathan-casabieille changed the title Fix decompiler highlighting compatibility with Ghidra 11.2+ Add Ghidra 12.0 support and fix decompiler highlighting (broken since 11.2) May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant