From 9bb1a15b800da0ac5b60c40e3b10321e4efc5a1b Mon Sep 17 00:00:00 2001 From: rollsafe Date: Tue, 30 Jul 2019 21:48:38 -0400 Subject: Cache function callee addresses and create an API to access them --- function.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'function.cpp') diff --git a/function.cpp b/function.cpp index 66fd870c..752d0bd1 100644 --- a/function.cpp +++ b/function.cpp @@ -246,6 +246,27 @@ void Function::SetCommentForAddress(uint64_t addr, const string& comment) } +vector Function::GetCallSites() const +{ + size_t count; + BNReferenceSource* refs = BNGetFunctionCallSites(m_object, &count); + + vector result; + result.reserve(count); + for (size_t i = 0; i < count; i++) + { + ReferenceSource src; + src.func = new Function(BNNewFunctionReference(refs[i].func)); + src.arch = new CoreArchitecture(refs[i].arch); + src.addr = refs[i].addr; + result.push_back(src); + } + + BNFreeCodeReferences(refs, count); + return result; +} + + void Function::AddUserCodeReference(Architecture* fromArch, uint64_t fromAddr, uint64_t toAddr) { BNAddUserCodeReference(m_object, fromArch->GetObject(), fromAddr, toAddr); -- cgit v1.3.1