summaryrefslogtreecommitdiff
path: root/plugins/warp/src/matcher.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-11-29 15:04:05 -0500
committerMason Reed <mason@vector35.com>2025-12-15 17:26:10 -0500
commit81b2d4d06826abc2bbfb658831643c69e453c461 (patch)
treedd5d51a72772236a494cdeebf74e25ebf41d069e /plugins/warp/src/matcher.rs
parent58cc21e4fae58cedd586497a220a0bbe285ef831 (diff)
[WARP] Allow multi-round matching to resolve matching function dependencies
Fixes some possible nondeterminism due to parallelized matching
Diffstat (limited to 'plugins/warp/src/matcher.rs')
-rw-r--r--plugins/warp/src/matcher.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/warp/src/matcher.rs b/plugins/warp/src/matcher.rs
index 48adee3a..f96128e5 100644
--- a/plugins/warp/src/matcher.rs
+++ b/plugins/warp/src/matcher.rs
@@ -312,6 +312,10 @@ pub struct MatcherSettings {
///
/// This is set to [MatcherSettings::MAXIMUM_POSSIBLE_FUNCTIONS_DEFAULT] by default.
pub maximum_possible_functions: Option<u64>,
+ /// The maximum number of matching rounds to run, consecutive rounds are ran until no new matched functions are found.
+ ///
+ /// This is set to [MatcherSettings::MAXIMUM_MATCHING_ROUNDS_DEFAULT] by default.
+ pub maximum_matching_rounds: Option<u64>,
}
impl MatcherSettings {
@@ -342,6 +346,9 @@ impl MatcherSettings {
pub const MAXIMUM_POSSIBLE_FUNCTIONS_SETTING: &'static str =
"warp.matcher.maximumPossibleFunctions";
pub const MAXIMUM_POSSIBLE_FUNCTIONS_DEFAULT: u64 = 1000;
+ pub const MAXIMUM_MATCHING_ROUNDS_SETTING: &'static str = "warp.matcher.maximumMatchingRounds";
+ pub const MAXIMUM_MATCHING_ROUNDS_DEFAULT: u64 = 0;
+
/// Populates the [MatcherSettings] to the current Binary Ninja settings instance.
///
/// Call this once when you initialize so that the settings exist.
@@ -426,6 +433,18 @@ impl MatcherSettings {
Self::MAXIMUM_POSSIBLE_FUNCTIONS_SETTING,
&maximum_possible_functions_props.to_string(),
);
+
+ let maximum_matching_rounds_props = json!({
+ "title" : "Maximum Matching Rounds",
+ "type" : "number",
+ "default" : Self::MAXIMUM_MATCHING_ROUNDS_DEFAULT,
+ "description" : "The maximum number of matching rounds to run, consecutive rounds are ran until no new matched functions are found. A value of 0 will disable this check.",
+ "ignore" : [],
+ });
+ bn_settings.register_setting_json(
+ Self::MAXIMUM_MATCHING_ROUNDS_SETTING,
+ &maximum_matching_rounds_props.to_string(),
+ );
}
/// Retrieve matcher settings from [`BNSettings`].
@@ -463,6 +482,14 @@ impl MatcherSettings {
len => settings.maximum_possible_functions = Some(len),
}
}
+ if bn_settings.contains(Self::MAXIMUM_MATCHING_ROUNDS_SETTING) {
+ match bn_settings
+ .get_integer_with_opts(Self::MAXIMUM_MATCHING_ROUNDS_SETTING, query_opts)
+ {
+ 0 => settings.maximum_matching_rounds = None,
+ len => settings.maximum_matching_rounds = Some(len),
+ }
+ }
settings
}
}
@@ -477,6 +504,7 @@ impl Default for MatcherSettings {
trivial_function_adjacent_allowed:
MatcherSettings::TRIVIAL_FUNCTION_ADJACENT_ALLOWED_DEFAULT,
maximum_possible_functions: Some(MatcherSettings::MAXIMUM_POSSIBLE_FUNCTIONS_DEFAULT),
+ maximum_matching_rounds: Some(MatcherSettings::MAXIMUM_MATCHING_ROUNDS_DEFAULT),
}
}
}