diff options
| author | Brandon Miller <brandon@vector35.com> | 2025-05-20 15:49:11 -0400 |
|---|---|---|
| committer | Brandon Miller <brandon@vector35.com> | 2025-09-29 07:07:41 -0400 |
| commit | 604a22a0050c000ed4d142589c9ce0e34ee7b570 (patch) | |
| tree | a3e2df1331303be24bbb82cb6966f1604ffe0bc9 /rust/src/llvm.rs | |
| parent | 288edd311e3312e98c934d0d35e5980d6147b6ca (diff) | |
Rust bindings for custom basic block analysis
Diffstat (limited to 'rust/src/llvm.rs')
| -rw-r--r-- | rust/src/llvm.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rust/src/llvm.rs b/rust/src/llvm.rs new file mode 100644 index 00000000..f74d00e3 --- /dev/null +++ b/rust/src/llvm.rs @@ -0,0 +1,23 @@ +use binaryninjacore_sys::BNLlvmServicesDisasmInstruction; +use std::ffi::CStr; + +pub fn disas_instruction(triplet: &str, data: &[u8], address64: u64) -> Option<(usize, String)> { + unsafe { + let mut buf = vec![0; 256]; + let instr_len = BNLlvmServicesDisasmInstruction( + triplet.as_ptr() as *const i8, + data.as_ptr() as *mut u8, + data.len() as i32, + address64, + buf.as_mut_ptr() as *mut i8, + buf.len(), + ); + if instr_len > 0 { + let cstr = CStr::from_ptr(buf.as_ptr() as *const i8); + let string = cstr.to_str().unwrap().to_string(); + Some((instr_len as usize, string)) + } else { + None + } + } +} |
