Class JavaScriptProvider
- All Implemented Interfaces:
ExtensionPoint,Comparable<GhidraScriptProvider>
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a newJavaScriptProviderassociated with the current bundle host used by scripting. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateNewScript(ResourceFile newScript, String category) Creates a new script using the specified file.booleandeleteScript(ResourceFile sourceFile) Deletes the script file and unloads the script from the script manager.protected StringFixup a script name for searching in script directories.Returns a Pattern that matches block comment closings.Returns a Pattern that matches block comment openings.ghidra.app.plugin.core.osgi.GhidraSourceBundlegetBundleForSource(ResourceFile sourceFile) Get theGhidraSourceBundlecontaining the given source file, assuming it already exists.protected StringReturn the prefix for each certification header body line if this file is subject to certification.protected StringReturn the end of certification header line if this file type is subject to certification.protected StringReturn the start of certification header line if this file type is subject to certification.Returns the comment character.Returns a description for this type of script.Returns the file extension for this type of script.Returns an optional runtime environment name of aGhidraScriptProviderthat scripts can specify they require to run under.getScriptInstance(ResourceFile sourceFile, PrintWriter writer) Returns a GhidraScript instance for the specified source file.Class<?> loadClass(ResourceFile sourceFile, PrintWriter writer) Activate and build theGhidraSourceBundlecontainingsourceFilethen load the script's class from its class loader.Methods inherited from class ghidra.app.script.GhidraScriptProvider
compareTo, equals, hashCode, toString, writeBody, writeHeader
-
Constructor Details
-
JavaScriptProvider
public JavaScriptProvider()Create a newJavaScriptProviderassociated with the current bundle host used by scripting.
-
-
Method Details
-
getBundleForSource
Get theGhidraSourceBundlecontaining the given source file, assuming it already exists.- Parameters:
sourceFile- the source file- Returns:
- the bundle
-
getDescription
Description copied from class:GhidraScriptProviderReturns a description for this type of script.- Specified by:
getDescriptionin classGhidraScriptProvider- Returns:
- a description for this type of script
-
getExtension
Description copied from class:GhidraScriptProviderReturns the file extension for this type of script.For example, ".java" or ".py".
- Specified by:
getExtensionin classGhidraScriptProvider- Returns:
- the file extension for this type of script
-
getRuntimeEnvironmentName
Description copied from class:GhidraScriptProviderReturns an optional runtime environment name of aGhidraScriptProviderthat scripts can specify they require to run under. Useful for when more than oneGhidraScriptProvideruses the same file extension.- Overrides:
getRuntimeEnvironmentNamein classGhidraScriptProvider- Returns:
- an optional runtime environment name of a
GhidraScriptProviderthat scripts can specify they require to run under (could be null if there is no requirement) - See Also:
-
deleteScript
Description copied from class:GhidraScriptProviderDeletes the script file and unloads the script from the script manager.- Overrides:
deleteScriptin classGhidraScriptProvider- Parameters:
sourceFile- the script source file- Returns:
- true if the script was completely deleted and cleaned up
-
getScriptInstance
public GhidraScript getScriptInstance(ResourceFile sourceFile, PrintWriter writer) throws GhidraScriptLoadException Description copied from class:GhidraScriptProviderReturns a GhidraScript instance for the specified source file.- Specified by:
getScriptInstancein classGhidraScriptProvider- Parameters:
sourceFile- the source filewriter- the print writer to write warning/error messages. If the error prevents success, throw an exception instead. The caller will print the error.- Returns:
- a GhidraScript instance for the specified source file
- Throws:
GhidraScriptLoadException- when the script instance cannot be created
-
loadClass
Activate and build theGhidraSourceBundlecontainingsourceFilethen load the script's class from its class loader. -
createNewScript
Description copied from class:GhidraScriptProviderCreates a new script using the specified file.- Specified by:
createNewScriptin classGhidraScriptProvider- Parameters:
newScript- the new script filecategory- the script category- Throws:
IOException- if an error occurs writing the file
-
getBlockCommentStart
Returns a Pattern that matches block comment openings.If block comments are not supported by this provider, then this returns null.
For Java this is "/*".
- Overrides:
getBlockCommentStartin classGhidraScriptProvider- Returns:
- the Pattern for block comment openings, null if block comments are not supported
-
getBlockCommentEnd
Returns a Pattern that matches block comment closings.If block comments are not supported by this provider, then this returns null.
In Java this is an asterisk followed by a forward slash.
- Overrides:
getBlockCommentEndin classGhidraScriptProvider- Returns:
- the Pattern for block comment closings, null if block comments are not supported
-
getCommentCharacter
Description copied from class:GhidraScriptProviderReturns the comment character.For example, "//" or "#".
- Specified by:
getCommentCharacterin classGhidraScriptProvider- Returns:
- the comment character
-
getCertifyHeaderStart
Description copied from class:GhidraScriptProviderReturn the start of certification header line if this file type is subject to certification.- Overrides:
getCertifyHeaderStartin classGhidraScriptProvider- Returns:
- start of certification header or null if not supported
-
getCertifyHeaderEnd
Description copied from class:GhidraScriptProviderReturn the end of certification header line if this file type is subject to certification.- Overrides:
getCertifyHeaderEndin classGhidraScriptProvider- Returns:
- end of certification header or null if not supported
-
getCertificationBodyPrefix
Description copied from class:GhidraScriptProviderReturn the prefix for each certification header body line if this file is subject to certification.- Overrides:
getCertificationBodyPrefixin classGhidraScriptProvider- Returns:
- certification header body prefix or null if not supported
-
fixupName
Fixup a script name for searching in script directories.This method is part of a poorly specified behavior that is due for future amendment, see
GhidraScriptUtil.fixupName(String).Fix script name for search in script directories, such as Java package parts in the name and inner class names.
This method can handle names with '$' (inner classes) and names with '.' characters for package separators
It is part of a poorly specified behavior that is due for future amendment, see
GhidraScriptUtil.fixupName(String).- Overrides:
fixupNamein classGhidraScriptProvider- Parameters:
scriptName- the name of the script- Returns:
- the name as a '.java' file path (with '/'s and not '.'s)
-