class documentation

class MemoryRange(_Generic[_address.AddressType]):

View In Hierarchy

This class represents a memory range as defined by its address and size.

Class Method from_string Parses the string and creates the corresponding memory range object if this string is in a valid memory range format.
Method __and__ Computes the intersection of this range with another of the same address type.
Method __contains__ Returns whether or not the passed address or range is contained in self.
Method __eq__ Compares the instance for equality with an object.
Method __hash__ Returns the hash for this value.
Method __init__ Initializes a MemoryRange
Method __iter__ Returns an iterator over all addresses in the range.
Method __len__ Returns the size of this memory range, which is at least 1 (empty ranges are not allowed).
Method __ne__ Compares the instance for equality with an object.
Method __or__ Computes the union of this range with another of the same address type.
Method __repr__ Returns the "official" string representation of this instance.
Method __str__ Returns the nicely printable string representation of this instance.
Method __sub__ Computes the difference of this range with another of the same address type.
Method difference Computes the difference of this range with another of the same address type.
Method format_as_html This method gets an html formatting string representation for this class instance.
Method intersection Computes the intersection of this range with another of the same address type.
Method isdisjoint Returns whether or not there exists no element contained both in self and in other.
Method issubset Returns whether or not all elements of self are contained in other.
Method issuperset Returns whether or not all elements of other are contained in self.
Method translate Translates this memory range into the corresponding physical memory ranges.
Method union Computes the union of this range with another of the same address type.
Property address Property: The start address of the memory range.
Property begin Property: The first address in the memory range.
Property end Property: The first address not contained in the memory range.
Property first Property: The first address in the memory range.
Property last Property: The last address in the memory range.
Property size Property: The size of the memory range.
Class Method _parse_memory_range Attempts to parse the string as a memory range.
Method _repr_html_ Representation used by Jupyter Notebook when an instance of a memory range is displayed in a cell.
Instance Variable _address Undocumented
Instance Variable _size Undocumented
@classmethod
def from_string(cls, memory_range_str):

Parses the string and creates the corresponding memory range object if this string is in a valid memory range format.

Information

Parameters
memory_range_str:strstring in the memory range format (eg. [ds:0xffff89754; 3])
Returns
MemoryRangeUndocumented
Raises
ValueErrorif the provided string cannot be parsed.
def __and__(self, other):

Computes the intersection of this range with another of the same address type.

The intersection is defined as the biggest subrange that is both contained in self and in other.

If such range would be empty, None is returned.

Parameters
other:_Optional[MemoryRange[_address.AddressType]]Undocumented
Returns
_Optional[MemoryRange[_address.AddressType]]Undocumented
def __contains__(self, x):

Returns whether or not the passed address or range is contained in self.

A range is considered as contained in another if it is a subset of that other range.

Parameters
x:_Union[_address.AddressType, MemoryRange[_address.AddressType]]Undocumented
Returns
boolUndocumented
def __eq__(self, other):

Compares the instance for equality with an object.

  • if the object is not a MemoryRange, will return False.
Returns
boolUndocumented
def __hash__(self):

Returns the hash for this value.

Returns
intUndocumented
def __init__(self, address, size):

Initializes a MemoryRange

Information

Parameters
address:_address.AddressTypeThe beginning address of the memory range.
size:intThe size of the memory range.
Raises
ValueErrorif size <= 0.
def __iter__(self):

Returns an iterator over all addresses in the range.

Returns
_Iterator[_address.AddressType]Undocumented
def __len__(self):

Returns the size of this memory range, which is at least 1 (empty ranges are not allowed).

Returns
intUndocumented
def __ne__(self, other):

Compares the instance for equality with an object.

  • if the object is not a MemoryRange, will return True.
Returns
boolUndocumented
def __or__(self, other):

Computes the union of this range with another of the same address type.

The union is defined as the smallest range that contains both self and other, but no other element.

If self and other are disjoint and not contiguous, then None is returned.

Parameters
other:_Optional[MemoryRange[_address.AddressType]]Undocumented
Returns
_Optional[MemoryRange[_address.AddressType]]Undocumented
def __repr__(self):

Returns the "official" string representation of this instance.

Returns
strUndocumented
def __str__(self):

Returns the nicely printable string representation of this instance.

Returns
strUndocumented
def __sub__(self, other):

Computes the difference of this range with another of the same address type.

The difference is defined as a pair of ranges such that:

  • The first range contains all elements of self that are before the first element of other.
  • The second range contains all elements of self that are after the last element of other.

If any of these ranges would be empty, then None is returned in its stead.

Parameters
other:_Optional[MemoryRange[_address.AddressType]]Undocumented
Returns
_Tuple[_Optional[MemoryRange[_address.AddressType]], _Optional[MemoryRange[_address.AddressType]]]Undocumented
def difference(self, other):

Computes the difference of this range with another of the same address type.

The difference is defined as a pair of ranges such that:

  • The first range contains all elements of self that are before the first element of other.
  • The second range contains all elements of self that are after the last element of other.

If any of these ranges would be empty, then None is returned in its stead.

Parameters
other:_Optional[MemoryRange[_address.AddressType]]Undocumented
Returns
_Tuple[_Optional[MemoryRange[_address.AddressType]], _Optional[MemoryRange[_address.AddressType]]]Undocumented
def format_as_html(self):

This method gets an html formatting string representation for this class instance.

Returns
strUndocumented
def intersection(self, other):

Computes the intersection of this range with another of the same address type.

The intersection is defined as the biggest subrange that is both contained in self and in other.

If such range would be empty, None is returned.

Parameters
other:_Optional[MemoryRange[_address.AddressType]]Undocumented
Returns
_Optional[MemoryRange[_address.AddressType]]Undocumented
def isdisjoint(self, other):

Returns whether or not there exists no element contained both in self and in other.

Parameters
other:MemoryRange[_address.AddressType]Undocumented
Returns
boolUndocumented
def issubset(self, other):

Returns whether or not all elements of self are contained in other.

Parameters
other:MemoryRange[_address.AddressType]Undocumented
Returns
boolUndocumented
def issuperset(self, other):

Returns whether or not all elements of other are contained in self.

Parameters
other:MemoryRange[_address.AddressType]Undocumented
Returns
boolUndocumented
def translate(self, context):

Translates this memory range into the corresponding physical memory ranges.

If self is already a physical memory range, it will be yielded without a translation.

Otherwise this virtual memory range will be translated to its corresponding physical range at the provided context.

Note that a single contiguous virtual memory range can be mapped to multiple non-contiguous physical memory ranges.

Information

Parameters
context:_Contextis the context used to translate a virtual range.
Returns
_Iterator[MemoryRange[_address.PhysicalAddress]]Undocumented
Raises
RuntimeErrorif the memory range is not fully mapped at the specified context.
def union(self, other):

Computes the union of this range with another of the same address type.

The union is defined as the smallest range that contains both self and other, but no other element.

If self and other are disjoint and not contiguous, then None is returned.

Parameters
other:_Optional[MemoryRange[_address.AddressType]]Undocumented
Returns
_Optional[MemoryRange[_address.AddressType]]Undocumented
@property
address: _address.AddressType =

Property: The start address of the memory range.

@property
begin: _address.AddressType =

Property: The first address in the memory range.

@property
end: _address.AddressType =

Property: The first address not contained in the memory range.

@property
first: _address.AddressType =

Property: The first address in the memory range.

@property
last: _address.AddressType =

Property: The last address in the memory range.

@property
size: int =

Property: The size of the memory range.

@classmethod
def _parse_memory_range(cls, memory_range):

Attempts to parse the string as a memory range.

The expected memory range form is [(segment_reg/phy/lin/segment_index):offset; size]

Parameters
memory_range:strUndocumented
Returns
MemoryRangeUndocumented
Raises
ValueErrorif the passed string cannot be parsed as a memory range
def _repr_html_(self):

Representation used by Jupyter Notebook when an instance of a memory range is displayed in a cell.

The range contains a clickable link containing the address string, that publishes the address to all tracked reven2.session.Sessions.

Returns
strUndocumented
_address =

Undocumented

_size =

Undocumented