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. Characters that are neither hex digits, ? nor whitespace are skipped; an empty signature finds nothing.
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)". ctype and any further arguments are passed to ffi.typeof, so a ctype object or a parameterized type with its arguments also works.
Returns: function.
Errors: module needs to be a string, interface needs to be a string, index needs to be a number, 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: module needs to be a string, interface needs to be a string, signature needs to be a string, 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: index needs to be a number or invalid C type; calling the result with NULL cdata raises attempt to dereference a null pointer.
