@@ -11,6 +11,7 @@ use binaryninja::background_task::BackgroundTask;
1111use binaryninja:: binary_view:: { BinaryView , BinaryViewExt } ;
1212use binaryninja:: command:: Command ;
1313use binaryninja:: settings:: { QueryOptions , Settings } ;
14+ use binaryninja:: workflow:: activity:: { Config , Eligibility } ;
1415use binaryninja:: workflow:: { Activity , AnalysisContext , Workflow } ;
1516use itertools:: Itertools ;
1617use std:: collections:: HashMap ;
@@ -19,41 +20,7 @@ use warp::r#type::class::function::{Location, RegisterLocation, StackLocation};
1920use warp:: signature:: function:: { Function , FunctionGUID } ;
2021use warp:: target:: Target ;
2122
22- pub const APPLY_ACTIVITY_NAME : & str = "analysis.warp.apply" ;
23- const APPLY_ACTIVITY_CONFIG : & str = r#"{
24- "name": "analysis.warp.apply",
25- "title" : "WARP Apply Matched",
26- "description": "This analysis step applies WARP info to matched functions...",
27- "eligibility": {
28- "auto": {},
29- "runOnce": false
30- }
31- }"# ;
32-
33- pub const MATCHER_ACTIVITY_NAME : & str = "analysis.warp.matcher" ;
34- const MATCHER_ACTIVITY_CONFIG : & str = r#"{
35- "name": "analysis.warp.matcher",
36- "title" : "WARP Matcher",
37- "description": "This analysis step attempts to find matching WARP functions after the initial analysis is complete...",
38- "eligibility": {
39- "auto": {},
40- "runOnce": true
41- },
42- "dependencies": {
43- "downstream": ["core.module.update"]
44- }
45- }"# ;
46-
4723pub const GUID_ACTIVITY_NAME : & str = "analysis.warp.guid" ;
48- const GUID_ACTIVITY_CONFIG : & str = r#"{
49- "name": "analysis.warp.guid",
50- "title" : "WARP GUID Generator",
51- "description": "This analysis step generates the GUID for all analyzed functions...",
52- "eligibility": {
53- "auto": {},
54- "runOnce": false
55- }
56- }"# ;
5724
5825pub struct RunMatcher ;
5926
@@ -259,29 +226,47 @@ pub fn insert_workflow() {
259226 }
260227 } ;
261228
262- let guid_activity = Activity :: new_with_action ( GUID_ACTIVITY_CONFIG , guid_activity) ;
263- let apply_activity = Activity :: new_with_action ( APPLY_ACTIVITY_CONFIG , apply_activity) ;
229+ let guid_config = Config :: action (
230+ GUID_ACTIVITY_NAME ,
231+ "WARP GUID Generator" ,
232+ "This analysis step generates the GUID for all analyzed functions..." ,
233+ )
234+ . eligibility ( Eligibility :: auto ( ) . run_once ( false ) ) ;
235+ let guid_activity = Activity :: new_with_action ( & guid_config, guid_activity) ;
236+
237+ let apply_config = Config :: action (
238+ "analysis.warp.apply" ,
239+ "WARP Apply Matched" ,
240+ "This analysis step applies WARP info to matched functions..." ,
241+ )
242+ . eligibility ( Eligibility :: auto ( ) . run_once ( false ) ) ;
243+ let apply_activity = Activity :: new_with_action ( & apply_config, apply_activity) ;
264244
265245 let add_function_activities = |workflow : & Workflow | {
266- let new_workflow = workflow. clone_to ( & workflow. name ( ) ) ;
267- new_workflow. register_activity ( & guid_activity) . unwrap ( ) ;
268- new_workflow. register_activity ( & apply_activity) . unwrap ( ) ;
269- new_workflow. insert_after ( "core.function.runFunctionRecognizers" , [ GUID_ACTIVITY_NAME ] ) ;
270- new_workflow. insert_after ( "core.function.generateMediumLevelIL" , [ APPLY_ACTIVITY_NAME ] ) ;
271- new_workflow. register ( ) . unwrap ( ) ;
246+ workflow. register_activity ( & guid_activity) . unwrap ( ) ;
247+ workflow. register_activity ( & apply_activity) . unwrap ( ) ;
248+ workflow. insert_after ( "core.function.runFunctionRecognizers" , [ & guid_config. name ] ) ;
249+ workflow. insert_after ( "core.function.generateMediumLevelIL" , [ & apply_config. name ] ) ;
250+ workflow. register ( ) . unwrap ( ) ;
272251 } ;
273252
274- add_function_activities ( & Workflow :: instance ( "core.function.metaAnalysis" ) ) ;
253+ add_function_activities ( & Workflow :: cloned ( "core.function.metaAnalysis" ) ) ;
275254 // TODO: Remove this once the objectivec workflow is registered on the meta workflow.
276- add_function_activities ( & Workflow :: instance ( "core.function.objectiveC" ) ) ;
255+ add_function_activities ( & Workflow :: cloned ( "core.function.objectiveC" ) ) ;
277256
278- let old_module_meta_workflow = Workflow :: instance ( "core.module.metaAnalysis" ) ;
279- let module_meta_workflow = old_module_meta_workflow. clone_to ( "core.module.metaAnalysis" ) ;
280- let matcher_activity = Activity :: new_with_action ( MATCHER_ACTIVITY_CONFIG , matcher_activity) ;
257+ let module_meta_workflow = Workflow :: cloned ( "core.module.metaAnalysis" ) ;
258+ let matcher_config = Config :: action (
259+ "analysis.warp.matcher" ,
260+ "WARP Matcher" ,
261+ "This analysis step attempts to find matching WARP functions after the initial analysis is complete..." ,
262+ )
263+ . eligibility ( Eligibility :: auto ( ) . run_once ( true ) )
264+ . downstream_dependencies ( [ "core.module.update" ] ) ;
265+ let matcher_activity = Activity :: new_with_action ( & matcher_config, matcher_activity) ;
281266 // Matcher activity must have core.module.update as subactivity otherwise analysis will sometimes never retrigger.
282267 module_meta_workflow
283268 . register_activity ( & matcher_activity)
284269 . unwrap ( ) ;
285- module_meta_workflow. insert ( "core.module.finishUpdate" , [ MATCHER_ACTIVITY_NAME ] ) ;
270+ module_meta_workflow. insert ( "core.module.finishUpdate" , [ & matcher_config . name ] ) ;
286271 module_meta_workflow. register ( ) . unwrap ( ) ;
287272}
0 commit comments