summaryrefslogtreecommitdiff
path: root/plugins/workflow_swift/src
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2025-12-23 13:12:02 -0700
committerRusty Wagner <rusty.wagner@gmail.com>2026-05-22 16:30:56 -0400
commit8d621c51b2797fda7b1dc22243dde611cfc04f68 (patch)
treeba5e6a90e644d21d13e75dabcbd0cc747444443a /plugins/workflow_swift/src
parent08e34ac325743085911f96b62c81d9a1f2127806 (diff)
Refactor calling conventions to support correct representation of structures
Diffstat (limited to 'plugins/workflow_swift/src')
-rw-r--r--plugins/workflow_swift/src/demangler/function_type.rs43
-rw-r--r--plugins/workflow_swift/src/demangler/type_reconstruction.rs6
2 files changed, 25 insertions, 24 deletions
diff --git a/plugins/workflow_swift/src/demangler/function_type.rs b/plugins/workflow_swift/src/demangler/function_type.rs
index 908f5940..73abe23f 100644
--- a/plugins/workflow_swift/src/demangler/function_type.rs
+++ b/plugins/workflow_swift/src/demangler/function_type.rs
@@ -1,8 +1,7 @@
-use binaryninja::architecture::{ArchitectureExt, CoreArchitecture, Register};
+use binaryninja::architecture::{ArchitectureExt, CoreArchitecture};
use binaryninja::confidence::Conf;
use binaryninja::rc::Ref;
-use binaryninja::types::{FunctionParameter, Type};
-use binaryninja::variable::{Variable, VariableSourceType};
+use binaryninja::types::{FunctionParameter, Type, ValueLocation, ValueLocationSource};
use swift_demangler::{
Accessor, AccessorKind, ConstructorKind, HasFunctionSignature, HasModule, Metadata,
MetadataKind, Symbol,
@@ -29,21 +28,17 @@ impl PlatformAbi {
}
}
- fn error_location(&self) -> Option<Variable> {
- self.register_variable(self.error_reg)
+ fn error_location(&self) -> Option<ValueLocation> {
+ self.register_location(self.error_reg)
}
- fn async_context_location(&self) -> Option<Variable> {
- self.register_variable(self.async_context_reg)
+ fn async_context_location(&self) -> Option<ValueLocation> {
+ self.register_location(self.async_context_reg)
}
- fn register_variable(&self, name: &str) -> Option<Variable> {
+ fn register_location(&self, name: &str) -> Option<ValueLocation> {
let reg = self.arch.register_by_name(name)?;
- Some(Variable::new(
- VariableSourceType::RegisterVariableSourceType,
- 0,
- reg.id().0 as i64,
- ))
+ Some(ValueLocation::from_register(reg))
}
}
@@ -83,7 +78,7 @@ impl CallingConvention {
self.leading_params.push(FunctionParameter {
ty: self_ty.into(),
name: "self".to_string(),
- location: None,
+ location: ValueLocationSource::Default,
});
}
@@ -103,12 +98,12 @@ impl CallingConvention {
self.trailing_params.push(FunctionParameter {
ty: void_ptr.clone().into(),
name: "selfMetadata".to_string(),
- location: None,
+ location: ValueLocationSource::Default,
});
self.trailing_params.push(FunctionParameter {
ty: void_ptr.into(),
name: "selfWitnessTable".to_string(),
- location: None,
+ location: ValueLocationSource::Default,
});
}
@@ -144,7 +139,7 @@ impl CallingConvention {
all_params.push(FunctionParameter {
ty: error_ty.into(),
name: "error".to_string(),
- location: self.abi.as_ref().and_then(|a| a.error_location()),
+ location: self.abi.as_ref().and_then(|a| a.error_location()).into(),
});
}
@@ -153,7 +148,11 @@ impl CallingConvention {
all_params.push(FunctionParameter {
ty: ptr_ty.into(),
name: "asyncContext".to_string(),
- location: self.abi.as_ref().and_then(|a| a.async_context_location()),
+ location: self
+ .abi
+ .as_ref()
+ .and_then(|a| a.async_context_location())
+ .into(),
});
}
@@ -245,7 +244,7 @@ pub fn build_function_type(symbol: &Symbol, arch: &CoreArchitecture) -> Option<R
Some(FunctionParameter {
ty: ty.into(),
name,
- location: None,
+ location: ValueLocationSource::Default,
})
})
.collect();
@@ -288,7 +287,7 @@ fn build_accessor_type(accessor: &Accessor, arch: &CoreArchitecture) -> Option<R
let params = vec![FunctionParameter {
ty: prop_ty.into(),
name: "newValue".to_string(),
- location: None,
+ location: ValueLocationSource::Default,
}];
Some(cc.build_type(&Type::void(), params))
}
@@ -314,12 +313,12 @@ fn build_metadata_function_type(metadata: &Metadata, arch: &CoreArchitecture) ->
FunctionParameter {
ty: void_ptr.clone().into(),
name: "metadata".to_string(),
- location: None,
+ location: ValueLocationSource::Default,
},
FunctionParameter {
ty: void_ptr.clone().into(),
name: "method".to_string(),
- location: None,
+ location: ValueLocationSource::Default,
},
];
Some(Type::function(&void_ptr, params, false))
diff --git a/plugins/workflow_swift/src/demangler/type_reconstruction.rs b/plugins/workflow_swift/src/demangler/type_reconstruction.rs
index 3a3ba3e7..33e44a72 100644
--- a/plugins/workflow_swift/src/demangler/type_reconstruction.rs
+++ b/plugins/workflow_swift/src/demangler/type_reconstruction.rs
@@ -1,6 +1,8 @@
use binaryninja::architecture::{Architecture, CoreArchitecture};
use binaryninja::rc::Ref;
-use binaryninja::types::{NamedTypeReference, NamedTypeReferenceClass, QualifiedName, Type};
+use binaryninja::types::{
+ NamedTypeReference, NamedTypeReferenceClass, QualifiedName, Type, ValueLocationSource,
+};
use swift_demangler::{TypeKind, TypeRef};
pub(crate) trait TypeRefExt {
@@ -57,7 +59,7 @@ impl TypeRefExt for TypeRef<'_> {
Some(binaryninja::types::FunctionParameter {
ty: ty.into(),
name,
- location: None,
+ location: ValueLocationSource::Default,
})
})
.collect();