Class PointerTypedefBuilder

java.lang.Object
ghidra.program.model.data.PointerTypedefBuilder

public class PointerTypedefBuilder extends Object
PointerTypedefBuilder provides a builder for creating Pointer - TypeDefs. These special typedefs allow a modified-pointer datatype to be used for special situations where a simple pointer will not suffice and special stored pointer interpretation/handling is required.
This builder simplifies the specification of various Pointer modifiers during the construction of an associated TypeDef.
A convenience method Pointer.typedefBuilder() also exists for creating a builder from a pointer instance. In addition the utility class PointerTypedefInspector can be used to easily determine pointer-typedef settings.
  • Constructor Details

    • PointerTypedefBuilder

      public PointerTypedefBuilder(DataType baseDataType, int pointerSize, DataTypeManager dtm)
      Construct a Pointer - TypeDef builder.
      Parameters:
      baseDataType - baseDataType or null to use a default pointer
      pointerSize - pointer size or -1 to use default pointer size for specified datatype manager.
      dtm - datatype manager (highly recommended although may be null)
    • PointerTypedefBuilder

      public PointerTypedefBuilder(Pointer pointerDataType, DataTypeManager dtm)
      Construct a Pointer - TypeDef builder.
      Parameters:
      pointerDataType - base pointer datatype (required)
      dtm - datatype manager (highly recommended although may be null)
  • Method Details

    • name

      Set pointer-typedef name. If not specified a default name will be generated based upon the associated pointer type and the specified settings.
      Parameters:
      name - typedef name
      Returns:
      this builder
      Throws:
      InvalidNameException - if name contains unsupported characters
    • type

      public PointerTypedefBuilder type(PointerType type)
      Update pointer type.
      Parameters:
      type - pointer type
      Returns:
      this builder
    • bitShift

      public PointerTypedefBuilder bitShift(int shift)
      Update pointer offset bit-shift when translating to an absolute memory offset. If specified, bit-shift will be applied after applying any specified bit-mask.
      Parameters:
      shift - bit-shift (right: positive, left: negative)
      Returns:
      this builder
    • bitMask

      public PointerTypedefBuilder bitMask(long unsignedMask)
      Update pointer offset bit-mask when translating to an absolute memory offset. If specified, bit-mask will be AND-ed with stored offset prior to any specified bit-shift.
      Parameters:
      unsignedMask - unsigned bit-mask
      Returns:
      this builder
    • componentOffset

      public PointerTypedefBuilder componentOffset(long offset)
      Update pointer relative component-offset. This setting is interpretted in two ways:
      • The specified offset is considered to be relative to the start of the base datatype (e.g., structure). It may refer to a component-offset within the base datatype or outside of it.
      • When pointer-typedef is initially applied to memory, an OffsetReference will be produced by subtracting the component-offset from the stored pointer offset to determine the base-offset for the reference. While the xref will be to the actual referenced location, the reference markup will be shown as <base>+<offset>
      Parameters:
      offset - component offset relative to a base-offset and associated base-datatype
      Returns:
      this builder
    • addressSpace

      public PointerTypedefBuilder addressSpace(AddressSpace space)
      Update pointer referenced address space when translating to an absolute memory offset.
      Parameters:
      space - pointer referenced address space or null for default space
      Returns:
      this builder
    • addressSpace

      public PointerTypedefBuilder addressSpace(String spaceName)
      Update pointer referenced address space when translating to an absolute memory offset.
      Parameters:
      spaceName - pointer referenced address space or null for default space
      Returns:
      this builder
    • build

      public TypeDef build()
      Build pointer-typedef with specified settings.
      Returns:
      unresolved pointer typedef