diff options
| -rw-r--r-- | binaryninjaapi.h | 45 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | database.cpp | 11 |
3 files changed, 35 insertions, 22 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 8a592ae2..a06d4bf7 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1553,37 +1553,37 @@ namespace BinaryNinja { BNDataBuffer* GetBufferObject() const { return m_buffer; } /*! Get the raw pointer to the data contained within this buffer - + @threadunsafe */ void* GetData(); /*! Get the raw pointer to the data contained within this buffer, as a const pointer. - + @threadunsafe */ const void* GetData() const; /*! Get the raw pointer to the data contained within this buffer, starting at a given offset - + @threadunsafe */ void* GetDataAt(size_t offset); /*! Get the const raw pointer to the data contained within this buffer, starting at a given offset - + @threadunsafe */ const void* GetDataAt(size_t offset) const; /*! Get the length of the data contained within this buffer - + @threadunsafe */ size_t GetLength() const; /*! Set the size of the data pointed to by this buffer - + @threadunsafe */ void SetSize(size_t len); @@ -1591,15 +1591,15 @@ namespace BinaryNinja { /*! Clear the data contained by this buffer. \note This will call \c free() on this buffer's data pointer. You shouldn't call it yourself, typically ever. - + @threadunsafe */ void Clear(); - + /*! Append \c len contents of the pointer \c data to the end of the buffer \note This will typically call \c realloc() on this buffer's data pointer. You should hold this DataBuffer and use it for accesses, instead of storing the raw pointer. - + @threadunsafe */ void Append(const void* data, size_t len); @@ -1607,22 +1607,22 @@ namespace BinaryNinja { /*! Append the contents of databuffer \c buf to the current DataBuffer \note This will typically call \c realloc() on this buffer's data pointer. You should hold this DataBuffer and use it for accesses, instead of storing the raw pointer. - + @threadunsafe */ void Append(const DataBuffer& buf); - /*! Append a single byte + /*! Append a single byte \note This will typically call \c realloc() on this buffer's data pointer. You should hold this DataBuffer and use it for accesses, instead of storing the raw pointer. - + @threadunsafe */ void AppendByte(uint8_t val); /*! Get the contents of a given slice of data, as a DataBuffer - + @threadunsafe */ DataBuffer GetSlice(size_t start, size_t len); @@ -1636,7 +1636,7 @@ namespace BinaryNinja { /*! Convert the contents of the DataBuffer to a string \param nullTerminates Whether the decoder should stop and return the string after encountering a null (\x00) byte. - + @threadunsafe */ std::string ToEscapedString(bool nullTerminates = false) const; @@ -1648,12 +1648,12 @@ namespace BinaryNinja { */ static DataBuffer FromEscapedString(const std::string& src); - /*! Convert the contents of this DataBuffer to a base64 representation - + /*! Convert the contents of this DataBuffer to a base64 representation + @threadunsafe */ std::string ToBase64() const; - + /*! Create a DataBuffer from a given base64 string. \param src Input base64 string @@ -1669,7 +1669,7 @@ namespace BinaryNinja { \returns Whether compression was successful */ bool ZlibCompress(DataBuffer& output) const; - + /*! Decompress the contents of this buffer via ZLIB compression @threadunsafe @@ -1869,6 +1869,7 @@ namespace BinaryNinja { bool HasValue(const std::string& name) const; Json::Value GetValue(const std::string& name) const; + DataBuffer GetValueHash(const std::string& name) const; DataBuffer GetBuffer(const std::string& name) const; void SetValue(const std::string& name, const Json::Value& value); void SetBuffer(const std::string& name, const DataBuffer& value); @@ -14788,7 +14789,7 @@ namespace BinaryNinja { For array data only @threadunsafewith{Array data modifiers} - + \param index Index of the item to retrieve \return Item at that index, if valid. */ @@ -14799,7 +14800,7 @@ namespace BinaryNinja { For array data only @threadunsafewith{Array data modifiers} - + \param data Data to append \return Whether the append was successful */ @@ -14810,7 +14811,7 @@ namespace BinaryNinja { For array data only @threadunsafewith{Array data modifiers} - + \param index Index of the item to remove */ void RemoveIndex(size_t index); @@ -14820,7 +14821,7 @@ namespace BinaryNinja { For array data only @threadunsafewith{Array data modifiers} - + \return Size of the array */ size_t Size() const; diff --git a/binaryninjacore.h b/binaryninjacore.h index e1602b9b..485d7860 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3198,6 +3198,7 @@ extern "C" BINARYNINJACOREAPI char** BNGetKeyValueStoreKeys(BNKeyValueStore* store, size_t* count); BINARYNINJACOREAPI bool BNKeyValueStoreHasValue(BNKeyValueStore* store, const char* name); BINARYNINJACOREAPI char* BNGetKeyValueStoreValue(BNKeyValueStore* store, const char* name); + BINARYNINJACOREAPI BNDataBuffer* BNGetKeyValueStoreValueHash(BNKeyValueStore* store, const char* name); BINARYNINJACOREAPI BNDataBuffer* BNGetKeyValueStoreBuffer(BNKeyValueStore* store, const char* name); BINARYNINJACOREAPI bool BNSetKeyValueStoreValue(BNKeyValueStore* store, const char* name, const char* value); BINARYNINJACOREAPI bool BNSetKeyValueStoreBuffer( diff --git a/database.cpp b/database.cpp index dd258967..33f22714 100644 --- a/database.cpp +++ b/database.cpp @@ -86,6 +86,17 @@ Json::Value KeyValueStore::GetValue(const std::string& name) const } +DataBuffer KeyValueStore::GetValueHash(const std::string& name) const +{ + BNDataBuffer* buffer = BNGetKeyValueStoreValueHash(m_object, name.c_str()); + if (buffer == nullptr) + { + throw DatabaseException("Unknown key"); + } + return DataBuffer(buffer); +} + + DataBuffer KeyValueStore::GetBuffer(const std::string& name) const { BNDataBuffer* buffer = BNGetKeyValueStoreBuffer(m_object, name.c_str()); |
