summaryrefslogtreecommitdiff
path: root/function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'function.cpp')
-rw-r--r--function.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/function.cpp b/function.cpp
index 976d73d2..550691d0 100644
--- a/function.cpp
+++ b/function.cpp
@@ -508,6 +508,25 @@ Confidence<bool> Function::HasVariableArguments() const
}
+Confidence<size_t> Function::GetStackAdjustment() const
+{
+ BNSizeWithConfidence sc = BNGetFunctionStackAdjustment(m_object);
+ return Confidence<size_t>(sc.value, sc.confidence);
+}
+
+
+Confidence<set<uint32_t>> Function::GetClobberedRegisters() const
+{
+ BNRegisterSetWithConfidence regs = BNGetFunctionClobberedRegisters(m_object);
+ set<uint32_t> regSet;
+ for (size_t i = 0; i < regs.count; i++)
+ regSet.insert(regs.regs[i]);
+ Confidence<set<uint32_t>> result(regSet, regs.confidence);
+ BNFreeClobberedRegisters(&regs);
+ return result;
+}
+
+
void Function::SetAutoType(Type* type)
{
BNSetFunctionAutoType(m_object, type->GetObject());
@@ -568,6 +587,29 @@ void Function::SetAutoCanReturn(const Confidence<bool>& returns)
}
+void Function::SetAutoStackAdjustment(const Confidence<size_t>& stackAdjust)
+{
+ BNSizeWithConfidence sc;
+ sc.value = stackAdjust.GetValue();
+ sc.confidence = stackAdjust.GetConfidence();
+ BNSetAutoFunctionStackAdjustment(m_object, &sc);
+}
+
+
+void Function::SetAutoClobberedRegisters(const Confidence<std::set<uint32_t>>& clobbered)
+{
+ BNRegisterSetWithConfidence regs;
+ regs.regs = new uint32_t[clobbered.GetValue().size()];
+ regs.count = clobbered.GetValue().size();
+ size_t i = 0;
+ for (auto reg : clobbered.GetValue())
+ regs.regs[i++] = reg;
+ regs.confidence = clobbered.GetConfidence();
+ BNSetAutoFunctionClobberedRegisters(m_object, &regs);
+ delete[] regs.regs;
+}
+
+
void Function::SetUserType(Type* type)
{
BNSetFunctionUserType(m_object, type->GetObject());
@@ -628,6 +670,29 @@ void Function::SetCanReturn(const Confidence<bool>& returns)
}
+void Function::SetStackAdjustment(const Confidence<size_t>& stackAdjust)
+{
+ BNSizeWithConfidence sc;
+ sc.value = stackAdjust.GetValue();
+ sc.confidence = stackAdjust.GetConfidence();
+ BNSetUserFunctionStackAdjustment(m_object, &sc);
+}
+
+
+void Function::SetClobberedRegisters(const Confidence<std::set<uint32_t>>& clobbered)
+{
+ BNRegisterSetWithConfidence regs;
+ regs.regs = new uint32_t[clobbered.GetValue().size()];
+ regs.count = clobbered.GetValue().size();
+ size_t i = 0;
+ for (auto reg : clobbered.GetValue())
+ regs.regs[i++] = reg;
+ regs.confidence = clobbered.GetConfidence();
+ BNSetUserFunctionClobberedRegisters(m_object, &regs);
+ delete[] regs.regs;
+}
+
+
void Function::ApplyImportedTypes(Symbol* sym)
{
BNApplyImportedTypes(m_object, sym->GetObject());
@@ -1014,6 +1079,20 @@ void Function::SetUserInstructionHighlight(Architecture* arch, uint64_t addr, ui
}
+Confidence<RegisterValue> Function::GetGlobalPointerValue() const
+{
+ BNRegisterValueWithConfidence value = BNGetFunctionGlobalPointerValue(m_object);
+ return Confidence<RegisterValue>(RegisterValue::FromAPIObject(value.value), value.confidence);
+}
+
+
+Confidence<RegisterValue> Function::GetRegisterValueAtExit(uint32_t reg) const
+{
+ BNRegisterValueWithConfidence value = BNGetFunctionRegisterValueAtExit(m_object, reg);
+ return Confidence<RegisterValue>(RegisterValue::FromAPIObject(value.value), value.confidence);
+}
+
+
void Function::Reanalyze()
{
BNReanalyzeFunction(m_object);