From 47e0f1f685119ebffecbb99d2cce35c53a384738 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 26 Aug 2025 23:43:32 -0400 Subject: [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 --- plugins/warp/src/cache/guid.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'plugins/warp/src/cache') 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( function: &BNFunction, - lifted_il: &LowLevelILFunction, -) -> FunctionGUID { + lifted_il_accessor: impl Fn() -> Option>>, +) -> Option { 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 { -- cgit v1.3.1