From 3452ee25b9aebdddf694f45b4273ab76ca1bc847 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 25 Oct 2024 12:09:57 -0400 Subject: Retrieve view from analysis context Makes it possible to write module workflows in plugins and scripts --- rust/src/workflow.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'rust/src/workflow.rs') diff --git a/rust/src/workflow.rs b/rust/src/workflow.rs index b3a17a77..8409ad70 100644 --- a/rust/src/workflow.rs +++ b/rust/src/workflow.rs @@ -10,6 +10,7 @@ use crate::llil::{self, FunctionForm, Mutable}; use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; use crate::string::{BnStrCompatible, BnString}; use crate::{hlil, mlil}; +use crate::binaryview::BinaryView; #[repr(transparent)] /// The AnalysisContext struct is used to represent the current state of @@ -29,6 +30,13 @@ impl AnalysisContext { Ref::new(Self { handle }) } + /// BinaryView for the current AnalysisContext + pub fn view(&self) -> Ref { + let result = unsafe { BNAnalysisContextGetBinaryView(self.handle.as_ptr()) }; + assert!(!result.is_null()); + unsafe { BinaryView::from_raw(result) } + } + /// Function for the current AnalysisContext pub fn function(&self) -> Ref { let result = unsafe { BNAnalysisContextGetFunction(self.handle.as_ptr()) }; -- cgit v1.3.1