summaryrefslogtreecommitdiff
path: root/basicblock.cpp
diff options
context:
space:
mode:
authorBrandon Miller <brandon@vector35.com>2025-04-25 13:30:45 -0400
committerRyan Snyder <ryan@vector35.com>2025-06-23 13:44:12 -0400
commitb079d1a1e19151f5c39de84c2e1e6cc6a91abc74 (patch)
tree8cf27224630b690fcfdfd490ee43ec1cd56fc9b6 /basicblock.cpp
parent76215b86ff629da58aa94d4cf4093d2e67017412 (diff)
Perform BB analysis from Architecture C++ API
This commit moves AnalyzeBasicBlocks from the binary ninja core to the API and allows architecture plugins to optionally override AnalyzeBasicBlocks for a custom implementation Supply ABB inputs in BNBasicBlockAnalysisContext Register default analyze basic blocks callback This allows the nanomips and rust core architecture plugins to work again while using the C++ API DefaultAnalyzeBasicBlocks Use default ABB from Python plugins Fix bug in API ArchAndAddr operator overload Python APIs for basic block analysis
Diffstat (limited to 'basicblock.cpp')
-rw-r--r--basicblock.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/basicblock.cpp b/basicblock.cpp
index 28ee393b..e178bd6e 100644
--- a/basicblock.cpp
+++ b/basicblock.cpp
@@ -317,6 +317,12 @@ uint64_t BasicBlock::GetStart() const
}
+void BasicBlock::SetEnd(uint64_t end)
+{
+ BNSetBasicBlockEnd(m_object, end);
+}
+
+
uint64_t BasicBlock::GetEnd() const
{
return BNGetBasicBlockEnd(m_object);
@@ -385,6 +391,81 @@ bool BasicBlock::HasUndeterminedOutgoingEdges() const
}
+bool BasicBlock::HasInvalidInstructions() const
+{
+ return BNBasicBlockHasInvalidInstructions(m_object);
+}
+
+
+void BasicBlock::SetHasInvalidInstructions(bool value)
+{
+ BNBasicBlockSetHasInvalidInstructions(m_object, value);
+}
+
+
+void BasicBlock::AddPendingOutgoingEdge(BNBranchType type, uint64_t addr, Ref<Architecture> arch, bool fallThrough)
+{
+ BNBasicBlockAddPendingOutgoingEdge(m_object, type, addr, arch ? arch->GetObject() : nullptr, fallThrough);
+}
+
+
+vector<PendingBasicBlockEdge> BasicBlock::GetPendingOutgoingEdges() const
+{
+ size_t count;
+ BNPendingBasicBlockEdge* edges = BNGetBasicBlockPendingOutgoingEdges(m_object, &count);
+ vector<PendingBasicBlockEdge> result;
+ result.reserve(count);
+ for (size_t i = 0; i < count; i++)
+ {
+ PendingBasicBlockEdge edge;
+ edge.type = edges[i].type;
+ edge.arch = edges[i].arch ? new CoreArchitecture(edges[i].arch) : nullptr;
+ edge.target = edges[i].target;
+ edge.fallThrough = edges[i].fallThrough;
+ result.push_back(edge);
+ }
+
+ BNFreePendingBasicBlockEdgeList(edges);
+ return result;
+}
+
+
+void BasicBlock::ClearPendingOutgoingEdges()
+{
+ BNClearBasicBlockPendingOutgoingEdges(m_object);
+}
+
+
+void BasicBlock::SetUndeterminedOutgoingEdges(bool value)
+{
+ BNBasicBlockSetUndeterminedOutgoingEdges(m_object, value);
+}
+
+
+const uint8_t* BasicBlock::GetInstructionData(uint64_t addr, size_t* len) const
+{
+ return BNBasicBlockGetInstructionData(m_object, addr, len);
+}
+
+
+void BasicBlock::AddInstructionData(const void* data, size_t len)
+{
+ BNBasicBlockAddInstructionData(m_object, data, len);
+}
+
+
+void BasicBlock::SetFallThroughToFunction(bool value)
+{
+ BNBasicBlockSetFallThroughToFunction(m_object, value);
+}
+
+
+bool BasicBlock::IsFallThroughToFunction() const
+{
+ return BNBasicBlockIsFallThroughToFunction(m_object);
+}
+
+
bool BasicBlock::CanExit() const
{
return BNBasicBlockCanExit(m_object);