diff options
| author | Rusty Wagner <rusty@vector35.com> | 2016-07-27 02:51:23 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2016-07-27 03:31:06 -0400 |
| commit | 9a40763268a7859288875e1ab59a7cf7592529f6 (patch) | |
| tree | c49016ef209ea9f33097e37631e7d9501b71edd2 /binaryview.cpp | |
| parent | db64a9d125fee897a461fc2dcc26c5f680afa390 (diff) | |
Add APIs to add user types
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
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<string, Ref<Type>> BinaryView::GetTypes() +{ + size_t count; + BNNameAndType* types = BNGetAnalysisTypeList(m_object, &count); + + map<string, Ref<Type>> 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<Type> 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())) { } |
