memory
Raw native access: pattern scans, CreateInterface, exports, and binding virtual or pattern-located functions through FFI.
Native memory: these functions expose raw addresses. Invalid pointers, types or virtual-function indices can crash the game.
Module names are exact and case-sensitive, for example "engine2.dll". Pattern signatures use space-separated hex bytes with ? or ?? wildcards: use 48 8B, not 488B.
memory.pattern
memory.pattern(module, signature)Searches the entire module image. Cache results; scanning large modules is expensive. No offset is applied; add one to the result yourself.
Returns: the first matching address as lightuserdata, or nil.
memory.interface
memory.interface(module, name)Calls the module's CreateInterface. name must include the full interface version, for example "Source2Client002".
Returns: lightuserdata, or nil.
memory.export
memory.export(module, name)Looks up an export by exact name. For a forwarded export, the result is the address of the forwarder string, not executable code.
Returns: lightuserdata, or nil.
memory.bind_virtual
memory.bind_virtual(module, interface, index, ctype)Resolves the named interface and its zero-based virtual-function slot once, then returns a Lua function f(...) that supplies the interface as this.
ctype is a function-pointer type whose first parameter is the this pointer, for example "int(__thiscall*)(void*, int)".
Returns: function.
Errors: invalid interface or invalid C type.
memory.bind_pattern
memory.bind_pattern(module, interface, signature, ctype)Like memory.bind_virtual, but locates the function by signature in the same module. No offset adjustment or relative-address resolution is performed.
Returns: function.
Errors: invalid interface, invalid C type or invalid signature.
memory.virtual_thunk
memory.virtual_thunk(index, ctype)Returns f(instance, ...), which reads the instance's vtable on each call.
Returns: function.
Errors: calling the result with NULL cdata raises attempt to dereference a null pointer.
