Package ghidra.app.decompiler.util
Class FillOutStructureHelper
java.lang.Object
ghidra.app.decompiler.util.FillOutStructureHelper
Automatically creates a structure definition based on the references found by the decompiler.
If the parameter is already a structure pointer, any new references found will be added
to the structure, even if the structure must grow.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class to create pair between an offset and its related PcodeOp -
Constructor Summary
ConstructorDescriptionFillOutStructureHelper
(Program program, DecompileOptions decompileOptions, TaskMonitor monitor) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncomputeHighVariable
(Address storageAddress, Function function) Decompile a function and return the resulting HighVariable associated with a storage addressRetrieve the component map that was generated when structure was created using decompiler info.Retrieve the offset/pcodeOp pairs that are used to load data from the variable used to fill-out structure.Retrieve the offset/pcodeOp pairs that are used to store data into the variable used to fill-out structure.static Structure
Check if a variable has a data-type that is suitable for being extended.processStructure
(HighVariable var, Function function, boolean createNewStructure, boolean createClassIfNeeded) Method to create a structure data type for a variable in the given function.
-
Constructor Details
-
FillOutStructureHelper
public FillOutStructureHelper(Program program, DecompileOptions decompileOptions, TaskMonitor monitor) Constructor.- Parameters:
program
- the current programdecompileOptions
- decompiler options (seeDecompilerUtils.getDecompileOptions(ServiceProvider, Program)
)monitor
- task monitor
-
-
Method Details
-
processStructure
public Structure processStructure(HighVariable var, Function function, boolean createNewStructure, boolean createClassIfNeeded) Method to create a structure data type for a variable in the given function. Unlike the applyTo() action, this method will not modify the function, its variables, or any existing data-types. A new structure is always created.- Parameters:
var
- a parameter, local variable, or global variable used in the given functionfunction
- the function to processcreateNewStructure
- if true a new structure with a unique name will always be generated, if false and variable corresponds to a structure pointer the existing structure will be updated instead.createClassIfNeeded
- if true and variable corresponds to a this pointer without an assigned Ghidra Class (i.e.,void * this
), the function will be assigned to a new unique Ghidra Class namespace with a new identically named structure returned. If false, a new uniquely structure will be created.- Returns:
- a filled-in structure or null if one could not be created
-
getComponentMap
Retrieve the component map that was generated when structure was created using decompiler info. Results are not valid untilprocessStructure(HighVariable, Function, boolean, boolean)
is invoked.- Returns:
- componentMap
-
getStorePcodeOps
Retrieve the offset/pcodeOp pairs that are used to store data into the variable used to fill-out structure. Results are not valid untilprocessStructure(HighVariable, Function, boolean, boolean)
is invoked.- Returns:
- the pcodeOps doing the storing to the associated variable
-
getLoadPcodeOps
Retrieve the offset/pcodeOp pairs that are used to load data from the variable used to fill-out structure. Results are not valid untilprocessStructure(HighVariable, Function, boolean, boolean)
is invoked.- Returns:
- the pcodeOps doing the loading from the associated variable
-
computeHighVariable
Decompile a function and return the resulting HighVariable associated with a storage address- Parameters:
storageAddress
- the storage address of the variablefunction
- is the function- Returns:
- the corresponding HighVariable or null
-
getStructureForExtending
Check if a variable has a data-type that is suitable for being extended. If so return the structure data-type, otherwise return null. Modulo typedefs, the data-type of the variable must be exactly a "pointer to a structure". Not a "structure" itself, or a "pointer to a pointer to ... a structure".- Parameters:
dt
- is the data-type of the variable to test- Returns:
- the extendable structure data-type or null
-