@@ -11,47 +11,15 @@ 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 , AnalysisContext , Workflow } ;
14+ use binaryninja:: workflow:: { activity , Activity , AnalysisContext , Workflow , WorkflowBuilder } ;
1515use itertools:: Itertools ;
1616use std:: collections:: HashMap ;
1717use std:: time:: Instant ;
1818use warp:: r#type:: class:: function:: { Location , RegisterLocation , StackLocation } ;
1919use warp:: signature:: function:: { Function , FunctionGUID } ;
2020use warp:: target:: Target ;
2121
22- const APPLY_ACTIVITY_CONFIG : & str = r#"{
23- "name": "analysis.warp.apply",
24- "title" : "WARP Apply Matched",
25- "description": "This analysis step applies WARP info to matched functions...",
26- "eligibility": {
27- "auto": {},
28- "runOnce": false
29- }
30- }"# ;
31-
32- const MATCHER_ACTIVITY_CONFIG : & str = r#"{
33- "name": "analysis.warp.matcher",
34- "title" : "WARP Matcher",
35- "description": "This analysis step attempts to find matching WARP functions after the initial analysis is complete...",
36- "eligibility": {
37- "auto": {},
38- "runOnce": true
39- },
40- "dependencies": {
41- "downstream": ["core.module.update"]
42- }
43- }"# ;
44-
4522pub const GUID_ACTIVITY_NAME : & str = "analysis.warp.guid" ;
46- const GUID_ACTIVITY_CONFIG : & str = r#"{
47- "name": "analysis.warp.guid",
48- "title" : "WARP GUID Generator",
49- "description": "This analysis step generates the GUID for all analyzed functions...",
50- "eligibility": {
51- "auto": {},
52- "runOnce": false
53- }
54- }"# ;
5523
5624pub struct RunMatcher ;
5725
@@ -257,28 +225,47 @@ pub fn insert_workflow() -> Result<(), ()> {
257225 }
258226 } ;
259227
260- let guid_activity = Activity :: new_with_action ( GUID_ACTIVITY_CONFIG , guid_activity) ;
261- let apply_activity = Activity :: new_with_action ( APPLY_ACTIVITY_CONFIG , apply_activity) ;
228+ let guid_config = activity:: Config :: action (
229+ GUID_ACTIVITY_NAME ,
230+ "WARP GUID Generator" ,
231+ "This analysis step generates the GUID for all analyzed functions..." ,
232+ )
233+ . eligibility ( activity:: Eligibility :: auto ( ) . run_once ( false ) ) ;
234+ let guid_activity = Activity :: new_with_action ( & guid_config, guid_activity) ;
235+
236+ let apply_config = activity:: Config :: action (
237+ "analysis.warp.apply" ,
238+ "WARP Apply Matched" ,
239+ "This analysis step applies WARP info to matched functions..." ,
240+ )
241+ . eligibility ( activity:: Eligibility :: auto ( ) . run_once ( false ) ) ;
242+ let apply_activity = Activity :: new_with_action ( & apply_config, apply_activity) ;
262243
263- let add_function_activities = |workflow : Option < Ref < Workflow > > | -> Result < ( ) , ( ) > {
244+ let add_function_activities = |workflow : Option < WorkflowBuilder > | -> Result < ( ) , ( ) > {
264245 let Some ( workflow) = workflow else {
265246 return Ok ( ( ) ) ;
266247 } ;
267248
268249 workflow
269- . clone_to ( & workflow. name ( ) )
270250 . activity_after ( & guid_activity, "core.function.runFunctionRecognizers" ) ?
271251 . activity_after ( & apply_activity, "core.function.generateMediumLevelIL" ) ?
272252 . register ( ) ?;
273253 Ok ( ( ) )
274254 } ;
275255
276- add_function_activities ( Workflow :: get ( "core.function.metaAnalysis" ) ) ?;
256+ add_function_activities ( Workflow :: cloned ( "core.function.metaAnalysis" ) ) ?;
277257 // TODO: Remove this once the objectivec workflow is registered on the meta workflow.
278- add_function_activities ( Workflow :: get ( "core.function.objectiveC" ) ) ?;
258+ add_function_activities ( Workflow :: cloned ( "core.function.objectiveC" ) ) ?;
279259
260+ let matcher_config = activity:: Config :: action (
261+ "analysis.warp.matcher" ,
262+ "WARP Matcher" ,
263+ "This analysis step attempts to find matching WARP functions after the initial analysis is complete..." ,
264+ )
265+ . eligibility ( activity:: Eligibility :: auto ( ) . run_once ( true ) )
280266 // Matcher activity must have core.module.update as subactivity otherwise analysis will sometimes never retrigger.
281- let matcher_activity = Activity :: new_with_action ( MATCHER_ACTIVITY_CONFIG , matcher_activity) ;
267+ . downstream_dependencies ( [ "core.module.update" ] ) ;
268+ let matcher_activity = Activity :: new_with_action ( & matcher_config, matcher_activity) ;
282269 Workflow :: cloned ( "core.module.metaAnalysis" )
283270 . ok_or ( ( ) ) ?
284271 . activity_before ( & matcher_activity, "core.module.finishUpdate" ) ?
0 commit comments