summaryrefslogtreecommitdiff
path: root/plugins/bntl_utils/src/lib.rs
blob: 381ea211d5b3b5de987debc09efbaace6c9bacf3 (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
62
63
mod command;
pub mod diff;
pub mod dump;
pub mod helper;
mod merge;
pub mod process;
pub mod schema;
pub mod tbd;
pub mod url;
pub mod validate;
mod winmd;

#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
    if plugin_init().is_err() {
        tracing::error!("Failed to initialize BNTL Utils plug-in");
        return false;
    }
    true
}

fn plugin_init() -> Result<(), ()> {
    binaryninja::tracing_init!("BNTL Utils");

    binaryninja::command::register_command(
        "Type Library\\Create\\From Current View",
        "Create .bntl files from the current view",
        command::create::CreateFromCurrentView {},
    );

    binaryninja::command::register_command_for_project(
        "Type Library\\Create\\From Project",
        "Create .bntl files from the given project",
        command::create::CreateFromProject {},
    );

    binaryninja::command::register_global_command(
        "Type Library\\Create\\From Directory",
        "Create .bntl files from the given directory",
        command::create::CreateFromDirectory {},
    );

    binaryninja::command::register_global_command(
        "Type Library\\Diff",
        "Diff two .bntl files and output the difference to a file",
        command::diff::Diff {},
    );

    binaryninja::command::register_global_command(
        "Type Library\\Dump To Header",
        "Dump a .bntl file to a header file",
        command::dump::Dump {},
    );

    binaryninja::command::register_global_command(
        "Type Library\\Validate",
        "Validate a .bntl file and report the issues",
        command::validate::Validate {},
    );

    Ok(())
}