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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
additionalMarkup
(MarkupSession session) Called to allow the implementor to perform custom markup of itself.static GoString
createInlineString
(GoRttiMapper goBinary, Address stringData, long len) Creates a artificial gostring instance that was not read from a memory location.long
Returns 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.boolean
isValid
(AddressSetView charValidRange, Predicate<String> stringContentValidator) Returns true if this string instance is valid and probably contains a go string.boolean
isValidInlineString
(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, wait
Methods 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
-GoRttiMapper
stringData
- 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: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 thestructureName
value in the@StructureMapping
annotation.- Specified by:
getStructureLabel
in 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:
getStructureContext
in interfaceStructureMarkup<GoString>
-
additionalMarkup
Description copied from interface:StructureMarkup
Called to allow the implementor to perform custom markup of itself.- Specified by:
additionalMarkup
in interfaceStructureMarkup<GoString>
- Parameters:
session
- state and methods to assist marking up the program- Throws:
IOException
- if error during markup
-