Class StructureContext<T>
java.lang.Object
ghidra.app.util.bin.format.golang.structmapping.StructureContext<T>
- Type Parameters:
T- a java class that has been tagged with aStructureMappingannotation.
Information about an instance of a structure that has been read from the memory of a
Ghidra program.
All StructureMapping tagged classes must have a ContextField tagged
StructureContext field for that class to be able to access meta-data about its self, and
for other classes to reference it when performing markup:
@StructureMapping(structureName = "mydatatype")
class MyDataType {
@ContextField
private StructureContext<MyDataType> context;
@FieldMapping
private long someField;
...
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataTypeMapperprotected final StructureMappingInfo<T>protected final BinaryReaderprotected Structureprotected Tprotected final long -
Constructor Summary
ConstructorsConstructorDescriptionStructureContext(DataTypeMapper dataTypeMapper, StructureMappingInfo<T> mappingInfo, BinaryReader reader) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendComment(int commentType, String prefix, String comment, String sep) Places a comment at the start of this structure, appending to any previous values already there.createFieldContext(FieldMappingInfo<T> fmi, boolean includeReader) Returns a reference to the rootDataTypeMapper, as a plain DataTypeMapper type.getFieldAddress(long fieldOffset) Returns the address of an offset from the start of this structure instance.longgetFieldLocation(long fieldOffset) Returns the stream location of an offset from the start of this structure instance.getFieldReader(long fieldOffset) Returns an independentBinaryReaderthat is positioned at the start of the specified field.Returns theStructureMappingInfofor this structure's class.Returns the address in the program of this structure instance.longReturns the stream location of the end of this structure instance.intReturns the length of this structure instance.longReturns the stream location of this structure instance.booleanvoidvoidmarkupStructure(boolean nested) toString()
-
Field Details
-
dataTypeMapper
-
mappingInfo
-
reader
-
structureStart
protected final long structureStart -
structureInstance
-
structureDataType
-
-
Constructor Details
-
StructureContext
public StructureContext(DataTypeMapper dataTypeMapper, StructureMappingInfo<T> mappingInfo, BinaryReader reader)
-
-
Method Details
-
readNewInstance
- Throws:
IOException
-
getMappingInfo
Returns theStructureMappingInfofor this structure's class.- Returns:
-
getDataTypeMapper
Returns a reference to the rootDataTypeMapper, as a plain DataTypeMapper type. If a more specific DataTypeMapper type is needed, either type-cast this value, or use aContextFieldtag on a field in your class that specifies the correct DataTypeMapper type.- Returns:
-
getProgram
-
getStructureAddress
Returns the address in the program of this structure instance.- Returns:
Address
-
getFieldAddress
Returns the address of an offset from the start of this structure instance.- Parameters:
fieldOffset-- Returns:
-
getFieldLocation
public long getFieldLocation(long fieldOffset) Returns the stream location of an offset from the start of this structure instance.- Parameters:
fieldOffset-- Returns:
-
getStructureStart
public long getStructureStart()Returns the stream location of this structure instance.- Returns:
-
getStructureEnd
public long getStructureEnd()Returns the stream location of the end of this structure instance.- Returns:
-
getStructureLength
public int getStructureLength()Returns the length of this structure instance.- Returns:
-
getStructureInstance
-
getReader
-
getFieldReader
Returns an independentBinaryReaderthat is positioned at the start of the specified field.- Parameters:
fieldOffset-- Returns:
-
createFieldContext
-
appendComment
public void appendComment(int commentType, String prefix, String comment, String sep) throws IOException Places a comment at the start of this structure, appending to any previous values already there.- Parameters:
commentType-prefix-comment-sep-- Throws:
IOException
-
isAlreadyMarkedup
public boolean isAlreadyMarkedup() -
markupStructure
- Parameters:
nested- if true, it is assumed that the Ghidra data types have already been placed and only markup needs to be performed.- Throws:
IOException
-
markupFields
- Throws:
IOException
-
getStructureDataType
- Throws:
IOException
-
toString
-