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
→ str¶ Get the name of the object.
-
TypedObject.
address
→ int¶ Get the virtual address of the object.
-
TypedObject.
type
→ str¶ Get the type name of the object.
-
TypedObject.
size
→ int¶ Get the size of the object in bytes.
-
TypedObject.
value
¶ Returns the value of the object, if it’s a primitive type. Raises
ValueError
otherwise.
-
TypedObject.
module
→ str¶ Get the module name of the typed object.
-
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]) → str¶ 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]) → str¶ 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) → bytes¶ 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.
-
builtin.
len
(obj) → int¶ If this object represents an array, returns its length, otherwise raises an
ValueError
.