Class GoTypeManager
java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoTypeManager
Manages all go RTTI type info, along with their Ghidra data type equivs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallTypes()voidcacheRecoveredDataType(GoType typ, DataType dt) Inserts a mapping between agolang typeand aghidra data type.findGoType(GoSymbolName name) findGoType(GoSymbolName name, String defaultTypeName) findGoType(String typeName) Finds a go type by its go-type name, from the list of discovered go types.findGoType(String typeName, String defaultTypeName) Returns the go type that represents a generic chan argument value.Returns the go type that represents the built-in golang channel RTTI type struct.getCP()getCP(GoSymbolName symbolName) Returns category path that should be used to place recovered golang types.Returns category path that should be used to place recovered golang types.getDTM()getFuncMultiReturn(List<DataType> returnTypes) Returns the data type that represents a generic golang slice.getGhidraDataType(GoType typ) Returns aGhidra data typethat represents thegolang type, using a cache of already recovered types to eliminate extra work and self recursion.<T extends DataType>
TgetGhidraDataType(GoType typ, Class<T> clazz, boolean cacheOnly) <T extends DataType>
TgetGhidraDataType(String goTypeName, Class<T> clazz) Returns the data type that represents a golang int32Returns a list of interfaces that the specified type has implemented.Returns the go type that represents a generic map argument value.Returns the go type that represents a golang built-in map RTTI type struct.getMethodClosureType(String recvType) getSubstitutionType(String typeName) getType(long offset) Returns theGoTypefor the specified offsetgetType(long offset, boolean cacheOnly) Returns a specializedGoTypefor the type that is located at the specified location.getTypeName(long offset) Returns the name of a gotype.getTypeName(GoType type) getTypeUnchecked(Address addr) Returns the data type that represents a golang uint32Returns the data type that represents a golang uintptrvoidinit(TaskMonitor monitor) Discovers available golang typesresolveTypeOff(long ptrInModule, long off) Returns theGoTypecorresponding to an offset that is relative to the controlling GoModuledata's typesOffset.
-
Constructor Details
-
GoTypeManager
-
-
Method Details
-
init
Discovers available golang types- Parameters:
monitor-TaskMonitor- Throws:
IOException- if error reading data or cancelled
-
getDTM
-
allTypes
-
allTypeOffsets
-
findGoType
Finds a go type by its go-type name, from the list of discovered go types.- Parameters:
typeName- name string- Returns:
GoType, or null if not found
-
findGoType
-
findGoType
-
findGoType
-
getClosureTypes
-
getMethodWrapperClosureTypes
-
getType
Returns theGoTypefor the specified offset- Parameters:
offset- absolute position of a go type- Returns:
- specialized
GoType(example, GoStructType, GoArrayType, etc) - Throws:
IOException- if error reading
-
getType
- Throws:
IOException
-
getType
Returns a specializedGoTypefor the type that is located at the specified location.- Parameters:
addr- location of a go type- Returns:
- specialized
GoType(example, GoStructType, GoArrayType, etc) - Throws:
IOException- if error reading
-
getTypeUnchecked
-
getMapGoType
Returns the go type that represents a golang built-in map RTTI type struct.- Returns:
- golang map data type
-
getMapArgGoType
Returns the go type that represents a generic map argument value.- Returns:
GoType
-
getChanGoType
Returns the go type that represents the built-in golang channel RTTI type struct.- Returns:
- golang channel type
-
getChanArgGoType
Returns the go type that represents a generic chan argument value.- Returns:
- golang type for chan args
-
getUint8DT
-
getUintDT
-
getUintptrDT
Returns the data type that represents a golang uintptr- Returns:
- golang uinptr data type
-
getInt32DT
Returns the data type that represents a golang int32- Returns:
- golang int32 data type
-
getUint32DT
Returns the data type that represents a golang uint32- Returns:
- golang uint32 data type
-
getVoidPtrDT
-
getTypeName
Returns the name of a gotype.- Parameters:
offset- offset of the gotype RTTI record- Returns:
- string name, with a fallback if the specified offset was invalid
-
getTypeName
-
getInterfacesImplementedByType
Returns a list of interfaces that the specified type has implemented.- Parameters:
type- GoType- Returns:
- list of itabs that map a GoType to the interfaces it was found to implement
-
getTypesThatImplementInterface
-
resolveTypeOff
Returns theGoTypecorresponding to an offset that is relative to the controlling GoModuledata's typesOffset.- Parameters:
ptrInModule- the address of the structure that contains the offset that needs to be calculated. The containing-structure's address is important because it indicates which GoModuledata is the 'parent'off- offset- Returns:
GoType, or null if offset is special value 0 or -1- Throws:
IOException- if error
-
cacheRecoveredDataType
Inserts a mapping between agolang typeand aghidra data type.Useful to prepopulate the data type mapping before recursing into contained/referenced types that might be self-referencing.
- Parameters:
typ-golang typedt-Ghidra type- Throws:
IOException- if golang type struct is not a valid struct mapped instance
-
getGhidraDataType
Returns aGhidra data typethat represents thegolang type, using a cache of already recovered types to eliminate extra work and self recursion.- Parameters:
typ- theGoTypeto convert- Returns:
- Ghidra
DataType - Throws:
IOException- if golang type struct is not a valid struct mapped instance
-
getGhidraDataType
public <T extends DataType> T getGhidraDataType(GoType typ, Class<T> clazz, boolean cacheOnly) throws IOException - Throws:
IOException
-
getGhidraDataType
public <T extends DataType> T getGhidraDataType(String goTypeName, Class<T> clazz) throws IOException - Throws:
IOException
-
getCP
-
getCP
Returns category path that should be used to place recovered golang types.- Parameters:
typ-GoType- Returns:
CategoryPathto use when creating recovered golang types
-
getCP
Returns category path that should be used to place recovered golang types.- Parameters:
symbolName-GoSymbolNameto convert to a category path- Returns:
CategoryPathto use when creating recovered golang types
-
getGenericSliceDT
Returns the data type that represents a generic golang slice.- Returns:
- golang generic slice data type
-
getGenericDictDT
-
getGenericInterfaceDT
-
getGenericITabDT
-
getMethodClosureType
- Throws:
IOException
-
getDefaultClosureType
-
getDefaultMethodWrapperClosureType
-
getFuncMultiReturn
-
getSubstitutionType
-
getMissingGoTypes
-