FunctionID: Add AddSingleFunction.java Ghidra script #7235
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.
Fixes #5212
Introduction
As described in the linked issue there is currently no way to add a single function to a FID DB which is something I have wanted for a long time as well. The Ghidra script
AddSingleFunction.java
now implements this functionality.Overview of the script
Prerequisites:
The script checks if there is any available library in the FID DB. If a library exists the user can select it. If not the user will be prompted to create one. The user can then decide whether to preserve the namespaces of the selected function or save only the basename. Finally the function entry is saved.
Testing
Empty FID DB (create new library)
Select a function (
rayon::main
):Run
AddSingleFunction.java
:List the FID DB content with
ListFunctions.java
:Non-empty FID DB (already contains at least one library)
Select a function (
crossbeam_deque::deque::Stealer<T>::steal
):Run
AddSingleFunction.java
:List the FID DB content with
ListFunctions.java
:Additional notes
I had to make
FidServiceLibraryIngest
andfindTerminator()
public because they are required to calculatehasTerminator
which is passed tocreateNewFunction()
. If this is not allowed let me know and I will duplicatefindTerminator()
instead.