Skip to content
Merged
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
15 changes: 8 additions & 7 deletions PyMemoryEditor/util/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ def scan_memory_for_exact_value(

This method uses an efficient searching algorithm.
"""
searcher = KMPSearch(target_value, target_value_size)
data = bytes(memory_region_data)
last_index = 0
found_index = data.find(target_value, 0)

for found_index in searcher.search(memory_region_data, memory_region_data_size):

while found_index != -1:
# Return the found index if user is searching for an exact value.
if comparison is ScanTypesEnum.EXACT_VALUE:
yield found_index
continue

# Return the interval between last_index and found_address, if user is searching for a different value.
for different_index in range(last_index, found_index):
yield different_index
last_index = found_index + 1
elif comparison is ScanTypesEnum.NOT_EXACT_VALUE:
for different_index in range(last_index, found_index):
yield different_index
last_index = found_index + 1
found_index = data.find(target_value, found_index+1)

# If user is searching for a different value, return the rest of the addresses that were not found.
if comparison is ScanTypesEnum.NOT_EXACT_VALUE:
Expand Down