Skip to content

Commit 2e31fd2

Browse files
committed
Add a way to disable function analysis update and use it to supress analysis update during debugger launch
1 parent c6623fa commit 2e31fd2

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

binaryninjaapi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5038,6 +5038,9 @@ namespace BinaryNinja {
50385038
*/
50395039
void SetAnalysisHold(bool enable);
50405040

5041+
bool GetFunctionAnalysisUpdateDisabled();
5042+
void SetFunctionAnalysisUpdateDisabled(bool disabled);
5043+
50415044
/*! start the analysis running and dont return till it is complete
50425045

50435046
Analysis of BinaryViews does not occur automatically, the user must start analysis by calling either

binaryninjacore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4253,6 +4253,8 @@ extern "C"
42534253
BINARYNINJACOREAPI void BNRemoveUserFunction(BNBinaryView* view, BNFunction* func);
42544254
BINARYNINJACOREAPI bool BNHasInitialAnalysis(BNBinaryView* view);
42554255
BINARYNINJACOREAPI void BNSetAnalysisHold(BNBinaryView* view, bool enable);
4256+
BINARYNINJACOREAPI bool BNGetFunctionAnalysisUpdateDisabled(BNBinaryView* view);
4257+
BINARYNINJACOREAPI void BNSetFunctionAnalysisUpdateDisabled(BNBinaryView* view, bool disabled);
42564258
BINARYNINJACOREAPI void BNUpdateAnalysisAndWait(BNBinaryView* view);
42574259
BINARYNINJACOREAPI void BNUpdateAnalysis(BNBinaryView* view);
42584260
BINARYNINJACOREAPI void BNAbortAnalysis(BNBinaryView* view);

binaryview.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,6 +2010,18 @@ void BinaryView::SetAnalysisHold(bool enable)
20102010
}
20112011

20122012

2013+
bool BinaryView::GetFunctionAnalysisUpdateDisabled()
2014+
{
2015+
return BNGetFunctionAnalysisUpdateDisabled(m_object);
2016+
}
2017+
2018+
2019+
void BinaryView::SetFunctionAnalysisUpdateDisabled(bool disabled)
2020+
{
2021+
BNSetFunctionAnalysisUpdateDisabled(m_object, disabled);
2022+
}
2023+
2024+
20132025
void BinaryView::UpdateAnalysisAndWait()
20142026
{
20152027
BNUpdateAnalysisAndWait(m_object);

python/binaryview.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,6 +4599,27 @@ def set_analysis_hold(self, enable: bool) -> None:
45994599
"""
46004600
core.BNSetAnalysisHold(self.handle, enable)
46014601

4602+
def get_function_analysis_update_disabled(self) -> bool:
4603+
"""
4604+
Returns True when functions are prevented from being marked as updates required, False otherwise.
4605+
:return:
4606+
"""
4607+
return core.BNGetFunctionAnalysisUpdateDisabled(self.handle)
4608+
4609+
def set_function_analysis_update_disabled(self, disabled: bool) -> None:
4610+
"""
4611+
``set_function_analysis_update_disabled`` prevents any function from being marked as updates required, so that
4612+
they would NOT be re-analyzed when the analysis is updated. The main difference between this API and
4613+
``set_analysis_hold`` is that ``set_analysis_hold`` only temporarily holds the analysis, and the functions
4614+
are still arranged to be updated when the hold is turned off. However, with
4615+
``set_function_analysis_update_disabled``, functions would not be put into the analysis queue at all.
4616+
4617+
Use with caution -- in most cases, this is NOT what you want, and you should use ``set_analysis_hold`` instead.
4618+
:param disabled:
4619+
:return:
4620+
"""
4621+
core.BNSetFunctionAnalysisUpdateDisabled(self.handle, disabled)
4622+
46024623
def update_analysis(self) -> None:
46034624
"""
46044625
``update_analysis`` asynchronously starts the analysis running and returns immediately.

0 commit comments

Comments
 (0)