(&self, view: &BinaryView)
| 24 | |
| 25 | impl 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 |
no test coverage detected