Class ProgramXmlMgr

java.lang.Object
ghidra.app.util.xml.ProgramXmlMgr

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

    • ProgramXmlMgr

      public ProgramXmlMgr(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 Details

    • getProgramInfo

      public ProgramInfo getProgramInfo() throws SAXException, 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:
      SAXException - if an XML error occurs
      IOException - if an I/O error occurs
    • read

      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:
      SAXException - if an XML error occurs
      IOException - if an I/O occurs
      AddressFormatException - if an invalid address is specified in the XML
    • getStandardName

      public static String getStandardName(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 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:
      IOException - if an I/O occurs
      CancelledException - if the user cancels the read