From aa407ca14f6a99c5a953ff564461ec8dac1e0a84 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Mon, 31 Aug 2020 17:53:02 +0800 Subject: allow redefining an existing type --- binaryview.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'binaryview.cpp') diff --git a/binaryview.cpp b/binaryview.cpp index 102578b7..9374c9b8 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -2446,15 +2446,27 @@ uint64_t BinaryView::GetPreviousDataVariableStartBeforeAddress(uint64_t addr) } -bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& result, string& errors) +bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& result, string& errors, + const std::set& typesAllowRedefinition) { BNQualifiedNameAndType nt; char* errorStr; - if (!BNParseTypeString(m_object, text.c_str(), &nt, &errorStr)) + BNQualifiedNameList typesList; + typesList.count = typesAllowRedefinition.size(); + typesList.names = new BNQualifiedName[typesList.count]; + size_t i = 0; + for(auto& type : typesAllowRedefinition) + { + typesList.names[i] = type.GetAPIObject(); + i ++; + } + + if (!BNParseTypeString(m_object, text.c_str(), &nt, &errorStr, &typesList)) { errors = errorStr; BNFreeString(errorStr); + delete[] typesList.names; return false; } @@ -2462,12 +2474,14 @@ bool BinaryView::ParseTypeString(const string& text, QualifiedNameAndType& resul result.type = new Type(BNNewTypeReference(nt.type)); errors = ""; BNFreeQualifiedNameAndType(&nt); + delete[] typesList.names; return true; } bool BinaryView::ParseTypeString(const string& source, map>& types, - map>& variables, map>& functions, string& errors) + map>& variables, map>& functions, string& errors, + const std::set& typesAllowRedefinition) { BNTypeParserResult result; char* errorStr = nullptr; @@ -2476,7 +2490,17 @@ bool BinaryView::ParseTypeString(const string& source, map