Package ghidra.app.util.headless
Class HeadlessAnalyzer
java.lang.Object
ghidra.app.util.headless.HeadlessAnalyzer
The class used kick-off and interact with headless processing. All headless options have been
broken out into their own class:
HeadlessOptions
. This class is intended to be used
one of two ways:
- Used by
AnalyzeHeadless
to perform headless analysis based on arguments specified on the command line. - Used by another tool as a library to perform headless analysis.
Note: This class is not thread safe.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks to see if the most recent analysis timed out.static HeadlessAnalyzer
Gets a headless analyzer instance, with the assumption that the application has already been initialized.static HeadlessAnalyzer
getLoggableInstance
(File logFile, File scriptLogFile, boolean useLog4j) Gets a headless analyzer, initializing the application if necessary with the specified logging parameters.Gets the headless analyzer's options.void
processLocal
(String projectLocation, String projectName, String rootFolderPath, List<File> filesToImport) Process the optional import file/directory list and process each imported file: execute ordered list of pre-scripts perform auto-analysis if not disabled execute ordered list of post-scripts If no import files or directories have been specified the ordered list of pre/post scripts will be executed once.void
processURL
(URL ghidraURL, List<File> filesToImport) Process the optional import file/directory list and process each imported file: execute ordered list of pre-scripts perform auto-analysis if not disabled execute ordered list of post-scripts If no import files or directories have been specified the ordered list of pre/post scripts will be executed once.void
reset()
Resets the state of the headless analyzer to the default settings.
-
Method Details
-
getLoggableInstance
public static HeadlessAnalyzer getLoggableInstance(File logFile, File scriptLogFile, boolean useLog4j) throws IllegalStateException, IOException Gets a headless analyzer, initializing the application if necessary with the specified logging parameters. AnIllegalStateException
will be thrown if the application has already been initialized or a headless analyzer has already been retrieved. In these cases, the headless analyzer should be gotten withgetInstance()
.- Parameters:
logFile
- The desired application log file. If null, the default application log file will be used (seeApplication.initializeLogging()
).scriptLogFile
- The desired scripting log file. If null, the default scripting log file will be used (seeApplication.initializeLogging()
).useLog4j
- true if log4j is to be used; otherwise, false. If this class is being used by another tool as a library, using log4j might interfere with that tool.- Returns:
- An instance of a new headless analyzer.
- Throws:
IllegalStateException
- if an application or headless analyzer instance has already been initialized.IOException
- if there was a problem reading the application.properties file.
-
getInstance
Gets a headless analyzer instance, with the assumption that the application has already been initialized. If this is called before the application has been initialized, it will initialize the application with no logging.- Returns:
- An instance of a new headless analyzer.
- Throws:
IOException
- if there was a problem reading the application.properties file (only possible if the application had not be initialized).
-
reset
public void reset()Resets the state of the headless analyzer to the default settings. -
getOptions
Gets the headless analyzer's options.- Returns:
- The headless analyer's options.
-
processURL
public void processURL(URL ghidraURL, List<File> filesToImport) throws IOException, MalformedURLException Process the optional import file/directory list and process each imported file:- execute ordered list of pre-scripts
- perform auto-analysis if not disabled
- execute ordered list of post-scripts
- Parameters:
ghidraURL
- ghidra URL for existing server repository and optional folder pathfilesToImport
- directories and files to be imported (null or empty is acceptable if we are in -process mode)- Throws:
IOException
- if there was an IO-related problemMalformedURLException
- specified URL is invalid
-
processLocal
public void processLocal(String projectLocation, String projectName, String rootFolderPath, List<File> filesToImport) throws IOException Process the optional import file/directory list and process each imported file:- execute ordered list of pre-scripts
- perform auto-analysis if not disabled
- execute ordered list of post-scripts
- Parameters:
projectLocation
- directory path of project If project exists it will be opened, otherwise it will be created.projectName
- project namerootFolderPath
- root folder for importsfilesToImport
- directories and files to be imported (null or empty is acceptable if we are in -process mode)- Throws:
IOException
- if there was an IO-related problem. If caused by a failure to obtain a write-lock on the project the exception cause will aLockException
.
-
checkAnalysisTimedOut
public boolean checkAnalysisTimedOut()Checks to see if the most recent analysis timed out.- Returns:
- true if the most recent analysis timed out; otherwise, false.
-