Add Ghidra 12.0 support and fix decompiler highlighting (broken since 11.2)#18
Open
nathan-casabieille wants to merge 2 commits into
Open
Add Ghidra 12.0 support and fix decompiler highlighting (broken since 11.2)#18nathan-casabieille wants to merge 2 commits into
nathan-casabieille wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.