From 143f4a0ba14bc717825d1a08682fc863df3da850 Mon Sep 17 00:00:00 2001 From: ghizard <50744617+ghizard@users.noreply.github.com> Date: Thu, 18 Feb 2021 19:51:12 -0500 Subject: [PATCH 1/2] GP-698 check-in of ANALYZED flag fix --- .../app/plugin/core/analysis/AutoAnalysisManager.java | 8 +++++++- .../app/plugin/core/analysis/AutoAnalysisPlugin.java | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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", "" + 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. From 90dd0e6dd57c3d10cb83896cb1a338195798447e Mon Sep 17 00:00:00 2001 From: ghizard <50744617+ghizard@users.noreply.github.com> Date: Fri, 19 Feb 2021 17:05:39 -0500 Subject: [PATCH 2/2] GP-698 - ANALYZED flag fixed better --- .../plugin/core/analysis/AutoAnalysisManager.java | 15 ++++++++------- .../plugin/core/analysis/AutoAnalysisPlugin.java | 3 --- 2 files changed, 8 insertions(+), 10 deletions(-) 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 0ff7a1f3a9..d8a52fba89 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,13 +1110,14 @@ public class AutoAnalysisManager implements DomainObjectListener, DomainObjectCl int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze", "" + HTMLUtilities.escapeHTML(program.getDomainFile().getName()) + " has not been analyzed. Would you like to analyze it now?"); - 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; + //Set to false for now. ANALYZED is a tri-valued variable: + // null means not asked. + // false means asked but could still turn true when analysis happens. + // true means analysis has started. + //Setting false here only works due to this code only being reachable + // because of the behavior of GhidraProgramUtilities.shouldAskToAnalyze(program) above. + GhidraProgramUtilities.setAnalyzedFlag(program, false); + return answer == OptionDialog.OPTION_ONE; //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 96cfa1e16f..802540285e 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,9 +188,6 @@ 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; }