Package ghidra.program.model.gclass
Class ClassUtils
java.lang.Object
ghidra.program.model.gclass.ClassUtils
Utility class for Class-related software modeling.
This class is experimental and subject to unannounced changes, including changes to processing philosophies and removal of methods
-
Nested Class Summary
Nested ClassesChangeModifier and TypeClassDescriptionstatic final recordRecord containing a name and a pointer data type -
Field Summary
FieldsChangeModifier and TypeFieldDescriptionstatic final StringStandard field name for a virtual base table pointer found within a classstatic final StringStandard field name for a class virtual base tablestatic final StringStandard field name for a virtual function table pointer found within a classstatic final StringStandard field name for a class virtual function tablestatic final StringStandard field name for a class virtual tablestatic final StringStandard field name for a virtual table pointer found within a classstatic final PointerDataType -
Method Summary
ChangeModifier and TypeMethodDescriptionstatic StringcreateVxTableDescriptionOffsetTag(long ptrOffsetInClass) Provides the __TEMPORARY__ standard special Description string for a virtual table (e.g., vtable, vbtable, vftable) that is keyed off of by the Decompiler during flattening and replacement of types within a class structure.static DataTypePathgetBaseClassDataTypePath(Composite composite) Returns the data type path for a suitable base classstatic CategoryPathgetClassInternalsPath(CategoryPath category) Returns the category path for class internals for the Class CategoryPathstatic CategoryPathgetClassInternalsPath(CategoryPath path, String className) Returns the category path for class internalsstatic CategoryPathgetClassInternalsPath(Composite composite) Returns the category path for class internalsstatic CategoryPathReturns the category path for class internals for the ClassIDstatic CategoryPathgetClassPath(Composite composite) Returns the category path for items belonging to this class, such as vxtablesstatic CategoryPathgetClassPath(ClassID id) Returns the category path for class for the ClassIDgetReplacementPointers(DataTypeManager dtm, Structure type) Finds and returns list of replacement pointer types for the specified owner class structurestatic ClassUtils.NameAndPointergetReplacementType(DataTypeComponent component, long accumulatedOffset, Map<Long, Pointer> ownerVxtptrs) Tries to provide an appropriate data type replacement for special components, particularly for class objects such as virtual function table and virtual base table pointers within a flattened class structurestatic StructuregetReplacementType(Structure structure) Tries to provide an appropriate data type replacement for special components, particularly for class objects such as virtual function table and virtual base table pointers within a flattened class structurestatic StructuregetReplacementType(Structure structure, boolean enabled) Tries to provide an appropriate data type replacement for special components, particularly for class objects such as virtual function table and virtual base table pointers within a flattened class structure.static CompositegetSelfBaseType(Composite composite) Returns the "self-base" composite for the specified class composite.static CompositegetSelfBaseType(DataTypeManager dtm, ClassID id) Returns the "self-base" composite for the specified class IDstatic DataTypeReturns a default data type for a VBTstatic intReturns the size of the default data type for a VBT entrystatic PointerDataTypeReturns a default data type for a VFTstatic intReturns the size of the default pointer data type for a VFT entrystatic booleanhasClassAttribute(Structure structure) This method returns true if the argument structure has a class attributestatic booleanIndicates whether a label satisfies the format of a vxtable labelstatic LongvalidateVtableDescriptionOffsetTag(String description) Validates a Vtable description and returns the encoded offset value
-
Field Details
-
VTABLE
Standard field name for a class virtual table- See Also:
-
VBTABLE
Standard field name for a class virtual base table- See Also:
-
VFTABLE
Standard field name for a class virtual function table- See Also:
-
VTPTR
Standard field name for a virtual table pointer found within a class- See Also:
-
VBPTR
Standard field name for a virtual base table pointer found within a class- See Also:
-
VFPTR
Standard field name for a virtual function table pointer found within a class- See Also:
-
VXPTR_TYPE
-
-
Method Details
-
getClassInternalsPath
Returns the category path for class internals- Parameters:
composite- the class composite- Returns:
- the category path
-
getClassPath
Returns the category path for items belonging to this class, such as vxtables- Parameters:
composite- the class composite- Returns:
- the category path
-
getClassPath
Returns the category path for class for the ClassID- Parameters:
id- the class ID- Returns:
- the category path
-
getClassInternalsPath
Returns the category path for class internals for the Class CategoryPath- Parameters:
category- the class category path- Returns:
- the category path
-
getClassInternalsPath
Returns the category path for class internals for the ClassID- Parameters:
id- the class ID- Returns:
- the category path
-
getClassInternalsPath
Returns the category path for class internals- Parameters:
path- the category path of the class compositeclassName- the name of the class- Returns:
- the category path
-
getBaseClassDataTypePath
Returns the data type path for a suitable base class- Parameters:
composite- the class composite- Returns:
- the base class data type path
-
getSelfBaseType
Returns the "self-base" composite for the specified class composite. This could be the composite argument itself of could be a component of it- Parameters:
composite- the main class type- Returns:
- the self-base composite
-
getSelfBaseType
Returns the "self-base" composite for the specified class ID- Parameters:
dtm- the data type managerid- the class id- Returns:
- the self-base composite
-
isVTable
Indicates whether a label satisfies the format of a vxtable label- Parameters:
type- the data type- Returns:
trueif is a vxtable label format
-
createVxTableDescriptionOffsetTag
Provides the __TEMPORARY__ standard special Description string for a virtual table (e.g., vtable, vbtable, vftable) that is keyed off of by the Decompiler during flattening and replacement of types within a class structure. This is __TEMPORARY__ in that we hope to use some special attribute in the future. More details to come- Parameters:
ptrOffsetInClass- the offset of the special field within the class- Returns:
- the special name
-
validateVtableDescriptionOffsetTag
Validates a Vtable description and returns the encoded offset value- Parameters:
description- the description string- Returns:
- the offset or
nullif invalid name
-
getVftDefaultEntry
Returns a default data type for a VFT- Parameters:
dtm- the data type manager- Returns:
- the pointer data type
-
getVbtDefaultEntry
Returns a default data type for a VBT- Parameters:
dtm- the data type manager- Returns:
- the data type
-
getVftEntrySize
Returns the size of the default pointer data type for a VFT entry- Parameters:
dtm- the data type manager- Returns:
- the size
-
getVbtEntrySize
Returns the size of the default data type for a VBT entry- Parameters:
dtm- the data type manager- Returns:
- the size
-
getReplacementPointers
Finds and returns list of replacement pointer types for the specified owner class structure- Parameters:
dtm- the data type managertype- the class structure type- Returns:
- the map of offset to owner replacement types
-
getReplacementType
public static ClassUtils.NameAndPointer getReplacementType(DataTypeComponent component, long accumulatedOffset, Map<Long, Pointer> ownerVxtptrs) Tries to provide an appropriate data type replacement for special components, particularly for class objects such as virtual function table and virtual base table pointers within a flattened class structure- Parameters:
component- the component to be checkedaccumulatedOffset- the accumulated offset of the component due to flatteningownerVxtptrs- the map of offset to owner vxtptr types- Returns:
- the replacement data type or the original type if there is no replacement needed
-
getReplacementType
Tries to provide an appropriate data type replacement for special components, particularly for class objects such as virtual function table and virtual base table pointers within a flattened class structure. Thestructureargument becomes the return type ifenabledisfalse, if the argument structure does not have class attributes, or if there is no suitable replacement for it- Parameters:
structure- the structure to processenabled-falsewill immediately return the argument type- Returns:
- the replacement data type or null if could not or did not need to be replaced
-
getReplacementType
Tries to provide an appropriate data type replacement for special components, particularly for class objects such as virtual function table and virtual base table pointers within a flattened class structure- Parameters:
structure- the structure to process- Returns:
- the replacement data type or null if could not or did not need to be replaced
-
hasClassAttribute
This method returns true if the argument structure has a class attribute- Parameters:
structure- the structure under question- Returns:
trueif has a class attribute
-