Class StructureFactory

java.lang.Object
ghidra.program.model.data.StructureFactory

public class StructureFactory extends Object
Creates and initializes Structure objects.
  • Field Details

  • Constructor Details

    • StructureFactory

      public StructureFactory()
  • Method Details

    • createStructureDataType

      public static Structure createStructureDataType(Program program, Address address, int dataLength)
      Creates a StructureDataType instance based upon the information provided. The instance will not be placed in memory.

      This method is just a pass-through method for createStructureDataType(Program,Address,int,String,boolean) equivalent to calling:

            Structure newStructure = StructureFactory.createStructureDataType(
                program, address, dataLength, DEFAULT_STRUCTURE_NAME, true );
       
      Parameters:
      program - The program to which the structure will belong.
      address - The address of the structure.
      dataLength - The number of components to add to the structure.
      Returns:
      A new structure not yet added to memory.
      Throws:
      IllegalArgumentException - for the following conditions:
      • if dataLength is not greater than zero
      • if the number of components to add exceeds the available address space
      • if there are any instructions in the provided address space
      • if there are no data components to add to the structure
    • createStructureDataType

      public static Structure createStructureDataType(Program program, Address address, int dataLength, String structureName, boolean makeUniqueName)
      Creates a StructureDataType instance based upon the information provided. The instance will not be placed in memory.
      Parameters:
      program - The program to which the structure will belong.
      address - The address of the structure.
      dataLength - The number of components to add to the structure.
      structureName - The name of the structure to create.
      makeUniqueName - True indicates that the provided name should be altered as necessary in order to make it unique in the program.
      Returns:
      A new structure not yet added to memory.
      Throws:
      IllegalArgumentException - for the following conditions:
      • if structureName is null
      • if dataLength is not greater than zero
      • if the number of components to add exceeds the available address space
      • if there are any instructions in the provided address space
      • if there are no data components to add to the structure
    • createStructureDataTypeInStrucuture

      public static Structure createStructureDataTypeInStrucuture(Program program, Address address, int[] fromPath, int[] toPath)
      Creates a StructureDataType instance, which is inside of another structure, based upon the information provided. The instance will not be placed in memory.

      This method is just a pass-through method for createStructureDataTypeInStrucuture(Program,Address,int[],int[],String,boolean) equivalent to calling:

            Structure newStructure = StructureFactory.createStructureDataTypeInStrucuture(
                program, address, fromPath, toPath, DEFAULT_STRUCTURE_NAME, true );
       
      Parameters:
      program - The program to which the structure will belong.
      address - The address of the structure.
      fromPath - The path to the first element in the parent structure that will be in the new structure.
      toPath - The path to the last element in the parent structure that will be in the new structure.
      Returns:
      A new structure not yet added to memory.
      Throws:
      IllegalArgumentException - for the following conditions:
      • if the component at fromPath or the component at toPath are null
      • if there is not data to add to the structure
      • if the parent data type is not a structure
    • createStructureDataTypeInStrucuture

      public static Structure createStructureDataTypeInStrucuture(Program program, Address address, int[] fromPath, int[] toPath, String structureName, boolean makeUniqueName)
      Creates a StructureDataType instance, which is inside of another structure, based upon the information provided. The instance will not be placed in memory.
      Parameters:
      program - The program to which the structure will belong.
      address - The address of the structure.
      fromPath - The path to the first element in the parent structure that will be in the new structure.
      toPath - The path to the last element in the parent structure that will be in the new structure.
      structureName - the name of the structure to create
      makeUniqueName - True indicates that the provided name should be altered as necessary in order to make it unique in the program.
      Returns:
      A new structure not yet added to memory.
      Throws:
      IllegalArgumentException - for the following conditions:
      • if structureName is null
      • if the component at fromPath or the component at toPath are null
      • if there is not data to add to the structure
      • if the parent data type is not a structure