Skip to content

Add a PyGhidraCustomLoadAnalyzer#677

Merged
rbs-jacob merged 13 commits into
masterfrom
feature/pyghidra_custom_loader
Dec 17, 2025
Merged

Add a PyGhidraCustomLoadAnalyzer#677
rbs-jacob merged 13 commits into
masterfrom
feature/pyghidra_custom_loader

Conversation

@paulnoalhyt
Copy link
Copy Markdown
Collaborator

@paulnoalhyt paulnoalhyt commented Dec 10, 2025

  • I have reviewed the OFRAK contributor guide and attest that this pull request is in accordance with it.
  • I have made or updated a changelog entry for the changes in this pull request.

One sentence summary of this PR (This should go in the CHANGELOG!)

Add a PyGhidraCustomLoadAnalyzer to allow loading of custom binary formats in PyGhidra, from MemoryRegions.

Link to Related Issue(s)

None.

Please describe the changes in your request.

With the Ghidra backend we had the GhidraCustomLoadAnalyzer, so this is a port to the PyGhidra backend:

  • introduce PyGhidraAutoLoadProject which corresponds to the former PyGhidraProject. Introduce PyGhidraCustomLoadProject for binaries that are not in the _GHIDRA_AUTO_LOADABLE_FORMATS list.
  • PyGhidraAnalysisIdentifier now checks the _GHIDRA_AUTO_LOADABLE_FORMATS list to add the PyGhidraAutoLoadProject or PyGhidraCustomLoadProject tag depending on the resource.
  • introduce PyGhidraCustomLoadAnalyzer which gets the list of MemoryRegions in a program (created by a custom unpacker for example) and passes that to the PyGhidra backend.
  • modified the unpack method in pyghidra_analysis.py: when provided with a list of memory_regions, it deletes all data in the program, then creates regions according to the list that was passed.

Another minor thing I fixed is in CachedCodeRegionUnpacker, with some binaries, I found that the PyGhidra backend tried to create a few ComplexBlocks outside of the CodeRegion. Instead of raising an alert I turned that into a warning to allow users to continue working with the PyGhidra backend.
[edit] I reverted my changes in the CachedCodeRegionUnpacker. It turned out I had a bug in the PyGhidra components: when running the PyGhidraCodeRegionUnpacker before any PyGhidra analysis, it was always running the PyGhidraAutoAnalyzer even if the Program resource did not have the PyGhidraAutoLoadProject tag. That resulted in loading the full file in Ghidra (not using the PyGhidraCustomLoadAnalyzer) so the region in PyGhidra was larger than the code region in OFRAK, producing ComplexBlocks outside of the CodeRegion. Now that I fixed the PyGhidraCodeRegionUnpacker, it's all good!

Also added a troubleshooting section to the PyGhidra documentation.

Anyone you think should look at this, specifically?

No.

Copy link
Copy Markdown
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good so far! (I know it's still marked "draft.")

Would love to see a test or two to validate that it didn't work before, but does with these changes.

Comment thread disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/components/pyghidra_components.py Outdated
Comment thread disassemblers/ofrak_pyghidra/src/ofrak_pyghidra/standalone/pyghidra_analysis.py Outdated
@paulnoalhyt paulnoalhyt changed the title Draft: Add a PyGhidraCustomAutoAnalyzer Draft: Add a PyGhidraCustomLoadAnalyzer Dec 17, 2025
Paul Noalhyt and others added 5 commits December 17, 2025 10:07
Co-authored-by: Jacob Strieb <99368685+rbs-jacob@users.noreply.github.com>
…nsecurity/ofrak into feature/pyghidra_custom_loader
…onUnpacker to have it run the right PyGhidra analyzer based on the program tag
@paulnoalhyt paulnoalhyt changed the title Draft: Add a PyGhidraCustomLoadAnalyzer Add a PyGhidraCustomLoadAnalyzer Dec 17, 2025
Copy link
Copy Markdown
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@rbs-jacob rbs-jacob merged commit 1f95e2a into master Dec 17, 2025
100 checks passed
@paulnoalhyt paulnoalhyt deleted the feature/pyghidra_custom_loader branch May 13, 2026 10:24
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.

2 participants