Package ghidra.app.util.xml
Class ProgramXmlMgr
- java.lang.Object
-
- ghidra.app.util.xml.ProgramXmlMgr
-
public class ProgramXmlMgr extends java.lang.Object
The manager responsible for reading and writing a program in XML.
-
-
Constructor Summary
Constructors Constructor Description ProgramXmlMgr(ByteProvider bp)
Constructs a new program XML manager using the specifiedByteProvider
.ProgramXmlMgr(java.io.File file)
Constructs a new program XML manager using the specified file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ProgramInfo
getProgramInfo()
Returns the program info from the underlying file.static java.lang.String
getStandardName(java.lang.String name)
Converts from a generic format name to standard Ghidra names;MessageLog
read(Program program, TaskMonitor monitor, XmlProgramOptions options)
Reads from the underlying XML file and populates the specified program.MessageLog
write(Program program, AddressSetView addrSet, TaskMonitor monitor, XmlProgramOptions options)
Writes the specified program in XML into the underlying file.
-
-
-
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 specifiedByteProvider
.If
ByteProvider
has aFSRL
and it is a simple local filepath, convert that to a normal local java.io.File instance instead of using theByteProvider
's File property which is probably located in theFileSystemService
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 occursjava.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 intomonitor
- the task monitoroptions
- 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 occursjava.io.IOException
- if an I/O occursAddressFormatException
- 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 XMLaddrSet
- an address set to limit areas of program that written, or null for entire programmonitor
- the task monitoroptions
- 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 occursCancelledException
- if the user cancels the read
-
-