diff options
| author | Mason Reed <mason@vector35.com> | 2025-06-13 16:42:24 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-06-13 16:43:01 -0400 |
| commit | 6a65bc11674312beb455426502cb791d0db40106 (patch) | |
| tree | b87298569f82ec6bd65e436ca2fe41f00d31c882 /rust/tests/binary_view.rs | |
| parent | 607ca37184716da4641aa178cf0cf2dc3c95f116 (diff) | |
[Rust] Add `BinaryViewExt::strings` and `BinaryViewExt::strings_in_range`
Diffstat (limited to 'rust/tests/binary_view.rs')
| -rw-r--r-- | rust/tests/binary_view.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/rust/tests/binary_view.rs b/rust/tests/binary_view.rs index a2407253..dbe47941 100644 --- a/rust/tests/binary_view.rs +++ b/rust/tests/binary_view.rs @@ -70,3 +70,25 @@ fn test_binary_saving_database() { "test" ); } + +#[test] +fn test_binary_view_strings() { + let _session = Session::new().expect("Failed to initialize session"); + let out_dir = env!("OUT_DIR").parse::<PathBuf>().unwrap(); + let view = binaryninja::load(out_dir.join("atox.obj")).expect("Failed to create view"); + let image_base = view.original_image_base(); + assert!(view.strings().len() > 0); + let str_15dc = view + .strings() + .iter() + .find(|s| { + let buffer = view + .read_buffer(s.start, s.length) + .expect("Failed to read string reference"); + let str = buffer.to_escaped_string(false, false); + str.contains("Microsoft") + }) + .expect("Failed to find string 'Microsoft (R) Optimizing Compiler'"); + assert_eq!(str_15dc.start, image_base + 0x15dc); + assert_eq!(str_15dc.length, 33); +} |
