From ecb8f071ca5f6e414e127e85ab660a4af052bebf Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 6 Jul 2025 16:45:05 -0400 Subject: [WARP] Recover register variables and re-add tags to matched functions --- plugins/warp/src/convert.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'plugins/warp/src/convert.rs') diff --git a/plugins/warp/src/convert.rs b/plugins/warp/src/convert.rs index 8272768b..bacf0024 100644 --- a/plugins/warp/src/convert.rs +++ b/plugins/warp/src/convert.rs @@ -5,11 +5,31 @@ use binaryninja::function::Comment as BNComment; use binaryninja::function::Function as BNFunction; use binaryninja::platform::Platform; use binaryninja::rc::Ref; +use binaryninja::variable::{Variable as BNVariable, VariableSourceType}; pub use symbol::*; pub use types::*; +use warp::r#type::class::function::{Location, RegisterLocation, StackLocation}; use warp::signature::comment::FunctionComment; use warp::target::Target; +pub fn bn_var_to_location(bn_variable: BNVariable) -> Option { + match bn_variable.ty { + VariableSourceType::StackVariableSourceType => { + let stack_loc = StackLocation { + offset: bn_variable.storage, + }; + Some(Location::Stack(stack_loc)) + } + VariableSourceType::RegisterVariableSourceType => { + let reg_loc = RegisterLocation { + id: bn_variable.storage as u64, + }; + Some(Location::Register(reg_loc)) + } + VariableSourceType::FlagVariableSourceType => None, + } +} + pub fn bn_comment_to_comment(func: &BNFunction, bn_comment: BNComment) -> FunctionComment { let offset = (bn_comment.addr as i64) - (func.start() as i64); FunctionComment { -- cgit v1.3.1