From f32f083c81a5034530ac33ad2bc460dd234186a5 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 20:43:32 -0400 Subject: [Rust] More cleanup regarding `BnString` - Removed `to_string` shortcut from `BnString`. - Misc formatting --- plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 2 +- plugins/dwarf/dwarf_import/src/functions.rs | 2 +- plugins/dwarf/dwarf_import/src/lib.rs | 2 ++ plugins/warp/src/cache.rs | 2 +- plugins/warp/src/convert.rs | 2 +- plugins/warp/src/plugin/copy.rs | 4 ++-- 6 files changed, 8 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 136a7a8b..017ed4be 100644 --- a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -622,7 +622,7 @@ impl DebugInfoBuilder { .items .len() { - func.full_name = Some(symbol_full_name.to_string()); + func.full_name = Some(symbol_full_name.to_string_lossy().to_string()); } } } diff --git a/plugins/dwarf/dwarf_import/src/functions.rs b/plugins/dwarf/dwarf_import/src/functions.rs index 6400ea84..6277c6b5 100644 --- a/plugins/dwarf/dwarf_import/src/functions.rs +++ b/plugins/dwarf/dwarf_import/src/functions.rs @@ -117,7 +117,7 @@ pub(crate) fn parse_function_entry( if let Ok(demangled) = sym.demangle(demangle_options) { let cleaned = abi_regex.replace_all(&demangled, ""); let simplified = simplify_str_to_str(&cleaned); - full_name = Some(simplified.to_string()); + full_name = Some(simplified.to_string_lossy().to_string()); } } } diff --git a/plugins/dwarf/dwarf_import/src/lib.rs b/plugins/dwarf/dwarf_import/src/lib.rs index d51b4e1d..1e3d02d5 100644 --- a/plugins/dwarf/dwarf_import/src/lib.rs +++ b/plugins/dwarf/dwarf_import/src/lib.rs @@ -234,6 +234,7 @@ fn recover_names_internal( .collect::>() .join("::"), ) + .to_string_lossy() .to_string(), ); } @@ -251,6 +252,7 @@ fn recover_names_internal( .collect::>() .join("::"), ) + .to_string_lossy() .to_string(), ); } diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs index 8c82c687..7219b547 100644 --- a/plugins/warp/src/cache.rs +++ b/plugins/warp/src/cache.rs @@ -439,7 +439,7 @@ pub struct TypeRefID(u64); impl From<&BNNamedTypeReference> for TypeRefID { fn from(value: &BNNamedTypeReference) -> Self { let mut hasher = DefaultHasher::new(); - hasher.write(value.id().to_bytes()); + hasher.write(value.id().as_bytes()); Self(hasher.finish()) } } diff --git a/plugins/warp/src/convert.rs b/plugins/warp/src/convert.rs index 01ba167c..2e0fb3f1 100644 --- a/plugins/warp/src/convert.rs +++ b/plugins/warp/src/convert.rs @@ -35,7 +35,7 @@ use warp::symbol::{Symbol, SymbolModifiers}; pub fn from_bn_symbol(raw_symbol: &BNSymbol) -> Symbol { // TODO: Use this? let _is_export = raw_symbol.external(); - let symbol_name = raw_symbol.raw_name().to_string(); + let symbol_name = raw_symbol.raw_name().to_string_lossy().to_string(); match raw_symbol.sym_type() { BNSymbolType::ImportAddress => { Symbol::new( diff --git a/plugins/warp/src/plugin/copy.rs b/plugins/warp/src/plugin/copy.rs index 18da7dfb..b9b985fc 100644 --- a/plugins/warp/src/plugin/copy.rs +++ b/plugins/warp/src/plugin/copy.rs @@ -14,8 +14,8 @@ impl FunctionCommand for CopyFunctionGUID { }; let guid = cached_function_guid(func, &llil); log::info!( - "Function GUID for {}... {}", - func.symbol().short_name().to_string(), + "Function GUID for {:?}... {}", + func.symbol().short_name(), guid ); if let Ok(mut clipboard) = arboard::Clipboard::new() { -- cgit v1.3.1