From 9a40763268a7859288875e1ab59a7cf7592529f6 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Wed, 27 Jul 2016 02:51:23 -0400 Subject: Add APIs to add user types --- binaryview.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index ee5bda8e..de0870b6 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -1358,6 +1358,59 @@ bool BinaryView::ParseTypeString(const string& text, NameAndType& result, string } +map> BinaryView::GetTypes() +{ + size_t count; + BNNameAndType* types = BNGetAnalysisTypeList(m_object, &count); + + map> result; + for (size_t i = 0; i < count; i++) + result[types[i].name] = new Type(BNNewTypeReference(types[i].type)); + + BNFreeTypeList(types, count); + return result; +} + + +Ref BinaryView::GetTypeByName(const string& name) +{ + BNType* type = BNGetAnalysisTypeByName(m_object, name.c_str()); + if (!type) + return nullptr; + return new Type(type); +} + + +bool BinaryView::IsTypeAutoDefined(const std::string& name) +{ + return BNIsAnalysisTypeAutoDefined(m_object, name.c_str()); +} + + +void BinaryView::DefineType(const std::string& name, Type* type) +{ + BNDefineAnalysisType(m_object, name.c_str(), type->GetObject()); +} + + +void BinaryView::DefineUserType(const std::string& name, Type* type) +{ + BNDefineUserAnalysisType(m_object, name.c_str(), type->GetObject()); +} + + +void BinaryView::UndefineType(const std::string& name) +{ + BNUndefineAnalysisType(m_object, name.c_str()); +} + + +void BinaryView::UndefineUserType(const std::string& name) +{ + BNUndefineUserAnalysisType(m_object, name.c_str()); +} + + BinaryData::BinaryData(FileMetadata* file): BinaryView(BNCreateBinaryDataView(file->GetObject())) { } -- cgit v1.3.1