Binary Ninja API C++: DataBuffer
Classes | |
| class | BinaryNinja::DataBuffer |
◆ 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 () | |
| DataBuffer & | operator= (const DataBuffer &buf) |
| DataBuffer & | operator= (DataBuffer &&buf) |
| BNDataBuffer * | GetBufferObject () const |
| void * | GetData () |
| Get the raw pointer to the data contained within this buffer. | |
| const void * | GetData () const |
| Get the raw pointer to the data contained within this buffer, as a const pointer. | |
| void * | GetDataAt (size_t offset) |
| Get the raw pointer to the data contained within this buffer, starting at a given offset. | |
| const void * | GetDataAt (size_t offset) const |
| Get the const raw pointer to the data contained within this buffer, starting at a given offset. | |
| size_t | GetLength () const |
| Get the length of the data contained within this buffer. | |
| void | SetSize (size_t len) |
| Set the size of the data pointed to by this buffer. | |
| void | Clear () |
| Clear the data contained by this buffer. | |
| void | Append (const void *data, size_t len) |
Append len contents of the pointer data to the end of the buffer. | |
| void | Append (const DataBuffer &buf) |
Append the contents of databuffer buf to the current DataBuffer. | |
| void | AppendByte (uint8_t val) |
| Append a single byte. | |
| DataBuffer | GetSlice (size_t start, size_t len) |
| Get the contents of a given slice of data, as a DataBuffer. | |
| 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, bool escapePrintable=false) const |
| Convert the contents of the DataBuffer to a string. | |
| std::string | ToBase64 () const |
| Convert the contents of this DataBuffer to a base64 representation. | |
| bool | ZlibCompress (DataBuffer &output) const |
| Compress this databuffer via ZLIB compression. | |
| bool | ZlibDecompress (DataBuffer &output) const |
| Decompress the contents of this buffer via ZLIB compression. | |
| bool | LzmaDecompress (DataBuffer &output) const |
| Decompress the contents of this buffer via LZMA compression. | |
| bool | Lzma2Decompress (DataBuffer &output) const |
| Decompress the contents of this buffer via LZMA2 compression. | |
| bool | XzDecompress (DataBuffer &output) const |
| Decompress the contents of this buffer via XZ compression. | |
Static Public Member Functions | |
| static DataBuffer | FromEscapedString (const std::string &src) |
| Create a DataBuffer from a given escaped string. | |
| static DataBuffer | FromBase64 (const std::string &src) |
| Create a DataBuffer from a given base64 string. | |
| 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::~DataBuffer | ( | ) |
◆ operator=() [1/2]
| DataBuffer & DataBuffer::operator= | ( | const DataBuffer & | buf | ) |
◆ operator=() [2/2]
| DataBuffer & DataBuffer::operator= | ( | DataBuffer && | buf | ) |
◆ GetBufferObject()
|
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, |
| bool | escapePrintable = false ) const |
Convert the contents of the DataBuffer to a string.
- Parameters
-
nullTerminates Whether the decoder should stop and return the string after encountering a null (\x00) byte.
Thread Safe: - No
◆ FromEscapedString()
|
static |
Create a DataBuffer from a given escaped string.
- Parameters
- 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()
|
static |
Create a DataBuffer from a given base64 string.
- Parameters
- Returns
- Databuffer created from this string
◆ ZlibCompress()
| bool DataBuffer::ZlibCompress | ( | DataBuffer & | output | ) | const |
Compress this databuffer via ZLIB compression.
Thread Safe: - No
- Parameters
-
[out] output Output 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] output Output DataBuffer the decompressed contents will be stored in.
- Returns
- Whether decompression was successful
◆ LzmaDecompress()
| bool DataBuffer::LzmaDecompress | ( | DataBuffer & | output | ) | const |
Decompress the contents of this buffer via LZMA compression.
Thread Safe: - No
- Parameters
-
[out] output Output DataBuffer the decompressed contents will be stored in.
- Returns
- Whether decompression was successful
◆ Lzma2Decompress()
| bool DataBuffer::Lzma2Decompress | ( | DataBuffer & | output | ) | const |
Decompress the contents of this buffer via LZMA2 compression.
Thread Safe: - No
- Parameters
-
[out] output Output DataBuffer the decompressed contents will be stored in.
- Returns
- Whether decompression was successful
◆ XzDecompress()
| bool DataBuffer::XzDecompress | ( | DataBuffer & | output | ) | const |
Decompress the contents of this buffer via XZ compression.
Thread Safe: - No
- Parameters
-
[out] output Output DataBuffer the decompressed contents will be stored in.
- Returns
- Whether decompression was successful