Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::StringManagerUnicode Class Reference

An implementation of StringManager that understands terminated unicode strings. More...

#include <stringmanage.hh>

Inheritance diagram for ghidra::StringManagerUnicode:
[legend]
Collaboration diagram for ghidra::StringManagerUnicode:
[legend]

Public Member Functions

 StringManagerUnicode (Architecture *g, int4 max)
 Constructor.
 
virtual const vector< uint1 > & getStringData (const Address &addr, Datatype *charType, bool &isTrunc)
 Retrieve string data at the given address as a UTF8 byte array.
 
- Public Member Functions inherited from ghidra::StringManager
 StringManager (int4 max)
 Constructor.
 
virtual ~StringManager (void)
 Destructor.
 
void clear (void)
 Clear out any cached strings.
 
bool isString (const Address &addr, Datatype *charType)
 
uint8 registerInternalStringData (const Address &addr, const uint1 *buf, int4 size, Datatype *charType)
 Associate string data at a code address or other location that doesn't hold string data normally.
 
void encode (Encoder &encoder) const
 Encode cached strings to a stream.
 
void decode (Decoder &decoder)
 Restore string cache from a stream.
 

Private Attributes

Architectureglb
 Underlying architecture.
 
uint1 * testBuffer
 Temporary buffer for pulling in loadimage bytes.
 

Additional Inherited Members

- Static Public Member Functions inherited from ghidra::StringManager
static bool hasCharTerminator (const uint1 *buffer, int4 size, int4 charsize)
 Check for a unicode string terminator.
 
static int4 readUtf16 (const uint1 *buf, bool bigend)
 Read a UTF16 code point from a byte array.
 
static void writeUtf8 (ostream &s, int4 codepoint)
 Write unicode character to stream in UTF8 encoding.
 
static int4 checkCharacters (const uint1 *buf, int4 size, int4 charsize, bool bigend)
 Make sure buffer has valid bounded set of unicode.
 
static int4 getCodepoint (const uint1 *buf, int4 charsize, bool bigend, int4 &skip)
 Extract next unicode codepoint.
 
- Protected Member Functions inherited from ghidra::StringManager
bool writeUnicode (ostream &s, const uint1 *buffer, int4 size, int4 charsize, bool bigend)
 Translate/copy unicode to UTF8.
 
void assignStringData (StringData &data, const uint1 *buf, int4 size, int4 charsize, int4 numChars, bool bigend)
 Translate and assign raw string data to a StringData object.
 
- Static Protected Member Functions inherited from ghidra::StringManager
static uint8 calcInternalHash (const Address &addr, const uint1 *buf, int4 size)
 Calculate hash of a specific Address and contents of a byte array.
 
- Protected Attributes inherited from ghidra::StringManager
map< Address, StringDatastringMap
 Map from address to string data.
 
int4 maximumChars
 Maximum characters in a string before truncating.
 

Detailed Description

An implementation of StringManager that understands terminated unicode strings.

This class understands UTF8, UTF16, and UTF32 encodings. It reports a string if its sees a valid encoding that is null terminated.

Constructor & Destructor Documentation

◆ StringManagerUnicode()

ghidra::StringManagerUnicode::StringManagerUnicode ( Architecture g,
int4  max 
)

Constructor.

Parameters
gis the underlying architecture (and loadimage)
maxis the maximum number of bytes to allow in a decoded string

References glb, and testBuffer.

Member Function Documentation

◆ getStringData()

const vector< uint1 > & ghidra::StringManagerUnicode::getStringData ( const Address addr,
Datatype charType,
bool &  isTrunc 
)
virtual

Retrieve string data at the given address as a UTF8 byte array.

If the address does not represent string data, a zero length vector is returned. Otherwise, the string data is fetched, converted to a UTF8 encoding, cached and returned.

Parameters
addris the given address
charTypeis a character data-type indicating the encoding
isTruncpasses back whether the string is truncated
Returns
the byte array of UTF8 data

Implements ghidra::StringManager.

References ghidra::StringManager::assignStringData(), ghidra::StringManager::StringData::byteData, ghidra::StringManager::checkCharacters(), ghidra::Datatype::getSize(), glb, ghidra::StringManager::hasCharTerminator(), ghidra::Address::isBigEndian(), ghidra::Datatype::isOpaqueString(), ghidra::StringManager::StringData::isTruncated, ghidra::Architecture::loader, ghidra::LoadImage::loadFill(), ghidra::StringManager::maximumChars, ghidra::StringManager::stringMap, and testBuffer.


The documentation for this class was generated from the following files: