Class StructureMappingInfo<T>

java.lang.Object
ghidra.app.util.bin.format.golang.structmapping.StructureMappingInfo<T>
Type Parameters:
T - the class that is being mapped into a structure

public class StructureMappingInfo<T> extends Object
Contains immutable information about a structure mapped class needed to deserialize a new object from the data found in a Ghidra program.
  • Method Details

    • fromClass

      public static <T> StructureMappingInfo<T> fromClass(Class<T> targetClass, Structure structDataType, DataTypeMapperContext context)
      Returns the mapping info for a class, using annotations found in that class.
      Type Parameters:
      T - structure mapped class
      Parameters:
      targetClass - structure mapped class
      structDataType - Ghidra DataType that defines the binary layout of the mapped fields of the class, or null if this is a self-reading StructureReader class
      context - DataTypeMapperContext
      Returns:
      new StructureMappingInfo for the specified class
      Throws:
      IllegalArgumentException - if targetClass isn't tagged as a structure mapped class
    • getDescription

      public String getDescription()
    • getStructureDataType

      public Structure getStructureDataType()
    • getStructureName

      public String getStructureName()
    • getStructureLength

      public int getStructureLength()
    • getTargetClass

      public Class<T> getTargetClass()
    • getInstanceCreator

      public ghidra.app.util.bin.format.golang.structmapping.StructureMappingInfo.ObjectInstanceCreator<T> getInstanceCreator()
    • getFields

      public List<FieldMappingInfo<T>> getFields()
    • getAfterMethods

      public List<Method> getAfterMethods()
    • readStructure

      public void readStructure(StructureContext<T> context) throws IOException
      Deserializes a structure mapped instance by assigning values to its @FieldMapping mapped java fields.
      Parameters:
      context - StructureContext
      Throws:
      IOException - if error reading the structure
    • getMarkupFuncs

      public List<StructureMarkupFunction<T>> getMarkupFuncs()
    • createStructureDataType

      public Structure createStructureDataType(StructureContext<T> context) throws IOException
      Creates a new customized structure data type for a variable length structure mapped class.
      Parameters:
      context - StructureContext of a variable length structure mapped instance
      Returns:
      new structure data type with a name that encodes the size information of the variable length fields
      Throws:
      IOException - if error creating the Ghidra data type
    • recoverStructureContext

      public StructureContext<T> recoverStructureContext(T structureInstance)
      Reaches into a structure mapped instance and extracts its StructureContext field value.
      Parameters:
      structureInstance - instance to query
      Returns:
      StructureContext, or null if error extracting value
    • assignContextFieldValues

      public void assignContextFieldValues(StructureContext<T> context) throws IOException
      Initializes any ContextField fields in a new structure instance.
      Parameters:
      context - StructureContext
      Throws:
      IOException - if error assigning values to context fields in the structure mapped instance