GP-4244 LoadPdbTask: schedule EntryPointAnalyzer

This commit is contained in:
ghizard 2024-01-31 16:03:21 -05:00
parent 85d276bce0
commit d5470e1086
3 changed files with 28 additions and 14 deletions

View file

@ -41,7 +41,7 @@ import ghidra.util.task.TaskMonitor;
public class EntryPointAnalyzer extends AbstractAnalyzer { public class EntryPointAnalyzer extends AbstractAnalyzer {
private final static String NAME = "Disassemble Entry Points"; public final static String NAME = "Disassemble Entry Points";
private static final String DESCRIPTION = "Disassembles entry points in newly added memory."; private static final String DESCRIPTION = "Disassembles entry points in newly added memory.";
private final static String OPTION_NAME_RESPECT_EXECUTE_FLAG = "Respect Execute Flag"; private final static String OPTION_NAME_RESPECT_EXECUTE_FLAG = "Respect Execute Flag";

View file

@ -26,7 +26,7 @@ import ghidra.program.model.listing.Program;
*/ */
public class MicrosoftDemanglerAnalyzer extends AbstractDemanglerAnalyzer { public class MicrosoftDemanglerAnalyzer extends AbstractDemanglerAnalyzer {
private static final String NAME = "Demangler Microsoft"; public static final String NAME = "Demangler Microsoft";
private static final String DESCRIPTION = private static final String DESCRIPTION =
"After a function is created, this analyzer will attempt to demangle " + "After a function is created, this analyzer will attempt to demangle " +
"the name and apply datatypes to parameters."; "the name and apply datatypes to parameters.";

View file

@ -21,6 +21,7 @@ import java.lang.reflect.InvocationTargetException;
import ghidra.app.plugin.core.analysis.*; import ghidra.app.plugin.core.analysis.*;
import ghidra.app.plugin.core.datamgr.archive.DuplicateIdException; import ghidra.app.plugin.core.datamgr.archive.DuplicateIdException;
import ghidra.app.plugin.core.disassembler.EntryPointAnalyzer;
import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.bin.format.pdb.PdbException; import ghidra.app.util.bin.format.pdb.PdbException;
import ghidra.app.util.bin.format.pdb.PdbParser; import ghidra.app.util.bin.format.pdb.PdbParser;
@ -165,21 +166,34 @@ class LoadPdbTask extends Task {
AutoAnalysisManager manager = AutoAnalysisManager.getAnalysisManager(program); AutoAnalysisManager manager = AutoAnalysisManager.getAnalysisManager(program);
Options analysisProperties = program.getOptions(Program.ANALYSIS_PROPERTIES); Options analysisProperties = program.getOptions(Program.ANALYSIS_PROPERTIES);
//other planned analysis here. if (!useMsDiaParser && control == PdbApplicatorControl.ALL) {
// one-byte functions could have been laid down
scheduleDemangler(manager, analysisProperties, addrs); scheduleEntryPointAnalyzer(manager, analysisProperties, addrs);
}
if (useMsDiaParser || control != PdbApplicatorControl.DATA_TYPES_ONLY) {
// mangled symbols could have been laid down
scheduleDemanglerAnalyzer(manager, analysisProperties, addrs);
} }
private void scheduleDemangler(AutoAnalysisManager manager, Options analysisProperties, }
AddressSetView addrs) {
MicrosoftDemanglerAnalyzer demanglerAnalyzer = new MicrosoftDemanglerAnalyzer();
String analyzerName = demanglerAnalyzer.getName();
String valueAsString = analysisProperties.getValueAsString(analyzerName);
private void scheduleEntryPointAnalyzer(AutoAnalysisManager manager, Options analysisProperties,
AddressSetView addrs) {
// Only schedule analyzer if enabled // Only schedule analyzer if enabled
if (!Boolean.parseBoolean(valueAsString)) { if (!analysisProperties.getBoolean(EntryPointAnalyzer.NAME, false)) {
return; return;
} }
EntryPointAnalyzer entryPointAnalyzer = new EntryPointAnalyzer();
manager.scheduleOneTimeAnalysis(entryPointAnalyzer, addrs);
}
private void scheduleDemanglerAnalyzer(AutoAnalysisManager manager, Options analysisProperties,
AddressSetView addrs) {
// Only schedule analyzer if enabled
if (!analysisProperties.getBoolean(MicrosoftDemanglerAnalyzer.NAME, false)) {
return;
}
MicrosoftDemanglerAnalyzer demanglerAnalyzer = new MicrosoftDemanglerAnalyzer();
manager.scheduleOneTimeAnalysis(demanglerAnalyzer, addrs); manager.scheduleOneTimeAnalysis(demanglerAnalyzer, addrs);
} }