ROSE 0.11.145.147
|
Parser for Vxcore format files.
The vxcore format is a format defined by ROSE itself for loading memory dumps from simple hardware devices. The format is intended to be as simple as possible so that it's easy to produce on the low-memory, low-powered device.
Version 1 of this file format consists of two kinds of records: memory and registers.
A memory record begins with header which is line of plain ASCII text terminated by a colon and line-feed. The line contains the starting address, the size in bytes, and the optional memory protection bits. These fields are separated from one another by horizontal white space. The address and size are hexadecimal values without a leading "0x". The optional protection bits are introduced with an equal sign "=" followed by zero or more of the upper-case letters "R" (read), "W" (write), "X" (execute) in any order. Within the protection bits, a hyphen "-" can be used as a placeholder if desired. The header's line-feed is immediately followed by the indicated number of bytes stored in binary format. The bytes are not terminated by any special sequence, but rather lead directly into the next header.
A register record (at most one per file) begins with the word "registers", a space, and the instruction set architecture name recognized by ROSE. Following the header is one line per register, each line being a register name recognized by ROSE, a colon, optional horizontal white space, and a hexadecimal value, this time with a leading "0x".
This format version was designed by Jim Leek.
@seciton vxcore_v2 Version 2
Version 2 of this format is a sequence of messages consisting of a binary header followed by a binary payload. Each header contains naturally aligned fields: a one byte version number having the value 2; two bytes not currently used for any purpose; one byte containing the memory access permission bits (see MemoryMap); a four-byte little-endian payload size in bytes; an eight-byte little-endian starting memory address.
Definition at line 47 of file BinaryVxcoreParser.h.
#include <frontend/BinaryFormats/BinaryVxcoreParser.h>
Classes | |
class | Exception |
Exception thrown for parse errors. More... | |
struct | Settings |
Settings that control the parser and unparser. More... | |
Public Member Functions | |
boost::filesystem::path | parseUrl (const std::string &) |
Parse a URL and adjust the settings. | |
const std::string & | isaName () const |
Parsed instruction set architecture name. | |
const Settings & | settings () const |
Property: Settings for parsing and unparsing. | |
Settings & | settings () |
Property: Settings for parsing and unparsing. | |
void | settings (const Settings &s) |
Property: Settings for parsing and unparsing. | |
void | parse (const boost::filesystem::path &, const MemoryMap::Ptr &) |
Parse input file. | |
void | parse (const boost::filesystem::path &, const InstructionSemantics::BaseSemantics::RegisterStatePtr ®isters, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops) |
Parse input file. | |
void | parse (const boost::filesystem::path &, const MemoryMap::Ptr &, const InstructionSemantics::BaseSemantics::RegisterStatePtr ®isters, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops) |
Parse input file. | |
void | parse (std::istream &, const MemoryMap::Ptr &, const InstructionSemantics::BaseSemantics::RegisterStatePtr ®isters, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &ops, const std::string &inputName="input") |
Parse input file. | |
void | unparse (std::ostream &, const MemoryMap::Ptr &, const AddressInterval &memoryLimit, const std::string &outputName="output") |
Unparse memory and/or registers to this format. | |
void | unparse (std::ostream &, const InstructionSemantics::BaseSemantics::RegisterStatePtr &, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &, const std::string &outputName="output") |
Unparse memory and/or registers to this format. | |
void | unparse (std::ostream &, const MemoryMap::Ptr &, const AddressInterval &memoryLimit, const InstructionSemantics::BaseSemantics::RegisterStatePtr &, const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &, const std::string &outputName="output") |
Unparse memory and/or registers to this format. | |
Static Public Member Functions | |
static void | initDiagnostics () |
Static Public Attributes | |
static Sawyer::Message::Facility | mlog |
Diagnostic facility for vxcore file format. | |
|
inline |
Property: Settings for parsing and unparsing.
Definition at line 112 of file BinaryVxcoreParser.h.
|
inline |
Property: Settings for parsing and unparsing.
Definition at line 113 of file BinaryVxcoreParser.h.
|
inline |
Property: Settings for parsing and unparsing.
Definition at line 114 of file BinaryVxcoreParser.h.
boost::filesystem::path Rose::BinaryAnalysis::VxcoreParser::parseUrl | ( | const std::string & | ) |
Parse a URL and adjust the settings.
Parses the specified URL which should not include the leading "vxcore:", adjusts this object's settings, and returns the file name part of the URL. Throws an Exception for any parsing errors.
Note that this function doesn't actually parse the file, only the URL that contains the file name.
void Rose::BinaryAnalysis::VxcoreParser::parse | ( | const boost::filesystem::path & | , |
const MemoryMap::Ptr & | |||
) |
Parse input file.
The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.
Parse errors throw an Exception.
void Rose::BinaryAnalysis::VxcoreParser::parse | ( | const boost::filesystem::path & | , |
const InstructionSemantics::BaseSemantics::RegisterStatePtr & | registers, | ||
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr & | ops | ||
) |
Parse input file.
The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.
Parse errors throw an Exception.
void Rose::BinaryAnalysis::VxcoreParser::parse | ( | const boost::filesystem::path & | , |
const MemoryMap::Ptr & | , | ||
const InstructionSemantics::BaseSemantics::RegisterStatePtr & | registers, | ||
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr & | ops | ||
) |
Parse input file.
The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.
Parse errors throw an Exception.
void Rose::BinaryAnalysis::VxcoreParser::parse | ( | std::istream & | , |
const MemoryMap::Ptr & | , | ||
const InstructionSemantics::BaseSemantics::RegisterStatePtr & | registers, | ||
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr & | ops, | ||
const std::string & | inputName = "input" |
||
) |
Parse input file.
The specified file is opened and parsed and the results used to initialize memory and/or registers. If a non-null memory map is passed as an argument, then then file data is copied into the map. If a non-null register state is provided (along with a required RiscOperators object for extraction and concatenation), then registers are set to values contained in the file.
Parse errors throw an Exception.
void Rose::BinaryAnalysis::VxcoreParser::unparse | ( | std::ostream & | , |
const MemoryMap::Ptr & | , | ||
const AddressInterval & | memoryLimit, | ||
const std::string & | outputName = "output" |
||
) |
Unparse memory and/or registers to this format.
If a non-null memory map is supplied, then the memory that's contained within the specified memoryLimit
address range is output (pass AddressInterval::whole()
to emit all mapped memory).
If a non-null register state is specified, then output values for all the registers contained in that state, skipping registers that don't have a concrete value. In this case, a RiscOperators object must also be supplied in order to concat and/or extract register parts.
The optional outputName
is used to identify the output stream in error messages and exceptions.
void Rose::BinaryAnalysis::VxcoreParser::unparse | ( | std::ostream & | , |
const InstructionSemantics::BaseSemantics::RegisterStatePtr & | , | ||
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr & | , | ||
const std::string & | outputName = "output" |
||
) |
Unparse memory and/or registers to this format.
If a non-null memory map is supplied, then the memory that's contained within the specified memoryLimit
address range is output (pass AddressInterval::whole()
to emit all mapped memory).
If a non-null register state is specified, then output values for all the registers contained in that state, skipping registers that don't have a concrete value. In this case, a RiscOperators object must also be supplied in order to concat and/or extract register parts.
The optional outputName
is used to identify the output stream in error messages and exceptions.
void Rose::BinaryAnalysis::VxcoreParser::unparse | ( | std::ostream & | , |
const MemoryMap::Ptr & | , | ||
const AddressInterval & | memoryLimit, | ||
const InstructionSemantics::BaseSemantics::RegisterStatePtr & | , | ||
const InstructionSemantics::BaseSemantics::RiscOperatorsPtr & | , | ||
const std::string & | outputName = "output" |
||
) |
Unparse memory and/or registers to this format.
If a non-null memory map is supplied, then the memory that's contained within the specified memoryLimit
address range is output (pass AddressInterval::whole()
to emit all mapped memory).
If a non-null register state is specified, then output values for all the registers contained in that state, skipping registers that don't have a concrete value. In this case, a RiscOperators object must also be supplied in order to concat and/or extract register parts.
The optional outputName
is used to identify the output stream in error messages and exceptions.
|
inline |
Parsed instruction set architecture name.
Latest encountered instruction set architecture name parsed from the input.
Definition at line 171 of file BinaryVxcoreParser.h.
|
static |
Diagnostic facility for vxcore file format.
Definition at line 105 of file BinaryVxcoreParser.h.