From ddce31c8d62c7ce0a385e5af65b0134c56e3b6c8 Mon Sep 17 00:00:00 2001 From: kat Date: Sat, 10 Feb 2024 14:59:50 -0500 Subject: Use TypeID for serializing enum types, replace set_int_enum_display_typeid with set_int_display_type, add get_int_display_type_and_typeid, bump ABI --- function.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'function.cpp') diff --git a/function.cpp b/function.cpp index 601df3aa..27a91952 100644 --- a/function.cpp +++ b/function.cpp @@ -1865,26 +1865,37 @@ BNIntegerDisplayType Function::GetIntegerConstantDisplayType( void Function::SetIntegerConstantDisplayType( - Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type) + Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, BNIntegerDisplayType type, Ref enumType) { - BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type); + if (enumType) + BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type, enumType->GetRegisteredName()->GetTypeId().c_str()); + else + BNSetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand, type, nullptr); } Ref Function::GetIntegerConstantDisplayTypeEnumType( Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand) { - BNType* apiType = BNGetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand); + char* apiType = BNGetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand); + std::string apiTypeStr = std::string(apiType); if (apiType) - return new Type(apiType); - return nullptr; + BNFreeString(apiType); + Ref type = GetView()->GetTypeById(apiTypeStr); + return type; } -void Function::SetIntegerConstantDisplayTypeEnumType( - Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, Ref type) +std::pair> Function::GetIntegerConstantDisplayTypeAndEnumType(Architecture* arch, + uint64_t instrAddr, uint64_t value, size_t operand) { - BNSetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand, type->m_object); + auto displayType = BNGetIntegerConstantDisplayType(m_object, arch->GetObject(), instrAddr, value, operand); + char* apiType = BNGetIntegerConstantDisplayTypeEnumerationType(m_object, arch->GetObject(), instrAddr, value, operand); + std::string apiTypeStr = std::string(apiType); + if (apiType) + BNFreeString(apiType); + Ref type = GetView()->GetTypeById(apiTypeStr); + return {displayType, type}; } -- cgit v1.3.1