Package ghidra.app.script
Class GhidraScriptUtil
- java.lang.Object
-
- ghidra.app.script.GhidraScriptUtil
-
public class GhidraScriptUtil extends java.lang.ObjectA utility class for managing script directories and ScriptInfo objects.
-
-
Field Summary
Fields Change Modifier and Type Field Description static java.lang.StringUSER_SCRIPTS_DIRUser's home scripts directoryREMOVED USER_SCRIPTS_BIN_DIR() (Removed)
-
Constructor Summary
Constructors Change Constructor Description GhidraScriptUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Change Modifier and Type Method Description NEW static ghidra.app.plugin.core.osgi.BundleHostacquireBundleHostReference()When running the GUI,GhidraScriptUtilmanages a singleBundleHostinstance.static ResourceFilecreateNewScript(GhidraScriptProvider provider, ResourceFile parentDirectory, java.util.List<ResourceFile> scriptDirectories)Creates a new script with a unique name using the specified provider in the specified directory.NEW static voiddispose()dispose of the bundle host and providers listMODIFIED static ResourceFilefindScriptByName(java.lang.String scriptName)Search the currently managed scripts for one with the given name.NEW static ResourceFilefindSourceDirectoryContaining(ResourceFile sourceFile)Search the currently managed source directories for the given script file.static java.lang.StringgetBaseName(ResourceFile script)Returns the base name give a script file.NEW static ghidra.app.plugin.core.osgi.BundleHostgetBundleHost()NEW static java.util.List<ResourceFile>getExplodedCompiledSourceBundlePaths()Deprecated.accessing class file directly precludes OSGi wiring according to requirements and capabilitiesstatic GhidraScriptProvidergetProvider(ResourceFile scriptFile)Returns the corresponding Ghidra script providers for the specified script file.static java.util.List<GhidraScriptProvider>getProviders()Returns a list of all Ghidra script providersstatic java.util.List<ResourceFile>getScriptSourceDirectories()Returns a list of the current script directories.NEW static java.util.List<ResourceFile>getSystemScriptDirectories()Returns a list of the default script directories.NEW static ResourceFilegetUserScriptDirectory()static booleanhasScriptProvider(ResourceFile scriptFile)Returns true if a provider exists that can process the specified file.static voidinitialize(ghidra.app.plugin.core.osgi.BundleHost aBundleHost, java.util.List<java.lang.String> extraSystemPaths)initialize state of GhidraScriptUtil with user, system paths, and optional extra system paths.NEW static booleanisSystemScript(ResourceFile file)Determine if the specified file is contained within the Ghidra installation.NEW static ScriptInfonewScriptInfo(ResourceFile file)NEW static voidreleaseBundleHostReference()release the reference the BundleHost reference.REMOVED voidrefreshRequested() (Removed)REMOVED longgetLastRefreshRequestTimestamp() (Removed)REMOVED List<Path>getDefaultScriptDirectories() (Removed)REMOVED booleanisSystemScriptPath(ResourceFile file) (Removed)REMOVED PathgetScriptPath(ResourceFile directory) (Removed)REMOVED ResourceFilegetScriptCompileOutputDirectory(ResourceFile scriptFile) (Removed)REMOVED List<ResourceFile>getScriptBinDirectories() (Removed)REMOVED voidclean() (Removed)REMOVED booleancontains(ResourceFile scriptFile) (Removed)REMOVED voidunloadScript(ResourceFile scriptFile) (Removed)REMOVED Iterator<ScriptInfo>getScriptInfoIterator() (Removed)REMOVED ScriptInfogetScriptInfo(ResourceFile scriptFile) (Removed)REMOVED List<ResourceFile>getAllScripts() (Removed)REMOVED booleanalreadyExists(String scriptName) (Removed)REMOVED ScriptInfogetExistingScriptInfo(String scriptName) (Removed)REMOVED booleanrunScript(GhidraState scriptState, GhidraScript script, PrintWriter writer, Object originator, TaskMonitor monitor) (Removed)REMOVED voidrefreshDuplicates() (Removed)
-
-
-
Method Detail
-
getBundleHost NEW
public static ghidra.app.plugin.core.osgi.BundleHost getBundleHost()
- Returns:
- the bundle host used for scripting
-
initialize
public static void initialize(ghidra.app.plugin.core.osgi.BundleHost aBundleHost, java.util.List<java.lang.String> extraSystemPaths)initialize state of GhidraScriptUtil with user, system paths, and optional extra system paths.- Parameters:
aBundleHost- the host to useextraSystemPaths- additional system paths for this run, can be null
-
getScriptSourceDirectories
public static java.util.List<ResourceFile> getScriptSourceDirectories()
Returns a list of the current script directories.- Returns:
- a list of the current script directories
-
findSourceDirectoryContaining NEW
public static ResourceFile findSourceDirectoryContaining(ResourceFile sourceFile)
Search the currently managed source directories for the given script file.- Parameters:
sourceFile- the source file- Returns:
- the source directory if found, or null if not
-
findScriptByName MODIFIED
param 1 renamed: name → scriptName; return type: ScriptInfo → ResourceFile-static ghidra.app.script.ScriptInfo findScriptByName(java.lang.String name)+static generic.jar.ResourceFile findScriptByName(java.lang.String scriptName)public static ResourceFile findScriptByName(java.lang.String scriptName)
Search the currently managed scripts for one with the given name.- Parameters:
scriptName- the name- Returns:
- the first file found or null if none are found
-
getSystemScriptDirectories NEW
public static java.util.List<ResourceFile> getSystemScriptDirectories()
Returns a list of the default script directories.- Returns:
- a list of the default script directories
-
getUserScriptDirectory NEW
public static ResourceFile getUserScriptDirectory()
-
isSystemScript NEW
public static boolean isSystemScript(ResourceFile file)
Determine if the specified file is contained within the Ghidra installation.- Parameters:
file- script file or directory- Returns:
- true if file contained within Ghidra installation area
-
getExplodedCompiledSourceBundlePaths NEW
@Deprecated public static java.util.List<ResourceFile> getExplodedCompiledSourceBundlePaths()
Deprecated.accessing class file directly precludes OSGi wiring according to requirements and capabilitiesReturns the list of exploded bundle directories- Returns:
- the list
-
getBaseName
public static java.lang.String getBaseName(ResourceFile script)
Returns the base name give a script file. For example, given "C:\Temp\SomeClass.java", it will return "SomeClass".- Parameters:
script- the script- Returns:
- the base name
-
getProviders
public static java.util.List<GhidraScriptProvider> getProviders()
Returns a list of all Ghidra script providers- Returns:
- a list of all Ghidra script providers
-
getProvider
public static GhidraScriptProvider getProvider(ResourceFile scriptFile)
Returns the corresponding Ghidra script providers for the specified script file.- Parameters:
scriptFile- the script file- Returns:
- the Ghidra script provider
-
hasScriptProvider
public static boolean hasScriptProvider(ResourceFile scriptFile)
Returns true if a provider exists that can process the specified file.- Parameters:
scriptFile- the script file- Returns:
- true if a provider exists that can process the specified file
-
createNewScript
public static ResourceFile createNewScript(GhidraScriptProvider provider, ResourceFile parentDirectory, java.util.List<ResourceFile> scriptDirectories) throws java.io.IOException
Creates a new script with a unique name using the specified provider in the specified directory.- Parameters:
provider- the Ghidra script providerparentDirectory- the directory where the new script will be created.scriptDirectories- The list of directories containing scripts (used to find a unique name).- Returns:
- the newly created script file
- Throws:
java.io.IOException- if an i/o error occurs
-
newScriptInfo NEW
public static ScriptInfo newScriptInfo(ResourceFile file)
-
acquireBundleHostReference NEW
public static ghidra.app.plugin.core.osgi.BundleHost acquireBundleHostReference()
When running the GUI,GhidraScriptUtilmanages a singleBundleHostinstance.- Returns:
- the BundleHost singleton
-
releaseBundleHostReference NEW
public static void releaseBundleHostReference()
release the reference the BundleHost reference. When no references remain,dispose()is called.
-
-