memory.manager module¶
Provides extended memory functionality.
-
class
memory.manager.
CustomType
(*args, *, wrap=False, auto_dealloc=True)[source]¶ Bases:
memory.helpers.BasePointer
Subclass this class if you want to create a new type.
Make sure that you have set the metaclass attribute to a valid TypeManager instance.
-
class
memory.manager.
TypeManager
[source]¶ Bases:
dict
Class able to reconstruct almost every possible data type.
-
convert
(name, ptr)[source]¶ Convert the pointer.
Tries to convert a pointer in the following order:
Attempts to convert the pointer... 1. to a custom type 2. to a exposed type 3. to a function typedef 4. by using a converter
-
static
create_pipe
(cls_dict)[source]¶ Create a new pipe class that acts like a collection of functions.
-
create_type
(name, cls_dict, bases=(<class 'memory.manager.CustomType'>, ))[source]¶ Create and registers a new class.
-
create_type_from_dict
(type_name, raw_data, bases=(<class 'memory.manager.CustomType'>, ))[source]¶ Create and registers a new type from a dictionary.
-
create_type_from_file
(type_name, f, bases=(<class 'memory.manager.CustomType'>, ))[source]¶ Create and registers a new type from a file or URL.
-
custom_calling_convention
(cls)[source]¶ Register a custom calling convention class by its name.
Example:
@manager.custom_calling_convention class MyCustomCallingConvention(CallingConvention): pass # Equals to... class MyCustomCallingConvention(CallingConvention): pass manager.register_convention( 'MyCustomCallingConvention', MyCustomCallingConvention)
-
dynamic_instance_array
(type_name, offset, length=None, doc=None)[source]¶ Create a wrapper for a dynamic instance array.
- Examples:
- Vector* pVecArray; bool* pBoolArray;
Those arrrays are mostly created by the “new” statement.
-
dynamic_pointer_array
(type_name, offset, length=None, doc=None)[source]¶ Create a wrapper for a dynamic pointer array.
- Examples:
- Vector** pVecArray; bool** pBoolArray;
Those arrays are mostly created by the “new” statement.
-
function
(identifier, args=(), return_type=_memory.DataType.VOID, convention=_memory.Convention.THISCALL, doc=None)[source]¶ Create a wrapper for a function.
-
function_typedef
(name, args=(), return_type=_memory.DataType.VOID, convention=_memory.Convention.CDECL, doc=None)[source]¶ Create a new function typedef.
When a class has an attribute that contains a pointer of a function, the attribute will return a Function object that will be created by this method.
-
get_class
(name)[source]¶ Return the custom type for the given name.
Tries to return a custom type that matches the given name. If no custom type was found, it tries to return a class that was exposed on the C++ side. If that fails too, None will be returned.
-
global_pointer
(cls, binary, identifier, offset=0, level=0, srv_check=True, accessor=False, accessor_offset=0)[source]¶ Search for a global pointer and wrap the it.
-
instance_attribute
(type_name, offset, doc=None)[source]¶ Create a wrapper for an instance attribute.
- Examples:
- Vector vecVal; bool bVal;
-
pipe_function
(binary, identifier, args=(), return_type=_memory.DataType.VOID, convention=_memory.Convention.CDECL, srv_check=True, doc=None)[source]¶ Create a simple pipe function.
-
pointer_attribute
(type_name, offset, doc=None)[source]¶ Create a wrapper for a pointer attribute.
- Examples:
- Vector* pVec; bool* pBool;
-
register_convention
(name, convention)[source]¶ Register a custom calling convention.
Parameters: - name (str) – Name of the custom calling convention.
- convention (CallingConvention) – The custom calling convention.
-
register_converter
(name, obj)[source]¶ Register a callable object as a converter.
The callable object should only accept a pointer as an argument.
-
static_instance_array
(type_name, offset, length=None, doc=None)[source]¶ Create a wrapper for a static instance array.
- Examples:
- Vector vecArray[10]; bool boolArray[10];
-