diff options
| author | Mason Reed <mason@vector35.com> | 2025-08-26 23:43:32 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-09-03 21:19:03 +0000 |
| commit | 47e0f1f685119ebffecbb99d2cce35c53a384738 (patch) | |
| tree | 4c2f2a012ecf324fd0f56d3f06987d14c412103a /plugins/warp/src/cache | |
| parent | b157aa0a337dc89d6817f2a26d2c3dd1e44efc9a (diff) | |
[WARP] Fix generating lifted IL when function GUID is already cached
We do not need to consult the lifted IL if we have already cached the function GUID in the function metadata
Diffstat (limited to 'plugins/warp/src/cache')
| -rw-r--r-- | plugins/warp/src/cache/guid.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/plugins/warp/src/cache/guid.rs b/plugins/warp/src/cache/guid.rs index f1788a33..df215554 100644 --- a/plugins/warp/src/cache/guid.rs +++ b/plugins/warp/src/cache/guid.rs @@ -4,28 +4,35 @@ use crate::function_guid; use binaryninja::binary_view::BinaryViewExt; use binaryninja::function::Function as BNFunction; use binaryninja::low_level_il::function::{FunctionMutability, LowLevelILFunction, NonSSA}; +use binaryninja::rc::Ref as BNRef; use binaryninja::symbol::Symbol as BNSymbol; use std::collections::HashSet; use uuid::Uuid; use warp::signature::constraint::Constraint; use warp::signature::function::FunctionGUID; +/// Try to get the cached function GUID from the metadata. +/// +/// If not cached, we will use `lifted_il_accessor` to retrieve the lifted IL and create the GUID. +/// +/// `lifted_il_accessor` exists as it is to allow the retrieval of a cached GUID without incurring +/// the cost of building the IL (if it no longer exists). pub fn cached_function_guid<M: FunctionMutability>( function: &BNFunction, - lifted_il: &LowLevelILFunction<M, NonSSA>, -) -> FunctionGUID { + lifted_il_accessor: impl Fn() -> Option<BNRef<LowLevelILFunction<M, NonSSA>>>, +) -> Option<FunctionGUID> { let cached_guid = try_cached_function_guid(function); if let Some(cached_guid) = cached_guid { - return cached_guid; + return Some(cached_guid); } - let function_guid = function_guid(function, lifted_il); + let function_guid = function_guid(function, lifted_il_accessor()?.as_ref()); function.store_metadata( "warp_function_guid", &function_guid.as_bytes().to_vec(), false, ); - function_guid + Some(function_guid) } pub fn try_cached_function_guid(function: &BNFunction) -> Option<FunctionGUID> { |
