@@ -19,7 +19,6 @@ use warp::r#type::class::function::{Location, RegisterLocation, StackLocation};
1919use warp:: signature:: function:: { Function , FunctionGUID } ;
2020use warp:: target:: Target ;
2121
22- pub const APPLY_ACTIVITY_NAME : & str = "analysis.warp.apply" ;
2322const APPLY_ACTIVITY_CONFIG : & str = r#"{
2423 "name": "analysis.warp.apply",
2524 "title" : "WARP Apply Matched",
@@ -30,7 +29,6 @@ const APPLY_ACTIVITY_CONFIG: &str = r#"{
3029 }
3130}"# ;
3231
33- pub const MATCHER_ACTIVITY_NAME : & str = "analysis.warp.matcher" ;
3432const MATCHER_ACTIVITY_CONFIG : & str = r#"{
3533 "name": "analysis.warp.matcher",
3634 "title" : "WARP Matcher",
@@ -189,7 +187,7 @@ pub fn run_matcher(view: &BinaryView) {
189187 view. update_analysis ( ) ;
190188}
191189
192- pub fn insert_workflow ( ) {
190+ pub fn insert_workflow ( ) -> Result < ( ) , ( ) > {
193191 // TODO: Note: because of symbol persistence function symbol is applied in `insert_cached_function_match`.
194192 // TODO: Comments are also applied there, they are "user" like, persisted and make undo actions.
195193 // "Hey look, it's a plier" ~ Josh 2025
@@ -262,26 +260,29 @@ pub fn insert_workflow() {
262260 let guid_activity = Activity :: new_with_action ( GUID_ACTIVITY_CONFIG , guid_activity) ;
263261 let apply_activity = Activity :: new_with_action ( APPLY_ACTIVITY_CONFIG , apply_activity) ;
264262
265- 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 ( ) ;
263+ let add_function_activities = |workflow : Option < Ref < Workflow > > | -> Result < ( ) , ( ) > {
264+ let Some ( workflow) = workflow else {
265+ return Ok ( ( ) ) ;
266+ } ;
267+
268+ workflow
269+ . clone_to ( & workflow. name ( ) )
270+ . activity_after ( & guid_activity, "core.function.runFunctionRecognizers" ) ?
271+ . activity_after ( & apply_activity, "core.function.generateMediumLevelIL" ) ?
272+ . register ( ) ?;
273+ Ok ( ( ) )
272274 } ;
273275
274- add_function_activities ( & Workflow :: instance ( "core.function.metaAnalysis" ) ) ;
276+ add_function_activities ( Workflow :: get ( "core.function.metaAnalysis" ) ) ? ;
275277 // TODO: Remove this once the objectivec workflow is registered on the meta workflow.
276- add_function_activities ( & Workflow :: instance ( "core.function.objectiveC" ) ) ;
278+ add_function_activities ( Workflow :: get ( "core.function.objectiveC" ) ) ? ;
277279
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) ;
281280 // Matcher activity must have core.module.update as subactivity otherwise analysis will sometimes never retrigger.
282- module_meta_workflow
283- . register_activity ( & matcher_activity)
284- . unwrap ( ) ;
285- module_meta_workflow. insert ( "core.module.finishUpdate" , [ MATCHER_ACTIVITY_NAME ] ) ;
286- module_meta_workflow. register ( ) . unwrap ( ) ;
281+ let matcher_activity = Activity :: new_with_action ( MATCHER_ACTIVITY_CONFIG , matcher_activity) ;
282+ Workflow :: cloned ( "core.module.metaAnalysis" )
283+ . ok_or ( ( ) ) ?
284+ . activity_before ( & matcher_activity, "core.module.finishUpdate" ) ?
285+ . register ( ) ?;
286+
287+ Ok ( ( ) )
287288}
0 commit comments