Overview
The Analyzer interface allows you to create custom analysis plugins that automatically analyze programs based on specific events or conditions. Analyzers are triggered when code, data, or functions are added or modified in a Ghidra program.Interface
Package:ghidra.app.servicesLocation:
Ghidra/Features/Base/src/main/java/ghidra/app/services/Analyzer.java
All analyzer classes MUST end in “Analyzer” for the ClassSearcher to find them.
Core Methods
getName()
Returns the name of the analyzer.getAnalysisType()
Returns the type of analysis this analyzer performs.BYTE_ANALYZER- Triggered when bytes are added (memory block added)INSTRUCTION_ANALYZER- Triggered when instructions are createdFUNCTION_ANALYZER- Triggered when functions are createdFUNCTION_MODIFIERS_ANALYZER- Triggered when a function’s modifiers changeFUNCTION_SIGNATURES_ANALYZER- Triggered when a function’s signature changesDATA_ANALYZER- Triggered when data is created
getDefaultEnablement()
Determines if this analyzer should be enabled by default.program- The program being analyzed
true if the analyzer should be enabled by default, false for specialized analyzers
canAnalyze()
Checks if this analyzer can work on the given program.program- Program to be analyzed
true if this analyzer can analyze this program
added()
Called when the requested information type has been added (e.g., when a function is added).program- Program to analyzeset- AddressSet of locations that have been addedmonitor- Task monitor that indicates progress and cancellation statuslog- Message log to record analysis information
true if the analysis succeeded
Throws: CancelledException if the analysis is cancelled
removed()
Called when the requested information type has been removed (e.g., when a function is removed).program- Program to analyzeset- AddressSet of locations that have been removedmonitor- Task monitor that indicates progress and cancellation statuslog- Message log to record analysis information
true if the analysis succeeded
Throws: CancelledException if the analysis is cancelled
registerOptions()
Registers analyzer options with default values, help content, and descriptions.options- The program options/property list that contains the optionsprogram- Program to be analyzed
optionsChanged()
Initializes analyzer options from the values in the given Options object.options- The program options/property list that contains the optionsprogram- Program to be analyzed
analysisEnded()
Called when an auto-analysis session ends, allowing cleanup of resources.program- The program that was just completed being analyzed
getPriority()
Returns the priority that this analyzer should run at.getDescription()
Returns a longer description of what this analyzer does.supportsOneTimeAnalysis()
Indicates if this analyzer can be directly invoked on an address or address set.true if the analyzer supports one-time analysis
The AutoAnalyzer plugin will automatically create an action for each analyzer that returns
true.isPrototype()
Indicates if this analyzer is a prototype.true if this analyzer is a prototype
Example Implementation
Here’s an example analyzer that condenses filler bytes between functions:See Also
- Function Manager - Managing functions in a program
- Reference Manager - Managing references between code units
