Skip to content

Commit 21a8896

Browse files
committed
Add Function::Analyze API to perform on-demand function analysis.
1 parent 67ae186 commit 21a8896

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

binaryninjaapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11299,6 +11299,7 @@ namespace BinaryNinja {
1129911299
Ref<Tag> CreateAutoFunctionTag(Ref<TagType> tagType, const std::string& data, bool unique = false);
1130011300
Ref<Tag> CreateUserFunctionTag(Ref<TagType> tagType, const std::string& data, bool unique = false);
1130111301

11302+
void Analyze();
1130211303
void Reanalyze(BNFunctionUpdateType type = UserFunctionUpdate);
1130311304
void MarkUpdatesRequired(BNFunctionUpdateType type = UserFunctionUpdate);
1130411305
void MarkCallerUpdatesRequired(BNFunctionUpdateType type = UserFunctionUpdate);

binaryninjacore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Current ABI version for linking to the core. This is incremented any time
3838
// there are changes to the API that affect linking, including new functions,
3939
// new types, or modifications to existing functions or types.
40-
#define BN_CURRENT_CORE_ABI_VERSION 103
40+
#define BN_CURRENT_CORE_ABI_VERSION 104
4141

4242
// Minimum ABI version that is supported for loading of plugins. Plugins that
4343
// are linked to an ABI version less than this will not be able to load and
@@ -5252,6 +5252,7 @@ extern "C"
52525252
BINARYNINJACOREAPI bool BNLookupImportedTypePlatform(BNBinaryView* view, const BNQualifiedName* typeName, BNPlatform** platform, BNQualifiedName* resultName);
52535253

52545254
BINARYNINJACOREAPI void BNReanalyzeAllFunctions(BNBinaryView* view);
5255+
BINARYNINJACOREAPI void BNAnalyzeFunction(BNFunction* func);
52555256
BINARYNINJACOREAPI void BNReanalyzeFunction(BNFunction* func, BNFunctionUpdateType type);
52565257
BINARYNINJACOREAPI void BNMarkUpdatesRequired(BNFunction* func, BNFunctionUpdateType type);
52575258
BINARYNINJACOREAPI void BNMarkCallerUpdatesRequired(BNFunction* func, BNFunctionUpdateType type);

function.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,12 @@ Confidence<RegisterValue> Function::GetRegisterValueAtExit(uint32_t reg) const
24882488
}
24892489

24902490

2491+
void Function::Analyze()
2492+
{
2493+
BNAnalyzeFunction(m_object);
2494+
}
2495+
2496+
24912497
void Function::Reanalyze(BNFunctionUpdateType type)
24922498
{
24932499
BNReanalyzeFunction(m_object, type);

python/function.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,14 @@ def get_int_display_type_and_typeid(self, instr_addr: int, value: int, operand:
24542454
type_id = core.BNGetIntegerConstantDisplayTypeEnumerationType(self.handle, arch.handle, instr_addr, value, operand)
24552455
return display_type, type_id
24562456

2457+
def analyze(self) -> None:
2458+
"""
2459+
``analyze`` causes this function to be analyzed if it's out of date. This function does not wait for the analysis to finish.
2460+
2461+
:rtype: None
2462+
"""
2463+
core.BNAnalyzeFunction(self.handle)
2464+
24572465
def reanalyze(self, update_type: FunctionUpdateType = FunctionUpdateType.UserFunctionUpdate) -> None:
24582466
"""
24592467
``reanalyze`` causes this function to be reanalyzed. This function does not wait for the analysis to finish.

rust/src/function.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,11 @@ impl Function {
21662166
unsafe { BNUnsplitVariable(self.handle, &raw_var) }
21672167
}
21682168

2169+
/// Causes this function to be analyzed if it's out of date. This function does not wait for the analysis to finish.
2170+
pub fn analyze(&self) {
2171+
unsafe { BNAnalyzeFunction(self.handle) }
2172+
}
2173+
21692174
/// Causes this function to be reanalyzed. This function does not wait for the analysis to finish.
21702175
///
21712176
/// * `update_type` - Desired update type

0 commit comments

Comments
 (0)