class Pointer(Type):
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 | __eq__ |
Compares the instance for equality with an object. |
Method | __hash__ |
Returns the hash for this value. |
Method | __init__ |
Initializes a new pointer type from its element type and the kind of address it should produce. |
Method | __ne__ |
Undocumented |
Method | __str__ |
Returns the nicely printable string representation of this instance. |
Method | cast |
Returns a new pointer type, specifying a different element type it should dereference to. |
Method | is |
Whether the context argument needed by some methods actually has an effect. |
Method | size |
The minimal number of bytes necessary to hold an instance of a pointer, that may depend on the context. |
Property | elem |
Property: The pointed-to type. |
Static Method | _compute |
Undocumented |
Method | _construct |
Return the underlying construct instance |
Method | _decode |
Undocumented |
Method | _encode |
Undocumented |
Method | _resolve |
Uses the resolver to return a resolved version of the type, if possible. |
Instance Variable | _base |
Undocumented |
Instance Variable | _elem |
Undocumented |
Instance Variable | _underlying |
Undocumented |
Inherited from Type
:
Method | description |
The short description of this type. |
Method | parse |
Parses the value of an instance of this type from a raw buffer, possibly depending on the context. |
Method | to |
Build a byte buffer from a value of this type. |
Compares the instance for equality with an object.
- if the object is not a
Pointer
, it will never be equal to this instance.
Parameters | |
o:object | Undocumented |
Returns | |
bool | Undocumented |
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).
Additionally, the pointer size can either be context-sensitive (by default), meaning it will be 64-bit in 64-bit contexts and 32-bit in 32-bit contexts, or explicitly specified (and thus not context-sensitive).
Information
Parameters | |
elemType | the pointed-to type. |
segment_Optional[ | a segment register indicating that logical addresses using this segment register should be produced. |
segment_Optional[ | an integer indicating that logical addresses using this segment index should be produced. |
isbool | if True, indicates that linear addresses should be produced. |
isbool | if True, indicates that physical addresses should be produced. |
base_Optional[ | the base address from which addresses should be produced. |
size:_Optional[ | if provided, the size of the pointer. If None, then the pointer's size is determined by the bitness of the current context. |
Raises | |
TypeError | if elem_type is not a type |
TypeError | if base_address is not an address |
ValueError | if more than one in 'segment_register', 'segment_index', 'is_linear', 'is_physical' or 'base_address' is provided |
ValueError | if a size different from 2, 4, 8, 16 or None is specified. |
Returns the nicely printable string representation of this instance.
Returns | |
str | Undocumented |
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
Returns | |
bool | Undocumented |
reven2.types._type.Type.size_bytes
The minimal number of bytes necessary to hold an instance of a pointer, that may depend on the context.
Information
Parameters | |
context | The context object. See package documentation. |
Returns | |
int | An integer. |
def _compute_base_address(segment_register=None, segment_index=None, is_linear=None, is_physical=None, base_address=None):
Undocumented
reven2.types._type.Type._construct_type
Return the underlying construct instance
Undocumented
Parameters | |
value:address._AbstractAddress | Undocumented |
_ | Undocumented |
reven2.types._type.Type._resolve
Uses the resolver to return a resolved version of the type, if possible.
Parameters | |
resolver:TypeResolver | Undocumented |
Returns | |
Type | Undocumented |