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.

__init__(*args, *, wrap=False, auto_dealloc=True)[source]

Initialize the custom type.

on_dealloc()[source]

Call the destructor.

This method is automatically called, when the pointer gets deallocated. It then calls the destructor if it was specified.

_binary = None
_constructor = None
_destructor = None
_manager = None
_srv_check = True
class memory.manager.TypeManager[source]

Bases: dict

Class able to reconstruct almost every possible data type.

__init__()[source]

Initialize the instance.

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

create_converter(name)[source]

Create a new converter for the given name.

create_function_typedefs_from_file(f)[source]

Create function typedefs from a file.

create_global_pointers_from_file(f)[source]

Create global pointers from a file.

static create_pipe(cls_dict)[source]

Create a new pipe class that acts like a collection of functions.

create_pipe_from_dict(raw_data)[source]

Create a pipe from a dictionary.

create_pipe_from_file(f)[source]

Create a pipe from a file or URL.

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.

get_global_pointer(name)[source]

Return the global pointer for the given class.

global_pointer(cls, binary, identifier, offset=0, level=0, srv_check=True)[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];
static_pointer_array(type_name, offset, length=None, doc=None)[source]

Create a wrapper for a static pointer array.

Examples:
Vector* pVecArray[10]; bool* pBoolArray[10];
unregister_convention(name)[source]

Unregister a custom calling convention.

unregister_converter(name)[source]

Unregister a converter.

virtual_function(index, args=(), return_type=_memory.DataType.VOID, convention=_memory.Convention.THISCALL, doc=None)[source]

Create a wrapper for a virtual function.