Class NoisyStructureBuilder

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

public class NoisyStructureBuilder extends Object
Build a structure from a "noisy" source of field information. Feed it field records, either via addDataType(), when we have more definitive info about the size of the field, or via addReference() when we have a pointer reference to the field with possibly less info about the field size. As records come in, overlaps and conflicts in specific field data-types are resolved. In a conflict, less specific data-types are replaced. After all information is collected a final Structure can be built by iterating over the final field entries. NOTE: No attempt has been made to utilize DataType.getAlignedLength() when considering component type lengths.
  • Constructor Details

    • NoisyStructureBuilder

      public NoisyStructureBuilder()
  • Method Details

    • getSize

      public long getSize()
      Returns:
      the size of the structure in bytes (given current information)
    • addDataType

      public void addDataType(long offset, DataType dt)
      Add data-type information about a specific field
      Parameters:
      offset - of the field within the structure
      dt - is the data-type of field if known (null otherwise)
    • addReference

      public void addReference(long offset, DataType dt)
      Adds information for a field given a pointer reference. The data-type information is not used unless it is a pointer.
      Parameters:
      offset - is the offset of the field within the structure
      dt - is the data-type of the pointer to the field (or null)
    • setMinimumSize

      public void setMinimumSize(long size)
      We may have partial information about the size of the structure. This method feeds it to the builder as a minimum size for the structure.
      Parameters:
      size - is the minimum size in bytes
    • iterator

      public Iterator<Map.Entry<Long,DataType>> iterator()
      Returns:
      an iterator to the current field entries
    • populateOriginalStructure

      public void populateOriginalStructure(Structure dt)
      Populate this builder with fields from a preexisting Structure. The builder presumes it is rebuilding this Structure so it can check for pathological containment issues.
      Parameters:
      dt - is the preexisting Structure