diff options
| author | Glenn Smith <glenn@vector35.com> | 2024-05-30 17:35:21 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2024-06-04 14:38:19 -0400 |
| commit | 5159182291014349046748525204335581348190 (patch) | |
| tree | 10ca599057a5d5d2720184cd815c98eb4f357d33 /rust/examples | |
| parent | 9619491446923956006456412424486179104727 (diff) | |
PDB: Setting to control use of interaction api
Diffstat (limited to 'rust/examples')
| -rw-r--r-- | rust/examples/pdb-ng/src/lib.rs | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/rust/examples/pdb-ng/src/lib.rs b/rust/examples/pdb-ng/src/lib.rs index 6e6d216a..25c44ca2 100644 --- a/rust/examples/pdb-ng/src/lib.rs +++ b/rust/examples/pdb-ng/src/lib.rs @@ -412,13 +412,27 @@ impl PDBParser { if check_guid { return Err(anyhow!("PDB GUID does not match")); } else { - if interaction::show_message_box( - "Mismatched PDB", - "This PDB does not look like it matches your binary. Do you want to load it anyway?", - MessageBoxButtonSet::YesNoButtonSet, - binaryninja::interaction::MessageBoxIcon::QuestionIcon - ) == MessageBoxButtonResult::NoButton { - return Err(anyhow!("User cancelled mismatched load")); + let ask = Settings::new("").get_string( + "pdb.features.loadMismatchedPDB", + Some(view), + None, + ); + + match ask.as_str() { + "true" => {}, + "ask" => { + if interaction::show_message_box( + "Mismatched PDB", + "This PDB does not look like it matches your binary. Do you want to load it anyway?", + MessageBoxButtonSet::YesNoButtonSet, + binaryninja::interaction::MessageBoxIcon::QuestionIcon + ) == MessageBoxButtonResult::NoButton { + return Err(anyhow!("User cancelled mismatched load")); + } + } + _ => { + return Err(anyhow!("PDB GUID does not match")); + } } } } @@ -513,13 +527,27 @@ impl PDBParser { if check_guid { return Err(anyhow!("File not compiled with PDB information")); } else { - if interaction::show_message_box( - "No PDB Information", - "This file does not look like it was compiled with a PDB, so your PDB might not correctly apply to the analysis. Do you want to load it anyway?", - MessageBoxButtonSet::YesNoButtonSet, - binaryninja::interaction::MessageBoxIcon::QuestionIcon - ) == MessageBoxButtonResult::NoButton { - return Err(anyhow!("User cancelled missing info load")); + let ask = Settings::new("").get_string( + "pdb.features.loadMismatchedPDB", + Some(view), + None, + ); + + match ask.as_str() { + "true" => {}, + "ask" => { + if interaction::show_message_box( + "No PDB Information", + "This file does not look like it was compiled with a PDB, so your PDB might not correctly apply to the analysis. Do you want to load it anyway?", + MessageBoxButtonSet::YesNoButtonSet, + binaryninja::interaction::MessageBoxIcon::QuestionIcon + ) == MessageBoxButtonResult::NoButton { + return Err(anyhow!("User cancelled missing info load")); + } + } + _ => { + return Err(anyhow!("File not compiled with PDB information")); + } } } } @@ -842,6 +870,24 @@ fn init_plugin() -> bool { ); settings.register_setting_json( + "pdb.features.loadMismatchedPDB", + r#"{ + "title" : "Load Mismatched PDB", + "type" : "string", + "default" : "ask", + "enum" : ["true", "ask", "false"], + "enumDescriptions" : [ + "Always load the PDB", + "Use the Interaction system to ask if the PDB should be loaded", + "Never load the PDB" + ], + "aliases" : [], + "description" : "If a manually loaded PDB has a mismatched GUID, should it be loaded?", + "ignore" : [] + }"#, + ); + + settings.register_setting_json( "pdb.features.parseSymbols", r#"{ "title" : "Parse PDB Symbols", |
