MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / plugin_init

Function plugin_init

plugins/svd/src/lib.rs:77–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75}
76
77fn plugin_init() {
78 Logger::new("SVD").with_level(LevelFilter::Debug).init();
79
80 binaryninja::command::register_command(
81 "Load SVD File",
82 "Loads an SVD file into the current view.",
83 LoadSVDFile {},
84 );
85
86 // Register settings globally.
87 LoadSettings::register();
88
89 let loader_activity = |ctx: &AnalysisContext| {
90 let view = ctx.view();
91 let load_settings = LoadSettings::from_view_settings(&view);
92 let Some(file) = &load_settings.auto_load_file else {
93 log::debug!("No SVD file specified, skipping...");
94 return;
95 };
96 let file_content = match std::fs::read_to_string(file) {
97 Ok(content) => content,
98 Err(e) => {
99 log::error!("Failed to read file: {}", e);
100 return;
101 }
102 };
103 match svd_parser::parse(&file_content) {
104 Ok(device) => {
105 let address_size = view.address_size();
106 let mapper = DeviceMapper::new(load_settings, address_size, device);
107 mapper.map_to_view(&view);
108 }
109 Err(e) => {
110 log::error!("Failed to parse SVD file: {}", e);
111 }
112 }
113 };
114
115 // Register new workflow activity to load svd information.
116 let old_module_meta_workflow = Workflow::instance("core.module.metaAnalysis");
117 let module_meta_workflow = old_module_meta_workflow.clone_to("core.module.metaAnalysis");
118 let loader_activity = Activity::new_with_action(LOADER_ACTIVITY_CONFIG, loader_activity);
119 module_meta_workflow
120 .register_activity(&loader_activity)
121 .unwrap();
122 module_meta_workflow.insert("core.module.loadDebugInfo", [LOADER_ACTIVITY_NAME]);
123 module_meta_workflow.register().unwrap();
124}

Callers 2

CorePluginInitFunction · 0.85
SVDPluginInitFunction · 0.85

Calls 11

register_commandFunction · 0.85
instanceFunction · 0.85
with_levelMethod · 0.80
map_to_viewMethod · 0.80
clone_toMethod · 0.80
initMethod · 0.45
viewMethod · 0.45
address_sizeMethod · 0.45
register_activityMethod · 0.45
insertMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected