mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-01 13:14:25 +08:00
Merge remote-tracking branch 'origin/GP-1860_ghidravore_opening_unanalyzed_program_with_connected_tools--SQUASHED'
This commit is contained in:
+7
-14
@@ -1099,24 +1099,17 @@ public class AutoAnalysisManager implements DomainObjectListener, DomainObjectCl
|
||||
}
|
||||
|
||||
boolean askToAnalyze(PluginTool tool) {
|
||||
if (program == null) {
|
||||
return false;
|
||||
}
|
||||
//if program has just been instantiated, then we can analyze it.
|
||||
if (!program.canSave() && !program.isChanged()) {
|
||||
return false;
|
||||
}
|
||||
// This code relies on being called in the swing thread to avoid a race condition
|
||||
// where multiple threads check the flag before either thread has a chance to set it.
|
||||
Swing.assertSwingThread("Asking to analyze must be on the swing thread!");
|
||||
|
||||
if (GhidraProgramUtilities.shouldAskToAnalyze(program)) {
|
||||
// initialize the analyzed flag to a non-null value to indicate we at least asked
|
||||
GhidraProgramUtilities.setAnalyzedFlag(program, false);
|
||||
|
||||
int answer = OptionDialog.showYesNoDialog(tool.getToolFrame(), "Analyze",
|
||||
"<html>" + HTMLUtilities.escapeHTML(program.getDomainFile().getName()) +
|
||||
" has not been analyzed. Would you like to analyze it now?");
|
||||
//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;
|
||||
|
||||
@@ -20,10 +20,6 @@ import ghidra.framework.options.Options;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.program.model.listing.Program;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class GhidraProgramUtilities {
|
||||
private GhidraProgramUtilities() {
|
||||
}
|
||||
@@ -38,21 +34,19 @@ public class GhidraProgramUtilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the program does not contain the analyzed flag.
|
||||
* Returns true if the program does not contain the analyzed flag. The assumption is that a
|
||||
* non-null value means that the user has already made a decision about analyzing.
|
||||
*
|
||||
* @param program the program to check for the property
|
||||
* @return true if the program does not contain the analyzed flag
|
||||
*/
|
||||
public static boolean shouldAskToAnalyze(Program program) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat(Program.ANALYSIS_START_DATE_FORMAT);
|
||||
Date analysisStartDate = format.parse(Program.ANALYSIS_START_DATE);
|
||||
Date creationDate = program.getCreationDate();
|
||||
if (creationDate.compareTo(analysisStartDate) < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (ParseException e) {
|
||||
|
||||
// no need to ask if the program can't be saved (i.e. read-only)
|
||||
if (program == null || !program.canSave()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Options options = program.getOptions(Program.PROGRAM_INFO);
|
||||
return !options.contains(Program.ANALYZED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user