DataBuffer

Detailed Description

Classes

class  BinaryNinja::DataBuffer
 

Class Documentation

◆ BinaryNinja::DataBuffer

class BinaryNinja::DataBuffer

Public Member Functions

 DataBuffer ()
 
 DataBuffer (size_t len)
 
 DataBuffer (const void *data, size_t len)
 
 DataBuffer (const DataBuffer &buf)
 
 DataBuffer (DataBuffer &&buf)
 
 DataBuffer (BNDataBuffer *buf)
 
 ~DataBuffer ()
 
DataBufferoperator= (const DataBuffer &buf)
 
DataBufferoperator= (DataBuffer &&buf)
 
BNDataBufferGetBufferObject () const
 
void * GetData ()
 Get the raw pointer to the data contained within this buffer. More...
 
const void * GetData () const
 Get the raw pointer to the data contained within this buffer, as a const pointer. More...
 
void * GetDataAt (size_t offset)
 Get the raw pointer to the data contained within this buffer, starting at a given offset. More...
 
const void * GetDataAt (size_t offset) const
 Get the const raw pointer to the data contained within this buffer, starting at a given offset. More...
 
size_t GetLength () const
 Get the length of the data contained within this buffer. More...
 
void SetSize (size_t len)
 Set the size of the data pointed to by this buffer. More...
 
void Clear ()
 Clear the data contained by this buffer. More...
 
void Append (const void *data, size_t len)
 Append len contents of the pointer data to the end of the buffer. More...
 
void Append (const DataBuffer &buf)
 Append the contents of databuffer buf to the current DataBuffer. More...
 
void AppendByte (uint8_t val)
 Append a single byte. More...
 
DataBuffer GetSlice (size_t start, size_t len)
 Get the contents of a given slice of data, as a DataBuffer. More...
 
uint8_t & operator[] (size_t offset)
 
const uint8_t & operator[] (size_t offset) const
 
bool operator== (const DataBuffer &other) const
 
bool operator!= (const DataBuffer &other) const
 
std::string ToEscapedString (bool nullTerminates=false) const
 Convert the contents of the DataBuffer to a string. More...
 
std::string ToBase64 () const
 Convert the contents of this DataBuffer to a base64 representation. More...
 
bool ZlibCompress (DataBuffer &output) const
 Compress this databuffer via ZLIB compression. More...
 
bool ZlibDecompress (DataBuffer &output) const
 Decompress the contents of this buffer via ZLIB compression. More...
 

Static Public Member Functions

static DataBuffer FromEscapedString (const std::string &src)
 Create a DataBuffer from a given escaped string. More...
 
static DataBuffer FromBase64 (const std::string &src)
 Create a DataBuffer from a given base64 string. More...
 

Constructor & Destructor Documentation

◆ DataBuffer() [1/6]

DataBuffer::DataBuffer ( )

◆ DataBuffer() [2/6]

DataBuffer::DataBuffer ( size_t  len)

◆ DataBuffer() [3/6]

DataBuffer::DataBuffer ( const void *  data,
size_t  len 
)

◆ DataBuffer() [4/6]

DataBuffer::DataBuffer ( const DataBuffer buf)

◆ DataBuffer() [5/6]

DataBuffer::DataBuffer ( DataBuffer &&  buf)

◆ DataBuffer() [6/6]

DataBuffer::DataBuffer ( BNDataBuffer buf)

◆ ~DataBuffer()

DataBuffer::~DataBuffer ( )

Member Function Documentation

◆ operator=() [1/2]

DataBuffer & DataBuffer::operator= ( const DataBuffer buf)

◆ operator=() [2/2]

DataBuffer & DataBuffer::operator= ( DataBuffer &&  buf)

◆ GetBufferObject()

BNDataBuffer * BinaryNinja::DataBuffer::GetBufferObject ( ) const
inline

◆ GetData() [1/2]

void * DataBuffer::GetData ( )

Get the raw pointer to the data contained within this buffer.

Thread Safe:
No

◆ GetData() [2/2]

const void * DataBuffer::GetData ( ) const

Get the raw pointer to the data contained within this buffer, as a const pointer.

Thread Safe:
No

◆ GetDataAt() [1/2]

void * DataBuffer::GetDataAt ( size_t  offset)

Get the raw pointer to the data contained within this buffer, starting at a given offset.

Thread Safe:
No

◆ GetDataAt() [2/2]

const void * DataBuffer::GetDataAt ( size_t  offset) const

Get the const raw pointer to the data contained within this buffer, starting at a given offset.

Thread Safe:
No

◆ GetLength()

size_t DataBuffer::GetLength ( ) const

Get the length of the data contained within this buffer.

Thread Safe:
No

◆ SetSize()

void DataBuffer::SetSize ( size_t  len)

Set the size of the data pointed to by this buffer.

Thread Safe:
No

◆ Clear()

void DataBuffer::Clear ( )

Clear the data contained by this buffer.

Note
This will call free() on this buffer's data pointer. You shouldn't call it yourself, typically ever.
Thread Safe:
No

◆ Append() [1/2]

void DataBuffer::Append ( const void *  data,
size_t  len 
)

Append len contents of the pointer data to the end of the buffer.

Note
This will typically call realloc() on this buffer's data pointer. You should hold this DataBuffer and use it for accesses, instead of storing the raw pointer.
Thread Safe:
No

◆ Append() [2/2]

void DataBuffer::Append ( const DataBuffer buf)

Append the contents of databuffer buf to the current DataBuffer.

Note
This will typically call realloc() on this buffer's data pointer. You should hold this DataBuffer and use it for accesses, instead of storing the raw pointer.
Thread Safe:
No

◆ AppendByte()

void DataBuffer::AppendByte ( uint8_t  val)

Append a single byte.

Note
This will typically call realloc() on this buffer's data pointer. You should hold this DataBuffer and use it for accesses, instead of storing the raw pointer.
Thread Safe:
No

◆ GetSlice()

DataBuffer DataBuffer::GetSlice ( size_t  start,
size_t  len 
)

Get the contents of a given slice of data, as a DataBuffer.

Thread Safe:
No

◆ operator[]() [1/2]

uint8_t & DataBuffer::operator[] ( size_t  offset)

◆ operator[]() [2/2]

const uint8_t & DataBuffer::operator[] ( size_t  offset) const

◆ operator==()

bool DataBuffer::operator== ( const DataBuffer other) const

◆ operator!=()

bool DataBuffer::operator!= ( const DataBuffer other) const

◆ ToEscapedString()

string DataBuffer::ToEscapedString ( bool  nullTerminates = false) const

Convert the contents of the DataBuffer to a string.

Parameters
nullTerminatesWhether the decoder should stop and return the string after encountering a null (\x00) byte.
Thread Safe:
No

◆ FromEscapedString()

DataBuffer DataBuffer::FromEscapedString ( const std::string &  src)
static

Create a DataBuffer from a given escaped string.

Parameters
srcInput string
Returns
Databuffer created from this string

◆ ToBase64()

string DataBuffer::ToBase64 ( ) const

Convert the contents of this DataBuffer to a base64 representation.

Thread Safe:
No

◆ FromBase64()

DataBuffer DataBuffer::FromBase64 ( const std::string &  src)
static

Create a DataBuffer from a given base64 string.

Parameters
srcInput base64 string
Returns
Databuffer created from this string

◆ ZlibCompress()

bool DataBuffer::ZlibCompress ( DataBuffer output) const

Compress this databuffer via ZLIB compression.

Thread Safe:
No
Parameters
[out]outputOutput DataBuffer the compressed contents will be stored in.
Returns
Whether compression was successful

◆ ZlibDecompress()

bool DataBuffer::ZlibDecompress ( DataBuffer output) const

Decompress the contents of this buffer via ZLIB compression.

Thread Safe:
No
Parameters
[out]outputOutput DataBuffer the decompressed contents will be stored in.
Returns
Whether decompression was successful