summaryrefslogtreecommitdiff
path: root/plugins/workflow_objc/src/lib.rs
blob: 8c859c6bd9d3366a19c22a0dee7d5f356d52e6c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use binaryninja::{add_optional_plugin_dependency, logger::Logger, settings::Settings};

mod activities;
mod error;
mod metadata;
mod workflow;

pub use error::Error;
use metadata::GlobalState;

use log::LevelFilter;

fn plugin_init() -> bool {
    Logger::new("Plugin.Objective-C")
        .with_level(LevelFilter::Debug)
        .init();

    if workflow::register_activities().is_err() {
        log::warn!("Failed to register Objective-C workflow");
        return false;
    };

    let settings = Settings::new();
    settings.register_setting_json(
        "analysis.objectiveC.resolveDynamicDispatch",
        r#"{
        "title" : "Resolve Dynamic Dispatch Calls",
        "type" : "boolean",
        "default" : false,
        "aliases": ["core.function.objectiveC.assumeMessageSendTarget", "core.function.objectiveC.rewriteMessageSendTarget"],
        "description" : "Replaces objc_msgSend calls with direct calls to the first found implementation when the target method is visible. May produce false positives when multiple classes implement the same selector or when selectors conflict with system framework methods."
        }"#,
    );

    GlobalState::register_cleanup();

    true
}

#[no_mangle]
#[allow(non_snake_case)]
#[cfg(not(feature = "demo"))]
pub extern "C" fn CorePluginDependencies() {
    add_optional_plugin_dependency("arch_x86");
    add_optional_plugin_dependency("arch_armv7");
    add_optional_plugin_dependency("arch_arm64");
}

#[no_mangle]
#[allow(non_snake_case)]
#[cfg(not(feature = "demo"))]
pub extern "C" fn CorePluginInit() -> bool {
    plugin_init()
}

#[no_mangle]
#[allow(non_snake_case)]
#[cfg(feature = "demo")]
pub extern "C" fn WorkflowObjcPluginInit() -> bool {
    plugin_init()
}