Class FillOutStructureHelper

java.lang.Object
ghidra.app.decompiler.util.FillOutStructureHelper

public class FillOutStructureHelper extends Object
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.
  • Constructor Details

  • 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 function
      function - the function to process
      createNewStructure - 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

      public NoisyStructureBuilder getComponentMap()
      Retrieve the component map that was generated when structure was created using decompiler info. Results are not valid until processStructure(HighVariable, Function, boolean, boolean) is invoked.
      Returns:
      componentMap
    • getStorePcodeOps

      public List<FillOutStructureHelper.OffsetPcodeOpPair> getStorePcodeOps()
      Retrieve the offset/pcodeOp pairs that are used to store data into the variable used to fill-out structure. Results are not valid until processStructure(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 until processStructure(HighVariable, Function, boolean, boolean) is invoked.
      Returns:
      the pcodeOps doing the loading from the associated variable
    • computeHighVariable

      public HighVariable computeHighVariable(Address storageAddress, Function function)
      Decompile a function and return the resulting HighVariable associated with a storage address
      Parameters:
      storageAddress - the storage address of the variable
      function - is the function
      Returns:
      the corresponding HighVariable or null
    • getStructureForExtending

      public static Structure getStructureForExtending(DataType dt)
      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