java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoSlice

public class GoSlice extends Object
  • Constructor Details

    • GoSlice

      public GoSlice()
    • GoSlice

      public GoSlice(long array, long len, long cap)
    • GoSlice

      public GoSlice(long array, long len, long cap, GoRttiMapper programContext)
  • Method Details

    • getSubSlice

      public GoSlice getSubSlice(long startElement, long elementCount, long elementSize)
      Return a artificial view of a portion of this slice's contents.
      Parameters:
      startElement - index of element that will be the new sub-slice's starting element
      elementCount - number of elements to include in new sub-slice
      elementSize - size of an individual element
      Returns:
      new GoSlice instance that is limited to a portion of this slice
    • isValid

      public boolean isValid()
    • isValid

      public boolean isValid(int elementSize)
    • getArrayOffset

      public long getArrayOffset()
    • getArrayAddress

      public Address getArrayAddress()
    • getArrayEnd

      public long getArrayEnd(Class<?> elementClass)
    • getLen

      public long getLen()
    • getCap

      public long getCap()
    • isFull

      public boolean isFull()
    • isOffsetWithinData

      public boolean isOffsetWithinData(long offset, int sizeofElement)
    • readList

      public <T> List<T> readList(Class<T> clazz) throws IOException
      Reads the content of the slice, treating each element as an instance of the specified structure mapped class.
      Type Parameters:
      T - struct mapped type of element
      Parameters:
      clazz - element type
      Returns:
      list of instances
      Throws:
      IOException - if error reading an element
    • readList

      public <T> List<T> readList(BinaryReader.ReaderFunction<T> readFunc) throws IOException
      Reads the contents of the slice, treating each element as an instance of an object that can be read using the supplied reading function.
      Type Parameters:
      T - struct mapped type of element
      Parameters:
      readFunc - function that will read an instance from a BinaryReader
      Returns:
      list of instances
      Throws:
      IOException - if error reading an element
    • readUIntList

      public long[] readUIntList(int intSize) throws IOException
      Treats this slice as a array of unsigned integers, of the specified intSize.

      Parameters:
      intSize - size of integer
      Returns:
      array of longs, containing the (possibly smaller) integers contained in the slice
      Throws:
      IOException - if error reading
    • markupArray

      public void markupArray(String sliceName, Class<?> elementClazz, boolean ptr, MarkupSession session) throws IOException
      Marks up the memory occupied by the array elements with a name and a Ghidra ArrayDataType, which has elements who's type is determined by the specified structure class.
      Parameters:
      sliceName - used to label the memory location
      elementClazz - structure mapped class of the element of the array
      ptr - boolean flag, if true the element type is really a pointer to the supplied data type
      session - state and methods to assist marking up the program
      Throws:
      IOException - if error
    • markupArray

      public void markupArray(String sliceName, DataType elementType, boolean ptr, MarkupSession session) throws IOException
      Marks up the memory occupied by the array elements with a name and a Ghidra ArrayDataType.
      Parameters:
      sliceName - used to label the memory location
      elementType - Ghidra datatype of the array elements, null ok if ptr == true
      ptr - boolean flag, if true the element type is really a pointer to the supplied data type
      session - state and methods to assist marking up the program
      Throws:
      IOException - if error
    • markupArrayElements

      public <T> List<T> markupArrayElements(Class<T> clazz, MarkupSession session) throws IOException
      Marks up each element of the array, useful when the elements are themselves structures.
      Type Parameters:
      T - element type
      Parameters:
      clazz - structure mapped class of element
      session - state and methods to assist marking up the program
      Returns:
      list of element instances
      Throws:
      IOException - if error reading
    • markupElementReferences

      public void markupElementReferences(int elementSize, List<Address> targetAddrs, MarkupSession session) throws IOException
      Marks up each element of the array with an outbound reference to the corresponding address in the targetAddrs list.

      Useful when marking up an array of offsets.

      The Listing UI doesn't show the outbound reference from each element (for arrays of primitive types), but the target will show the inbound reference.

      Parameters:
      elementSize - size of each element in the array
      targetAddrs - list of addresses, should be same size as this slice
      session - state and methods to assist marking up the program
      Throws:
      IOException - if error creating references