A type constructor that accepts a type T as parameter and builds the type representing "a pointer to T" (T*).

The main use of pointer types is that they can be dereferenced. See reven2.trace.Context.deref for more information.

When an instance of a pointer type is read, it is returned as an address, built from the read offset and from a base address stored in the pointer type.

Note: when reading the address of a pointer, it is considered like an integer of the same endianness, signedness and size as USize.

Method __init__ Initializes a new pointer type from its element type and the kind of address it should produce.
Method size_bytes The minimal number of bytes necessary to hold an instance of a pointer, depending on the context.
Method parse Parses the value of a pointer from a raw buffer, depending on the context. Always returns an address
Method elem_type Property: The pointed-to type.
Method is_context_sensitive Whether the context argument needed by some methods actually has an effect.
Method _construct_type Return the underlying construct instance
Static Method _compute_base_address Undocumented
def __init__(self, elem_type, segment_register=None, segment_index=None, is_linear=False, is_physical=False, base_address=None):

Initializes a new pointer type from its element type and the kind of address it should produce.

Kind of address

When the value of a Pointer is read, it is returned as an address. Since there are logical addresses with various segments, linear addresses and physical addresses, it is important that a Pointer instance knows which kind of addresses it should produce.

To determine the kind of address produced by a Pointer instance, one of the following arguments can be provided to its constructor:

  • segment_register: to specify a logical address using a segment register
  • segment_index: to specify a logical address using a segment index
  • is_linear: to specify a linear address
  • is_physical: to specify a physical address
  • base_address: to specify that the produced address is an offset relative to an existing base_address. This is useful for instance when reading a table containing offsets used to build function pointers relative to a fixed base address.

If none of these arguments is provided, then the address kind will default to logical addresses with the default segment (ds).

Information

Parameterselem_typethe pointed-to type.
segment_registera segment register indicating that logical addresses using this segment register should be produced.
segment_indexan integer indicating that logical addresses using this segment index should be produced.
is_linearif True, indicates that linear addresses should be produced.
is_physicalif True, indicates that physical addresses should be produced.
base_addressthe base address from which addresses should be produced.
RaisesTypeErrorif elem_type is not a type
TypeErrorif base_address is not an address
ValueErrorif more than one in 'segment_register', 'segment_index', 'is_linear', 'is_physical' or 'base_address' is provided
def size_bytes(self, context=None):

The minimal number of bytes necessary to hold an instance of a pointer, depending on the context.

Information

ParameterscontextThe context object. See package documentation.
ReturnsAn integer.
def parse(self, buf, context):

Parses the value of a pointer from a raw buffer, depending on the context. Always returns an address

Information

ParameterscontextThe context object. See package documentation.
ReturnsAn address from reven2.address.
def _construct_type(self, context=None):

Return the underlying construct instance

@property
def elem_type(self):

Property: The pointed-to type.

Information

ReturnsA type from reven2.types.
def is_context_sensitive(self):

Whether the context argument needed by some methods actually has an effect.

Types that return False to this method are context-insensitive types. You can safely pass any object as context parameter (including None) to the methods of such type.

Note that the context-sensitivity of a type may change in the future.

Examples

Getting the size of a type without needing a context for context-insensitive types: >>> types.U32.is_context_sensitive() False >>> types.U32.size_bytes(context=None) 4 >>> array32_12 = types.Array(types.U32, 12) >>> array32_12.is_context_sensitive() False >>> array32_12.size_bytes() # context=None by default 48

Context-sensitive types may raise errors when attempting to get the size without a context: >>> types.USize.is_context_sensitive() True >>> types.USize.size_bytes(context=None) ValueError: Please provide a context when using a context-sensitive type

@staticmethod
def _compute_base_address(segment_register=None, segment_index=None, is_linear=None, is_physical=None, base_address=None):
Undocumented
API Documentation for reven2, generated by pydoctor at 2019-11-13 18:38:15.