Skip to content

Commit 5244be1

Browse files
committed
Add support for declarative downstream dependencies to workflow system.
1 parent c2a48b1 commit 5244be1

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

binaryninjacore.h

Lines changed: 8 additions & 7 deletions
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 126
40+
#define BN_CURRENT_CORE_ABI_VERSION 127
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
@@ -2731,12 +2731,13 @@ extern "C"
27312731

27322732
typedef enum BNAnalysisState
27332733
{
2734-
InitialState,
2735-
HoldState,
2736-
IdleState,
2737-
DisassembleState,
2738-
AnalyzeState,
2739-
ExtendedAnalyzeState
2734+
InitialState, // Entry point before any analysis begins
2735+
HoldState, // Module-level analysis is deferred; On-demand function analysis is permitted
2736+
IdleState, // No active analysis; system is idle and ready
2737+
DiscoveryState, // Context gathering and auxiliary data preparation
2738+
DisassembleState, // Instruction decoding and control flow discovery
2739+
AnalyzeState, // Core semantic and structural analysis
2740+
ExtendedAnalyzeState // Supplemental analysis: sweeping, type resolution, and pattern matching
27402741
} BNAnalysisState;
27412742

27422743
typedef struct BNActiveAnalysisInfo

plugins/efi_resolver/src/Plugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ extern "C"
7070
"eligibility": {
7171
"runOnce": true,
7272
"auto": {}
73+
},
74+
"dependencies": {
75+
"downstream": ["core.module.update"]
7376
}
7477
})~", &RunWorkflow);
7578

plugins/rtti/plugin.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,16 @@ extern "C" {
115115
"eligibility": {
116116
"runOnce": true,
117117
"auto": {}
118+
},
119+
"dependencies": {
120+
"downstream": ["core.module.update"]
118121
}
119-
})~", &VFTAnalysis, {"core.module.update"});
122+
})~", &VFTAnalysis);
120123

121124
// Run rtti before debug info is applied.
122125
rttiMetaWorkflow->Insert("core.module.loadDebugInfo", "analysis.rtti.rttiAnalysis");
123126
// Run vft after functions have analyzed (so that the virtual functions have analyzed)
124-
rttiMetaWorkflow->Insert("core.module.deleteUnusedAutoFunctions", "analysis.rtti.vftAnalysis");
127+
rttiMetaWorkflow->InsertAfter("core.module.extendedAnalysis", "analysis.rtti.vftAnalysis");
125128
Workflow::RegisterWorkflow(rttiMetaWorkflow);
126129

127130
return true;

plugins/warp/src/plugin/workflow.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ const MATCHER_ACTIVITY_CONFIG: &str = r#"{
4040
"eligibility": {
4141
"auto": {},
4242
"runOnce": true
43+
},
44+
"dependencies": {
45+
"downstream": ["core.module.update"]
4346
}
4447
}"#;
4548

@@ -288,10 +291,10 @@ pub fn insert_workflow() {
288291
let matcher_activity = Activity::new_with_action(MATCHER_ACTIVITY_CONFIG, matcher_activity);
289292
// Matcher activity must have core.module.update as subactivity otherwise analysis will sometimes never retrigger.
290293
module_meta_workflow
291-
.register_activity_with_subactivities(&matcher_activity, vec!["core.module.update"])
294+
.register_activity(&matcher_activity)
292295
.unwrap();
293296
module_meta_workflow.insert(
294-
"core.module.deleteUnusedAutoFunctions",
297+
"core.module.finishUpdate",
295298
[MATCHER_ACTIVITY_NAME],
296299
);
297300
module_meta_workflow.register().unwrap();

python/binaryview.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@ def __str__(self):
656656
return "Hold"
657657
if self.state == AnalysisState.IdleState:
658658
return "Idle"
659+
if self.state == AnalysisState.DiscoveryState:
660+
return "Discovery"
659661
if self.state == AnalysisState.DisassembleState:
660662
return "Disassembling (%d/%d)" % (self.count, self.total)
661663
if self.state == AnalysisState.AnalyzeState:

0 commit comments

Comments
 (0)