Class DynamicDataType

All Implemented Interfaces:
BuiltInDataType, DataType, Dynamic, ExtensionPoint
Direct Known Subclasses:
AndroidElfRelocationTableDataType, BitmapResourceDataType, CountedDynamicDataType, DialogResourceDataType, GroupIconResourceDataType, IndexedDynamicDataType, MenuResourceDataType, MUIResourceDataType, PERichTableDataType, PEx64UnwindInfoDataType, RepeatCountDataType, RepeatedDynamicDataType, RTTIDataType, StructuredDynamicDataType, WEVTResourceDataType

public abstract class DynamicDataType extends BuiltIn implements Dynamic
Interface for dataTypes that don't get applied, but instead generate dataTypes on the fly based on the data.
  • Constructor Details

  • Method Details

    • canSpecifyLength

      public final boolean canSpecifyLength()
      Description copied from interface: Dynamic
      Determine if the length may be specified for an instanceof this datatype (e.g., Data, Array, DataTypeComponent, etc.).
      Specified by:
      canSpecifyLength in interface Dynamic
      Returns:
      true if a user-specified length can be used, else false
    • getNumComponents

      public final int getNumComponents(MemBuffer buf)
      Gets the number of component data types in this data type.
      Parameters:
      buf - a memory buffer to be used by dataTypes that change depending on their data context.
      Returns:
      the number of components that make up this data prototype - if this is an Array, return the number of elements in the array. - if this datatype is a subcomponent of another datatype and it won't fit in it's defined space, return -1.
    • getComps

      protected DataTypeComponent[] getComps(MemBuffer buf)
    • getComponent

      public final DataTypeComponent getComponent(int ordinal, MemBuffer buf)
      Returns the immediate n'th component of this data type.
      Parameters:
      ordinal - the components ordinal (zero based).
      buf - a memory buffer to be used by dataTypes that change depending on their data context.
      Returns:
      the component data type or null if there is no component at the indicated index.
      Throws:
      ArrayIndexOutOfBoundsException - if index is out of bounds
    • getComponents

      public final DataTypeComponent[] getComponents(MemBuffer buf)
      Returns an array of components that make up this data type. Could return null if there are no subcomponents.
      Parameters:
      buf - a memory buffer to be used by dataTypes that change depending on their data context.
      Returns:
      datatype component array or null.
    • getComponentAt

      public final DataTypeComponent getComponentAt(int offset, MemBuffer buf)
      Returns the first component containing the byte at the given offset. It is possible with zero-length components (see DataType.isZeroLength()) and bitfields (see @DataTypeComponent#isBitFieldComponent()} for multiple components to share the same offset.
      Parameters:
      offset - the offset into the dataType
      buf - the memory buffer containing the bytes.
      Returns:
      the first component containing the byte at the given offset or null if no component defined. A zero-length component may be returned.
    • getAllComponents

      protected abstract DataTypeComponent[] getAllComponents(MemBuffer buf)
      Get all dynamic components associated with the specified MemBuffer
      Parameters:
      buf - memory buffer positioned at start of data type instance
      Returns:
      all components or null if memory data is not valid for this data type.
    • getLength

      public final int getLength(MemBuffer buf, int maxLength)
      Description copied from interface: Dynamic
      Compute the length for this data-type which corresponds to the specified memory location.
      Specified by:
      getLength in interface Dynamic
      Parameters:
      buf - memory location
      maxLength - maximum number of bytes to consume in computing length, or -1 for unspecified.
      Returns:
      data length or -1 if it could not be determined. Returned length may exceed maxLength if data-type does not supported constrained lengths.
    • getLength

      public int getLength()
      Description copied from interface: DataType
      Get the length of this DataType as a number of 8-bit bytes.

      For primitive datatypes this reflects the smallest varnode which can be used to contain its value (i.e., raw data length).

      Example: For x86 32-bit gcc an 80-bit long double raw data length of 10-bytes will fit within a floating point register while its aligned-length of 12-bytes is used by the gcc compiler for data/array/component allocations to maintain alignment (i.e., sizeof(long double) ).

      NOTE: Other than the VoidDataType, no datatype should ever return 0, even if DataType.isZeroLength(), and only Dynamic/FactoryDataType datatypes should return -1. If DataType.isZeroLength() is true a length of 1 should be returned. Where a zero-length datatype can be handled (e.g., Composite) the DataType.isZeroLength() method should be used.

      Specified by:
      getLength in interface DataType
      Returns:
      the length of this DataType
    • invalidateCache

      public void invalidateCache()
    • getReplacementBaseType

      public DataType getReplacementBaseType()
      Description copied from interface: Dynamic
      Returns a suitable replacement base data-type for pointers and arrays when exporting to C code
      Specified by:
      getReplacementBaseType in interface Dynamic
      Returns:
      suitable base data-type for this Dynamic data-type