From 4baa6fc4add2b1d9ff32d8eba67621dfdb1cbfd4 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 28 Apr 2015 02:31:19 -0400 Subject: Implement renaming of functions with persistence and undo --- binaryninjaapi.h | 5 +++++ binaryview.cpp | 12 ++++++++++++ databuffer.cpp | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index ecacba34..ce5e95ae 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -155,6 +155,9 @@ namespace BinaryNinja bool LogToFile(BNLogLevel minimumLevel, const std::string& path, bool append = false); void CloseLogs(); + std::string EscapeString(const std::string& s); + std::string UnescapeString(const std::string& s); + class DataBuffer { BNDataBuffer* m_buffer; @@ -397,6 +400,8 @@ namespace BinaryNinja std::string GetFullName() const; std::string GetRawName() const; uint64_t GetAddress() const; + bool IsAutoDefined() const; + void SetAutoDefined(bool val); }; struct ReferenceSource diff --git a/binaryview.cpp b/binaryview.cpp index d5776bc7..173e3e06 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -130,6 +130,18 @@ uint64_t Symbol::GetAddress() const } +bool Symbol::IsAutoDefined() const +{ + return BNIsSymbolAutoDefined(m_sym); +} + + +void Symbol::SetAutoDefined(bool val) +{ + BNSetSymbolAutoDefined(m_sym, val); +} + + BinaryView::BinaryView(const std::string& typeName, FileMetadata* file) { BNCustomBinaryView view; diff --git a/databuffer.cpp b/databuffer.cpp index 4bcd930b..6a0748b4 100644 --- a/databuffer.cpp +++ b/databuffer.cpp @@ -134,3 +134,17 @@ DataBuffer DataBuffer::FromEscapedString(const string& src) { return DataBuffer(BNDecodeEscapedString(src.c_str())); } + + +string BinaryNinja::EscapeString(const string& s) +{ + DataBuffer buffer(s.c_str(), s.size()); + return buffer.ToEscapedString(); +} + + +string BinaryNinja::UnescapeString(const string& s) +{ + DataBuffer buffer = DataBuffer::FromEscapedString(s); + return string((const char*)buffer.GetData(), buffer.GetLength()); +} -- cgit v1.3.1