summaryrefslogtreecommitdiff
path: root/plugins/warp/src/convert.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-07-06 16:45:05 -0400
committerMason Reed <mason@vector35.com>2025-07-06 16:46:56 -0400
commitecb8f071ca5f6e414e127e85ab660a4af052bebf (patch)
tree8276061cbdf181a70599d8f181f8fa14520bfb4a /plugins/warp/src/convert.rs
parent796b8ac0e6cc2c0d6f2c3ac968f2578af4c608c7 (diff)
[WARP] Recover register variables and re-add tags to matched functions
Diffstat (limited to 'plugins/warp/src/convert.rs')
-rw-r--r--plugins/warp/src/convert.rs20
1 files changed, 20 insertions, 0 deletions
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<Location> {
+ 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 {