Class GoString

java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoString
All Implemented Interfaces:
StructureMarkup<GoString>

public class GoString extends Object implements StructureMarkup<GoString>
A structure that represents a golang string instance.
  • Field Details

  • Constructor Details

    • GoString

      public GoString()
  • Method Details

    • createInlineString

      public static GoString createInlineString(GoRttiMapper goBinary, Address stringData, long len)
      Creates a artificial gostring instance that was not read from a memory location.

      Parameters:
      goBinary - GoRttiMapper
      stringData - location of char array
      len - length of char array
      Returns:
      new GoString instance
    • getStringAddr

      public Address getStringAddr()
      Returns the address of the char data, referenced via the str field's markup annotation
      Returns:
      address of the char data
    • getStringDataRange

      public AddressRange getStringDataRange()
      Returns an AddressRange that encompasses the string char data.
      Returns:
      AddressRange that encompasses the string char data
    • getLength

      public long getLength()
      Returns the length of the string data
      Returns:
      length of the string data
    • getStringValue

      public String getStringValue() throws IOException
      Returns the string value.
      Returns:
      string value
      Throws:
      IOException - if error reading char data
    • isValid

      public boolean isValid(AddressSetView charValidRange, Predicate<String> stringContentValidator) throws IOException
      Returns true if this string instance is valid and probably contains a go string.
      Parameters:
      charValidRange - addresses that are valid locations for a string's char[] data
      stringContentValidator - a callback that will test a recovered string for validity
      Returns:
      boolean true if valid string, false if not valid string
      Throws:
      IOException - if error reading data
    • isValidInlineString

      public boolean isValidInlineString(AddressSetView charValidRange, Predicate<String> stringContentValidator) throws IOException
      Returns true if this string instance points to valid char[] data.
      Parameters:
      charValidRange - addresses that are valid locations for a string's char[] data
      stringContentValidator - a callback that will test a recovered string for validity
      Returns:
      boolean true if valid string, false if not valid string
      Throws:
      IOException - if error reading data
    • getStructureLabel

      public String getStructureLabel() throws IOException
      Description copied from interface: StructureMarkup
      Returns a string that can be used to place a label on the instance.

      This default implementation will query the StructureMarkup.getStructureName() method, and if it provides a value, will produce a string that looks like "name___mappingstructname", where "mappingstructname" will be the structureName value in the @StructureMapping annotation.

      Specified by:
      getStructureLabel in interface StructureMarkup<GoString>
      Returns:
      string to be used as a label, or null if there is not a valid label for the instance
      Throws:
      IOException - if error getting label
    • getStructureContext

      public StructureContext<GoString> getStructureContext()
      Specified by:
      getStructureContext in interface StructureMarkup<GoString>
    • additionalMarkup

      public void additionalMarkup(MarkupSession session) throws IOException
      Description copied from interface: StructureMarkup
      Called to allow the implementor to perform custom markup of itself.
      Specified by:
      additionalMarkup in interface StructureMarkup<GoString>
      Parameters:
      session - state and methods to assist marking up the program
      Throws:
      IOException - if error during markup