summaryrefslogtreecommitdiff
path: root/rust/tests/binary_view.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-02-06 23:59:12 -0500
committerMason Reed <mason@vector35.com>2025-02-06 23:59:12 -0500
commitb451efd609f94152fbca97cb944467234dcc74d7 (patch)
tree7b4100ca9a7feaadadc7201cc54981ee7f2a073a /rust/tests/binary_view.rs
parentf9bd8eb2a8aa8b492d4145624d12e7014c7ee65c (diff)
Update Rust tests to respect image base
Diffstat (limited to 'rust/tests/binary_view.rs')
-rw-r--r--rust/tests/binary_view.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/rust/tests/binary_view.rs b/rust/tests/binary_view.rs
index 6cb617c2..08e530aa 100644
--- a/rust/tests/binary_view.rs
+++ b/rust/tests/binary_view.rs
@@ -26,11 +26,12 @@ fn test_binary_saving(_session: &Session) {
let out_dir = env!("OUT_DIR").parse::<PathBuf>().unwrap();
let view = binaryninja::load(out_dir.join("atox.obj")).expect("Failed to create view");
// Verify the contents before we modify.
- let original_contents = view.read_vec(0x1560, 4);
+ let contents_addr = view.original_image_base() + 0x1560;
+ let original_contents = view.read_vec(contents_addr, 4);
assert_eq!(original_contents, [0x00, 0xf1, 0x00, 0x00]);
- assert_eq!(view.write(0x1560, &[0xff, 0xff, 0xff, 0xff]), 4);
+ assert_eq!(view.write(contents_addr, &[0xff, 0xff, 0xff, 0xff]), 4);
// Verify that we modified the binary
- let modified_contents = view.read_vec(0x1560, 4);
+ let modified_contents = view.read_vec(contents_addr, 4);
assert_eq!(modified_contents, [0xff, 0xff, 0xff, 0xff]);
// HACK: To prevent us from deadlocking in save_to_path we wait for all main thread actions to finish.
@@ -41,7 +42,10 @@ fn test_binary_saving(_session: &Session) {
// Verify that the file exists and is modified.
let new_view =
binaryninja::load(out_dir.join("atox.obj.new")).expect("Failed to load new view");
- assert_eq!(new_view.read_vec(0x1560, 4), [0xff, 0xff, 0xff, 0xff]);
+ assert_eq!(
+ new_view.read_vec(contents_addr, 4),
+ [0xff, 0xff, 0xff, 0xff]
+ );
}
#[rstest]