summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-07 19:22:21 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit2f214f6c9935e8ce8df4732cde44a540a003258c (patch)
tree6fe319433ef0d2ad75fcc58a50eaa632bb627ec9 /plugins
parentb4cf0be8816182c9efca037e27e9439482f8bf36 (diff)
[Rust] Reduce usage of `IntoCStr` in function signatures
This is being done to reduce complexity in function signatures, specifically many of the strings we are passing ultimately should be new types themselves instead of "just strings", things such as type ids. Another place which was confusing was dealing with filesystem related APIs, this commit turns most of those params into a stricter `Path` type. This is bringing the rust api more inline with both python and C++, where the wrapper eagerly converts the string into the languages standard string type. Special consideration must be made for symbols or other possible non utf-8 objects. This commit will be followed up with one that adds the `IntoCStr` bound on API's we want to keep as invalid utf-8 so we can for example, get section by name on a section with invalid utf-8.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dwarf/dwarf_import/src/die_handlers.rs16
-rw-r--r--plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs2
-rw-r--r--plugins/dwarf/dwarf_import/src/helpers.rs6
-rw-r--r--plugins/dwarf/dwarf_import/src/types.rs8
-rw-r--r--plugins/dwarf/shared/src/lib.rs7
-rw-r--r--plugins/idb_import/src/lib.rs9
-rw-r--r--plugins/idb_import/src/types.rs8
-rw-r--r--plugins/pdb-ng/src/lib.rs12
-rw-r--r--plugins/pdb-ng/src/parser.rs10
-rw-r--r--plugins/pdb-ng/src/struct_grouper.rs10
-rw-r--r--plugins/pdb-ng/src/symbol_parser.rs4
-rw-r--r--plugins/pdb-ng/src/type_parser.rs10
-rw-r--r--plugins/svd/src/mapper.rs12
-rw-r--r--plugins/svd/src/settings.rs12
-rw-r--r--plugins/warp/src/convert.rs6
-rw-r--r--plugins/warp/src/matcher.rs14
-rw-r--r--plugins/warp/src/plugin.rs2
-rw-r--r--plugins/warp/src/plugin/create.rs4
-rw-r--r--plugins/warp/src/plugin/find.rs2
-rw-r--r--plugins/warp/src/plugin/types.rs4
-rw-r--r--plugins/warp/src/plugin/workflow.rs4
21 files changed, 81 insertions, 81 deletions
diff --git a/plugins/dwarf/dwarf_import/src/die_handlers.rs b/plugins/dwarf/dwarf_import/src/die_handlers.rs
index 52280320..f71fdabc 100644
--- a/plugins/dwarf/dwarf_import/src/die_handlers.rs
+++ b/plugins/dwarf/dwarf_import/src/die_handlers.rs
@@ -47,19 +47,19 @@ pub(crate) fn handle_base_type<R: ReaderType>(
constants::DW_ATE_address => None,
constants::DW_ATE_boolean => Some(Type::bool()),
constants::DW_ATE_complex_float => None,
- constants::DW_ATE_float => Some(Type::named_float(size, name)),
- constants::DW_ATE_signed => Some(Type::named_int(size, true, name)),
- constants::DW_ATE_signed_char => Some(Type::named_int(size, true, name)),
- constants::DW_ATE_unsigned => Some(Type::named_int(size, false, name)),
- constants::DW_ATE_unsigned_char => Some(Type::named_int(size, false, name)),
+ constants::DW_ATE_float => Some(Type::named_float(size, &name)),
+ constants::DW_ATE_signed => Some(Type::named_int(size, true, &name)),
+ constants::DW_ATE_signed_char => Some(Type::named_int(size, true, &name)),
+ constants::DW_ATE_unsigned => Some(Type::named_int(size, false, &name)),
+ constants::DW_ATE_unsigned_char => Some(Type::named_int(size, false, &name)),
constants::DW_ATE_imaginary_float => None,
constants::DW_ATE_packed_decimal => None,
constants::DW_ATE_numeric_string => None,
constants::DW_ATE_edited => None,
constants::DW_ATE_signed_fixed => None,
constants::DW_ATE_unsigned_fixed => None,
- constants::DW_ATE_decimal_float => Some(Type::named_float(size, name)),
- constants::DW_ATE_UTF => Some(Type::named_int(size, false, name)), // TODO : Verify
+ constants::DW_ATE_decimal_float => Some(Type::named_float(size, &name)),
+ constants::DW_ATE_UTF => Some(Type::named_int(size, false, &name)), // TODO : Verify
constants::DW_ATE_UCS => None,
constants::DW_ATE_ASCII => None, // Some sort of array?
constants::DW_ATE_lo_user => None,
@@ -114,7 +114,7 @@ pub(crate) fn handle_enum<R: ReaderType>(
match &child.entry().attr(constants::DW_AT_const_value) {
Ok(Some(attr)) => {
if let Some(value) = get_attr_as_u64(attr) {
- enumeration_builder.insert(name, value);
+ enumeration_builder.insert(&name, value);
} else {
// Somehow the child entry is not a const value.
log::error!("Unhandled enum member value type for `{}`", name);
diff --git a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs
index 017ed4be..1cedbdf2 100644
--- a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs
+++ b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs
@@ -546,7 +546,7 @@ impl DebugInfoBuilder {
assert!(debug_info.add_data_variable(
address,
&self.get_type(*type_uid).unwrap().ty,
- name.clone(),
+ name.as_deref(),
&[] // TODO : Components
));
}
diff --git a/plugins/dwarf/dwarf_import/src/helpers.rs b/plugins/dwarf/dwarf_import/src/helpers.rs
index e23eb498..f2f67170 100644
--- a/plugins/dwarf/dwarf_import/src/helpers.rs
+++ b/plugins/dwarf/dwarf_import/src/helpers.rs
@@ -14,7 +14,7 @@
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
-use std::{collections::HashMap, ops::Deref, str::FromStr, sync::mpsc};
+use std::{ops::Deref, str::FromStr, sync::mpsc};
use crate::{DebugInfoBuilderContext, ReaderType};
use binaryninja::binary_view::BinaryViewBase;
@@ -450,8 +450,8 @@ pub(crate) fn download_debug_info(
let result = inst
.perform_custom_request(
"GET",
- artifact_url,
- HashMap::<String, String>::new(),
+ &artifact_url,
+ vec![],
DownloadInstanceInputOutputCallbacks {
read: None,
write: Some(Box::new(write)),
diff --git a/plugins/dwarf/dwarf_import/src/types.rs b/plugins/dwarf/dwarf_import/src/types.rs
index 1e9dd146..78992510 100644
--- a/plugins/dwarf/dwarf_import/src/types.rs
+++ b/plugins/dwarf/dwarf_import/src/types.rs
@@ -215,8 +215,8 @@ fn do_structure_parse<R: ReaderType>(
});
structure_builder.insert(
- child_type.as_ref(),
- child_name,
+ &child_type,
+ &child_name,
struct_offset,
false,
MemberAccess::NoAccess, // TODO : Resolve actual scopes, if possible
@@ -224,8 +224,8 @@ fn do_structure_parse<R: ReaderType>(
);
} else {
structure_builder.append(
- child_type.as_ref(),
- child_name,
+ &child_type,
+ &child_name,
MemberAccess::NoAccess,
MemberScope::NoScope,
);
diff --git a/plugins/dwarf/shared/src/lib.rs b/plugins/dwarf/shared/src/lib.rs
index c4ed7937..7aa3b486 100644
--- a/plugins/dwarf/shared/src/lib.rs
+++ b/plugins/dwarf/shared/src/lib.rs
@@ -179,9 +179,10 @@ pub fn create_section_reader<'a, Endian: 'a + Endianity>(
}
}
// Truncate Mach-O section names to 16 bytes
- else if let Some(section) =
- view.section_by_name("__".to_string() + &section_name[1..section_name.len().min(15)])
- {
+ else if let Some(section) = view.section_by_name(&format!(
+ "__{}",
+ &section_name[1..section_name.len().min(15)]
+ )) {
Ok(EndianRcSlice::new(
Rc::from(view.read_vec(section.start(), section.len()).as_slice()),
endian,
diff --git a/plugins/idb_import/src/lib.rs b/plugins/idb_import/src/lib.rs
index c554831d..46acfd42 100644
--- a/plugins/idb_import/src/lib.rs
+++ b/plugins/idb_import/src/lib.rs
@@ -198,7 +198,7 @@ pub fn import_til_section(
if let TranslateTypeResult::Translated(bn_ty)
| TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
{
- if !debug_info.add_type(ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
+ if !debug_info.add_type(&ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
error!("Unable to add type `{}`", ty.name.as_utf8_lossy())
}
}
@@ -209,7 +209,7 @@ pub fn import_til_section(
if let TranslateTypeResult::Translated(bn_ty)
| TranslateTypeResult::PartiallyTranslated(bn_ty, _) = &ty.ty
{
- if !debug_info.add_type(ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
+ if !debug_info.add_type(&ty.name.as_utf8_lossy(), bn_ty, &[/* TODO */]) {
error!("Unable to fix type `{}`", ty.name.as_utf8_lossy())
}
}
@@ -239,10 +239,7 @@ fn parse_id0_section_info(
} = info;
// TODO set comments to address here
for function in &bv.functions_containing(addr) {
- function.set_comment_at(
- addr,
- String::from_utf8_lossy(&comments.join(&b"\n"[..])).to_string(),
- );
+ function.set_comment_at(addr, &String::from_utf8_lossy(&comments.join(&b"\n"[..])));
}
let bnty = ty
diff --git a/plugins/idb_import/src/types.rs b/plugins/idb_import/src/types.rs
index 7b4ca675..b3c9bea0 100644
--- a/plugins/idb_import/src/types.rs
+++ b/plugins/idb_import/src/types.rs
@@ -335,7 +335,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
format!("bitfield_{}_{}", offset + start_idx, offset + (i - 1))
};
let field = field_from_bytes(bytes);
- struct_builder.append(&field, name, MemberAccess::NoAccess, MemberScope::NoScope);
+ struct_builder.append(&field, &name, MemberAccess::NoAccess, MemberScope::NoScope);
};
for (i, member) in members {
@@ -423,7 +423,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
.as_ref()
.map(|name| name.as_utf8_lossy().to_string())
.unwrap_or_else(|| format!("member_{i}"));
- structure.append(&mem, name, MemberAccess::NoAccess, MemberScope::NoScope);
+ structure.append(&mem, &name, MemberAccess::NoAccess, MemberScope::NoScope);
}
if let Some(start_idx) = first_bitfield_seq {
let members_bitrange = &ty_struct.members[start_idx..];
@@ -470,7 +470,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
.as_ref()
.map(|name| name.as_utf8_lossy().to_string())
.unwrap_or_else(|| format!("member_{i}"));
- structure.append(&mem, name, MemberAccess::NoAccess, MemberScope::NoScope);
+ structure.append(&mem, &name, MemberAccess::NoAccess, MemberScope::NoScope);
}
let str_ref = structure.finalize();
@@ -492,7 +492,7 @@ impl<F: Fn(usize, usize) -> Result<(), ()>> TranslateIDBTypes<'_, F> {
.as_ref()
.map(|name| name.as_utf8_lossy().to_string())
.unwrap_or_else(|| format!("member_{i}"));
- eb.insert(name, member.value);
+ eb.insert(&name, member.value);
}
Type::enumeration(
&eb.finalize(),
diff --git a/plugins/pdb-ng/src/lib.rs b/plugins/pdb-ng/src/lib.rs
index 188b2ed5..a87a8076 100644
--- a/plugins/pdb-ng/src/lib.rs
+++ b/plugins/pdb-ng/src/lib.rs
@@ -13,7 +13,6 @@
// limitations under the License.
#![allow(dead_code)]
-use std::collections::HashMap;
use std::env::{current_dir, current_exe, temp_dir};
use std::io::Cursor;
use std::path::PathBuf;
@@ -31,7 +30,6 @@ use binaryninja::download_provider::{DownloadInstanceInputOutputCallbacks, Downl
use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet};
use binaryninja::logger::Logger;
use binaryninja::settings::{QueryOptions, Settings};
-use binaryninja::string::BnString;
use binaryninja::{interaction, user_directory};
use parser::PDBParserInstance;
@@ -196,7 +194,7 @@ fn read_from_sym_store(bv: &BinaryView, path: &str) -> Result<(bool, Vec<u8>)> {
.perform_custom_request(
"GET",
path,
- HashMap::<BnString, BnString>::new(),
+ vec![],
DownloadInstanceInputOutputCallbacks {
read: None,
write: Some(Box::new(write)),
@@ -278,21 +276,21 @@ fn search_sym_store(
}
fn parse_pdb_info(view: &BinaryView) -> Option<PDBInfo> {
- match view.get_metadata::<u64, _>("DEBUG_INFO_TYPE") {
+ match view.get_metadata::<u64>("DEBUG_INFO_TYPE") {
Some(Ok(0x53445352 /* 'SDSR' */)) => {}
_ => return None,
}
// This is stored in the BV by the PE loader
- let file_path = match view.get_metadata::<String, _>("PDB_FILENAME") {
+ let file_path = match view.get_metadata::<String>("PDB_FILENAME") {
Some(Ok(md)) => md,
_ => return None,
};
- let mut guid = match view.get_metadata::<Vec<u8>, _>("PDB_GUID") {
+ let mut guid = match view.get_metadata::<Vec<u8>>("PDB_GUID") {
Some(Ok(md)) => md,
_ => return None,
};
- let age = match view.get_metadata::<u64, _>("PDB_AGE") {
+ let age = match view.get_metadata::<u64>("PDB_AGE") {
Some(Ok(md)) => md as u32,
_ => return None,
};
diff --git a/plugins/pdb-ng/src/parser.rs b/plugins/pdb-ng/src/parser.rs
index 783a8a2d..2ca8e209 100644
--- a/plugins/pdb-ng/src/parser.rs
+++ b/plugins/pdb-ng/src/parser.rs
@@ -168,7 +168,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
) -> Result<()> {
self.parse_types(Self::split_progress(&progress, 0, &[1.0, 3.0, 0.5, 0.5]))?;
for (name, ty) in self.named_types.iter() {
- self.debug_info.add_type(name, ty.as_ref(), &[]); // TODO : Components
+ self.debug_info
+ .add_type(&name.to_string(), ty.as_ref(), &[]); // TODO : Components
}
info!(
@@ -406,7 +407,8 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
match class {
NamedTypeReferenceClass::UnknownNamedTypeClass
| NamedTypeReferenceClass::TypedefNamedTypeClass => {
- self.debug_info.add_type(&name, Type::void().as_ref(), &[]);
+ self.debug_info
+ .add_type(&name.to_string(), Type::void().as_ref(), &[]);
// TODO : Components
}
NamedTypeReferenceClass::ClassNamedTypeClass
@@ -429,7 +431,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
structure.alignment(1);
self.debug_info.add_type(
- &name,
+ &name.to_string(),
Type::structure(structure.finalize().as_ref()).as_ref(),
&[], // TODO : Components
);
@@ -437,7 +439,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
NamedTypeReferenceClass::EnumNamedTypeClass => {
let enumeration = EnumerationBuilder::new();
self.debug_info.add_type(
- &name,
+ &name.to_string(),
Type::enumeration(
enumeration.finalize().as_ref(),
self.arch.default_integer_size().try_into()?,
diff --git a/plugins/pdb-ng/src/struct_grouper.rs b/plugins/pdb-ng/src/struct_grouper.rs
index 09a81fa7..ff911afd 100644
--- a/plugins/pdb-ng/src/struct_grouper.rs
+++ b/plugins/pdb-ng/src/struct_grouper.rs
@@ -361,7 +361,7 @@ pub fn group_structure(
for member in members {
structure.insert(
&member.ty,
- member.name.clone(),
+ &member.name,
member.offset,
false,
member.access,
@@ -390,7 +390,7 @@ fn apply_groups(
if offset > member.offset {
structure.insert(
&member.ty,
- member.name.clone(),
+ &member.name,
0,
false,
member.access,
@@ -399,7 +399,7 @@ fn apply_groups(
} else {
structure.insert(
&member.ty,
- member.name.clone(),
+ &member.name,
member.offset - offset,
false,
member.access,
@@ -412,7 +412,7 @@ fn apply_groups(
apply_groups(members, &mut inner, children, inner_offset);
structure.insert(
&Conf::new(Type::structure(inner.finalize().as_ref()), MAX_CONFIDENCE),
- format!("__inner{}", i),
+ &format!("__inner{}", i),
inner_offset - offset,
false,
MemberAccess::PublicAccess,
@@ -425,7 +425,7 @@ fn apply_groups(
apply_groups(members, &mut inner, children, inner_offset);
structure.insert(
&Conf::new(Type::structure(inner.finalize().as_ref()), MAX_CONFIDENCE),
- format!("__inner{}", i),
+ &format!("__inner{}", i),
inner_offset - offset,
false,
MemberAccess::PublicAccess,
diff --git a/plugins/pdb-ng/src/symbol_parser.rs b/plugins/pdb-ng/src/symbol_parser.rs
index 6d6e978e..79049d03 100644
--- a/plugins/pdb-ng/src/symbol_parser.rs
+++ b/plugins/pdb-ng/src/symbol_parser.rs
@@ -2027,13 +2027,13 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
Some(X86(xreg)) => {
self.log(|| format!("Register {:?} ==> {:?}", reg, xreg));
self.arch
- .register_by_name(xreg.to_string().to_lowercase())
+ .register_by_name(&xreg.to_string().to_lowercase())
.map(|reg| reg.id())
}
Some(AMD64(areg)) => {
self.log(|| format!("Register {:?} ==> {:?}", reg, areg));
self.arch
- .register_by_name(areg.to_string().to_lowercase())
+ .register_by_name(&areg.to_string().to_lowercase())
.map(|reg| reg.id())
}
// TODO: Other arches
diff --git a/plugins/pdb-ng/src/type_parser.rs b/plugins/pdb-ng/src/type_parser.rs
index 61c64218..d4d5feb4 100644
--- a/plugins/pdb-ng/src/type_parser.rs
+++ b/plugins/pdb-ng/src/type_parser.rs
@@ -898,7 +898,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
bitfield_builder
.as_mut()
.expect("Invariant")
- .insert(&m.ty, m.name, 0, false, m.access, m.scope);
+ .insert(&m.ty, &m.name, 0, false, m.access, m.scope);
}
(None, None) => {
if let Some(mut builder) = bitfield_builder.take() {
@@ -1633,7 +1633,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
for field in fields {
match field {
ParsedType::Enumerate(member) => {
- enumeration.insert(member.name.clone(), member.value);
+ enumeration.insert(&member.name, member.value);
}
e => return Err(anyhow!("Unexpected enumerate member: {:?}", e)),
}
@@ -1803,7 +1803,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
if group.len() == 1 {
structure.insert(
&group[0].ty,
- group[0].name.clone(),
+ &group[0].name,
group[0].offset,
false,
group[0].access,
@@ -1814,7 +1814,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
for member in group {
inner_struct.insert(
&member.ty,
- member.name.clone(),
+ &member.name,
member.offset,
false,
member.access,
@@ -1826,7 +1826,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> {
Type::structure(inner_struct.finalize().as_ref()),
MAX_CONFIDENCE,
),
- format!("__inner{:x}", i),
+ &format!("__inner{:x}", i),
0,
false,
MemberAccess::PublicAccess,
diff --git a/plugins/svd/src/mapper.rs b/plugins/svd/src/mapper.rs
index 2d511615..314fba76 100644
--- a/plugins/svd/src/mapper.rs
+++ b/plugins/svd/src/mapper.rs
@@ -205,7 +205,7 @@ impl DeviceMapper {
let peripheral_ty_id = format!("SVD:{}", peripheral.name);
let id = view.define_auto_type_with_id(
&peripheral.name,
- peripheral_ty_id,
+ &peripheral_ty_id,
&peripheral_ty,
);
let ntr =
@@ -224,14 +224,14 @@ impl DeviceMapper {
view.define_auto_symbol(&symbol);
view.set_comment_at(
block_addr,
- format!("Buffer block with size {}", address_block.size),
+ &format!("Buffer block with size {}", address_block.size),
);
}
AddressBlockUsage::Reserved => {
// TODO: What to do for reserved blocks?
view.set_comment_at(
block_addr,
- format!("Reserved block with size {}", address_block.size),
+ &format!("Reserved block with size {}", address_block.size),
);
}
}
@@ -286,11 +286,11 @@ impl DeviceMapper {
for (field_addr, comments) in unaligned_comments {
let comment = comments.join("\n");
- view.set_comment_at(field_addr, comment);
+ view.set_comment_at(field_addr, &comment);
}
}
}
- view.file().commit_undo_actions(undo_id);
+ view.file().commit_undo_actions(&undo_id);
}
pub fn peripheral_block_memory_info(
@@ -662,7 +662,7 @@ impl DeviceMapper {
current_value = enumerated_value.value.unwrap_or(current_value + 1);
// TODO: The Rust API needs to expose this...
let _is_default = enumerated_value.is_default.unwrap_or(false);
- enum_builder.insert(enumerated_value.name.to_owned(), current_value);
+ enum_builder.insert(&enumerated_value.name, current_value);
}
let enum_width = NonZeroUsize::new(byte_aligned_width as usize).unwrap();
diff --git a/plugins/svd/src/settings.rs b/plugins/svd/src/settings.rs
index 9621da64..fb2f680c 100644
--- a/plugins/svd/src/settings.rs
+++ b/plugins/svd/src/settings.rs
@@ -32,7 +32,7 @@ impl LoadSettings {
});
bn_settings.register_setting_json(
Self::ADD_BACKING_REGIONS_SETTING,
- add_backing_region_props.to_string(),
+ &add_backing_region_props.to_string(),
);
let add_bitfields_props = json!({
@@ -41,8 +41,10 @@ impl LoadSettings {
"default" : Self::ADD_BITFIELDS_DEFAULT,
"description" : "Whether to add bitfields. Bitfields are not supported by Binary Ninja, so this is a workaround using unions.",
});
- bn_settings
- .register_setting_json(Self::ADD_BITFIELDS_SETTING, add_bitfields_props.to_string());
+ bn_settings.register_setting_json(
+ Self::ADD_BITFIELDS_SETTING,
+ &add_bitfields_props.to_string(),
+ );
let add_comments_props = json!({
"title" : "Add Comments",
@@ -51,7 +53,7 @@ impl LoadSettings {
"description" : "Whether to add comments. If you see comment placement is off, try disabling this.",
});
bn_settings
- .register_setting_json(Self::ADD_COMMENTS_SETTING, add_comments_props.to_string());
+ .register_setting_json(Self::ADD_COMMENTS_SETTING, &add_comments_props.to_string());
let file_props = json!({
"title" : "SVD File",
@@ -60,7 +62,7 @@ impl LoadSettings {
"description" : "The SVD File to automatically load when opening the view.",
"uiSelectionAction" : "file"
});
- bn_settings.register_setting_json(Self::AUTO_LOAD_FILE_SETTING, file_props.to_string());
+ bn_settings.register_setting_json(Self::AUTO_LOAD_FILE_SETTING, &file_props.to_string());
}
pub fn from_view_settings(view: &BinaryView) -> Self {
diff --git a/plugins/warp/src/convert.rs b/plugins/warp/src/convert.rs
index 2e0fb3f1..b6c2f7b4 100644
--- a/plugins/warp/src/convert.rs
+++ b/plugins/warp/src/convert.rs
@@ -431,7 +431,7 @@ pub fn to_bn_type<A: BNArchitecture>(arch: &A, ty: &Type) -> BNRef<BNType> {
let base_struct_ntr = match c.guid {
Some(guid) => BNNamedTypeReference::new_with_id(
NamedTypeReferenceClass::UnknownNamedTypeClass,
- guid.to_string(),
+ &guid.to_string(),
base_struct_ntr_name,
),
None => BNNamedTypeReference::new(
@@ -475,7 +475,7 @@ pub fn to_bn_type<A: BNArchitecture>(arch: &A, ty: &Type) -> BNRef<BNType> {
// TODO: Add default name?
let member_name = member.name.to_owned().unwrap_or("enum_VAL".into());
let member_value = member.constant;
- builder.insert(member_name, member_value);
+ builder.insert(&member_name, member_value);
}
// TODO: Warn if enumeration has no size.
let width = bits_to_bytes(c.member_type.size().unwrap()) as usize;
@@ -545,7 +545,7 @@ pub fn to_bn_type<A: BNArchitecture>(arch: &A, ty: &Type) -> BNRef<BNType> {
let ntr_name = c.name.to_owned().unwrap_or(guid_str.clone());
NamedTypeReference::new_with_id(
NamedTypeReferenceClass::UnknownNamedTypeClass,
- guid_str,
+ &guid_str,
ntr_name,
)
}
diff --git a/plugins/warp/src/matcher.rs b/plugins/warp/src/matcher.rs
index 6352cd7a..0ce258ad 100644
--- a/plugins/warp/src/matcher.rs
+++ b/plugins/warp/src/matcher.rs
@@ -159,7 +159,7 @@ impl Matcher {
if let Some(ref_guid) = c.guid {
// NOTE: We do not need to check for cyclic reference here because
// NOTE: GUID references are unable to be referenced by themselves.
- if view.type_by_id(ref_guid.to_string()).is_none() {
+ if view.type_by_id(&ref_guid.to_string()).is_none() {
// Add the referrer to the view if it is in the Matcher types
if let Some(ref_ty) = matcher.types.get(&ref_guid) {
inner_add_type_to_view(matcher, view, arch, visited_refs, &ref_ty);
@@ -186,7 +186,7 @@ impl Matcher {
// All nested types _should_ be added now, we can add this type.
// TODO: Do we want to make unnamed types visible? I think we should, but some people might be opposed.
let ty_name = ty.name.to_owned().unwrap_or_else(|| ty_id_str.clone());
- view.define_auto_type_with_id(ty_name, ty_id_str, &to_bn_type(arch, ty));
+ view.define_auto_type_with_id(ty_name, &ty_id_str, &to_bn_type(arch, ty));
}
_ => {}
}
@@ -409,7 +409,7 @@ impl MatcherSettings {
});
bn_settings.register_setting_json(
Self::TRIVIAL_FUNCTION_LEN_SETTING,
- trivial_function_len_props.to_string(),
+ &trivial_function_len_props.to_string(),
);
let minimum_function_len_props = json!({
@@ -421,7 +421,7 @@ impl MatcherSettings {
});
bn_settings.register_setting_json(
Self::MINIMUM_FUNCTION_LEN_SETTING,
- minimum_function_len_props.to_string(),
+ &minimum_function_len_props.to_string(),
);
let maximum_function_len_props = json!({
@@ -433,7 +433,7 @@ impl MatcherSettings {
});
bn_settings.register_setting_json(
Self::MAXIMUM_FUNCTION_LEN_SETTING,
- maximum_function_len_props.to_string(),
+ &maximum_function_len_props.to_string(),
);
let minimum_matched_constraints_props = json!({
@@ -445,7 +445,7 @@ impl MatcherSettings {
});
bn_settings.register_setting_json(
Self::MINIMUM_MATCHED_CONSTRAINTS_SETTING,
- minimum_matched_constraints_props.to_string(),
+ &minimum_matched_constraints_props.to_string(),
);
let trivial_function_adjacent_allowed_props = json!({
@@ -457,7 +457,7 @@ impl MatcherSettings {
});
bn_settings.register_setting_json(
Self::TRIVIAL_FUNCTION_ADJACENT_ALLOWED_SETTING,
- trivial_function_adjacent_allowed_props.to_string(),
+ &trivial_function_adjacent_allowed_props.to_string(),
);
}
diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs
index b84173f7..ec903f9c 100644
--- a/plugins/warp/src/plugin.rs
+++ b/plugins/warp/src/plugin.rs
@@ -52,7 +52,7 @@ pub fn on_matched_function(function: &Function, matched: &WarpFunction) {
// TODO: Add metadata. (both binja metadata and warp metadata)
function.add_tag(
&get_warp_tag_type(&view),
- matched.guid.to_string(),
+ &matched.guid.to_string(),
None,
true,
None,
diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs
index e84e42ad..1dd83e6e 100644
--- a/plugins/warp/src/plugin/create.rs
+++ b/plugins/warp/src/plugin/create.rs
@@ -31,7 +31,7 @@ impl Command for CreateSignatureFile {
let total_functions = view.functions().len();
let done_functions = AtomicUsize::default();
let background_task = binaryninja::background_task::BackgroundTask::new(
- format!("Generating signatures... ({}/{})", 0, total_functions),
+ &format!("Generating signatures... ({}/{})", 0, total_functions),
true,
);
@@ -43,7 +43,7 @@ impl Command for CreateSignatureFile {
.par_iter()
.inspect(|_| {
done_functions.fetch_add(1, Relaxed);
- background_task.set_progress_text(format!(
+ background_task.set_progress_text(&format!(
"Generating signatures... ({}/{})",
done_functions.load(Relaxed),
total_functions
diff --git a/plugins/warp/src/plugin/find.rs b/plugins/warp/src/plugin/find.rs
index b2102e5e..accc015d 100644
--- a/plugins/warp/src/plugin/find.rs
+++ b/plugins/warp/src/plugin/find.rs
@@ -27,7 +27,7 @@ impl Command for FindFunctionFromGUID {
let funcs = view.functions();
thread::spawn(move || {
let background_task = binaryninja::background_task::BackgroundTask::new(
- format!("Searching functions for GUID... {}", searched_guid),
+ &format!("Searching functions for GUID... {}", searched_guid),
false,
);
diff --git a/plugins/warp/src/plugin/types.rs b/plugins/warp/src/plugin/types.rs
index 057d5f98..41e03cd3 100644
--- a/plugins/warp/src/plugin/types.rs
+++ b/plugins/warp/src/plugin/types.rs
@@ -35,7 +35,7 @@ impl Command for LoadTypes {
let view = view.to_owned();
std::thread::spawn(move || {
let background_task = binaryninja::background_task::BackgroundTask::new(
- format!("Applying {} types...", data.types.len()),
+ &format!("Applying {} types...", data.types.len()),
true,
);
@@ -43,7 +43,7 @@ impl Command for LoadTypes {
for comp_ty in data.types {
let ty_id = comp_ty.guid.to_string();
let ty_name = comp_ty.ty.name.to_owned().unwrap_or_else(|| ty_id.clone());
- view.define_auto_type_with_id(ty_name, ty_id, &to_bn_type(&arch, &comp_ty.ty));
+ view.define_auto_type_with_id(ty_name, &ty_id, &to_bn_type(&arch, &comp_ty.ty));
}
log::info!("Type application took {:?}", start.elapsed());
diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs
index 5a857fbb..9f7c4d0d 100644
--- a/plugins/warp/src/plugin/workflow.rs
+++ b/plugins/warp/src/plugin/workflow.rs
@@ -44,7 +44,7 @@ impl Command for RunMatcher {
.for_each(|function| cached_function_matcher(&function));
log::info!("Function matching took {:?}", start.elapsed());
background_task.finish();
- view.file().commit_undo_actions(undo_id);
+ view.file().commit_undo_actions(&undo_id);
// Now we want to trigger re-analysis.
view.update_analysis();
});
@@ -66,7 +66,7 @@ pub fn insert_workflow() {
.for_each(|function| cached_function_matcher(&function));
log::info!("Function matching took {:?}", start.elapsed());
background_task.finish();
- view.file().commit_undo_actions(undo_id);
+ view.file().commit_undo_actions(&undo_id);
// Now we want to trigger re-analysis.
view.update_analysis();
};