Annotation Interface StructureMapping


@Retention(RUNTIME) @Target(TYPE) public @interface StructureMapping
Indicates that the tagged class corresponds to a Ghidra structure.

For fixed/static length structures, an existing Ghidra structure data type will be found and then bound to the tagged class, and it will control how instances of the tagged class are deserialized. Only fields that are interesting / relevant need to be tagged with a FieldMapping annotation, which causes them to be pulled into the java class.

For variable length structures, a unique Ghidra structure data type will be created for each combination of field lengths, and the tagged class must deserialize itself by implementing the StructureReader interface. (each field that needs to be mapped into the Ghidra structure must be tagged with a FieldOutput annotation)

In either case, various annotations on fields and methods will control how this structure will be marked up in the Ghidra program.

The tagged class must be registered with the program context to enable the suite of structure mapped classes to work together when applied to a Ghidra binary.

For variable length structure classes, when the struct mapping system creates a custom-fitted structure to markup a specific location with its specific data, the new struct data type's name will be patterned as "structurename_NN_MM_...", where NN and MM and etc are the lengths of the variable length fields found in the structure.

Structure mapped classes must have a StructureContext member variable that is tagged with the ContextField annotation, and probably should have a DataTypeMapper member variable (that corresponds to a more specific type of DataTypeMapper) that is also tagged with the ContextField annotation.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Specifies the name, and optionally alternate names, of a Ghidra structure that the tagged class represents.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional reference to a 'function' (implemented via a class) that will be called to do custom markup.
  • Element Details

    • structureName

      String[] structureName
      Specifies the name, and optionally alternate names, of a Ghidra structure that the tagged class represents. For fixed length structures, the DataTypeMapper will search for this Ghidra data type in it's configured archive and program search paths.
      Returns:
      name(s) of a Ghidra structure data type
    • markupFunc

      Class<? extends StructureMarkupFunction> markupFunc
      Optional reference to a 'function' (implemented via a class) that will be called to do custom markup.
      Returns:
      StructureMarkupFunction class
      Default:
      ghidra.app.util.bin.format.golang.structmapping.StructureMarkupFunction.class