ROSE 0.11.145.147
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Rose::BinaryAnalysis::MemoryMap Class Reference

Description

An efficient mapping from an address space to stored data.

This class, a specialization of Sawyer::Container::AddressMap, maps 64-bit addresses to bytes. The address space is organized into non-overlapping, contiguous "segments" (Sawyer::Container::AddressSegment) that impart properties such as names and access permissions. Each segment points into a buffer (subclass of Sawyer::Container::Buffer) where the data bytes are stored.

The buffers pointed to by the segments are reference counted with smart pointers. Normally, each segment points to the beginning of its own buffer, but this is not always true. Sometimes segments share buffers, and sometimes segments point into the middle of buffers. This flexibility allows parts of an address space to be erased or replaced even from the middle of existing segments. It also allows the same data to be mapped and shared at multiple addresses.

The MemoryMap objects are also reference counted and created by the instance method. Copying a MemoryMap object is shallow: the new object will have its own mapping and segments, but will share the underying buffers with the source map.

Most of the low level functionality for a MemoryMap comes from the Sawyer::Container::AddressMap base class, such as the ability to add, erase, or replace parts of the address space and the ability to read data from the address space. The base class documentation has lots of example code. On the other hand, most of the more complex behaviors are defined in the MemoryMap class, such as initializing a MemoryMap from a Linux process or reading a NUL-terminated string.

Here's an example of mapping a file into an address space at virtual address 0x08040000 and then temporarily replacing the second 1kB page of the file with our own data. We demonstrate using a Sawyer::Container::MappedBuffer because these are very fast for large files, especially if only small parts of the file are ever accessed.

using namespace Sawyer::Container;
// Create and initialize the overlay data
uint8_t myData[8192];
initialize(myData, myDataSize);
// Create the two buffers: one for the file, one for the overlay data
Buffer::Ptr fileBuf = MappedBuffer::instance("the_file", boost::iostreams::mapped_file::readonly);
Buffer::Ptr dataBuf = StaticBuffer::instance(myData, 8192);
// Create the memory map.
map->insert(AddressInterval::baseSize(0x08040000, fileBuf->size()),
AddressSegment(fileBuf, 0, MemoryMap::MM_PROT_READ, "the file contents"));
map->insert(AddressInterval::baseSize(0x08040000+1024, dataBuf->size()),
AddressSegment(dataBuf, 0, MemoryMap::MM_PROT_RW, "data overlay"));
static Ptr instance()
Construct an empty memory map.
Definition MemoryMap.h:267
A homogeneous interval of an address space.
static Interval baseSize(Address lo, Address size)
Construct an interval from one endpoint and a size.
Definition Interval.h:173
static Buffer< A, T >::Ptr instance(const boost::iostreams::mapped_file_params &params)
Map a file according to boost parameters.
static Buffer< A, T >::Ptr instance(Value *values, Address size)
Construct from caller-supplied data.
Reference-counting intrusive smart pointer.
ROSE_DLL_API void initialize(const char *configToken)
Initialize the library.
Container classes that store user-defined values.
Definition AddressMap.h:31

A MemoryMap provides methods to easily read from and write to the underlying data storage, addressing it in terms of the virtual address space. These functions return the addresses that were accessed, and are prefixed by calls that describe what data is to be accessed.

// read part of the data, right across the file/overlay boundary
uint8_t data[4096];
size_t nRead = map->at(0x08040100).limit(sizeof data).read(data).size();
assert(nread == sizeof data);

The Sawyer documentation contains many more examples.

Definition at line 115 of file MemoryMap.h.

#include <Rose/BinaryAnalysis/MemoryMap.h>

Inheritance diagram for Rose::BinaryAnalysis::MemoryMap:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::MemoryMap:
Collaboration graph
[legend]

Classes

struct  Attach
 Attach with ptrace first when reading a process? More...
 
class  Exception
 Exception for MemoryMap operations. More...
 
struct  Inconsistent
 Exception for an inconsistent mapping. More...
 
struct  NoFreeSpace
 Exception thrown by find_free() when there's not enough free space left. More...
 
struct  NotMapped
 Exception for when we try to access a virtual address that isn't mapped. More...
 
struct  ProcessMapRecord
 Information about a process map. More...
 
struct  SyntaxError
 Exception thrown by load() when there's a syntax error in the index file. More...
 

Public Types

enum class  Clobber {
  NO ,
  YES
}
 Overwrite (parts of) existing segments? More...
 
enum  InsertFileMapMode {
  MAP_PRIVATE = 0 ,
  MAP_READWRITE = 1 ,
  MAP_RDONLY = 2
}
 Mapping mode for insertFile. More...
 
using Ptr = MemoryMapPtr
 Reference counting pointer.
 
typedef rose_addr_t Address
 
typedef uint8_t Value
 
typedef Sawyer::Container::AddressMap< Address, Value > Super
 
typedef Sawyer::Container::Buffer< Address, Value > Buffer
 
typedef Sawyer::Container::AllocatingBuffer< Address, Value > AllocatingBuffer
 
typedef Sawyer::Container::MappedBuffer< Address, Value > MappedBuffer
 
typedef Sawyer::Container::NullBuffer< Address, Value > NullBuffer
 
typedef Sawyer::Container::StaticBuffer< Address, Value > StaticBuffer
 
typedef Sawyer::Container::SegmentPredicate< Address, Value > SegmentPredicate
 
typedef Sawyer::Container::AddressMapConstraints< Sawyer::Container::AddressMap< rose_addr_t, uint8_t > > Constraints
 
typedef Sawyer::Container::AddressMapConstraints< const Sawyer::Container::AddressMap< rose_addr_t, uint8_t > > ConstConstraints
 
- Public Types inherited from Sawyer::Container::AddressMap< rose_addr_t, uint8_t >
typedef rose_addr_t Address
 Type for addresses.
 
typedef uint8_t Value
 Type of data stored in the address space.
 
typedef AddressSegment< rose_addr_t, uint8_t > Segment
 Type of segments stored by this map.
 
typedef Sawyer::Container::Buffer< Address, ValueBuffer
 
typedef Super::Node Node
 Storage node containing interval/segment pair.
 
typedef Super::ValueIterator SegmentIterator
 Iterates over segments in the map.
 
typedef Super::ConstValueIterator ConstSegmentIterator
 Iterators over segments in the map.
 
typedef Super::ConstIntervalIterator ConstIntervalIterator
 Iterates over address intervals in the map.
 
typedef Super::NodeIterator NodeIterator
 Iterates over address interval, segment pairs in the map.
 
typedef Super::ConstNodeIterator ConstNodeIterator
 Iterates over address interval/segment pairs in the map.
 
- Public Types inherited from Sawyer::Container::IntervalMap< I, T, Policy >
typedef I Interval
 Interval type.
 
typedef T Value
 Value type.
 
typedef Container::Map< Interval, Value, IntervalCompare > Map
 Type of the underlying map.
 
typedef Map::Node Node
 Storage node.
 
typedef Map::ConstKeyIterator ConstIntervalIterator
 Interval iterator.
 
typedef Map::ValueIterator ValueIterator
 Value iterator.
 
typedef Map::ConstValueIterator ConstValueIterator
 Value iterator.
 
typedef Map::NodeIterator NodeIterator
 Node iterator.
 
typedef Map::ConstNodeIterator ConstNodeIterator
 Node iterator.
 

Public Member Functions

Ptr shallowCopy ()
 Create a new copy of the memory map.
 
size_t insertFile (const std::string &fileName, rose_addr_t va, InsertFileMapMode mode=MAP_PRIVATE, std::string segmentName="")
 Insert file contents into memory map.
 
AddressInterval insertFile (const std::string &locatorString)
 Insert file contents into memory map.
 
AddressInterval insertData (const std::string &locatorString)
 Insert data into a memory map.
 
void adjustMap (const std::string &locatorString)
 Adjusts a memory map according to the locator string.
 
void insertProcess (pid_t pid, Attach::Boolean attach)
 Insert the memory of some other process into this memory map.
 
void insertProcess (const std::string &locatorString)
 Insert the memory of some other process into this memory map.
 
MemoryMap::Ptr align (rose_addr_t lowAlignment, rose_addr_t highAlignment) const
 Create a new map by padding and aligning segments.
 
void eraseZeros (size_t minsize)
 Erases regions of zero bytes that are executable and readable and at least minsize in size.
 
bool shrinkUnshare ()
 Shrink buffers and remove sharing.
 
size_t readQuick (void *buf, rose_addr_t startVa, size_t desired) const
 Read data into buffer.
 
std::string readString (rose_addr_t startVa, size_t desired, int(*validChar)(int)=NULL, int(*invalidChar)(int)=NULL, unsigned requiredPerms=READABLE, unsigned prohibitedPerms=0, char terminator='\0') const
 Reads a NUL-terminated string from the memory map.
 
template<typename U >
Sawyer::Optional< U > readUnsigned (rose_addr_t startVa) const
 Read an unsigned value.
 
Sawyer::Optional< uint64_t > readLongUnsinged (rose_addr_t startVa) const
 Read a long unsigned value.
 
size_t writeUnsigned (uint32_t value, rose_addr_t startVa)
 Write an unsigned value.
 
size_t writeUnsigned (uint64_t value, rose_addr_t startVa)
 Write a long unsigned value.
 
Sawyer::Optional< uint8_t > readByte (rose_addr_t) const
 Read a byte from memory.
 
SgUnsignedCharList readVector (rose_addr_t startVa, size_t desired, unsigned requiredPerms=READABLE) const
 Read quickly into a vector.
 
size_t writeQuick (const void *buf, rose_addr_t startVa, size_t desired)
 Write data from buffer.
 
Sawyer::Optional< rose_addr_t > findSequence (const AddressInterval &interval, const std::vector< uint8_t > &sequence) const
 Search for a byte sequence.
 
Combinatorics::Hasherhash (Combinatorics::Hasher &) const
 Compute a hash of the entire memory contents.
 
ByteOrder::Endianness byteOrder () const
 Property: Byte order.
 
void byteOrder (ByteOrder::Endianness order)
 Property: Byte order.
 
const std::string & name () const
 Property: Name.
 
void name (const std::string &)
 Property: Name.
 
bool insertProcessPid (pid_t, const AddressInterval &where, unsigned accessibility, const std::string &name)
 Insert part of another process's memory into this memory map.
 
void insertProcessPid (pid_t, const std::vector< ProcessMapRecord > &)
 Insert part of another process's memory into this memory map.
 
bool insertProcessMemory (int memFile, const AddressInterval &where, unsigned accessibility, std::string name)
 Insert part of another process's memory into this memory map.
 
AddressIntervalSet linkTo (const MemoryMap::Ptr &source, const AddressIntervalSet &where, Clobber=Clobber::YES)
 Insert part of another map by reference.
 
AddressIntervalSet linkTo (const MemoryMap::Ptr &source, const AddressInterval &where, Clobber=Clobber::YES)
 Insert part of another map by reference.
 
Sawyer::Optional< rose_addr_t > findAny (const Extent &limits, const std::vector< uint8_t > &bytesToFind, unsigned requiredPerms=READABLE, unsigned prohibitedPerms=0) const
 Search for any byte.
 
Sawyer::Optional< rose_addr_t > findAny (const AddressInterval &limits, const std::vector< uint8_t > &bytesToFind, unsigned requiredPerms=READABLE, unsigned prohibitedPerms=0) const
 Search for any byte.
 
void dump (FILE *, const char *prefix="") const
 Prints the contents of the map for debugging.
 
void dump (std::ostream &, std::string prefix="") const
 Prints the contents of the map for debugging.
 
void print (std::ostream &o, std::string prefix="") const
 Prints the contents of the map for debugging.
 
void dump () const
 Prints the contents of the map for debugging.
 
- Public Member Functions inherited from Sawyer::Container::AddressMap< rose_addr_t, uint8_t >
 AddressMap ()
 Constructs an empty address map.
 
 AddressMap (const AddressMap &other, bool copyOnWrite=false)
 Copy constructor.
 
void checkConsistency () const
 Check map consistency.
 
Address nSegments () const
 Number of segments contained in the map.
 
Optional< Addressnext (const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Minimum or maximum address that satisfies constraints.
 
Sawyer::Container::Interval< Addressavailable (const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Adress interval that satisfies constraints.
 
bool exists (const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Determines if an address exists with the specified constraints.
 
Sawyer::Container::Interval< Addressunmapped (Address boundary, MatchFlags flags=0) const
 Find unmapped interval.
 
Optional< AddressfindFreeSpace (size_t nValues, size_t alignment=1, Sawyer::Container::Interval< Address > restriction=Sawyer::Container::Interval< Address >::whole(), MatchFlags flags=0) const
 Find free space.
 
void prune (const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Prune away addresses that match constraints.
 
void keep (const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Keep only addresses that match constraints.
 
void changeAccess (unsigned requiredAccess, unsigned prohibitedAccess, const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Change access bits for addresses that match constraints.
 
AddressMapConstraints< const AddressMaprequire (unsigned x) const
 Constraint: required access bits.
 
AddressMapConstraints< AddressMaprequire (unsigned x)
 Constraint: required access bits.
 
AddressMapConstraints< const AddressMapprohibit (unsigned x) const
 Constraint: prohibited access bits.
 
AddressMapConstraints< AddressMapprohibit (unsigned x)
 Constraint: prohibited access bits.
 
AddressMapConstraints< const AddressMapaccess (unsigned x) const
 Constraint: required and prohibited access bits.
 
AddressMapConstraints< AddressMapaccess (unsigned x)
 Constraint: required and prohibited access bits.
 
AddressMapConstraints< const AddressMapsubstr (const std::string &x) const
 Constraint: segment name substring.
 
AddressMapConstraints< AddressMapsubstr (const std::string &x)
 Constraint: segment name substring.
 
AddressMapConstraints< const AddressMapat (Address x) const
 Constraint: anchor point.
 
AddressMapConstraints< AddressMapat (Address x)
 Constraint: anchor point.
 
AddressMapConstraints< const AddressMapat (const Sawyer::Container::Interval< Address > &x) const
 Constraint: anchored interval.
 
AddressMapConstraints< AddressMapat (const Sawyer::Container::Interval< Address > &x)
 Constraint: anchored interval.
 
AddressMapConstraints< const AddressMaplimit (size_t x) const
 Constraint: limit matched size.
 
AddressMapConstraints< AddressMaplimit (size_t x)
 Constraint: limit matched size.
 
AddressMapConstraints< const AddressMapatOrAfter (Address x) const
 Constraint: address lower bound.
 
AddressMapConstraints< AddressMapatOrAfter (Address x)
 Constraint: address lower bound.
 
AddressMapConstraints< const AddressMapatOrBefore (Address x) const
 Constraint: address upper bound.
 
AddressMapConstraints< AddressMapatOrBefore (Address x)
 Constraint: address upper bound.
 
AddressMapConstraints< const AddressMapwithin (const Sawyer::Container::Interval< Address > &x) const
 Constraint: address lower and upper bounds.
 
AddressMapConstraints< AddressMapwithin (const Sawyer::Container::Interval< Address > &x)
 Constraint: address lower and upper bounds.
 
AddressMapConstraints< const AddressMapwithin (Address x, Address y) const
 Constraint: address lower and upper bounds.
 
AddressMapConstraints< AddressMapwithin (Address x, Address y)
 Constraint: address lower and upper bounds.
 
AddressMapConstraints< const AddressMapbaseSize (Address base, Address size) const
 Constraint: address lower and upper bounds.
 
AddressMapConstraints< AddressMapbaseSize (Address base, Address size)
 Constraint: address lower and upper bounds.
 
AddressMapConstraints< const AddressMapafter (Address x) const
 Constraint: address lower bound.
 
AddressMapConstraints< AddressMapafter (Address x)
 Constraint: address lower bound.
 
AddressMapConstraints< const AddressMapbefore (Address x) const
 Constraint: address upper bound.
 
AddressMapConstraints< AddressMapbefore (Address x)
 Constraint: address upper bound.
 
AddressMapConstraints< const AddressMapsingleSegment () const
 Constraint: single segment.
 
AddressMapConstraints< AddressMapsingleSegment ()
 Constraint: single segment.
 
AddressMapConstraints< const AddressMapsegmentPredicate (SegmentPredicate< Address, Value > *p) const
 Constraint: arbitrary segment constraint.
 
AddressMapConstraints< AddressMapsegmentPredicate (SegmentPredicate< Address, Value > *p)
 Constraint: arbitrary segment constraint.
 
AddressMapConstraints< const AddressMapany () const
 Constraint: matches anything.
 
AddressMapConstraints< AddressMapany ()
 Constraint: matches anything.
 
AddressMapConstraints< const AddressMapnone () const
 Constraint: matches nothing.
 
AddressMapConstraints< AddressMapnone ()
 Constraint: matches nothing.
 
boost::iterator_range< SegmentIteratorsegments ()
 Iterator range for all segments.
 
boost::iterator_range< ConstSegmentIteratorsegments () const
 Iterator range for all segments.
 
boost::iterator_range< ConstSegmentIteratorsegments (const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Segments that overlap with constraints.
 
boost::iterator_range< SegmentIteratorsegments (const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Iterator range for all segments.
 
boost::iterator_range< NodeIteratornodes ()
 Iterator range for nodes.
 
boost::iterator_range< ConstNodeIteratornodes () const
 Iterator range for nodes.
 
boost::iterator_range< ConstNodeIteratornodes (const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Nodes that overlap with constraints.
 
boost::iterator_range< NodeIteratornodes (const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Nodes that overlap with constraints.
 
ConstNodeIterator findNode (const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Find node containing address.
 
NodeIterator findNode (const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Find node containing address.
 
void traverse (Functor &functor, const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Invoke a function on each address interval.
 
void traverse (Functor &functor, const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Invoke a function on each address interval.
 
void traverse (Visitor &visitor, const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Invoke a function on each address interval.
 
void traverse (Visitor &visitor, const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Invoke a function on each address interval.
 
Sawyer::Container::Interval< Addressread (Value *buf, const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Reads data into the supplied buffer.
 
Sawyer::Container::Interval< Addressread (std::vector< Value > &buf, const AddressMapConstraints< const AddressMap > &c, MatchFlags flags=0) const
 Reads data into the supplied buffer.
 
Sawyer::Container::Interval< Addresswrite (const Value *buf, const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Writes data from the supplied buffer.
 
Sawyer::Container::Interval< Addresswrite (const std::vector< Value > &buf, const AddressMapConstraints< AddressMap > &c, MatchFlags flags=0)
 Writes data from the supplied buffer.
 
- Public Member Functions inherited from Sawyer::Container::IntervalMap< I, T, Policy >
 IntervalMap ()
 Default constructor.
 
template<class Interval2 , class T2 , class Policy2 >
 IntervalMap (const IntervalMap< Interval2, T2, Policy2 > &other)
 Copy constructor.
 
template<class Interval2 , class T2 , class Policy2 >
IntervalMapoperator= (const IntervalMap< Interval2, T2, Policy2 > &other)
 Assignment operator.
 
boost::iterator_range< ConstIntervalIteratorintervals () const
 Iterators for traversing keys.
 
Interval firstUnmapped (typename Interval::Value minAddr) const
 Find the first unmapped region.
 
Interval lastUnmapped (typename Interval::Value maxAddr) const
 Find the last unmapped region.
 
bool exists (const typename Interval::Value &size) const
 Returns true if element exists.
 
Optional< ValuegetOptional (const typename Interval::Value &scalar) const
 Lookup and return a value or nothing.
 
const ValuegetOrDefault (const typename Interval::Value &scalar) const
 Lookup and return a value or a default.
 
bool isEmpty () const
 Determine if the container is empty.
 
size_t nIntervals () const
 Number of nodes in the container.
 
Interval::Value size () const
 Returns the number of values represented by this container.
 
Interval::Value least () const
 Returns the minimum scalar key.
 
Interval::Value greatest () const
 Returns the maximum scalar key.
 
Optional< typename Interval::Valueleast (typename Interval::Value lowerLimit) const
 Returns the limited-minimum scalar key.
 
Optional< typename Interval::Valuegreatest (typename Interval::Value upperLimit) const
 Returns the limited-maximum scalar key.
 
Optional< typename Interval::ValueleastUnmapped (typename Interval::Value lowerLimit) const
 Returns the limited-minimum unmapped scalar key.
 
Optional< typename Interval::ValuegreatestUnmapped (typename Interval::Value upperLimit) const
 Returns the limited-maximum unmapped scalar key.
 
Interval hull () const
 Returns the range of values in this map.
 
void clear ()
 Empties the container.
 
void erase (const Interval &erasure)
 Erase the specified interval.
 
template<typename T2 , class Policy2 >
void eraseMultiple (const IntervalMap< Interval, T2, Policy2 > &other)
 Erase intervals specified in another IntervalMap.
 
void insert (Interval key, Value value, bool makeHole=true)
 Insert a key/value pair.
 
template<typename T2 , class Policy2 >
void insertMultiple (const IntervalMap< Interval, T2, Policy2 > &other, bool makeHole=true)
 Insert values from another container.
 
bool overlaps (const Interval &interval) const
 
bool isOverlapping (const Interval &interval) const
 
template<typename T2 , class Policy2 >
bool overlaps (const IntervalMap< Interval, T2, Policy2 > &other) const
 
template<typename T2 , class Policy2 >
bool isOverlapping (const IntervalMap< Interval, T2, Policy2 > &other) const
 
bool isDistinct (const Interval &interval) const
 
template<typename T2 , class Policy2 >
bool isDistinct (const IntervalMap< Interval, T2, Policy2 > &other) const
 
bool contains (Interval key) const
 
template<typename T2 , class Policy2 >
bool contains (const IntervalMap< Interval, T2, Policy2 > &other) const
 
boost::iterator_range< NodeIteratornodes ()
 Iterators for traversing nodes.
 
boost::iterator_range< ConstNodeIteratornodes () const
 Iterators for traversing nodes.
 
boost::iterator_range< ValueIteratorvalues ()
 Iterators for traversing values.
 
boost::iterator_range< ConstValueIteratorvalues () const
 Iterators for traversing values.
 
NodeIterator lowerBound (const typename Interval::Value &scalar)
 Find the first node whose interval ends at or above the specified scalar key.
 
ConstNodeIterator lowerBound (const typename Interval::Value &scalar) const
 Find the first node whose interval ends at or above the specified scalar key.
 
NodeIterator upperBound (const typename Interval::Value &scalar)
 Find the first node whose interval begins above the specified scalar key.
 
ConstNodeIterator upperBound (const typename Interval::Value &scalar) const
 Find the first node whose interval begins above the specified scalar key.
 
const Valueoperator[] (const typename Interval::Value &scalar) const
 Returns a reference to an existing value.
 
const Valueget (const typename Interval::Value &scalar) const
 Returns a reference to an existing value.
 
ValuegetOrElse (const typename Interval::Value &scalar, Value &dflt)
 Lookup and return a value or something else.
 
const ValuegetOrElse (const typename Interval::Value &scalar, const Value &dflt) const
 Lookup and return a value or something else.
 
NodeIterator findPrior (const typename Interval::Value &scalar)
 Find the last node whose interval starts at or below the specified scalar key.
 
ConstNodeIterator findPrior (const typename Interval::Value &scalar) const
 Find the last node whose interval starts at or below the specified scalar key.
 
NodeIterator find (const typename Interval::Value &scalar)
 Find the node containing the specified scalar key.
 
ConstNodeIterator find (const typename Interval::Value &scalar) const
 Find the node containing the specified scalar key.
 
boost::iterator_range< NodeIteratorfindAll (const Interval &interval)
 Finds all nodes overlapping the specified interval.
 
boost::iterator_range< ConstNodeIteratorfindAll (const Interval &interval) const
 Finds all nodes overlapping the specified interval.
 
NodeIterator findFirstOverlap (const Interval &interval)
 Find first interval that overlaps with the specified interval.
 
ConstNodeIterator findFirstOverlap (const Interval &interval) const
 Find first interval that overlaps with the specified interval.
 
template<typename T2 , class Policy2 >
std::pair< NodeIterator, typename IntervalMap< Interval, T2, Policy2 >::ConstNodeIteratorfindFirstOverlap (typename IntervalMap::NodeIterator thisIter, const IntervalMap< Interval, T2, Policy2 > &other, typename IntervalMap< Interval, T2, Policy2 >::ConstNodeIterator otherIter)
 Find first interval that overlaps with any in another container.
 
template<typename T2 , class Policy2 >
std::pair< ConstNodeIterator, typename IntervalMap< Interval, T2, Policy2 >::ConstNodeIteratorfindFirstOverlap (typename IntervalMap::ConstNodeIterator thisIter, const IntervalMap< Interval, T2, Policy2 > &other, typename IntervalMap< Interval, T2, Policy2 >::ConstNodeIterator otherIter) const
 Find first interval that overlaps with any in another container.
 
NodeIterator firstFit (const typename Interval::Value &size, NodeIterator start)
 Find the first fit node at or after a starting point.
 
ConstNodeIterator firstFit (const typename Interval::Value &size, ConstNodeIterator start) const
 Find the first fit node at or after a starting point.
 
NodeIterator bestFit (const typename Interval::Value &size, NodeIterator start)
 Find the best fit node at or after a starting point.
 
ConstNodeIterator bestFit (const typename Interval::Value &size, ConstNodeIterator start) const
 Find the best fit node at or after a starting point.
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor.
 
 SharedObject (const SharedObject &)
 Copy constructor.
 
virtual ~SharedObject ()
 Virtual destructor.
 
SharedObjectoperator= (const SharedObject &)
 Assignment.
 

Static Public Member Functions

static Ptr instance ()
 Construct an empty memory map.
 
static std::string insertFileDocumentation ()
 Documentation string for insertFile.
 
static std::string insertDataDocumentation ()
 Documentation string for insertData.
 
static std::string adjustMapDocumentation ()
 Documentation string for adjustMap.
 
static std::vector< ProcessMapRecordreadProcessMap (pid_t)
 Obtain the memory map information for a process.
 
static std::string insertProcessDocumentation ()
 Documentation string for insertProcess.
 
static std::pair< Buffer::Ptr, std::string > copyFromFile (int fd, const AddressInterval &)
 Copy part of a file into a buffer.
 
static std::string segmentTitle (const Segment &)
 Title of a segment when printing the map.
 
- Static Public Member Functions inherited from Sawyer::Container::IntervalMap< I, T, Policy >
template<class IMap >
static IntervalMapTraits< IMap >::NodeIterator findPriorImpl (IMap &imap, const typename Interval::Value &scalar)
 Find the last node whose interval starts at or below the specified scalar key.
 
template<class IMap >
static IntervalMapTraits< IMap >::NodeIterator findImpl (IMap &imap, const typename Interval::Value &scalar)
 Find the node containing the specified scalar key.
 
template<class IMap >
static boost::iterator_range< typename IntervalMapTraits< IMap >::NodeIteratorfindAllImpl (IMap &imap, const Interval &interval)
 Finds all nodes overlapping the specified interval.
 
template<class IMap >
static IntervalMapTraits< IMap >::NodeIterator findFirstOverlapImpl (IMap &imap, const Interval &interval)
 Find first interval that overlaps with the specified interval.
 
template<class IMap , typename T2 , class Policy2 >
static std::pair< typename IntervalMapTraits< IMap >::NodeIterator, typename IntervalMap< Interval, T2, Policy2 >::ConstNodeIteratorfindFirstOverlapImpl (IMap &imap, typename IntervalMapTraits< IMap >::NodeIterator thisIter, const IntervalMap< Interval, T2, Policy2 > &other, typename IntervalMap< Interval, T2, Policy2 >::ConstNodeIterator otherIter)
 Find first interval that overlaps with any in another container.
 
template<class IMap >
static IntervalMapTraits< IMap >::NodeIterator firstFitImpl (IMap &imap, const typename Interval::Value &size, typename IntervalMapTraits< IMap >::NodeIterator start)
 Find the first fit node at or after a starting point.
 
template<class IMap >
static IntervalMapTraits< IMap >::NodeIterator bestFitImpl (IMap &imap, const typename Interval::Value &size, typename IntervalMapTraits< IMap >::NodeIterator start)
 Find the best fit node at or after a starting point.
 

Static Public Attributes

static const unsigned NO_ACCESS = 0
 
static const unsigned READABLE = Sawyer::Access::READABLE
 
static const unsigned WRITABLE = Sawyer::Access::WRITABLE
 
static const unsigned EXECUTABLE = Sawyer::Access::EXECUTABLE
 
static const unsigned IMMUTABLE = Sawyer::Access::IMMUTABLE
 
static const unsigned PRIVATE = Sawyer::Access::PRIVATE
 
static const unsigned INITIALIZED = 0x00000200
 
static const unsigned READ_WRITE = READABLE | WRITABLE
 
static const unsigned READ_EXECUTE = READABLE | EXECUTABLE
 
static const unsigned READ_WRITE_EXECUTE = READABLE | WRITABLE | EXECUTABLE
 
static const unsigned RESERVED_ACCESS_BITS = 0x0000ffff
 

Protected Member Functions

 MemoryMap ()
 Constructs an empty memory map.
 

Member Typedef Documentation

◆ Ptr

Reference counting pointer.

Definition at line 118 of file MemoryMap.h.

◆ Address

typedef rose_addr_t Rose::BinaryAnalysis::MemoryMap::Address

Definition at line 120 of file MemoryMap.h.

◆ Value

typedef uint8_t Rose::BinaryAnalysis::MemoryMap::Value

Definition at line 121 of file MemoryMap.h.

◆ Super

Definition at line 122 of file MemoryMap.h.

◆ Buffer

Definition at line 123 of file MemoryMap.h.

◆ AllocatingBuffer

Definition at line 124 of file MemoryMap.h.

◆ MappedBuffer

Definition at line 125 of file MemoryMap.h.

◆ NullBuffer

Definition at line 126 of file MemoryMap.h.

◆ StaticBuffer

Definition at line 127 of file MemoryMap.h.

◆ SegmentPredicate

Definition at line 128 of file MemoryMap.h.

◆ Constraints

Definition at line 129 of file MemoryMap.h.

◆ ConstConstraints

Definition at line 130 of file MemoryMap.h.

Member Enumeration Documentation

◆ Clobber

Overwrite (parts of) existing segments?

Definition at line 141 of file MemoryMap.h.

◆ InsertFileMapMode

Mapping mode for insertFile.

Enumerator
MAP_PRIVATE 

File is mapped privately.

Writing to the memory map is allowed, but the changes will not show up in the file.

MAP_READWRITE 

File is mapped with read and write permission.

Changes to the memory map will also cause the file to change.

MAP_RDONLY 

File is mapped with read-only permission.

Any attempt to modify the file will likely result in a segmentation fault.

Definition at line 303 of file MemoryMap.h.

Constructor & Destructor Documentation

◆ MemoryMap()

Rose::BinaryAnalysis::MemoryMap::MemoryMap ( )
inlineprotected

Constructs an empty memory map.

Definition at line 263 of file MemoryMap.h.

Referenced by shallowCopy().

Member Function Documentation

◆ instance()

static Ptr Rose::BinaryAnalysis::MemoryMap::instance ( )
inlinestatic

Construct an empty memory map.

Definition at line 267 of file MemoryMap.h.

◆ shallowCopy()

Ptr Rose::BinaryAnalysis::MemoryMap::shallowCopy ( )
inline

Create a new copy of the memory map.

The copy maintains its own independent list of segments, but points to the same data buffers as the source map.

Definition at line 274 of file MemoryMap.h.

References MemoryMap().

◆ byteOrder() [1/2]

ByteOrder::Endianness Rose::BinaryAnalysis::MemoryMap::byteOrder ( ) const
inline

Property: Byte order.

Every map has a default byte order property which can be used by functions that read and write multi-byte values when the user does not provide a byte order to those functions. The MemoryMap constructors initialize this property to ByteOrder::ORDER_UNSPECIFIED.

Definition at line 285 of file MemoryMap.h.

◆ byteOrder() [2/2]

void Rose::BinaryAnalysis::MemoryMap::byteOrder ( ByteOrder::Endianness  order)
inline

Property: Byte order.

Every map has a default byte order property which can be used by functions that read and write multi-byte values when the user does not provide a byte order to those functions. The MemoryMap constructors initialize this property to ByteOrder::ORDER_UNSPECIFIED.

Definition at line 286 of file MemoryMap.h.

◆ name() [1/2]

const std::string & Rose::BinaryAnalysis::MemoryMap::name ( ) const

Property: Name.

Optional name of the map, mostly used for debugging.

◆ name() [2/2]

void Rose::BinaryAnalysis::MemoryMap::name ( const std::string &  )

Property: Name.

Optional name of the map, mostly used for debugging.

◆ insertFile() [1/2]

size_t Rose::BinaryAnalysis::MemoryMap::insertFile ( const std::string &  fileName,
rose_addr_t  va,
InsertFileMapMode  mode = MAP_PRIVATE,
std::string  segmentName = "" 
)

Insert file contents into memory map.

Insert the contents of a file into the memory map at the specified address. This is just a convenience wrapper that creates a new MappedBuffer and inserts it into the mapping. Returns the size of the file mapping.

◆ insertFile() [2/2]

AddressInterval Rose::BinaryAnalysis::MemoryMap::insertFile ( const std::string &  locatorString)

Insert file contents into memory map.

Uses a locator string to load a file into a memory map.

Returns the address interval that was inserted into this memory map, or throws an std::runtime_error for syntax errors and problems reading the file.

Locator Syntax

The locator string is a file name preceded by various other parameters to control where the file is loaded in memory. It takes the form:

*  :[ADDR][+VMSIZE][=PERM]:[OFFSET[+FSIZE]]:FILENAME
* 

The fields between the first and second colon are parameters for virtual memory; the fields between the second and third colon are parameters for the file. Their meanings are:

  • ADDR: The virtual address where the first byte of the file is mapped. This can be specified in decimal, octal, or hexadecimal using the usual C syntax. If no address is specified then the file is mapped at the lowest unmapped region which is large enough to hold the file.
  • VMSIZE: Size of virtual memory to map. If VMSIZE is not specified then it is either the FSIZE (if specified) or the file size. On POSIX systems the file size is that which is reported by stat, and on other systems it is the number of bytes that can be read from the file. The size can be specified as decimal, octal, or hexadecimal with the usual C syntax. If VMSIZE is greater than the specified or calculated FSIZE then the data from the file is padded with zero bytes.
  • PERM: Accessibility for the mapped segment. If present, it should be any of the letters "r", "w", and/or "x" in that order to indicate readable, writable, and/or executable. If not present, the accessibility of the segment is the same as the user's accessibility of the file (on POSIX systems; "rwx" on Windows systems).
  • OFFSET: Byte offset within file for first byte to map. If no offset is specified then zero is assumed. The size can be decimal, octal, or hexadecimal in the usual C sytax.
  • FSIZE: Number of file bytes to map. If not specified the entire readable content of the file is mapped beginning at the specified OFFSET but not exceeding a specified VMSIZE. If this number of bytes cannot be read from the file then an error is thrown.
  • FILENAME: Name of file to read. The file must be readable by the user and its contents are copied into the memory map. Once inside the memory map, the segment can be given any accessibility according to PERM. The name of the segment will be the non-directory part of the FILENAME (e.g., on POSIX systems, the part after the final slash).

Examples

To load a couple raw files at the lowest available addresses:

:::myfile1.bin :::myfile2.bin

To load a 4k page of zeros with read and execute permission at address 0x7ffff000 (won't work on Microsoft systems):

:0x7ffff000+0x1000=rx::/dev/zero
@code
On Microsoft Windows one could create a large file containing zeros:
@code
:0x7ffff000+0x1000=rx::myzeros.dat

To load the .text and .data segments from a PE file when we know where they occur in the PE file but the PE file is damaged to the point where it cannot be loaded by ROSE's frontend. Both sections are zero-padded since the memory segment size is larger than the file size. But if one wants to more closely emulate the Windows loader, leave off the file sizes:

:0x01000400+0xa00=rx:0x1000+0x9a8:proxycfg.exe
:0x01000e00+0x200=rw:0x3000+8:proxycfg.exe
See also
insertFileDocumentation

◆ insertData()

AddressInterval Rose::BinaryAnalysis::MemoryMap::insertData ( const std::string &  locatorString)

Insert data into a memory map.

This is intended for insert small pieces of data parsed from the locator string. The locator string has the form:

*  :[ADDR][+VMSIZE][=PERM]::DATA
* 

The fields between the first and second colon are parameters for virtual memory; the fields between the second and third colon are parameters for the data (none currently defined). Their meanings are:

  • ADDR: The virtual address where the first byte of data is mapped. This can be specified in decimal, octal, or hexadecimal using the usual C syntax. If no address is specified then the data is mapped at the lowest unmapped region which is large enough to hold it.
  • VMSIZE: Size in bytes of the virtual memory to map. If VMSIZE is not specified then it is the same as the number of bytes of DATA. If VMSIZE is smaller than DATA then the DATA will be truncated; if VMSIZE is larger than DATA then DATA is zero-padded. If the resulting memory are size is zero then no change is made to the memory map.
  • PERM: Accessibility for the mapped segment. If present, it should be any of the letters "r", "w", and/or "x" in that order to indicate readable, writable, and/or executable. If not present, then the new memory is readable, writable, and executable.
  • DATA: The byte values in ascending address order. The values should be separated from one another by white space and all values must be in the range 0 through 255, inclusive. Values can be specified in hexadecimal (leading "0x"), binary (leading "0b"), octal (leading "0"), or decimal.

◆ adjustMap()

void Rose::BinaryAnalysis::MemoryMap::adjustMap ( const std::string &  locatorString)

Adjusts a memory map according to the locator string.

See –help output from tools that support this feature, or look at the implementation of adjustMapDocumentation for details about the syntax of the locatorString.

◆ readProcessMap()

static std::vector< ProcessMapRecord > Rose::BinaryAnalysis::MemoryMap::readProcessMap ( pid_t  )
static

Obtain the memory map information for a process.

Returns an empty vector if there was an error parsing the process information.

◆ insertProcess()

void Rose::BinaryAnalysis::MemoryMap::insertProcess ( const std::string &  locatorString)

Insert the memory of some other process into this memory map.

The locator string follows the syntax described in insertProcessDocumentation.

◆ linkTo() [1/2]

AddressIntervalSet Rose::BinaryAnalysis::MemoryMap::linkTo ( const MemoryMap::Ptr source,
const AddressIntervalSet where,
Clobber  = Clobber::YES 
)

Insert part of another map by reference.

The segments of the source map that overlap with the addresses specified by where are copied and inserted into this map. The new copied segments point to the same data buffers as source, therefore the segments in the new map will share the same data as the old map and changing the data in either map will change the data in the other map as well.

If the Clobber flag is set, then any segment that previously existed in the this map will be overwritten by segments copied from the source map. Otherwise, when Clobber is clear, only those parts of the source map that are not already mapped in this map are copied.

The return value is the set of addresses that were actually copied from the source to this map.

◆ linkTo() [2/2]

AddressIntervalSet Rose::BinaryAnalysis::MemoryMap::linkTo ( const MemoryMap::Ptr source,
const AddressInterval where,
Clobber  = Clobber::YES 
)

Insert part of another map by reference.

The segments of the source map that overlap with the addresses specified by where are copied and inserted into this map. The new copied segments point to the same data buffers as source, therefore the segments in the new map will share the same data as the old map and changing the data in either map will change the data in the other map as well.

If the Clobber flag is set, then any segment that previously existed in the this map will be overwritten by segments copied from the source map. Otherwise, when Clobber is clear, only those parts of the source map that are not already mapped in this map are copied.

The return value is the set of addresses that were actually copied from the source to this map.

◆ align()

MemoryMap::Ptr Rose::BinaryAnalysis::MemoryMap::align ( rose_addr_t  lowAlignment,
rose_addr_t  highAlignment 
) const

Create a new map by padding and aligning segments.

A new map is created by padding the segments of this map so they're aligned in the returned map. Data is copied (not linked) from this map to the new map. After alignment and padding, it's possible that more than one segment from the source maps to a single segment in the destination. When this happens, the destination segment's name comes from the first corresponding source segment, and the destination access permissions are the union of all the corresponding source segment access permissions.

A low or high aligment of zero is treated as an alignment of one; that is, the endpoint is not aligned. Higher values will cause segment beginning address to be aligned downward, and segment one-past-end addresses to be aligned upward.

◆ copyFromFile()

static std::pair< Buffer::Ptr, std::string > Rose::BinaryAnalysis::MemoryMap::copyFromFile ( int  fd,
const AddressInterval  
)
static

Copy part of a file into a buffer.

This copies (rather than directly references) part of a file and returns a pointer to a new buffer containing the data. If an error occurs when reading the file, then a buffer is still returned but its length will only be what was actually read, and a string is also returned containing the error message.

◆ shrinkUnshare()

bool Rose::BinaryAnalysis::MemoryMap::shrinkUnshare ( )

Shrink buffers and remove sharing.

Creates a new buffer per segment and copies the data for that segment into the new buffer. The new buffers are allocated to be just large enough to hold the data for the segment's interval. Segments that shared the same underlying data no longer share data.

Returns true if new buffers could be allocated for all segments, and false otherwise. A false return value could occur if a buffer does not support the Sawyer::Container::Buffer::data. As of this writing (Nov 2016) the only buffer type that doesn't support data is NullBuffer, which doesn't appear in memory maps created by ROSE's binary specimen mappers.

◆ readQuick()

size_t Rose::BinaryAnalysis::MemoryMap::readQuick ( void *  buf,
rose_addr_t  startVa,
size_t  desired 
) const
inline

Read data into buffer.

Definition at line 533 of file MemoryMap.h.

References Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::at().

◆ readString()

std::string Rose::BinaryAnalysis::MemoryMap::readString ( rose_addr_t  startVa,
size_t  desired,
int(*)(int)  validChar = NULL,
int(*)(int)  invalidChar = NULL,
unsigned  requiredPerms = READABLE,
unsigned  prohibitedPerms = 0,
char  terminator = '\0' 
) const

Reads a NUL-terminated string from the memory map.

Reads data beginning at startVa in the memory map and continuing until one of the following conditions is met:

  • The desired number of characters has been read (returns empty string)
  • The next character is the termination character (defaults to NUL)
  • An invalidChar function is specified and the next character causes it to return true (returns empty string)
  • A validChar function is specified and the next character causes it to return false (returns empty string)

The empty string is returned unless the terminator character is encountered.

The validChar and invalidChar take an integer argument and return an integer value so that the C character classification functions from <ctype.h> can be used directly.

◆ readUnsigned()

template<typename U >
Sawyer::Optional< U > Rose::BinaryAnalysis::MemoryMap::readUnsigned ( rose_addr_t  startVa) const
inline

Read an unsigned value.

Reads an unsigned value from memory and converts it from the memory byte order to the host byte order. If the entire value is not mapped in memory then return nothing (not even any part of the multi-byte value that might have been present.

Definition at line 558 of file MemoryMap.h.

References Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::at(), Rose::BinaryAnalysis::ByteOrder::convert(), Rose::BinaryAnalysis::ByteOrder::hostOrder(), Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::limit(), Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::read(), and Sawyer::Container::IntervalMap< I, T, Policy >::size().

◆ readLongUnsinged()

Sawyer::Optional< uint64_t > Rose::BinaryAnalysis::MemoryMap::readLongUnsinged ( rose_addr_t  startVa) const
inline

Read a long unsigned value.

Reads a long unsigned value from memory and converts it from the memory byte order to the host byte order. If the entire value is not mapped in memory then return nothing (not even any part of the multi-byte value that might have been present.

Definition at line 571 of file MemoryMap.h.

References Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::at(), Rose::BinaryAnalysis::ByteOrder::convert(), Rose::BinaryAnalysis::ByteOrder::hostOrder(), Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::limit(), Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::read(), and Sawyer::Container::IntervalMap< I, T, Policy >::size().

◆ writeUnsigned() [1/2]

size_t Rose::BinaryAnalysis::MemoryMap::writeUnsigned ( uint32_t  value,
rose_addr_t  startVa 
)
inline

Write an unsigned value.

Takes a unsigned value converts it from the memory byte order to the host byte order then writes to memory. This does not verify the memory is writable. Returns the number of bytes written.

Definition at line 583 of file MemoryMap.h.

References Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::at().

◆ writeUnsigned() [2/2]

size_t Rose::BinaryAnalysis::MemoryMap::writeUnsigned ( uint64_t  value,
rose_addr_t  startVa 
)
inline

Write a long unsigned value.

Takes a long unsigned value converts it from the memory byte order to the host byte order then writes to memory. This does not verify the memory is writable. Returns the number of bytes written.

Definition at line 591 of file MemoryMap.h.

References Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::at().

◆ readByte()

Sawyer::Optional< uint8_t > Rose::BinaryAnalysis::MemoryMap::readByte ( rose_addr_t  ) const

Read a byte from memory.

Reads a byte at the specified address and returns it. Returns nothing if the address is not mapped.

◆ writeQuick()

size_t Rose::BinaryAnalysis::MemoryMap::writeQuick ( const void *  buf,
rose_addr_t  startVa,
size_t  desired 
)
inline

Write data from buffer.

Definition at line 604 of file MemoryMap.h.

References Sawyer::Container::AddressMap< rose_addr_t, uint8_t >::at().

◆ findAny() [1/2]

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::MemoryMap::findAny ( const Extent limits,
const std::vector< uint8_t > &  bytesToFind,
unsigned  requiredPerms = READABLE,
unsigned  prohibitedPerms = 0 
) const

Search for any byte.

Searches for all of the specified bytes simultaneously and returns the lowest address (subject to limits) where one of the specified values appears. If none of the specified bytes appear within the given address extent, then this method returns none.

◆ findAny() [2/2]

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::MemoryMap::findAny ( const AddressInterval limits,
const std::vector< uint8_t > &  bytesToFind,
unsigned  requiredPerms = READABLE,
unsigned  prohibitedPerms = 0 
) const

Search for any byte.

Searches for all of the specified bytes simultaneously and returns the lowest address (subject to limits) where one of the specified values appears. If none of the specified bytes appear within the given address extent, then this method returns none.

◆ findSequence()

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::MemoryMap::findSequence ( const AddressInterval interval,
const std::vector< uint8_t > &  sequence 
) const

Search for a byte sequence.

Searches for the bytes specified by sequence occuring within the specified interval. If the interval is empty or the sequence cannot be found then nothing is returned. Otherwise, the virtual address for the start of the sequence is returned. An empty sequence matches at the beginning of the interval.

◆ dump() [1/3]

void Rose::BinaryAnalysis::MemoryMap::dump ( FILE *  ,
const char *  prefix = "" 
) const

Prints the contents of the map for debugging.

The prefix string is added to the beginning of every line of output and typically is used to indent the output.

◆ dump() [2/3]

void Rose::BinaryAnalysis::MemoryMap::dump ( std::ostream &  ,
std::string  prefix = "" 
) const

Prints the contents of the map for debugging.

The prefix string is added to the beginning of every line of output and typically is used to indent the output.

◆ print()

void Rose::BinaryAnalysis::MemoryMap::print ( std::ostream &  o,
std::string  prefix = "" 
) const
inline

Prints the contents of the map for debugging.

The prefix string is added to the beginning of every line of output and typically is used to indent the output.

Definition at line 633 of file MemoryMap.h.

References dump().

◆ dump() [3/3]

void Rose::BinaryAnalysis::MemoryMap::dump ( ) const

Prints the contents of the map for debugging.

The prefix string is added to the beginning of every line of output and typically is used to indent the output.

Referenced by print().

◆ hash()

Combinatorics::Hasher & Rose::BinaryAnalysis::MemoryMap::hash ( Combinatorics::Hasher ) const

Compute a hash of the entire memory contents.

This hashes the memory contents. Segment information (names, addresses, permissions, etc) are not included in the hash; only the bytes stored in the map. The user should supply a hasher whose append method will be called to add memory map contents to the hash. For instance, here's one way to hash the contents of a file without having to read the entire file into memory first:

file->insertFile("/name/of/the/file", 0);
HasherSha1 hasher;
file->hash(hasher);
std::cout <<"file SHA1 hash is " <<hash <<"\n";
Combinatorics::Hasher & hash(Combinatorics::Hasher &) const
Compute a hash of the entire memory contents.

Member Data Documentation

◆ NO_ACCESS

const unsigned Rose::BinaryAnalysis::MemoryMap::NO_ACCESS = 0
static

Definition at line 179 of file MemoryMap.h.

◆ READABLE

const unsigned Rose::BinaryAnalysis::MemoryMap::READABLE = Sawyer::Access::READABLE
static

Definition at line 180 of file MemoryMap.h.

◆ WRITABLE

const unsigned Rose::BinaryAnalysis::MemoryMap::WRITABLE = Sawyer::Access::WRITABLE
static

Definition at line 181 of file MemoryMap.h.

◆ EXECUTABLE

const unsigned Rose::BinaryAnalysis::MemoryMap::EXECUTABLE = Sawyer::Access::EXECUTABLE
static

Definition at line 182 of file MemoryMap.h.

◆ IMMUTABLE

const unsigned Rose::BinaryAnalysis::MemoryMap::IMMUTABLE = Sawyer::Access::IMMUTABLE
static

Definition at line 183 of file MemoryMap.h.

◆ PRIVATE

const unsigned Rose::BinaryAnalysis::MemoryMap::PRIVATE = Sawyer::Access::PRIVATE
static

Definition at line 184 of file MemoryMap.h.

◆ INITIALIZED

const unsigned Rose::BinaryAnalysis::MemoryMap::INITIALIZED = 0x00000200
static

Definition at line 185 of file MemoryMap.h.

◆ READ_WRITE

const unsigned Rose::BinaryAnalysis::MemoryMap::READ_WRITE = READABLE | WRITABLE
static

Definition at line 188 of file MemoryMap.h.

◆ READ_EXECUTE

const unsigned Rose::BinaryAnalysis::MemoryMap::READ_EXECUTE = READABLE | EXECUTABLE
static

Definition at line 189 of file MemoryMap.h.

◆ READ_WRITE_EXECUTE

const unsigned Rose::BinaryAnalysis::MemoryMap::READ_WRITE_EXECUTE = READABLE | WRITABLE | EXECUTABLE
static

Definition at line 190 of file MemoryMap.h.

◆ RESERVED_ACCESS_BITS

const unsigned Rose::BinaryAnalysis::MemoryMap::RESERVED_ACCESS_BITS = 0x0000ffff
static

Definition at line 193 of file MemoryMap.h.


The documentation for this class was generated from the following file: