diff options
| author | Mark Rowe <mark@vector35.com> | 2025-09-04 19:21:48 -0700 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2025-09-17 21:28:50 -0700 |
| commit | 4fccb2c8c9673247bfb9ba176021c9889ce680e8 (patch) | |
| tree | cd7900681d55ad235bddf3e05b8725abccf91fa1 /plugins/workflow_objc/src/workflow.rs | |
| parent | 5489c5b71773ac020f0c9dec134fe92310d4cb36 (diff) | |
[ObjC] Propagate type information from calls to `[super init]`
Calls to `objc_msgSendSuper2` with a selector in the `init` family are
detected and their arguments are analyzed to determine the receiver
class. A call type adjustment is added to update the return type.
This handles most calls to `[super init]` from Objective-C code as the
compiler generates a straightforward code sequence for these calls. Some
calls from Swift are handled, but the Swift compiler generates more varied
code so additional work is needed for complete coverage.
Diffstat (limited to 'plugins/workflow_objc/src/workflow.rs')
| -rw-r--r-- | plugins/workflow_objc/src/workflow.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/workflow_objc/src/workflow.rs b/plugins/workflow_objc/src/workflow.rs index 090a8e5e..f411951b 100644 --- a/plugins/workflow_objc/src/workflow.rs +++ b/plugins/workflow_objc/src/workflow.rs @@ -2,6 +2,14 @@ use binaryninja::workflow::{activity, Activity, AnalysisContext, Workflow}; use crate::{activities, error::WorkflowRegistrationError}; +/// Base confidence levels for types applied by each of the activities in this workflow. +/// These are ordered such that later activities can override types applied by earlier activities. +#[repr(u8)] +pub enum Confidence { + ObjCMsgSend = 96, + SuperInit = 100, +} + const WORKFLOW_INFO: &str = r#"{ "title": "Objective-C", "description": "Enhanced analysis for Objective-C code.", @@ -48,9 +56,23 @@ pub fn register_activities() -> Result<(), WorkflowRegistrationError> { run(activities::inline_stubs::process), ); + let super_init_activity = Activity::new_with_action( + activity::Config::action( + "core.function.objectiveC.types.superInit", + "Obj-C: Adjust return types of [super init…] calls", + "Adjust the return type of calls to objc_msgSendSuper2 where the selector is in the init family.", + ) + .eligibility( + activity::Eligibility::auto().predicate( + activity::ViewType::in_(["Mach-O", "DSCView"]), + )), + run(activities::super_init::process), + ); + workflow .activity_after(&inline_stubs_activity, "core.function.translateTailCalls")? .activity_after(&objc_msg_send_calls_activity, &inline_stubs_activity.name())? + .activity_after(&super_init_activity, "core.function.generateMediumLevelIL")? .register_with_config(WORKFLOW_INFO)?; Ok(()) |
