diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-07 19:22:21 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 2f214f6c9935e8ce8df4732cde44a540a003258c (patch) | |
| tree | 6fe319433ef0d2ad75fcc58a50eaa632bb627ec9 /plugins/warp/src/plugin | |
| parent | b4cf0be8816182c9efca037e27e9439482f8bf36 (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/warp/src/plugin')
| -rw-r--r-- | plugins/warp/src/plugin/create.rs | 4 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/find.rs | 2 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/types.rs | 4 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/workflow.rs | 4 |
4 files changed, 7 insertions, 7 deletions
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(); }; |
