mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-1689 - Added analysis options update mechanism to allow for changing option names and types
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package ghidra.feature.fid.analyzer;
|
||||
|
||||
import ghidra.app.plugin.core.analysis.AnalysisOptionsUpdater;
|
||||
import ghidra.app.plugin.core.analysis.AutoAnalysisManager;
|
||||
import ghidra.app.services.*;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
@@ -42,7 +43,8 @@ public class FidAnalyzer extends AbstractAnalyzer {
|
||||
private static final String OPTION_DESCRIPTION_CREATE_BOOKMARKS =
|
||||
"If checked, an analysis bookmark will be created for each function which was matched " +
|
||||
"against one or more known library functions.";
|
||||
public static final String APPLY_ALL_FID_LABELS_OPTION_NAME = "Always apply FID labels";
|
||||
|
||||
public static final String APPLY_ALL_FID_LABELS_OPTION_NAME = "Always Apply FID Labels";
|
||||
private static final String APPLY_ALL_FID_LABELS_OPTION_DESCRIPTION = "Enable this option to " +
|
||||
"always apply FID labels at functions regardless of existing labels at that function." +
|
||||
" When enabled, FID labels will always be added." +
|
||||
@@ -57,18 +59,33 @@ public class FidAnalyzer extends AbstractAnalyzer {
|
||||
private boolean alwaysApplyFidLabels = APPLY_ALL_FID_LABELS_DEFAULT;
|
||||
private boolean createBookmarksEnabled = OPTION_DEFAULT_CREATE_BOOKMARKS_ENABLED;
|
||||
|
||||
public static final String SCORE_THRESHOLD_OPTION_NAME = "Instruction count threshold";
|
||||
private static final String SCORE_THRESHOLD_OPTION_NAME = "Instruction Count Threshold";
|
||||
|
||||
private static final String SCORE_THRESHOLD_OPTION_DESCRIPTION =
|
||||
"The minimum score that a potential match must meet to be labeled by the analyzer. " +
|
||||
"Score corresponds roughly to the number of instructions in the function.";
|
||||
private float scoreThreshold;
|
||||
|
||||
public static final String MULTIMATCH_THRESHOLD_OPTION_NAME = "Multiple match threshold";
|
||||
private static final String MULTIMATCH_THRESHOLD_OPTION_NAME = "Multiple Match Threshold";
|
||||
private static final String MULTIMATCH_THRESHOLD_OPTION_DESCRIPTION =
|
||||
"If there are multiple conflicting matches for a function, its score must exceed " +
|
||||
"this secondary threshold in order to be labeled by the analyzer";
|
||||
private float multiScoreThreshold;
|
||||
|
||||
//==================================================================================================
|
||||
// Old Option Names - Should stick around for multiple major versions after 10.2
|
||||
//==================================================================================================
|
||||
|
||||
private static final String SCORE_THRESHOLD_OPTION_NAME_OLD = "Instruction count threshold";
|
||||
private static final String MULTIMATCH_THRESHOLD_OPTION_NAME_OLD = "Multiple match threshold";
|
||||
private static final String APPLY_ALL_FID_LABELS_OPTION_NAME_OLD = "Always apply FID labels";
|
||||
|
||||
private AnalysisOptionsUpdater optionsUpdater = new AnalysisOptionsUpdater();
|
||||
|
||||
//==================================================================================================
|
||||
// End Old Option Names
|
||||
//==================================================================================================
|
||||
|
||||
public FidAnalyzer() {
|
||||
/*
|
||||
* FID is listed as a byte analyzer because we don't want to run it all the time. It
|
||||
@@ -86,6 +103,13 @@ public class FidAnalyzer extends AbstractAnalyzer {
|
||||
setPriority(AnalysisPriority.FUNCTION_ID_ANALYSIS.before());
|
||||
scoreThreshold = service.getDefaultScoreThreshold();
|
||||
multiScoreThreshold = service.getDefaultMultiNameThreshold();
|
||||
|
||||
optionsUpdater.registerReplacement(SCORE_THRESHOLD_OPTION_NAME,
|
||||
SCORE_THRESHOLD_OPTION_NAME_OLD);
|
||||
optionsUpdater.registerReplacement(MULTIMATCH_THRESHOLD_OPTION_NAME,
|
||||
MULTIMATCH_THRESHOLD_OPTION_NAME_OLD);
|
||||
optionsUpdater.registerReplacement(APPLY_ALL_FID_LABELS_OPTION_NAME,
|
||||
APPLY_ALL_FID_LABELS_OPTION_NAME_OLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,8 +136,9 @@ public class FidAnalyzer extends AbstractAnalyzer {
|
||||
|
||||
// Name Change can change the nature of a function from a system
|
||||
// library. Probably a better way to do this.
|
||||
AutoAnalysisManager.getAnalysisManager(program).functionModifierChanged(
|
||||
cmd.getFIDLocations());
|
||||
AutoAnalysisManager.getAnalysisManager(program)
|
||||
.functionModifierChanged(
|
||||
cmd.getFIDLocations());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,6 +154,11 @@ public class FidAnalyzer extends AbstractAnalyzer {
|
||||
OPTION_DESCRIPTION_CREATE_BOOKMARKS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalysisOptionsUpdater getOptionsUpdater() {
|
||||
return optionsUpdater;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optionsChanged(Options options, Program program) {
|
||||
scoreThreshold =
|
||||
|
||||
Reference in New Issue
Block a user