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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
use crate::cache::register_cache_destructor;
use std::time::Instant;
use crate::cache::container::add_cached_container;
use crate::container::disk::DiskContainer;
use crate::matcher::MatcherSettings;
use crate::plugin::render_layer::HighlightRenderLayer;
use crate::plugin::settings::PluginSettings;
use crate::{core_signature_dir, user_signature_dir};
use binaryninja::background_task::BackgroundTask;
use binaryninja::command::{
register_command, register_command_for_function, register_command_for_project,
};
use binaryninja::logger::Logger;
use binaryninja::settings::Settings;
use log::LevelFilter;
mod create;
mod debug;
mod ffi;
mod file;
mod function;
mod load;
mod project;
mod render_layer;
mod settings;
mod workflow;
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
Logger::new("WARP").with_level(LevelFilter::Debug).init();
// Register our matcher and plugin settings globally.
let mut global_bn_settings = Settings::new();
MatcherSettings::register(&mut global_bn_settings);
PluginSettings::register(&mut global_bn_settings);
// Make sure caches are flushed when the views get destructed.
register_cache_destructor();
// Register our highlight render layer.
HighlightRenderLayer::register();
workflow::insert_workflow();
let plugin_settings = PluginSettings::from_settings(&global_bn_settings);
// We want to load all the bundled directories into the container cache.
let background_task = BackgroundTask::new("Loading WARP files...", false);
let start = Instant::now();
if plugin_settings.load_bundled_files {
let core_disk_container = DiskContainer::new_from_dir(core_signature_dir());
log::debug!("{:#?}", core_disk_container);
add_cached_container(core_disk_container);
}
if plugin_settings.load_user_files {
let user_disk_container = DiskContainer::new_from_dir(user_signature_dir());
log::debug!("{:#?}", user_disk_container);
add_cached_container(user_disk_container);
}
log::info!("Loading bundled files took {:?}", start.elapsed());
background_task.finish();
register_command(
"WARP\\Run Matcher",
"Run the matcher manually",
workflow::RunMatcher {},
);
#[cfg(debug_assertions)]
register_command(
"WARP\\Debug\\Cache",
"Debug cache sizes... because...",
debug::DebugCache {},
);
#[cfg(debug_assertions)]
register_command(
"WARP\\Debug\\Invalidate Caches",
"Invalidate all WARP caches",
debug::DebugInvalidateCache {},
);
#[cfg(debug_assertions)]
register_command_for_function(
"WARP\\Debug\\Function Signature",
"Print the entire signature for the function",
debug::DebugFunction {},
);
register_command(
"WARP\\Load File",
"Load file into the matcher, this does NOT kick off matcher analysis",
load::LoadSignatureFile {},
);
register_command_for_function(
"WARP\\Include Function",
"Add current function to the list of functions to add to the signature file",
function::IncludeFunction {},
);
register_command_for_function(
"WARP\\Copy GUID",
"Copy the computed GUID for the function",
function::CopyFunctionGUID {},
);
register_command(
"WARP\\Find GUID",
"Locate the function in the view using a GUID",
function::FindFunctionFromGUID {},
);
register_command(
"WARP\\Create\\From Current View",
"Creates a signature file containing all selected functions",
create::CreateFromCurrentView {},
);
register_command(
"WARP\\Create\\From File(s)",
"Creates a signature file containing all selected functions",
create::CreateFromFiles {},
);
register_command(
"WARP\\Show Report",
"Creates a report for the selected file, displaying info on functions and types",
file::ShowFileReport {},
);
register_command_for_project(
"WARP\\Create\\From Project",
"Create signature files from select project files",
project::CreateSignatures {},
);
true
}
|