Class StringDataInstance.StaticStringInstance
- java.lang.Object
-
- ghidra.program.model.data.StringDataInstance
-
- ghidra.program.model.data.StringDataInstance.StaticStringInstance
-
- Enclosing class:
- StringDataInstance
public static class StringDataInstance.StaticStringInstance extends StringDataInstance
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ghidra.program.model.data.StringDataInstance
StringDataInstance.StaticStringInstance
-
-
Field Summary
-
Fields inherited from class ghidra.program.model.data.StringDataInstance
DEFAULT_CHARSET_NAME, MAX_STRING_LENGTH, NULL_INSTANCE, UNKNOWN, UNKNOWN_DOT_DOT_DOT
-
-
Constructor Summary
Constructors Constructor Description StaticStringInstance(java.lang.String fakeStr, int fakeLen)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetLabel(java.lang.String prefixStr, java.lang.String abbrevPrefixStr, java.lang.String defaultStr, DataTypeDisplayOptions options)java.lang.StringgetOffcutLabelString(java.lang.String prefixStr, java.lang.String abbrevPrefixStr, java.lang.String defaultStr, DataTypeDisplayOptions options, int offcutOffset)intgetStringLength()Returns the length, in bytes, of the string data object contained in theMemBuffer, or -1 if the length could not be determined.java.lang.StringgetStringRepresentation()Returns a formatted version of the string returned byStringDataInstance.getStringValue().java.lang.StringgetStringValue()Returns the string contained in the specifiedMemBuffer, or null if all the bytes of the string could not be read.-
Methods inherited from class ghidra.program.model.data.StringDataInstance
encodeReplacementFromCharRepresentation, encodeReplacementFromCharValue, encodeReplacementFromStringRepresentation, encodeReplacementFromStringValue, getAddress, getByteOffcut, getCharOffcut, getCharRepresentation, getCharRepresentation, getCharsetName, getDataLength, getStringDataInstance, getStringDataInstance, getStringDataTypeGuess, getTranslatedValue, isChar, isMissingNullTerminator, isShowTranslation, isString, isStringDataType, toString
-
-
-
-
Method Detail
-
getStringValue
public java.lang.String getStringValue()
Description copied from class:StringDataInstanceReturns the string contained in the specifiedMemBuffer, or null if all the bytes of the string could not be read.This method deals in characters of size
StringDataInstance.charSize, that might bepaddedto a larger size. The raw n-byte characters are converted into a Java String using a JavaCharsetor by using a custom Ghidra conversion. (see convertBytesToStringCustomCharset)The MemBuffer's endian'ness is used to determine which end of the
paddedfield contains ourStringDataInstance.charSizecharacter bytes which will be used to create the java String.- Overrides:
getStringValuein classStringDataInstance- Returns:
- String containing the characters in buf or null if unable to read all
lengthbytes from the membuffer.
-
getStringRepresentation
public java.lang.String getStringRepresentation()
Description copied from class:StringDataInstanceReturns a formatted version of the string returned byStringDataInstance.getStringValue().The resulting string will be formatted with quotes around the parts that contain plain ASCII alpha characters (and simple escape sequences), and out-of-range byte-ish values listed as comma separated hex-encoded values:
Example (quotes are part of result):
"Test\tstring",01,02,"Second\npart",00- Overrides:
getStringRepresentationin classStringDataInstance- Returns:
- formatted String
-
getStringLength
public int getStringLength()
Description copied from class:StringDataInstanceReturns the length, in bytes, of the string data object contained in theMemBuffer, or -1 if the length could not be determined.This is not the same as the number of characters in the string, or the number of bytes occupied by the characters. For instance, pascal strings have a 1 or 2 byte length field that increases the size of the string data object beyond the characters in the string, and null terminated strings have don't include the null character, but its presence is included in the size of the string object.
For length-specified string data types that do not use null-terminators and with a known data instance length (ie. not a probe), this method just returns the value specified in the constructor
lengthparameter, otherwise a null-terminator is searched for.When searching for a null-terminator, the constructor
lengthparameter will be respected or ignored depending on theStringLayoutEnum.When the length parameter is ignored (ie. "unbounded" searching), the search is limited to
StringDataInstance.MAX_STRING_LENGTHbytes.The MemBuffer's endian'ness is used to determine which end of the padded character field contains our n-bit character which will be tested for null-ness. (not the endian'ness of the character set name - ie. "UTF-16BE")
- Overrides:
getStringLengthin classStringDataInstance- Returns:
- length of the string (NOT including null term if null term probe), in bytes, or -1 if no terminator found.
-
getLabel
public java.lang.String getLabel(java.lang.String prefixStr, java.lang.String abbrevPrefixStr, java.lang.String defaultStr, DataTypeDisplayOptions options)- Overrides:
getLabelin classStringDataInstance
-
getOffcutLabelString
public java.lang.String getOffcutLabelString(java.lang.String prefixStr, java.lang.String abbrevPrefixStr, java.lang.String defaultStr, DataTypeDisplayOptions options, int offcutOffset)- Overrides:
getOffcutLabelStringin classStringDataInstance
-
-