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 aGo typeand aghidra data type.createFuncDef(List<ParameterDefinition> params, DataType returnDT, GoSymbolName symbolName, boolean noReturn) createFuncDef(List<ParameterDefinition> params, List<ParameterDefinition> returnParams, GoSymbolName symbolName, boolean noReturn) createSpecializedMapDT(String mapTypeName) createSpecializedSlice(GoSymbolName sliceTypeName, DataType element) findDataType(GoSymbolName typeName) Finds a Ghidra data type by its go-type name.<T extends DataType>
TfindDataType(GoSymbolName typeName, Class<T> clazz) Finds a Ghidra data type by its go-type name.findDataType(String typeName) Finds a Ghidra data type by its go-type name.<T extends DataType>
TfindDataType(String typeName, Class<T> clazz) Finds a Ghidra data type by its go-type name.findGoType(String typeName) Finds a Go type by its go-type name, from the list of discovered Go types.getCP()getCP(GoSymbolName symbolName) ReturnsCategoryPaththat should be used to place recovered Go types.Returns category path that should be used to place recovered Go types.getDataType(GoType typ) Returns aGhidra data typethat represents theGo type, using a cache of already recovered types to eliminate extra work and self recursion.<T extends DataType>
TgetDataType(GoType typ, Class<T> clazz, boolean cacheOnly) getDataType(String typeName) Returns a Ghidra data type by its go-type name.getDTM()getFuncMultiReturn(List<DataType> returnTypes) Returns data type that represents a generic Go slice.Returns list of interfaces that the specified type has implemented.getMethodClosureType(String recvType) intgetSubstitutionType(String typeName) getType(long offset) ReturnsGoTypefor the specified offset (example: GoStructType, GoArrayType, etc).getType(long offset, boolean cacheOnly) getTypeName(long offset) Returns string name, with a fallback if the specified offset was invalid.getTypeName(GoType type) getTypeUnchecked(Address addr) booleanvoidinit(TaskMonitor monitor) Discovers available Go typesvoidmarkupGoTypes(MarkupSession markupSession, TaskMonitor monitor) voidrecoverGhidraDataTypes(TaskMonitor monitor) recoverPlainDataType(GoKind kind) resolveTypeOff(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 Go types- Parameters:
monitor-TaskMonitor- Throws:
IOException- if error reading data or cancelled
-
markupGoTypes
public void markupGoTypes(MarkupSession markupSession, TaskMonitor monitor) throws CancelledException, IOException - Throws:
CancelledExceptionIOException
-
getDTM
-
getPtrSize
public int getPtrSize() -
allTypes
-
allTypeOffsets
-
hasGoType
-
findGoType
Finds a Go type by its go-type name, from the list of discovered Go types.- Parameters:
typeName- name string- Returns:
GoType, orNULLif not found- Throws:
IOException- if error
-
findDataType
Finds a Ghidra data type by its go-type name.- Parameters:
typeName- go type name- Returns:
- Ghidra
DataTypecorresponding to the requested name, coerced into a specificDataTypesubclass, orNULLif not found - Throws:
IOException- if error
-
findDataType
public <T extends DataType> T findDataType(GoSymbolName typeName, Class<T> clazz) throws IOException Finds a Ghidra data type by its go-type name.- Type Parameters:
T- Ghidra DataType generic type specifier- Parameters:
typeName- go type nameclazz-DataTypeclass reference- Returns:
- Ghidra
DataTypecorresponding to the requested name, coerced into a specificDataTypesubclass, orNULLif not found - Throws:
IOException- if error
-
findDataType
Finds a Ghidra data type by its go-type name.- Parameters:
typeName- go type name- Returns:
- Ghidra
DataTypecorresponding to the requested name, orNULLif not found - Throws:
IOException- if error
-
findDataType
Finds a Ghidra data type by its go-type name.- Type Parameters:
T- Ghidra DataType generic type specifier- Parameters:
typeName- go type nameclazz-DataTypeclass reference- Returns:
- Ghidra
DataTypecorresponding to the requested name, coerced into a specificDataTypesubclass, orNULLif not found - Throws:
IOException- if error
-
getDataType
Returns a Ghidra data type by its go-type name.- Parameters:
typeName- go type name- Returns:
- Ghidra
DataTypecorresponding to the requested name, neverNULL - Throws:
IOException- if error or not found
-
getClosureTypes
-
getMethodWrapperClosureTypes
-
getType
ReturnsGoTypefor the specified offset (example: GoStructType, GoArrayType, etc).- Parameters:
offset- absolute position of a Go type- Returns:
GoTypefor the specified offset (example: GoStructType, GoArrayType, etc)- Throws:
IOException- if error reading
-
getType
- Throws:
IOException
-
getTypeUnchecked
-
getVoidPtrDT
-
getTypeName
Returns string name, with a fallback if the specified offset was invalid.- Parameters:
offset- offset of the gotype RTTI record- Returns:
- string name, with a fallback if the specified offset was invalid
-
getTypeName
-
getInterfacesImplementedByType
Returns list of interfaces that the specified type has implemented.- Parameters:
type- GoType- Returns:
- list of interfaces that the specified type has implemented
-
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, orNULLif offset is special value 0 or -1- Throws:
IOException- if error
-
cacheRecoveredDataType
Inserts a mapping between aGo typeand aghidra data type.Useful to prepopulate the data type mapping before recursing into contained/referenced types that might be self-referencing.
- Parameters:
typ-Go typedt-Ghidra type- Throws:
IOException- if Go type struct is not a valid struct mapped instance
-
recoverGhidraDataTypes
- Throws:
IOExceptionCancelledException
-
recoverPlainDataType
-
getDataType
Returns aGhidra data typethat represents theGo 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 Go type struct is not a valid struct mapped instance
-
getDataType
public <T extends DataType> T getDataType(GoType typ, Class<T> clazz, boolean cacheOnly) throws IOException - Throws:
IOException
-
getCP
-
getCP
Returns category path that should be used to place recovered Go types.- Parameters:
typ-GoType- Returns:
- category path that should be used to place recovered Go types
-
getCP
ReturnsCategoryPaththat should be used to place recovered Go types.- Parameters:
symbolName-GoSymbolNameto convert to a category path- Returns:
CategoryPaththat should be used to place recovered Go types
-
createSpecializedMapDT
-
getGenericSliceDT
Returns data type that represents a generic Go slice.- Returns:
- data type that represents a generic Go slice
- Throws:
IOExceptionIllegalArgumentException
-
createSpecializedSlice
public Structure createSpecializedSlice(GoSymbolName sliceTypeName, DataType element) throws IllegalArgumentException, IOException - Throws:
IllegalArgumentExceptionIOException
-
getGenericDictDT
-
getGenericInterfaceDT
-
getGenericITabDT
-
getMethodClosureType
- Throws:
IOException
-
getDefaultClosureType
- Throws:
IOException
-
getDefaultMethodWrapperClosureType
-
getFuncMultiReturn
-
getSubstitutionType
- Throws:
IOException
-
getMissingGoTypes
-
createFuncDef
public FunctionDefinitionDataType createFuncDef(List<ParameterDefinition> params, List<ParameterDefinition> returnParams, GoSymbolName symbolName, boolean noReturn) -
createFuncDef
public FunctionDefinitionDataType createFuncDef(List<ParameterDefinition> params, DataType returnDT, GoSymbolName symbolName, boolean noReturn)
-