summaryrefslogtreecommitdiff
path: root/rust/src/binary_view/memory_map.rs
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 /rust/src/binary_view/memory_map.rs
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 'rust/src/binary_view/memory_map.rs')
-rw-r--r--rust/src/binary_view/memory_map.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/rust/src/binary_view/memory_map.rs b/rust/src/binary_view/memory_map.rs
index ad7c8ea1..28b52369 100644
--- a/rust/src/binary_view/memory_map.rs
+++ b/rust/src/binary_view/memory_map.rs
@@ -42,7 +42,7 @@ impl MemoryMap {
pub fn add_binary_memory_region(
&mut self,
- name: impl IntoCStr,
+ name: &str,
start: u64,
view: &BinaryView,
segment_flags: Option<SegmentFlags>,
@@ -61,7 +61,7 @@ impl MemoryMap {
pub fn add_data_memory_region(
&mut self,
- name: impl IntoCStr,
+ name: &str,
start: u64,
data: &DataBuffer,
segment_flags: Option<SegmentFlags>,
@@ -80,7 +80,7 @@ impl MemoryMap {
pub fn add_remote_memory_region(
&mut self,
- name: impl IntoCStr,
+ name: &str,
start: u64,
accessor: &mut FileAccessor,
segment_flags: Option<SegmentFlags>,
@@ -97,7 +97,7 @@ impl MemoryMap {
}
}
- pub fn remove_memory_region(&mut self, name: impl IntoCStr) -> bool {
+ pub fn remove_memory_region(&mut self, name: &str) -> bool {
let name_raw = name.to_cstr();
unsafe { BNRemoveMemoryRegion(self.view.handle, name_raw.as_ptr()) }
}
@@ -109,44 +109,44 @@ impl MemoryMap {
}
}
- pub fn memory_region_flags(&self, name: impl IntoCStr) -> SegmentFlags {
+ pub fn memory_region_flags(&self, name: &str) -> SegmentFlags {
let name_raw = name.to_cstr();
let flags_raw = unsafe { BNGetMemoryRegionFlags(self.view.handle, name_raw.as_ptr()) };
SegmentFlags::from_raw(flags_raw)
}
- pub fn set_memory_region_flags(&mut self, name: impl IntoCStr, flags: SegmentFlags) -> bool {
+ pub fn set_memory_region_flags(&mut self, name: &str, flags: SegmentFlags) -> bool {
let name_raw = name.to_cstr();
unsafe { BNSetMemoryRegionFlags(self.view.handle, name_raw.as_ptr(), flags.into_raw()) }
}
- pub fn is_memory_region_enabled(&self, name: impl IntoCStr) -> bool {
+ pub fn is_memory_region_enabled(&self, name: &str) -> bool {
let name_raw = name.to_cstr();
unsafe { BNIsMemoryRegionEnabled(self.view.handle, name_raw.as_ptr()) }
}
- pub fn set_memory_region_enabled(&mut self, name: impl IntoCStr, enabled: bool) -> bool {
+ pub fn set_memory_region_enabled(&mut self, name: &str, enabled: bool) -> bool {
let name_raw = name.to_cstr();
unsafe { BNSetMemoryRegionEnabled(self.view.handle, name_raw.as_ptr(), enabled) }
}
// TODO: Should we just call this is_memory_region_relocatable?
- pub fn is_memory_region_rebaseable(&self, name: impl IntoCStr) -> bool {
+ pub fn is_memory_region_rebaseable(&self, name: &str) -> bool {
let name_raw = name.to_cstr();
unsafe { BNIsMemoryRegionRebaseable(self.view.handle, name_raw.as_ptr()) }
}
- pub fn set_memory_region_rebaseable(&mut self, name: impl IntoCStr, enabled: bool) -> bool {
+ pub fn set_memory_region_rebaseable(&mut self, name: &str, enabled: bool) -> bool {
let name_raw = name.to_cstr();
unsafe { BNSetMemoryRegionRebaseable(self.view.handle, name_raw.as_ptr(), enabled) }
}
- pub fn memory_region_fill(&self, name: impl IntoCStr) -> u8 {
+ pub fn memory_region_fill(&self, name: &str) -> u8 {
let name_raw = name.to_cstr();
unsafe { BNGetMemoryRegionFill(self.view.handle, name_raw.as_ptr()) }
}
- pub fn set_memory_region_fill(&mut self, name: impl IntoCStr, fill: u8) -> bool {
+ pub fn set_memory_region_fill(&mut self, name: &str, fill: u8) -> bool {
let name_raw = name.to_cstr();
unsafe { BNSetMemoryRegionFill(self.view.handle, name_raw.as_ptr(), fill) }
}