TypedObject class¶
TypedObject represents a typed object in the target process’s virtual address space. It can be constructed from a type and an address, or by looking up fields of a struct, dereferencing pointers, accessing array elements, and so on.
-
class
DbgScript::
TypedObject
¶
-
TypedObject#name -> String
Get the name of the object.
-
TypedObject#address -> Integer
Get the virtual address of the object.
-
TypedObject#type -> String
Get the type name of the object.
-
TypedObject#module -> String
Get the module name of the typed object.
-
TypedObject#data_size -> Integer
Get the size of the object in bytes.
-
TypedObject#value
Returns the value of the object, if it’s a primitive type. Raises
TypeError
otherwise.
-
obj[key]
If key is an integer, attempts an array element access. If the object is not an array or pointer, raises
RuntimeError
.If key is a string, attempts to look up a field with that name. If no such field exists, raises
RuntimeError
.
-
obj.
field
()¶ Secondary way of looking up fields. If field names a built-in attribute, that attribute is returned. Otherwise a field lookup is performed.
This allows a more convenient way of traversing C/C++ objects. E.g.:
foo.m_bar foo['m_bar']
are equivalent. The explicit form is more performant though and recommended for tight loops.
-
TypedObject#read_string([count]) -> String
Read an ANSI string from the target process starting at this object’s address. count (optional) specifies the maximum number of characters to read.
-
TypedObject#read_wide_string([count]) -> String
Read a wide string from the target process starting at this object’s address. count (optional) specifies the maximum number of characters to read.
-
TypedObject#read_bytes(count) -> String
Read a block of count bytes from the target process from this object’s address.
New in version 1.0.3.
-
TypedObject#deref -> TypedObject
Dereference the current object, if it’s a pointer or array.
-
TypedObject#get_runtime_obj -> TypedObject
Attempts to dynamically down-cast the current object if it has a vtable.
-
TypedObject#length -> Integer
-
TypedObject#size -> Integer
If this object represents an array, returns its length, otherwise raises a
TypeError
.