Package ghidra.app.script
Class GhidraScriptProvider
- java.lang.Object
-
- ghidra.app.script.GhidraScriptProvider
-
- All Implemented Interfaces:
ExtensionPoint,java.lang.Comparable<GhidraScriptProvider>
- Direct Known Subclasses:
JavaScriptProvider,PythonScriptProvider
public abstract class GhidraScriptProvider extends java.lang.Object implements ExtensionPoint, java.lang.Comparable<GhidraScriptProvider>
NOTE: ALL GhidraScriptProvider CLASSES MUST END IN "ScriptProvider". If not, the ClassSearcher will not find them.
-
-
Constructor Summary
Constructors Constructor Description GhidraScriptProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(GhidraScriptProvider that)abstract voidcreateNewScript(ResourceFile newScript, java.lang.String category)Creates a new script using the specified file.booleandeleteScript(ResourceFile scriptSource)Deletes the script file and unloads the script from the script manager.booleanequals(java.lang.Object obj)protected java.lang.StringfixupName(java.lang.String scriptName)Deprecated.java.util.regex.PatterngetBlockCommentEnd()Returns a Pattern that matches block comment closings.java.util.regex.PatterngetBlockCommentStart()Returns a Pattern that matches block comment openings.protected java.lang.StringgetCertificationBodyPrefix()Return the prefix for each certification header body line if this file is subject to certification.protected java.lang.StringgetCertifyHeaderEnd()Return the end of certification header line if this file type is subject to certification.protected java.lang.StringgetCertifyHeaderStart()Return the start of certification header line if this file type is subject to certification.abstract java.lang.StringgetCommentCharacter()Returns the comment character.abstract java.lang.StringgetDescription()Returns a description for this type of script.abstract java.lang.StringgetExtension()Returns the file extension for this type of script.abstract GhidraScriptgetScriptInstance(ResourceFile sourceFile, java.io.PrintWriter writer)Returns a GhidraScript instance for the specified source file.inthashCode()java.lang.StringtoString()protected voidwriteBody(java.io.PrintWriter writer)Writes the script body template.protected voidwriteHeader(java.io.PrintWriter writer, java.lang.String category)Writes the script header.
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(GhidraScriptProvider that)
- Specified by:
compareToin interfacejava.lang.Comparable<GhidraScriptProvider>
-
deleteScript
public boolean deleteScript(ResourceFile scriptSource)
Deletes the script file and unloads the script from the script manager.- Parameters:
scriptSource- the script source file- Returns:
- true if the script was completely deleted and cleaned up
-
getDescription
public abstract java.lang.String getDescription()
Returns a description for this type of script.- Returns:
- a description for this type of script
-
getExtension
public abstract java.lang.String getExtension()
Returns the file extension for this type of script. For example, ".java" or ".py".- Returns:
- the file extension for this type of script
-
getScriptInstance
public abstract GhidraScript getScriptInstance(ResourceFile sourceFile, java.io.PrintWriter writer) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
Returns a GhidraScript instance for the specified source file.- 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.ClassNotFoundException- if the script class cannot be foundjava.lang.InstantiationException- if the construction of the script fails for some reasonjava.lang.IllegalAccessException- if the class constructor is not accessible
-
createNewScript
public abstract void createNewScript(ResourceFile newScript, java.lang.String category) throws java.io.IOException
Creates a new script using the specified file.- Parameters:
newScript- the new script filecategory- the script category- Throws:
java.io.IOException- if an error occurs writing the file
-
getBlockCommentStart
public java.util.regex.Pattern getBlockCommentStart()
Returns a Pattern that matches block comment openings. If block comments are not supported by this provider, then this returns null.- Returns:
- the Pattern for block comment openings, null if block comments are not supported
-
getBlockCommentEnd
public java.util.regex.Pattern getBlockCommentEnd()
Returns a Pattern that matches block comment closings. If block comments are not supported by this provider, then this returns null.- Returns:
- the Pattern for block comment closings, null if block comments are not supported
-
getCommentCharacter
public abstract java.lang.String getCommentCharacter()
Returns the comment character. For example, "//" or "#".- Returns:
- the comment character
-
writeHeader
protected void writeHeader(java.io.PrintWriter writer, java.lang.String category)Writes the script header. Include a place holder for each meta-data item.- Parameters:
writer- the print writercategory- the default category
-
writeBody
protected void writeBody(java.io.PrintWriter writer)
Writes the script body template.- Parameters:
writer- the print writer
-
fixupName
@Deprecated protected java.lang.String fixupName(java.lang.String scriptName)
Deprecated.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).- Parameters:
scriptName- the name of the script, must end with this provider's extension- Returns:
- a (relative) file path to the corresponding script
-
getCertifyHeaderStart
protected java.lang.String getCertifyHeaderStart()
Return the start of certification header line if this file type is subject to certification.- Returns:
- start of certification header or null if not supported
-
getCertificationBodyPrefix
protected java.lang.String getCertificationBodyPrefix()
Return the prefix for each certification header body line if this file is subject to certification.- Returns:
- certification header body prefix or null if not supported
-
getCertifyHeaderEnd
protected java.lang.String getCertifyHeaderEnd()
Return the end of certification header line if this file type is subject to certification.- Returns:
- end of certification header or null if not supported
-
-