diff --git a/Cargo.lock b/Cargo.lock index 182b0eb..9ff5130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -894,6 +894,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "ehttp" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80b69a6f9168b96c0ae04763bec27a8b06b34343c334dd2703a4ec21f0f5e110" +dependencies = [ + "js-sys", + "ureq", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "either" version = "1.8.1" @@ -1076,7 +1089,7 @@ dependencies = [ "futures-sink", "nanorand", "pin-project", - "spin", + "spin 0.9.5", ] [[package]] @@ -2420,6 +2433,7 @@ version = "0.3.0" dependencies = [ "crossbeam-channel", "dashmap", + "ehttp", "insta", "instant", "log", @@ -2429,6 +2443,7 @@ dependencies = [ "regex", "similar", "thiserror", + "url", "wasm_thread", ] @@ -2469,6 +2484,21 @@ dependencies = [ "windows 0.44.0", ] +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "ron" version = "0.8.0" @@ -2494,6 +2524,18 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "rustls" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "ryu" version = "1.0.13" @@ -2539,6 +2581,16 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sctk-adwaita" version = "0.5.3" @@ -2692,6 +2744,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.5" @@ -3052,6 +3110,28 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "ureq" +version = "2.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338b31dd1314f68f3aabf3ed57ab922df95ffcd902476ca7ba3c4ce7b908c46d" +dependencies = [ + "base64 0.13.1", + "flate2", + "log", + "once_cell", + "rustls", + "url", + "webpki", + "webpki-roots", +] + [[package]] name = "url" version = "2.3.1" @@ -3301,6 +3381,25 @@ dependencies = [ "web-sys", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + [[package]] name = "weezl" version = "0.1.7" diff --git a/resym/Cargo.toml b/resym/Cargo.toml index 0576b77..e4ace60 100644 --- a/resym/Cargo.toml +++ b/resym/Cargo.toml @@ -18,9 +18,10 @@ path = "src/lib.rs" crate-type = ["cdylib", "rlib"] [features] -default = ["rayon"] +default = ["rayon", "http"] rayon = ["resym_core/rayon"] +http = ["resym_core/http"] [dependencies] resym_core = { version = "0.3", path = "../resym_core", default-features = false } diff --git a/resym/src/resym_app.rs b/resym/src/resym_app.rs index 43cc45f..9813c64 100644 --- a/resym/src/resym_app.rs +++ b/resym/src/resym_app.rs @@ -6,11 +6,12 @@ use resym_core::{ frontend::FrontendCommand, }; -use std::fmt::Write; #[cfg(target_arch = "wasm32")] use std::{cell::RefCell, rc::Rc}; -use std::{sync::Arc, vec}; +use std::{fmt::Write, sync::Arc, vec}; +#[cfg(feature = "http")] +use crate::ui_components::OpenURLComponent; use crate::{ frontend::EguiFrontendController, mode::ResymAppMode, @@ -24,6 +25,7 @@ use crate::{ const PKG_NAME: &str = env!("CARGO_PKG_NAME"); const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[derive(Clone, Copy)] pub enum ResymPDBSlots { /// Slot for the single PDB or for the PDB we're diffing from Main = 0, @@ -31,6 +33,12 @@ pub enum ResymPDBSlots { Diff = 1, } +impl Into for ResymPDBSlots { + fn into(self) -> PDBSlot { + self as PDBSlot + } +} + /// Struct that represents our GUI application. /// It contains the whole application's context at all time. pub struct ResymApp { @@ -40,6 +48,8 @@ pub struct ResymApp { code_view: CodeViewComponent, console: ConsoleComponent, settings: SettingsComponent, + #[cfg(feature = "http")] + open_url: OpenURLComponent, frontend_controller: Arc, backend: Backend, /// Field used by wasm32 targets to store PDB file information @@ -72,6 +82,10 @@ impl eframe::App for ResymApp { // Update the "Settings" window if open self.settings.update(ctx); + // Update "Open URL" window if open + #[cfg(feature = "http")] + self.open_url.update(ctx, &self.backend); + // Update the top panel (i.e, menu bar) self.update_top_panel(ctx, frame); @@ -122,6 +136,8 @@ impl ResymApp { code_view: CodeViewComponent::new(), console: ConsoleComponent::new(logger), settings: SettingsComponent::new(app_settings), + #[cfg(feature = "http")] + open_url: OpenURLComponent::new(), frontend_controller, backend, #[cfg(target_arch = "wasm32")] @@ -234,6 +250,19 @@ impl ResymApp { } }); + /// Keyboard shortcut for opening URLs + #[cfg(feature = "http")] + const CTRL_L_SHORTCUT: egui::KeyboardShortcut = egui::KeyboardShortcut { + modifiers: egui::Modifiers::CTRL, + key: egui::Key::L, + }; + #[cfg(feature = "http")] + ui.input_mut(|input_state| { + if input_state.consume_shortcut(&CTRL_L_SHORTCUT) { + self.open_url.open(ResymPDBSlots::Main); + } + }); + /// Keyboard shortcut for saving reconstructed content #[cfg(not(target_arch = "wasm32"))] const CTRL_S_SHORTCUT: egui::KeyboardShortcut = egui::KeyboardShortcut { @@ -311,6 +340,20 @@ impl ResymApp { } }, + FrontendCommand::LoadURLResult(result) => match result { + Err(err) => { + log::error!("Failed to load URL: {}", err); + } + Ok((pdb_slot, file_name, data)) => { + if let Err(err) = self + .backend + .send_command(BackendCommand::LoadPDBFromVec(pdb_slot, file_name, data)) + { + log::error!("Failed to load the PDB file: {err}"); + } + } + }, + FrontendCommand::ReconstructTypeResult(type_reconstruction_result) => { match type_reconstruction_result { Err(err) => { @@ -391,16 +434,42 @@ impl ResymApp { ui.close_menu(); self.start_open_pdb_file(ResymPDBSlots::Main as usize); } + + #[cfg(feature = "http")] + if ui.button("Open URL (Ctrl+L)").clicked() { + ui.close_menu(); + self.open_url.open(ResymPDBSlots::Main); + } + + // Separate "Open" from "Compare" + ui.separator(); + if ui .add_enabled( matches!(self.current_mode, ResymAppMode::Browsing(..)), - egui::Button::new("Compare with..."), + egui::Button::new("Compare with file ..."), ) .clicked() { ui.close_menu(); self.start_open_pdb_file(ResymPDBSlots::Diff as usize); } + + #[cfg(feature = "http")] + if ui + .add_enabled( + matches!(self.current_mode, ResymAppMode::Browsing(..)), + egui::Button::new("Compare with URL ..."), + ) + .clicked() + { + ui.close_menu(); + self.open_url.open(ResymPDBSlots::Diff); + } + + // Separate "Compare" from "Settings" + ui.separator(); + if ui.button("Settings").clicked() { ui.close_menu(); self.settings.open(); @@ -423,7 +492,7 @@ impl ResymApp { if let Some(file_path) = file_path_opt { if let Err(err) = self .backend - .send_command(BackendCommand::LoadPDB(pdb_slot, file_path)) + .send_command(BackendCommand::LoadPDBFromPath(pdb_slot, file_path)) { log::error!("Failed to load the PDB file: {err}"); } @@ -432,13 +501,15 @@ impl ResymApp { #[cfg(target_arch = "wasm32")] fn start_open_pdb_file(&mut self, pdb_slot: PDBSlot) { - let open_pdb_data = std::rc::Rc::clone(&self.open_pdb_data); + let open_pdb_data = self.open_pdb_data.clone(); wasm_bindgen_futures::spawn_local(async move { let file_opt = rfd::AsyncFileDialog::new() .add_filter("PDB files (*.pdb)", &["pdb"]) .pick_file() .await; if let Some(file) = file_opt { + // We unwrap() the return value to assert that we are not expecting + // threads to ever fail while holding the lock. *open_pdb_data.borrow_mut() = Some((pdb_slot, file.file_name(), file.read().await)); } }); @@ -446,6 +517,8 @@ impl ResymApp { #[cfg(target_arch = "wasm32")] fn process_open_pdb_file_result(&self) { + // We unwrap() the return value to assert that we are not expecting + // threads to ever fail while holding the lock. if let Some((pdb_slot, pdb_name, pdb_bytes)) = self.open_pdb_data.borrow_mut().take() { if let Err(err) = self.backend.send_command(BackendCommand::LoadPDBFromVec( pdb_slot, pdb_name, pdb_bytes, @@ -491,7 +564,7 @@ impl ResymApp { if let Some(file_path) = &file.path { if let Err(err) = self .backend - .send_command(BackendCommand::LoadPDB(*slot, file_path.into())) + .send_command(BackendCommand::LoadPDBFromPath(*slot, file_path.into())) { log::error!("Failed to load the PDB file: {err}"); } diff --git a/resym/src/ui_components/mod.rs b/resym/src/ui_components/mod.rs index ddfa148..aec69e1 100644 --- a/resym/src/ui_components/mod.rs +++ b/resym/src/ui_components/mod.rs @@ -1,11 +1,15 @@ mod code_view; mod console; +#[cfg(feature = "http")] +mod open_url; mod settings; mod type_list; mod type_search; pub use code_view::*; pub use console::*; +#[cfg(feature = "http")] +pub use open_url::*; pub use settings::*; pub use type_list::*; pub use type_search::*; diff --git a/resym/src/ui_components/open_url.rs b/resym/src/ui_components/open_url.rs new file mode 100644 index 0000000..fe8b0f0 --- /dev/null +++ b/resym/src/ui_components/open_url.rs @@ -0,0 +1,55 @@ +use eframe::egui; +use resym_core::backend::{Backend, BackendCommand}; + +use crate::resym_app::ResymPDBSlots; + +pub struct OpenURLComponent { + url_text: String, + pdb_slot: Option, +} + +impl OpenURLComponent { + pub fn new() -> Self { + Self { + url_text: String::default(), + pdb_slot: None, + } + } + + pub fn open(&mut self, pdb_slot: ResymPDBSlots) { + self.pdb_slot = Some(pdb_slot); + } + + fn close(&mut self) { + self.pdb_slot = None; + self.url_text.clear(); + } + + pub fn update(&mut self, ctx: &egui::Context, backend: &Backend) { + if let Some(pdb_slot) = self.pdb_slot { + egui::Window::new("Open URL") + .anchor(egui::Align2::CENTER_CENTER, [0.0; 2]) + .auto_sized() + .collapsible(false) + .show(ctx, |ui| { + ui.label("URL to open:"); + ui.text_edit_singleline(&mut self.url_text); + ui.horizontal(|ui| { + if ui.button("Cancel").clicked() { + self.close(); + } else if ui.button("Open").clicked() { + self.start_open_pdb_from_url(backend, pdb_slot, self.url_text.clone()); + self.close(); + } + }) + }); + } + } + + fn start_open_pdb_from_url(&self, backend: &Backend, pdb_slot: ResymPDBSlots, url: String) { + if let Err(err) = backend.send_command(BackendCommand::LoadPDBFromURL(pdb_slot.into(), url)) + { + log::error!("Failed to load URL: {err}"); + } + } +} diff --git a/resym_core/Cargo.toml b/resym_core/Cargo.toml index f3cfaa3..1d3d193 100644 --- a/resym_core/Cargo.toml +++ b/resym_core/Cargo.toml @@ -9,9 +9,10 @@ exclude = [ ] [features] -default = ["rayon"] +default = ["rayon", "http"] rayon = ["dep:rayon", "dep:num_cpus", "dashmap/rayon"] +http = ["dep:ehttp", "dep:url"] [dependencies] pdb = { git = "https://github.com/ergrelet/pdb", branch = "0.8.0-resym" } @@ -23,6 +24,8 @@ crossbeam-channel = "0.5" dashmap = { version = "5.2" } regex = "1.5" similar = "2.1" +ehttp = { version = "0.2", optional = true } +url = { version = "2.3", optional = true } # Web: [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/resym_core/src/backend.rs b/resym_core/src/backend.rs index 2c70450..005ec62 100644 --- a/resym_core/src/backend.rs +++ b/resym_core/src/backend.rs @@ -16,12 +16,11 @@ use std::{ sync::Arc, }; #[cfg(not(target_arch = "wasm32"))] -use std::{fs, path::PathBuf, time::Instant}; +use std::{path::PathBuf, time::Instant}; #[cfg(all(not(feature = "rayon"), target_arch = "wasm32"))] use wasm_thread::{self as thread, JoinHandle}; -#[cfg(target_arch = "wasm32")] -use crate::pdb_file::PDBData; +use crate::pdb_file::PDBDataSource; use crate::{ cond_par_iter, cond_sort_by, diffing::diff_type_by_name, @@ -38,13 +37,14 @@ pub type PDBSlot = usize; pub enum BackendCommand { /// Load a PDB file given its path as a `PathBuf`. #[cfg(not(target_arch = "wasm32"))] - LoadPDB(PDBSlot, PathBuf), + LoadPDBFromPath(PDBSlot, PathBuf), /// Load a PDB file given its name and content as a `Vec`. - #[cfg(target_arch = "wasm32")] LoadPDBFromVec(PDBSlot, String, Vec), /// Load a PDB file given its name and content as an `Arc<[u8]>`. - #[cfg(target_arch = "wasm32")] LoadPDBFromArray(PDBSlot, String, Arc<[u8]>), + /// Fetch data via HTTP given its URL as a `String`. + #[cfg(feature = "http")] + LoadPDBFromURL(PDBSlot, String), /// Unload a PDB file given its slot. UnloadPDB(PDBSlot), /// Reconstruct a type given its type index for a given PDB. @@ -110,7 +110,7 @@ impl Backend { .num_threads(cpu_count - 1) .build()?; thread_pool.spawn(move || { - let exit_result = worker_thread_routine(rx_worker, frontend_controller.as_ref()); + let exit_result = worker_thread_routine(rx_worker, frontend_controller.clone()); if let Err(err) = exit_result { log::error!("Background thread aborted: {}", err); } @@ -132,7 +132,7 @@ impl Backend { // Start a new thread let worker_thread = thread::spawn(move || { - let exit_result = worker_thread_routine(rx_worker, frontend_controller.as_ref()); + let exit_result = worker_thread_routine(rx_worker, frontend_controller.clone()); if let Err(err) = exit_result { log::error!("Background thread aborted: {}", err); } @@ -156,16 +156,13 @@ impl Backend { /// the result back. fn worker_thread_routine( rx_worker: Receiver, - frontend_controller: &impl FrontendController, + frontend_controller: Arc, ) -> Result<()> { - #[cfg(target_arch = "wasm32")] - let mut pdb_files: BTreeMap>> = BTreeMap::new(); - #[cfg(not(target_arch = "wasm32"))] - let mut pdb_files: BTreeMap> = BTreeMap::new(); + let mut pdb_files: BTreeMap> = BTreeMap::new(); while let Ok(command) = rx_worker.recv() { match command { #[cfg(not(target_arch = "wasm32"))] - BackendCommand::LoadPDB(pdb_slot, pdb_file_path) => { + BackendCommand::LoadPDBFromPath(pdb_slot, pdb_file_path) => { log::info!("Loading a new PDB file ..."); match PdbFile::load_from_file(&pdb_file_path) { Err(err) => frontend_controller @@ -184,7 +181,6 @@ fn worker_thread_routine( } } - #[cfg(target_arch = "wasm32")] BackendCommand::LoadPDBFromVec(pdb_slot, pdb_name, pdb_data) => { log::info!("Loading a new PDB file ..."); match PdbFile::load_from_bytes_as_vec(pdb_name.clone(), pdb_data) { @@ -201,7 +197,6 @@ fn worker_thread_routine( } } - #[cfg(target_arch = "wasm32")] BackendCommand::LoadPDBFromArray(pdb_slot, pdb_name, pdb_data) => { log::info!("Loading a new PDB file ..."); match PdbFile::load_from_bytes_as_array(pdb_name.clone(), pdb_data) { @@ -218,6 +213,43 @@ fn worker_thread_routine( } } + #[cfg(feature = "http")] + BackendCommand::LoadPDBFromURL(pdb_slot, url) => { + log::info!("Fetching data from URL ..."); + // Parse URL and extract file name, if any + match url::Url::parse(&url) { + Err(err) => log::error!("Failed to parse URL: {err}"), + Ok(url) => { + let url_path = url.path(); + if let Some(pdb_name) = url_path.split('/').last() { + let frontend_controller = frontend_controller.clone(); + let pdb_name = pdb_name.to_string(); + let request = ehttp::Request::get(url); + ehttp::fetch(request, move |result: ehttp::Result| { + match result { + Err(err) => frontend_controller + .send_command(FrontendCommand::LoadPDBResult(Err( + ResymCoreError::EHttpError(err), + ))) + .expect("frontend unavailable"), + Ok(response) => { + frontend_controller + .send_command(FrontendCommand::LoadURLResult(Ok(( + pdb_slot, + pdb_name, + response.bytes, + )))) + .expect("frontend unavailable"); + } + } + }); + } else { + log::error!("URL doesn't point to a file"); + } + } + } + } + BackendCommand::UnloadPDB(pdb_slot) => match pdb_files.remove(&pdb_slot) { None => { log::error!("Trying to unload an inexistent PDB"); diff --git a/resym_core/src/error.rs b/resym_core/src/error.rs index 65c536d..27e6140 100644 --- a/resym_core/src/error.rs +++ b/resym_core/src/error.rs @@ -30,6 +30,11 @@ pub enum ResymCoreError { #[error("int conversion error: {0}")] TryFromIntError(#[from] std::num::TryFromIntError), + /// Error reported from `ehttp`. + #[cfg(feature = "http")] + #[error("http error: {0}")] + EHttpError(String), + /// Error returned when `resym_core` cannot process the request because of /// of an invalid parameter. #[error("invalid parameter: {0}")] diff --git a/resym_core/src/frontend.rs b/resym_core/src/frontend.rs index 04a1b10..887b9ec 100644 --- a/resym_core/src/frontend.rs +++ b/resym_core/src/frontend.rs @@ -4,6 +4,9 @@ pub type TypeList = Vec<(String, pdb::TypeIndex)>; pub enum FrontendCommand { LoadPDBResult(Result), + /// Send result from `LoadURL` backend command. + /// Contains last path segment (i.e., file name) as a `String` and data as `Vec`. + LoadURLResult(Result<(PDBSlot, String, Vec)>), UpdateFilteredTypes(TypeList), ReconstructTypeResult(Result), DiffTypeResult(Result), diff --git a/resym_core/src/pdb_file.rs b/resym_core/src/pdb_file.rs index 51dbd5c..b30409f 100644 --- a/resym_core/src/pdb_file.rs +++ b/resym_core/src/pdb_file.rs @@ -5,7 +5,12 @@ use pdb::FallibleIterator; #[cfg(feature = "rayon")] use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; -use std::{collections::BTreeSet, io, path::PathBuf, sync::Arc}; +use std::{ + collections::BTreeSet, + io::{self, Read, Seek}, + path::PathBuf, + sync::Arc, +}; #[cfg(not(target_arch = "wasm32"))] use std::{fs::File, path::Path, time::Instant}; @@ -15,20 +20,30 @@ use crate::{ pdb_types::{self, is_unnamed_type, DataFormatConfiguration, PrimitiveReconstructionFlavor}, }; -/// Wrapper for different buffer types processed by wasm32 targets -#[cfg(target_arch = "wasm32")] -#[derive(Clone, Debug)] -pub enum PDBData { - Vec(Vec), - SharedArray(Arc<[u8]>), +/// Wrapper for different buffer types processed by `resym` +#[derive(Debug)] +pub enum PDBDataSource { + File(std::fs::File), + Vec(io::Cursor>), + SharedArray(io::Cursor>), } -#[cfg(target_arch = "wasm32")] -impl AsRef<[u8]> for PDBData { - fn as_ref(&self) -> &[u8] { +impl Seek for PDBDataSource { + fn seek(&mut self, pos: io::SeekFrom) -> io::Result { match self { - PDBData::Vec(vec) => &vec, - PDBData::SharedArray(shared_array) => shared_array, + PDBDataSource::File(file) => file.seek(pos), + PDBDataSource::Vec(vec) => vec.seek(pos), + PDBDataSource::SharedArray(array) => array.seek(pos), + } + } +} + +impl Read for PDBDataSource { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + match self { + PDBDataSource::File(file) => file.read(buf), + PDBDataSource::Vec(vec) => vec.read(buf), + PDBDataSource::SharedArray(array) => array.read(buf), } } } @@ -48,8 +63,8 @@ where #[cfg(not(target_arch = "wasm32"))] impl<'p> PdbFile<'p, File> { /// Create `PdbFile` from an `std::path::Path` - pub fn load_from_file(pdb_file_path: &Path) -> Result> { - let file = File::open(pdb_file_path)?; + pub fn load_from_file(pdb_file_path: &Path) -> Result> { + let file = PDBDataSource::File(File::open(pdb_file_path)?); let mut pdb = pdb::PDB::open(file)?; let type_information = pdb.type_information()?; let machine_type = pdb.debug_information()?.machine_type()?; @@ -68,14 +83,13 @@ impl<'p> PdbFile<'p, File> { } } -#[cfg(target_arch = "wasm32")] -impl<'p> PdbFile<'p, io::Cursor> { +impl<'p> PdbFile<'p, PDBDataSource> { /// Create `PdbFile` from a `String` and a `Vec` pub fn load_from_bytes_as_vec( pdb_file_name: String, pdb_file_data: Vec, - ) -> Result>> { - let reader = io::Cursor::new(PDBData::Vec(pdb_file_data)); + ) -> Result> { + let reader = PDBDataSource::Vec(io::Cursor::new(pdb_file_data)); let mut pdb = pdb::PDB::open(reader)?; let type_information = pdb.type_information()?; let machine_type = pdb.debug_information()?.machine_type()?; @@ -97,8 +111,8 @@ impl<'p> PdbFile<'p, io::Cursor> { pub fn load_from_bytes_as_array( pdb_file_name: String, pdb_file_data: Arc<[u8]>, - ) -> Result>> { - let reader = io::Cursor::new(PDBData::SharedArray(pdb_file_data)); + ) -> Result> { + let reader = PDBDataSource::SharedArray(io::Cursor::new(pdb_file_data)); let mut pdb = pdb::PDB::open(reader)?; let type_information = pdb.type_information()?; let machine_type = pdb.debug_information()?.machine_type()?; diff --git a/resymc/src/main.rs b/resymc/src/main.rs index 1b9a1cd..e803fa5 100644 --- a/resymc/src/main.rs +++ b/resymc/src/main.rs @@ -223,7 +223,7 @@ impl ResymcApp { ) -> Result<()> { // Request the backend to load the PDB self.backend - .send_command(BackendCommand::LoadPDB(PDB_MAIN_SLOT, pdb_path))?; + .send_command(BackendCommand::LoadPDBFromPath(PDB_MAIN_SLOT, pdb_path))?; // Wait for the backend to finish loading the PDB if let FrontendCommand::LoadPDBResult(result) = self.frontend_controller.rx_ui.recv()? { if let Err(err) = result { @@ -276,7 +276,7 @@ impl ResymcApp { ) -> Result<()> { // Request the backend to load the PDB self.backend - .send_command(BackendCommand::LoadPDB(PDB_MAIN_SLOT, pdb_path))?; + .send_command(BackendCommand::LoadPDBFromPath(PDB_MAIN_SLOT, pdb_path))?; // Wait for the backend to finish loading the PDB if let FrontendCommand::LoadPDBResult(result) = self.frontend_controller.rx_ui.recv()? { if let Err(err) = result { @@ -349,7 +349,7 @@ impl ResymcApp { output_file_path: Option, ) -> Result<()> { // Request the backend to load the first PDB - self.backend.send_command(BackendCommand::LoadPDB( + self.backend.send_command(BackendCommand::LoadPDBFromPath( PDB_MAIN_SLOT, from_pdb_path.clone(), ))?; @@ -367,7 +367,7 @@ impl ResymcApp { } // Request the backend to load the second PDB - self.backend.send_command(BackendCommand::LoadPDB( + self.backend.send_command(BackendCommand::LoadPDBFromPath( PDB_DIFF_TO_SLOT, to_pdb_path.clone(), ))?;