diff options
| author | Xusheng <xusheng@vector35.com> | 2020-08-31 17:53:02 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2020-09-03 21:14:41 +0800 |
| commit | aa407ca14f6a99c5a953ff564461ec8dac1e0a84 (patch) | |
| tree | 6c0e699b434893b1b8dc01702c114f348828c34d /binaryview.cpp | |
| parent | c1b11a0085c780ac3d5e3400a31ad939b376ede3 (diff) | |
allow redefining an existing type
Diffstat (limited to 'binaryview.cpp')
| -rw-r--r-- | binaryview.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
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<QualifiedName>& 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<QualifiedName, Ref<Type>>& types, - map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, string& errors) + map<QualifiedName, Ref<Type>>& variables, map<QualifiedName, Ref<Type>>& functions, string& errors, + const std::set<QualifiedName>& typesAllowRedefinition) { BNTypeParserResult result; char* errorStr = nullptr; @@ -2476,7 +2490,17 @@ bool BinaryView::ParseTypeString(const string& source, map<QualifiedName, Ref<Ty variables.clear(); functions.clear(); - bool ok = BNParseTypesString(m_object, source.c_str(), &result, &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 ++; + } + + bool ok = BNParseTypesString(m_object, source.c_str(), &result, &errorStr, typesList); if (errorStr) { errors = errorStr; |
