Class JavaScriptProvider

    • Constructor Detail

      • JavaScriptProvider

        public JavaScriptProvider()
        Create a new JavaScriptProvider associated with the current bundle host used by scripting.
    • Method Detail

      • getBundleForSource

        public ghidra.app.plugin.core.osgi.GhidraSourceBundle getBundleForSource​(ResourceFile sourceFile)
        Get the GhidraSourceBundle containing the given source file, assuming it already exists.
        Parameters:
        sourceFile - the source file
        Returns:
        the bundle
      • getExtension

        public java.lang.String getExtension()
        Description copied from class: GhidraScriptProvider
        Returns the file extension for this type of script. For example, ".java" or ".py".
        Specified by:
        getExtension in class GhidraScriptProvider
        Returns:
        the file extension for this type of script
      • deleteScript

        public boolean deleteScript​(ResourceFile sourceFile)
        Description copied from class: GhidraScriptProvider
        Deletes the script file and unloads the script from the script manager.
        Overrides:
        deleteScript in class GhidraScriptProvider
        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: GhidraScriptProvider
        Returns a GhidraScript instance for the specified source file.
        Specified by:
        getScriptInstance in class GhidraScriptProvider
        Parameters:
        sourceFile - the source file
        writer - the print writer to write warning/error messages
        Returns:
        a GhidraScript instance for the specified source file
        Throws:
        java.lang.ClassNotFoundException
        java.lang.InstantiationException
        java.lang.IllegalAccessException
      • loadClass

        public java.lang.Class<?> loadClass​(ResourceFile sourceFile,
                                            java.io.PrintWriter writer)
                                     throws java.lang.Exception
        Activate and build the GhidraSourceBundle containing sourceFile then load the script's class from its class loader.
        Parameters:
        sourceFile - the source file
        writer - the target for build messages
        Returns:
        the loaded Class object
        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: GhidraScriptProvider
        Creates a new script using the specified file.
        Specified by:
        createNewScript in class GhidraScriptProvider
        Parameters:
        newScript - the new script file
        category - the script category
        Throws:
        java.io.IOException - if an error occurs writing the file