summaryrefslogtreecommitdiff
path: root/rust/src/binaryview.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2024-08-09 13:27:40 -0700
committerMason Reed <mason@vector35.com>2024-09-22 19:19:48 -0400
commitcb326b45064ade9228d219895ef64e36b263a1e5 (patch)
tree8d50e71b2e31d50984caab0bf001ddaaef185d6e /rust/src/binaryview.rs
parent2b05272e4f369bb261eea72832696496cfabd6a0 (diff)
Add get_relocation_ranges to rust api
Diffstat (limited to 'rust/src/binaryview.rs')
-rw-r--r--rust/src/binaryview.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs
index b20bc59c..ed35bc76 100644
--- a/rust/src/binaryview.rs
+++ b/rust/src/binaryview.rs
@@ -1371,6 +1371,25 @@ pub trait BinaryViewExt: BinaryViewBase {
}
}
+ fn get_relocation_ranges(&self) -> Vec<Range<u64>> {
+ let ranges = unsafe {
+ let mut count = 0;
+ let reloc_ranges_ptr = BNGetRelocationRanges(self.as_ref().handle, &mut count);
+ let ranges = std::slice::from_raw_parts(reloc_ranges_ptr, count).clone();
+ BNFreeRelocationRanges(reloc_ranges_ptr);
+ ranges
+ };
+
+ // TODO: impl From BNRange for Range?
+ ranges
+ .iter()
+ .map(|range| Range {
+ start: range.start,
+ end: range.end,
+ })
+ .collect()
+ }
+
fn component_by_guid<S: BnStrCompatible>(&self, guid: S) -> Option<Component> {
let name = guid.into_bytes_with_nul();
let result = unsafe {