Class AbstractPythonScriptProvider

java.lang.Object
ghidra.app.script.GhidraScriptProvider
ghidra.app.script.AbstractPythonScriptProvider
All Implemented Interfaces:
ExtensionPoint, Comparable<GhidraScriptProvider>
Direct Known Subclasses:
JythonScriptProvider

public abstract class AbstractPythonScriptProvider extends GhidraScriptProvider
An abstract GhidraScriptProvider used to provide common functionality to different types of Python script implementations
  • Constructor Details

    • AbstractPythonScriptProvider

      public AbstractPythonScriptProvider()
  • Method Details

    • getDescription

      public abstract String getDescription()
      Description copied from class: GhidraScriptProvider
      Returns a description for this type of script.
      Specified by:
      getDescription in class GhidraScriptProvider
      Returns:
      a description for this type of script
    • getRuntimeEnvironmentName

      public abstract String getRuntimeEnvironmentName()
      Description copied from class: GhidraScriptProvider
      Returns an optional runtime environment name of a GhidraScriptProvider that scripts can specify they require to run under. Useful for when more than one GhidraScriptProvider uses the same file extension.
      Overrides:
      getRuntimeEnvironmentName in class GhidraScriptProvider
      Returns:
      an optional runtime environment name of a GhidraScriptProvider that scripts can specify they require to run under (could be null if there is no requirement)
      See Also:
      • ScriptInfo.AT_RUNTIME
    • getScriptInstance

      public abstract GhidraScript getScriptInstance(ResourceFile sourceFile, PrintWriter writer) throws GhidraScriptLoadException
      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. 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
    • createNewScript

      public void createNewScript(ResourceFile newScript, String category) throws 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:
      IOException - if an error occurs writing the file
    • getBlockCommentStart

      public Pattern getBlockCommentStart()
      Returns a Pattern that matches block comment openings.

      If block comments are not supported by this provider, then this returns null.

      In Python this is a triple single quote sequence, "'''".

      Overrides:
      getBlockCommentStart in class GhidraScriptProvider
      Returns:
      the Pattern for Python block comment openings
    • getBlockCommentEnd

      public Pattern getBlockCommentEnd()
      Returns a Pattern that matches block comment closings.

      If block comments are not supported by this provider, then this returns null.

      In Python this is a triple single quote sequence, "'''".

      Overrides:
      getBlockCommentEnd in class GhidraScriptProvider
      Returns:
      the Pattern for Python block comment openings
    • getCommentCharacter

      public String getCommentCharacter()
      Description copied from class: GhidraScriptProvider
      Returns the comment character.

      For example, "//" or "#".

      Specified by:
      getCommentCharacter in class GhidraScriptProvider
      Returns:
      the comment character
    • getCertifyHeaderStart

      protected String getCertifyHeaderStart()
      Description copied from class: GhidraScriptProvider
      Return the start of certification header line if this file type is subject to certification.
      Overrides:
      getCertifyHeaderStart in class GhidraScriptProvider
      Returns:
      start of certification header or null if not supported
    • getCertificationBodyPrefix

      protected String getCertificationBodyPrefix()
      Description copied from class: GhidraScriptProvider
      Return the prefix for each certification header body line if this file is subject to certification.
      Overrides:
      getCertificationBodyPrefix in class GhidraScriptProvider
      Returns:
      certification header body prefix or null if not supported
    • getCertifyHeaderEnd

      protected String getCertifyHeaderEnd()
      Description copied from class: GhidraScriptProvider
      Return the end of certification header line if this file type is subject to certification.
      Overrides:
      getCertifyHeaderEnd in class GhidraScriptProvider
      Returns:
      end of certification header or null if not supported
    • getExtension

      public 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