From 584e4d244a9124f6ec403162994434ff085e9c5d Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 19 Feb 2015 01:32:45 -0500 Subject: Add APIs for accessing function information --- function.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 function.cpp (limited to 'function.cpp') diff --git a/function.cpp b/function.cpp new file mode 100644 index 00000000..db99b97d --- /dev/null +++ b/function.cpp @@ -0,0 +1,41 @@ +#include "binaryninjaapi.h" + +using namespace BinaryNinja; +using namespace std; + + +Function::Function(BNFunction* func): m_func(func) +{ +} + + +Function::~Function() +{ + BNFreeFunction(m_func); +} + + +Ref Function::GetArchitecture() const +{ + return new CoreArchitecture(BNGetFunctionArchitecture(m_func)); +} + + +uint64_t Function::GetStart() const +{ + return BNGetFunctionStart(m_func); +} + + +vector> Function::GetBasicBlocks() const +{ + size_t count; + BNBasicBlock** blocks = BNGetFunctionBasicBlockList(m_func, &count); + + vector> result; + for (size_t i = 0; i < count; i++) + result.push_back(new BasicBlock(BNNewBasicBlockReference(blocks[i]))); + + BNFreeBasicBlockList(blocks, count); + return result; +} -- cgit v1.3.1