summaryrefslogtreecommitdiff
path: root/function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'function.cpp')
-rw-r--r--function.cpp27
1 files changed, 19 insertions, 8 deletions
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<Type> 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<Type> 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> type = GetView()->GetTypeById(apiTypeStr);
+ return type;
}
-void Function::SetIntegerConstantDisplayTypeEnumType(
- Architecture* arch, uint64_t instrAddr, uint64_t value, size_t operand, Ref<Type> type)
+std::pair<BNIntegerDisplayType, Ref<Type>> 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> type = GetView()->GetTypeById(apiTypeStr);
+ return {displayType, type};
}