From d8e3001e535fad178c621ff07418f81f25123dc4 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 22 Aug 2024 12:55:49 -0600 Subject: Allow multiple high level representations for display, add Pseudo Rust and a Pseudo Python example plugin --- function.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'function.cpp') diff --git a/function.cpp b/function.cpp index 033a8453..33cb5e52 100644 --- a/function.cpp +++ b/function.cpp @@ -200,12 +200,12 @@ ConstantData::ConstantData(BNRegisterValueType _state, uint64_t _value, size_t _ } -DataBuffer ConstantData::ToDataBuffer() const +pair ConstantData::ToDataBuffer() const { if (func) return func->GetConstantData(state, value, size); - return DataBuffer(); + return make_pair(DataBuffer(), BuiltinNone); } @@ -612,9 +612,11 @@ void PossibleValueSet::FreeAPIObject(BNPossibleValueSet* value) } -DataBuffer Function::GetConstantData(BNRegisterValueType state, uint64_t value, size_t size) +pair Function::GetConstantData(BNRegisterValueType state, uint64_t value, size_t size) { - return DataBuffer(BNGetConstantData(m_object, state, value, size)); + BNBuiltinType builtin; + auto buffer = DataBuffer(BNGetConstantData(m_object, state, value, size, &builtin)); + return make_pair(buffer, builtin); } @@ -908,21 +910,22 @@ Ref Function::GetHighLevelILIfAvailable() const } -Ref Function::GetLanguageRepresentation() const +Ref Function::GetLanguageRepresentation(const string& language) const { - BNLanguageRepresentationFunction* function = BNGetFunctionLanguageRepresentation(m_object); + BNLanguageRepresentationFunction* function = BNGetFunctionLanguageRepresentation(m_object, language.c_str()); if (!function) return nullptr; - return new LanguageRepresentationFunction(function); + return new CoreLanguageRepresentationFunction(function); } -Ref Function::GetLanguageRepresentationIfAvailable() const +Ref Function::GetLanguageRepresentationIfAvailable(const string& language) const { - BNLanguageRepresentationFunction* function = BNGetFunctionLanguageRepresentationIfAvailable(m_object); + BNLanguageRepresentationFunction* function = + BNGetFunctionLanguageRepresentationIfAvailable(m_object, language.c_str()); if (!function) return nullptr; - return new LanguageRepresentationFunction(function); + return new CoreLanguageRepresentationFunction(function); } @@ -1275,9 +1278,9 @@ void Function::ApplyAutoDiscoveredType(Type* type) } -Ref Function::CreateFunctionGraph(BNFunctionGraphType type, DisassemblySettings* settings) +Ref Function::CreateFunctionGraph(const FunctionViewType& type, DisassemblySettings* settings) { - BNFlowGraph* graph = BNCreateFunctionGraph(m_object, type, settings ? settings->GetObject() : nullptr); + BNFlowGraph* graph = BNCreateFunctionGraph(m_object, type.ToAPIObject(), settings ? settings->GetObject() : nullptr); return new CoreFlowGraph(graph); } -- cgit v1.3.1