Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/qbindiff/differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,6 @@ def match_import_functions(
secondary: Program,
primary_mapping: dict[Addr, Idx],
secondary_mapping: dict[Addr, Idx],
primary_features: dict[Addr, FeatureCollector],
secondary_features: dict[Addr, FeatureCollector],
) -> None:
"""
Anchoring phase. This phase considers import functions as anchors to the matching and set these functions
Expand Down
13 changes: 8 additions & 5 deletions src/qbindiff/passes/passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def match_same_hash_functions(
secondary: Program,
primary_mapping: dict[Addr, Idx],
secondary_mapping: dict[Addr, Idx],
*,
primary_features: dict[Addr, FeatureCollector],
secondary_features: dict[Addr, FeatureCollector],
) -> None:
Expand Down Expand Up @@ -63,21 +62,25 @@ def match_same_hash_functions(
hash_map: dict[FeatureValue, tuple[set[Addr], set[Addr]]] = defaultdict(lambda: (set(), set()))

# Store the hash of the primary functions
for f1_addr in primary:
for f1_addr in primary.keys():
# If no features for this function skip it
if (p_feature := primary_features.get(f1_addr)) is None:
continue

hash_map[p_feature.get(BytesHash.key)][0].add(f1_addr)

# Store the hash of the secondary functions
for f2_addr in primary:
for f2_addr in secondary.keys():
# If no features for this function skip it
if (s_feature := secondary_features.get(f2_addr)) is None:
continue

hash_map[s_feature.get(BytesHash.key)][1].add(f2_addr)

# Remove None key
if None in hash_map:
hash_map.pop(None)

# No hash means no feature registered
if len(hash_map) == 0:
logging.warning("To use this post-pass, please use BytesHash as a feature")
Expand All @@ -92,8 +95,8 @@ def match_same_hash_functions(
continue

# Create the indexes for fast numpy access
primary_indexes = list(map(primary_mapping.get, primary_addr_set))
secondary_indexes = list(map(secondary_mapping.get, secondary_addr_set))
primary_indexes = tuple(map(primary_mapping.get, primary_addr_set))
secondary_indexes = tuple(map(secondary_mapping.get, secondary_addr_set))

# Initialize the rows and cols to zero
sim_matrix[primary_indexes, :] = 0
Expand Down