Class ClassUtils

java.lang.Object
ghidra.program.model.gclass.ClassUtils

public class ClassUtils extends Object
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

  • Field Details

    • VTABLE NEW

      public static final String VTABLE
      Standard field name for a class virtual table
      See Also:
    • VBTABLE NEW

      public static final String VBTABLE
      Standard field name for a class virtual base table
      See Also:
    • VFTABLE NEW

      public static final String VFTABLE
      Standard field name for a class virtual function table
      See Also:
    • VTPTR NEW

      public static final String VTPTR
      Standard field name for a virtual table pointer found within a class
      See Also:
    • VBPTR MODIFIED

      public static final String VBPTR
      constant: "{vbptr}" → "vbptr"
      -static java.lang.String VBPTR
      +static java.lang.String VBPTR
      Standard field name for a virtual base table pointer found within a class
      See Also:
    • VFPTR MODIFIED

      public static final String VFPTR
      constant: "{vfptr}" → "vfptr"
      -static java.lang.String VFPTR
      +static java.lang.String VFPTR
      Standard field name for a virtual function table pointer found within a class
      See Also:
    • VXPTR_TYPE

      public static final PointerDataType VXPTR_TYPE
      Type used for VBPTR and VFPTR fields in a class
  • Method Details

    • getClassInternalsPath

      public static CategoryPath getClassInternalsPath(Composite composite)
      Returns the category path for class internals
      Parameters:
      composite - the class composite
      Returns:
      the category path
    • getClassPath NEW

      public static CategoryPath getClassPath(Composite composite)
      Returns the category path for items belonging to this class, such as vxtables
      Parameters:
      composite - the class composite
      Returns:
      the category path
    • getClassPath NEW

      public static CategoryPath getClassPath(ClassID id)
      Returns the category path for class for the ClassID
      Parameters:
      id - the class ID
      Returns:
      the category path
    • getClassInternalsPath NEW

      public static CategoryPath getClassInternalsPath(CategoryPath category)
      Returns the category path for class internals for the Class CategoryPath
      Parameters:
      category - the class category path
      Returns:
      the category path
    • getClassInternalsPath

      public static CategoryPath getClassInternalsPath(ClassID id)
      Returns the category path for class internals for the ClassID
      Parameters:
      id - the class ID
      Returns:
      the category path
    • getClassInternalsPath

      public static CategoryPath getClassInternalsPath(CategoryPath path, String className)
      Returns the category path for class internals
      Parameters:
      path - the category path of the class composite
      className - the name of the class
      Returns:
      the category path
    • getBaseClassDataTypePath

      public static DataTypePath getBaseClassDataTypePath(Composite composite)
      Returns the data type path for a suitable base class
      Parameters:
      composite - the class composite
      Returns:
      the base class data type path
    • getSelfBaseType

      public static Composite getSelfBaseType(Composite composite)
      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 NEW

      public static Composite getSelfBaseType(DataTypeManager dtm, ClassID id)
      Returns the "self-base" composite for the specified class ID
      Parameters:
      dtm - the data type manager
      id - the class id
      Returns:
      the self-base composite
    • isVTable

      public static boolean isVTable(DataType type)
      Indicates whether a label satisfies the format of a vxtable label
      Parameters:
      type - the data type
      Returns:
      true if is a vxtable label format
    • createVxTableDescriptionOffsetTag NEW

      public static String createVxTableDescriptionOffsetTag(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. 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 NEW

      public static Long validateVtableDescriptionOffsetTag(String description)
      Validates a Vtable description and returns the encoded offset value
      Parameters:
      description - the description string
      Returns:
      the offset or null if invalid name
    • getVftDefaultEntry MODIFIED

      public static PointerDataType getVftDefaultEntry(DataTypeManager dtm)
      return type: DataType → PointerDataType
      -static ghidra.program.model.data.DataType getVftDefaultEntry(ghidra.program.model.data.DataTypeManager dtm)
      +static ghidra.program.model.data.PointerDataType getVftDefaultEntry(ghidra.program.model.data.DataTypeManager dtm)
      Returns a default data type for a VFT
      Parameters:
      dtm - the data type manager
      Returns:
      the pointer data type
    • getVbtDefaultEntry

      public static DataType getVbtDefaultEntry(DataTypeManager dtm)
      Returns a default data type for a VBT
      Parameters:
      dtm - the data type manager
      Returns:
      the data type
    • getVftEntrySize

      public static int getVftEntrySize(DataTypeManager dtm)
      Returns the size of the default pointer data type for a VFT entry
      Parameters:
      dtm - the data type manager
      Returns:
      the size
    • getVbtEntrySize

      public static int getVbtEntrySize(DataTypeManager dtm)
      Returns the size of the default data type for a VBT entry
      Parameters:
      dtm - the data type manager
      Returns:
      the size
    • getReplacementPointers NEW

      public static Map<Long,Pointer> getReplacementPointers(DataTypeManager dtm, Structure type)
      Finds and returns list of replacement pointer types for the specified owner class structure
      Parameters:
      dtm - the data type manager
      type - 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 checked
      accumulatedOffset - the accumulated offset of the component due to flattening
      ownerVxtptrs - the map of offset to owner vxtptr types
      Returns:
      the replacement data type or the original type if there is no replacement needed
    • getReplacementType NEW

      public static Structure getReplacementType(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. The structure argument becomes the return type if enabled is false, if the argument structure does not have class attributes, or if there is no suitable replacement for it
      Parameters:
      structure - the structure to process
      enabled - false will immediately return the argument type
      Returns:
      the replacement data type or null if could not or did not need to be replaced
    • getReplacementType NEW

      public static Structure getReplacementType(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 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 NEW

      public static boolean hasClassAttribute(Structure structure)
      This method returns true if the argument structure has a class attribute
      Parameters:
      structure - the structure under question
      Returns:
      true if has a class attribute