Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-698 check-in of ANALYZED flag fix

ghizard143f4a0ba14b
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisManager.java
index 01838c2ed7..0ff7a1f3a9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisManager.java
@@ -1110,7 +1110,13 @@ public class AutoAnalysisManager implements DomainObjectListener, DomainObjectCl
int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze",
"<html>" + HTMLUtilities.escapeHTML(program.getDomainFile().getName()) +
" has not been analyzed. Would you like to analyze it now?");
- return answer == OptionDialog.OPTION_ONE; // Analyze
+ boolean analyze = answer == OptionDialog.OPTION_ONE;
+ if (!analyze) {
+ // Must set this to false at each fall-out location. Setting it true too early
+ // results in false positives. It is set true only at the beginning of analysis.
+ GhidraProgramUtilities.setAnalyzedFlag(program, false);
+ }
+ return analyze;
}
return false;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisPlugin.java
index 13e4f68cfa..96cfa1e16f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AutoAnalysisPlugin.java
@@ -188,12 +188,17 @@ public class AutoAnalysisPlugin extends Plugin implements AutoAnalysisManagerLis
analysisMgr.initializeOptions(); // get initial options
if (!showOptionsDialog(program)) {
+ // Must set this to false at each fall-out location. Setting it true too early
+ // results in false positives. It is set true only at the beginning of analysis.
+ GhidraProgramUtilities.setAnalyzedFlag(program, false);
return;
}
- GhidraProgramUtilities.setAnalyzedFlag(program, true);
analysisMgr.initializeOptions(); // options may have changed
+ // At this point, any analysis that is done is consider to be true for analyzed.
+ GhidraProgramUtilities.setAnalyzedFlag(program, true);
+
// start analysis to set the flag, but it probably won't do more. A bit goofy but better
// than the way it was
//TODO simplify all this after creating a taskManager per program instead of per tool.