Package ghidra.app.util.xml
Class ProgramXmlMgr
java.lang.Object
ghidra.app.util.xml.ProgramXmlMgr
The manager responsible for reading and writing a program in XML.
-
Constructor Summary
ConstructorDescriptionConstructs a new program XML manager using the specifiedByteProvider
.ProgramXmlMgr
(File file) Constructs a new program XML manager using the specified file. -
Method Summary
Modifier and TypeMethodDescriptionReturns the program info from the underlying file.static String
getStandardName
(String name) Converts from a generic format name to standard Ghidra names;read
(Program program, TaskMonitor monitor, XmlProgramOptions options) Reads from the underlying XML file and populates the specified program.write
(Program program, AddressSetView addrSet, TaskMonitor monitor, XmlProgramOptions options) Writes the specified program in XML into the underlying file.
-
Constructor Details
-
ProgramXmlMgr
Constructs a new program XML manager using the specified file. The file should be an XML file.- Parameters:
file
- the XML file
-
ProgramXmlMgr
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 Details
-
getProgramInfo
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 occursIOException
- if an I/O error occurs
-
read
public MessageLog read(Program program, TaskMonitor monitor, XmlProgramOptions options) throws SAXException, 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:
SAXException
- if an XML error occursIOException
- if an I/O occursAddressFormatException
- if an invalid address is specified in the XML
-
getStandardName
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 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:
IOException
- if an I/O occursCancelledException
- if the user cancels the read
-