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

Method action

plugins/svd/src/lib.rs:26–54  ·  view source on GitHub ↗
(&self, view: &BinaryView)

Source from the content-addressed store, hash-verified

24
25impl Command for LoadSVDFile {
26 fn action(&self, view: &BinaryView) {
27 let Some(file) =
28 binaryninja::interaction::get_open_filename_input("Select a .svd file", "*.svd")
29 else {
30 return;
31 };
32
33 let file_content = match std::fs::read_to_string(&file) {
34 Ok(content) => content,
35 Err(e) => {
36 log::error!("Failed to read file: {}", e);
37 return;
38 }
39 };
40
41 match svd_parser::parse(&file_content) {
42 Ok(device) => {
43 // We have a supported svd device. map it!
44 let load_settings = LoadSettings::from_view_settings(view);
45 let address_size = view.address_size();
46 let mapper = DeviceMapper::new(load_settings, address_size, device);
47 mapper.map_to_view(view);
48 view.update_analysis();
49 }
50 Err(e) => {
51 log::error!("Failed to parse SVD file: {}", e);
52 }
53 }
54 }
55
56 fn valid(&self, _view: &BinaryView) -> bool {
57 true

Callers 1

_actionMethod · 0.45

Calls 4

map_to_viewMethod · 0.80
get_open_filename_inputFunction · 0.50
address_sizeMethod · 0.45
update_analysisMethod · 0.45

Tested by

no test coverage detected