From 465a8d5d7afd5a5648338009e0fb8dbe4f199347 Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Thu, 11 Apr 2024 10:40:09 -0400 Subject: Querying candidate base address reasons Querying vector of reason information for a candidate base address using the new core API --- basedetection.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'basedetection.cpp') diff --git a/basedetection.cpp b/basedetection.cpp index 4389f1b7..e994ede5 100644 --- a/basedetection.cpp +++ b/basedetection.cpp @@ -21,7 +21,6 @@ #include "binaryninjaapi.h" using namespace BinaryNinja; -using namespace std; BaseAddressDetection::BaseAddressDetection(Ref bv) @@ -65,13 +64,29 @@ bool BaseAddressDetection::IsAborted() } -std::set> BaseAddressDetection::GetScores(BaseAddressDetectionConfidence* confidence) +std::set> BaseAddressDetection::GetScores(BNBaseAddressDetectionConfidence* confidence, + uint64_t *lastTestedBaseAddress) { std::set> result; BNBaseAddressDetectionScore scores[10]; - size_t numCandidates = BNGetBaseAddressDetectionScores(m_object, scores, 10, - (BNBaseAddressDetectionConfidence *)confidence); + size_t numCandidates = BNGetBaseAddressDetectionScores(m_object, scores, 10, confidence, lastTestedBaseAddress); for (size_t i = 0; i < numCandidates; i++) result.insert(std::make_pair(scores[i].Score, scores[i].BaseAddress)); return result; } + + +std::vector BaseAddressDetection::GetReasonsForBaseAddress(uint64_t baseAddress) +{ + std::vector result; + size_t count; + BNBaseAddressDetectionReason *reasons = BNGetBaseAddressDetectionReasons(m_object, baseAddress, &count); + if (!reasons) + return result; + + for (size_t i = 0; i < count; i++) + result.push_back(reasons[i]); + + free(reasons); + return result; +} -- cgit v1.3.1