summaryrefslogtreecommitdiff
path: root/rust/src/binary_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/binary_view.rs')
-rw-r--r--rust/src/binary_view.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs
index aa5f47f5..aa7c65e6 100644
--- a/rust/src/binary_view.rs
+++ b/rust/src/binary_view.rs
@@ -1222,6 +1222,31 @@ pub trait BinaryViewExt: BinaryViewBase {
unsafe { BNRemoveUserDataTag(self.as_ref().handle, addr, tag.handle) }
}
+ fn comment_at(&self, addr: u64) -> Option<BnString> {
+ unsafe {
+ let comment_raw = BNGetGlobalCommentForAddress(self.as_ref().handle, addr);
+ match comment_raw.is_null() {
+ false => Some(BnString::from_raw(comment_raw)),
+ true => None,
+ }
+ }
+ }
+
+ /// Sets a comment for the [`BinaryView`] at the address specified.
+ ///
+ /// NOTE: This is different from setting a comment at the function-level. To set a comment in a
+ /// function use [`Function::set_comment_at`]
+ fn set_comment_at(&self, addr: u64, comment: impl BnStrCompatible) {
+ let comment_raw = comment.into_bytes_with_nul();
+ unsafe {
+ BNSetGlobalCommentForAddress(
+ self.as_ref().handle,
+ addr,
+ comment_raw.as_ref().as_ptr() as *const c_char,
+ )
+ }
+ }
+
/// Retrieves a list of the next disassembly lines.
///
/// Retrieves an [`Array`] over [`LinearDisassemblyLine`] objects for the