Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2829 - Fixed bug that prevented 'Repeat Memory Search' from using the current search limit option

dragonmacher495261b96c12
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
index 5dcfe23bee..0ff9d72326 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
@@ -411,6 +411,11 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
throw new OptionsVetoException("Search limit must be greater than 0");
}
searchLimit = newSearchLimit;
+
+ if (searchInfo != null) {
+ searchInfo.setSearchLimit(newSearchLimit);
+ }
+
prepopulateSearch = opt.getBoolean(PluginConstants.PRE_POPULATE_MEM_SEARCH, true);
autoRestrictSelection = opt.getBoolean(PluginConstants.AUTO_RESTRICT_SELECTION, true);
doHighlight = opt.getBoolean(PluginConstants.SEARCH_HIGHLIGHT_NAME, true);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/MemSearcherAlgorithm.java b/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/MemSearcherAlgorithm.java
index 43d07c7701..258fa2dc10 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/MemSearcherAlgorithm.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/MemSearcherAlgorithm.java
@@ -30,7 +30,7 @@ public class MemSearcherAlgorithm implements MemorySearchAlgorithm {
private boolean forwardSearch;
private SearchData searchData;
private AddressSetView searchSet;
- private int matchLimit;
+ protected int searchLimit;
private Program program;
private int alignment;
private CodeUnitSearchInfo codeUnitSearchInfo;
@@ -41,7 +41,7 @@ public class MemSearcherAlgorithm implements MemorySearchAlgorithm {
this.forwardSearch = searchInfo.isSearchForward();
this.alignment = searchInfo.getAlignment();
this.searchSet = searchSet;
- this.matchLimit = searchInfo.getMatchLimit();
+ this.searchLimit = searchInfo.getSearchLimit();
this.program = program;
this.codeUnitSearchInfo = searchInfo.getCodeUnitSearchInfo();
}
@@ -58,7 +58,7 @@ public class MemSearcherAlgorithm implements MemorySearchAlgorithm {
searchRange(accumulator, range, monitor, progressCount);
progressCount += range.getLength();
monitor.setProgress(progressCount);
- if (accumulator.size() >= matchLimit) {
+ if (accumulator.size() >= searchLimit) {
return;
}
}
@@ -78,7 +78,7 @@ public class MemSearcherAlgorithm implements MemorySearchAlgorithm {
if (isMatchingAddress(matchAddress)) {
MemSearchResult result = new MemSearchResult(matchAddress, length);
accumulator.add(result);
- if (accumulator.size() >= matchLimit) {
+ if (accumulator.size() >= searchLimit) {
return;
}
monitor.setProgress(progressCount + getRangeDifference(range, matchAddress));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/RegExMemSearcherAlgorithm.java b/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/RegExMemSearcherAlgorithm.java
index 65eb5e0d18..c9a0f41c06 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/RegExMemSearcherAlgorithm.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/RegExMemSearcherAlgorithm.java
@@ -111,7 +111,7 @@ public class RegExMemSearcherAlgorithm implements MemorySearchAlgorithm {
SearchData searchData = searchInfo.getSearchData();
Pattern pattern = ((RegExSearchData) searchData).getRegExPattern();
Memory memory = program.getMemory();
- int matchLimit = searchInfo.getMatchLimit();
+ int searchLimit = searchInfo.getSearchLimit();
try {
MemoryAddressSetCharSequence charSet =
@@ -129,7 +129,7 @@ public class RegExMemSearcherAlgorithm implements MemorySearchAlgorithm {
accumulator.add(result);
monitor.setProgress(progressCount + startIndex);
- if (accumulator.size() >= matchLimit) {
+ if (accumulator.size() >= searchLimit) {
return;
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/SearchInfo.java b/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/SearchInfo.java
index 3e5adcae52..8ea9a8ca4c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/SearchInfo.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/search/memory/SearchInfo.java
@@ -25,7 +25,7 @@ import ghidra.util.task.TaskListener;
public class SearchInfo {
private final SearchData searchData;
- private final int matchLimit;
+ private int searchLimit;
private final boolean forwardSearch;
protected final boolean searchSelection;
private final int alignment;
@@ -40,11 +40,11 @@ public class SearchInfo {
includeNonLoadedBlocks, new CodeUnitSearchInfo(true, true, true), listener);
}
- public SearchInfo(SearchData searchData, int matchLimit, boolean searchSelection,
+ public SearchInfo(SearchData searchData, int searchLimit, boolean searchSelection,
boolean forwardSearch, int alignment, boolean includeNonLoadedBlocks,
CodeUnitSearchInfo codeUnitSearchInfo, TaskListener listener) {
this.searchData = searchData;
- this.matchLimit = matchLimit;
+ this.searchLimit = searchLimit;
this.searchSelection = searchSelection;
this.forwardSearch = forwardSearch;
this.alignment = alignment;
@@ -55,7 +55,7 @@ public class SearchInfo {
/**
* Generate an address set which only includes initialized memory
- *
+ *
* @param program the program
* @param startAddress starting point for search or null to start from the top of memory
* @param selection addresses to be searched or null to search all memory
@@ -111,10 +111,6 @@ public class SearchInfo {
return alignment;
}
- public int getMatchLimit() {
- return matchLimit;
- }
-
public TaskListener getListener() {
return listener;
}
@@ -128,6 +124,10 @@ public class SearchInfo {
}
public int getSearchLimit() {
- return matchLimit;
+ return searchLimit;
+ }
+
+ public void setSearchLimit(int searchLimit) {
+ this.searchLimit = searchLimit;
}
}