Class GoString
java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoString
- All Implemented Interfaces:
StructureMarkup<GoString>
A structure that represents a golang string instance.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadditionalMarkup(MarkupSession session) Called to allow the implementor to perform custom markup of itself.static GoStringcreateInlineString(GoRttiMapper goBinary, Address stringData, long len) Creates a artificial gostring instance that was not read from a memory location.longReturns the length of the string dataReturns the address of the char data, referenced via the str field's markup annotationReturns an AddressRange that encompasses the string char data.Returns the string value.Returns a string that can be used to place a label on the instance.booleanisValid(AddressSetView charValidRange, Predicate<String> stringContentValidator) Returns true if this string instance is valid and probably contains a go string.booleanisValidInlineString(AddressSetView charValidRange, Predicate<String> stringContentValidator) Returns true if this string instance points to valid char[] data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.app.util.bin.format.golang.structmapping.StructureMarkup
getExternalInstancesToMarkup, getStructureName, getStructureNamespace
-
Field Details
-
MAX_SANE_STR_LEN
public static final int MAX_SANE_STR_LEN- See Also:
-
-
Constructor Details
-
GoString
public GoString()
-
-
Method Details
-
createInlineString
Creates a artificial gostring instance that was not read from a memory location.- Parameters:
goBinary-GoRttiMapperstringData- location of char arraylen- length of char array- Returns:
- new GoString instance
-
getStringAddr
Returns the address of the char data, referenced via the str field's markup annotation- Returns:
- address of the char data
-
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
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[] datastringContentValidator- 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[] datastringContentValidator- 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
Description copied from interface:StructureMarkupReturns 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 thestructureNamevalue in the@StructureMappingannotation.- Specified by:
getStructureLabelin interfaceStructureMarkup<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
- Specified by:
getStructureContextin interfaceStructureMarkup<GoString>
-
additionalMarkup
Description copied from interface:StructureMarkupCalled to allow the implementor to perform custom markup of itself.- Specified by:
additionalMarkupin interfaceStructureMarkup<GoString>- Parameters:
session- state and methods to assist marking up the program- Throws:
IOException- if error during markup
-