@@ -108,8 +108,21 @@ pub fn run_matcher(view: &BinaryView) {
108108 if functions_by_target_and_guid. is_empty ( ) && !view. functions ( ) . is_empty ( ) {
109109 // The user is likely trying to run the matcher on a database before guids were automatically
110110 // generated, we should alert them and ask if they would like to reanalyze.
111- // TODO: Call reanalyze for them?
112- log:: error!( "Trying to match with an older database, please reanalyze the database." ) ;
111+ // NOTE: We only alert if we actually have the GUID activity enabled.
112+ if let Some ( sample_function) = view. functions ( ) . iter ( ) . next ( ) {
113+ let function_workflow = sample_function
114+ . workflow ( )
115+ . expect ( "Function has no workflow" ) ;
116+ if function_workflow. contains ( GUID_ACTIVITY_NAME ) {
117+ log:: error!( "No function guids in database, please reanalyze the database." ) ;
118+ } else {
119+ log:: error!(
120+ "Activity '{}' is not in workflow '{}', create function guids manually to run matcher..." ,
121+ GUID_ACTIVITY_NAME ,
122+ function_workflow. name( )
123+ )
124+ }
125+ }
113126 background_task. finish ( ) ;
114127 return ;
115128 }
@@ -245,22 +258,21 @@ pub fn insert_workflow() {
245258 }
246259 } ;
247260
248- let old_function_meta_workflow = Workflow :: instance ( "core.function.metaAnalysis" ) ;
249- let function_meta_workflow = old_function_meta_workflow. clone_to ( "core.function.metaAnalysis" ) ;
250261 let guid_activity = Activity :: new_with_action ( GUID_ACTIVITY_CONFIG , guid_activity) ;
251262 let apply_activity = Activity :: new_with_action ( APPLY_ACTIVITY_CONFIG , apply_activity) ;
252- function_meta_workflow
253- . register_activity ( & guid_activity)
254- . unwrap ( ) ;
255- // Because we are going to impact analysis with application we must make sure the function update is triggered to continue to update analysis.
256- function_meta_workflow
257- . register_activity ( & apply_activity)
258- . unwrap ( ) ;
259- function_meta_workflow
260- . insert_after ( "core.function.runFunctionRecognizers" , [ GUID_ACTIVITY_NAME ] ) ;
261- function_meta_workflow
262- . insert_after ( "core.function.generateMediumLevelIL" , [ APPLY_ACTIVITY_NAME ] ) ;
263- function_meta_workflow. register ( ) . unwrap ( ) ;
263+
264+ let add_function_activities = |workflow : & Workflow | {
265+ let new_workflow = workflow. clone_to ( & workflow. name ( ) ) ;
266+ new_workflow. register_activity ( & guid_activity) . unwrap ( ) ;
267+ new_workflow. register_activity ( & apply_activity) . unwrap ( ) ;
268+ new_workflow. insert_after ( "core.function.runFunctionRecognizers" , [ GUID_ACTIVITY_NAME ] ) ;
269+ new_workflow. insert_after ( "core.function.generateMediumLevelIL" , [ APPLY_ACTIVITY_NAME ] ) ;
270+ new_workflow. register ( ) . unwrap ( ) ;
271+ } ;
272+
273+ add_function_activities ( & Workflow :: instance ( "core.function.metaAnalysis" ) ) ;
274+ // TODO: Remove this once the objectivec workflow is registered on the meta workflow.
275+ add_function_activities ( & Workflow :: instance ( "core.function.objectiveC" ) ) ;
264276
265277 let old_module_meta_workflow = Workflow :: instance ( "core.module.metaAnalysis" ) ;
266278 let module_meta_workflow = old_module_meta_workflow. clone_to ( "core.module.metaAnalysis" ) ;
0 commit comments