Class DataTypeMapper
java.lang.Object
ghidra.app.util.bin.format.golang.structmapping.DataTypeMapper
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
GoRttiMapper
Information about
StructureMapping classes and their metadata, as well as
accumulated information about structure instances that have been deserialized.
To use the full might and majesty of StructureMapping(tm), a DataTypeMapper must be created. It
must be able to find
(more find) the Ghidra structure data
types being used, and it must know about all classes that are
going to participate during deserialization and markup.
Structure mapped classes can receive a reference to the specific DataTypeMapper type that
created them by declaring a DataTypeMapper field, and tagging it with
the @ContextField annotation:
class MyDataTypeMapper extends DataTypeMapper {
public MyDataTypeMapper() {
...
registerStructure(MyDataType.class);
}
public void foo() { ... }
}
@StructureMapping(structureName = "mydatatype")
class MyDataType {
@ContextField
private MyDataTypeMapper myDataTypeMapper;
@ContextField
private StructureContext<MyDataType> context;
@FieldMapping
private long someField;
void bar() {
context.getDataTypeMapper().getProgram(); // can only access methods defined on base DataTypeMapper type
myDataTypeMapper.foo(); // same context as previous line, but typed correctly
...
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataTypeManagerprotected List<CategoryPath>protected Map<Class<?>,StructureMappingInfo<?>> protected TaskMonitorprotected Programprotected DataTypeManagerprotected List<CategoryPath> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddArchiveSearchCategoryPath(CategoryPath... paths) addProgramSearchCategoryPath(CategoryPath... paths) voidclose()protected BinaryReaderprotected DataTypefindType(String name, List<CategoryPath> searchList, DataTypeManager dtm) getCodeAddress(long offset) getDataAddress(long offset) getDTM()<T> AddressgetExistingStructureAddress(T structureInstance) Attempts to convert an instance of an object (that represents a chunk of memory in the program) into its Address.<T> StructureContext<T>getExistingStructureContext(T structureInstance) getReader(long position) getStructureDataType(Class<?> clazz) Returns a Ghidra structure data type representing the specified class.getStructureDataTypeName(Class<?> clazz) Returns the name of the Ghidra structure that has been registered for the specified structure mapped class.<T> StructureMappingInfo<T>getStructureMappingInfo(Class<T> clazz) <T> StructureMappingInfo<T>getStructureMappingInfo(T structureInstance) <T extends DataType>
T<T extends DataType>
TgetTypeOrDefault(String name, Class<T> clazz, T defaultValue) voidlabelAddress(Address addr, String symbolName) <T> voidlabelStructure(T obj, String symbolName) <T> voidmarkup(T obj, boolean nested) voidmarkupAddress(Address addr, DataType dt) voidmarkupAddress(Address addr, DataType dt, int length) voidmarkupAddressIfUndefined(Address addr, DataType dt) <T> TreadStructure(Class<T> structureClass, long position) <T> TreadStructure(Class<T> structureClass, BinaryReader structReader) <T> TreadStructure(Class<T> structureClass, Address address) <T> voidregisterStructure(Class<T> clazz) Registers a class that hasstructure mappinginformation.voidregisterStructures(List<Class<?>> classes) voidsetMarkupTaskMonitor(TaskMonitor monitor) toString()
-
Field Details
-
program
-
programDTM
-
archiveDTM
-
programSearchCPs
-
archiveSearchCPs
-
mappingInfo
-
markedupStructs
-
markupTaskMonitor
-
-
Constructor Details
-
DataTypeMapper
- Parameters:
program-archiveGDT-- Throws:
IOException
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getDefaultVariableLengthStructCategoryPath
-
getProgram
-
createProgramReader
-
getDataConverter
-
addProgramSearchCategoryPath
-
addArchiveSearchCategoryPath
-
registerStructure
Registers a class that hasstructure mappinginformation.- Type Parameters:
T-- Parameters:
clazz-- Throws:
IOException- if the class's Ghidra structure data type could not be found
-
registerStructures
- Throws:
IOException
-
getStructureMappingInfo
-
getStructureMappingInfo
-
getStructureDataType
Returns a Ghidra structure data type representing the specified class.- Parameters:
clazz- a structure mapped class- Returns:
Structuredata type, or null if the class was a struct with variable length fields
-
getStructureDataTypeName
Returns the name of the Ghidra structure that has been registered for the specified structure mapped class.- Parameters:
clazz-- Returns:
-
findType
-
getType
- Type Parameters:
T-- Parameters:
name-clazz-- Returns:
-
getTypeOrDefault
-
getDTM
-
getExistingStructureContext
- Throws:
IOException
-
getExistingStructureAddress
Attempts to convert an instance of an object (that represents a chunk of memory in the program) into its Address.- Type Parameters:
T- type of the object- Parameters:
structureInstance- instance of an object that represents something in the program's memory- Returns:
Addressof the object, or null if not found or not a supported object- Throws:
IOException
-
setMarkupTaskMonitor
-
markup
- Throws:
IOException
-
readStructure
- Throws:
IOException
-
readStructure
- Throws:
IOException
-
readStructure
- Throws:
IOException
-
getReader
-
getDataAddress
-
getCodeAddress
-
labelAddress
- Throws:
IOException
-
labelStructure
- Throws:
IOException
-
markupAddress
- Throws:
IOException
-
markupAddress
- Throws:
IOException
-
markupAddressIfUndefined
- Throws:
IOException
-
toString
-