Class ProgramXmlMgr


  • public class ProgramXmlMgr
    extends java.lang.Object
    The manager responsible for reading and writing a program in XML.
    • Constructor Detail

      • ProgramXmlMgr

        public ProgramXmlMgr​(java.io.File file)
        Constructs a new program XML manager using the specified file. The file should be an XML file.
        Parameters:
        file - the XML file
      • ProgramXmlMgr

        public ProgramXmlMgr​(ByteProvider bp)
        Constructs a new program XML manager using the specified ByteProvider.

        If ByteProvider has a FSRL and it is a simple local filepath, convert that to a normal local java.io.File instance instead of using the ByteProvider's File property which is probably located in the FileSystemService filecache directory, which will break the ability to find the *.bytes file associated with this .xml file.

        This workaround will not help xml files that are truly embedded in a GFileSystem (ie. in a .zip file).

        Parameters:
        bp -
    • Method Detail

      • getProgramInfo

        public ProgramInfo getProgramInfo()
                                   throws org.xml.sax.SAXException,
                                          java.io.IOException
        Returns the program info from the underlying file. T``his method does not make sense to invoke if a write is being performed to a new file.
        Returns:
        the program info
        Throws:
        org.xml.sax.SAXException - if an XML error occurs
        java.io.IOException - if an I/O error occurs
      • read

        public MessageLog read​(Program program,
                               TaskMonitor monitor,
                               XmlProgramOptions options)
                        throws org.xml.sax.SAXException,
                               java.io.IOException,
                               AddressFormatException
        Reads from the underlying XML file and populates the specified program.
        Parameters:
        program - the program to load the XML into
        monitor - the task monitor
        options - the XML options, which features to load and to ignore
        Returns:
        the message log containing any warning/error messages
        Throws:
        org.xml.sax.SAXException - if an XML error occurs
        java.io.IOException - if an I/O occurs
        AddressFormatException - if an invalid address is specified in the XML
      • getStandardName

        public static java.lang.String getStandardName​(java.lang.String name)
        Converts from a generic format name to standard Ghidra names;
        Parameters:
        name - the generic format name
        Returns:
        the equivalent Ghidra name
      • write

        public MessageLog write​(Program program,
                                AddressSetView addrSet,
                                TaskMonitor monitor,
                                XmlProgramOptions options)
                         throws java.io.IOException,
                                CancelledException
        Writes the specified program in XML into the underlying file.
        Parameters:
        program - the program to write into XML
        addrSet - an address set to limit areas of program that written, or null for entire program
        monitor - the task monitor
        options - the XML options to limit what is and is not written out
        Returns:
        the message log containing any warning/error messages
        Throws:
        java.io.IOException - if an I/O occurs
        CancelledException - if the user cancels the read