Package ghidra.app.script
Class JavaScriptProvider
- java.lang.Object
-
- ghidra.app.script.GhidraScriptProvider
-
- ghidra.app.script.JavaScriptProvider
-
- All Implemented Interfaces:
ExtensionPoint,java.lang.Comparable<GhidraScriptProvider>
public class JavaScriptProvider extends GhidraScriptProvider
-
-
Constructor Summary
Constructors Change Constructor Description JavaScriptProvider()Create a newJavaScriptProviderassociated with the current bundle host used by scripting.
-
Method Summary
All Methods Instance Methods Concrete Methods Change Modifier and Type Method Description voidcreateNewScript(ResourceFile newScript, java.lang.String category)Creates a new script using the specified file.MODIFIED booleandeleteScript(ResourceFile sourceFile)Deletes the script file and unloads the script from the script manager.NEW ghidra.app.plugin.core.osgi.GhidraSourceBundlegetBundleForSource(ResourceFile sourceFile)Get theGhidraSourceBundlecontaining the given source file, assuming it already exists.java.lang.StringgetCommentCharacter()Returns the comment character.java.lang.StringgetDescription()Returns a description for this type of script.java.lang.StringgetExtension()Returns the file extension for this type of script.GhidraScriptgetScriptInstance(ResourceFile sourceFile, java.io.PrintWriter writer)Returns a GhidraScript instance for the specified source file.NEW java.lang.Class<?>loadClass(ResourceFile sourceFile, java.io.PrintWriter writer)Activate and build theGhidraSourceBundlecontainingsourceFilethen load the script's class from its class loader.REMOVED FilegetClassFile(ResourceFile sourceFile, String className) (Removed)REMOVED booleanneedsCompile(ResourceFile sourceFile, File classFile) (Removed)REMOVED booleanscriptCompiledExternally(File classFile) (Removed)REMOVED booleancompile(ResourceFile sourceFile, PrintWriter writer) (Removed)-
Methods inherited from class ghidra.app.script.GhidraScriptProvider
compareTo, equals, hashCode, toString, writeBody, writeHeader
-
-
-
-
Constructor Detail
-
JavaScriptProvider
public JavaScriptProvider()
Create a newJavaScriptProviderassociated with the current bundle host used by scripting.
-
-
Method Detail
-
getBundleForSource NEW
public ghidra.app.plugin.core.osgi.GhidraSourceBundle getBundleForSource(ResourceFile sourceFile)
Get theGhidraSourceBundlecontaining the given source file, assuming it already exists.- Parameters:
sourceFile- the source file- Returns:
- the bundle
-
getDescription
public java.lang.String 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
public java.lang.String 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
-
deleteScript MODIFIED
param 1 renamed: scriptSource → sourceFile-boolean deleteScript(generic.jar.ResourceFile scriptSource)+boolean deleteScript(generic.jar.ResourceFile sourceFile)public boolean deleteScript(ResourceFile sourceFile)
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, java.io.PrintWriter writer) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
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- Returns:
- a GhidraScript instance for the specified source file
- Throws:
java.lang.ClassNotFoundExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessException
-
loadClass NEW
public java.lang.Class<?> loadClass(ResourceFile sourceFile, java.io.PrintWriter writer) throws java.lang.Exception
Activate and build theGhidraSourceBundlecontainingsourceFilethen load the script's class from its class loader.- Parameters:
sourceFile- the source filewriter- the target for build messages- Returns:
- the loaded
Classobject - Throws:
java.lang.Exception- if build, activation, or class loading fail
-
createNewScript
public void createNewScript(ResourceFile newScript, java.lang.String category) throws java.io.IOException
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:
java.io.IOException- if an error occurs writing the file
-
getCommentCharacter
public java.lang.String getCommentCharacter()
Description copied from class:GhidraScriptProviderReturns the comment character. For example, "//" or "#".- Specified by:
getCommentCharacterin classGhidraScriptProvider- Returns:
- the comment character
-
-