Read the game's memory and, if the user allows it, write it. Opt-in, limited, and undone automatically when the script stops.
since 1.1permission: memory, memory_write, memory_patch
Added in API 1.1. Three permissions, each listed in the manifest and granted by the user on the Scripts page:
Permission
Allows
memory
Reads, scans, and the lookups below. Nothing is changed.
memory_write
Writes to data pages. Also needs the master switch Scripts > Let scripts write game memory, which is off at every start unless the user turned it on.
memory_patch
Writes to code pages as well. Needs memory_write in the manifest too.
Addresses are plain Lua integers. Reads answer nil when an address cannot be read (the game changes under you; that is normal). Writes answer true, or false, reason when the place cannot be written, and raise an error for what a script must not do at all: no permission, the master switch off, or too many writes in a frame.
Every write is undone when the script stops (disabled, reloaded, removed, stopped by the host, or the permission or the switch taken away). The host remembers the bytes each write replaced and puts them back, unless the game has changed those bytes since (then they are left as the game has them). If the game was restarted in between, old writes are forgotten rather than undone. A script that wants a change to last has to keep running.
Limits: 4096 bytes per read and 8192 reads per frame; 1 to 256 bytes per write, 512 writes per frame, at most 4096 writes (64 KB) in force; user-mode addresses only; one write must stay inside one memory region; 8 scans at a time.
Use mem.can_write() to find out why writes are not working instead of letting a write raise an error every frame.
An address the overlay has resolved. The *_slot, entity_list, planted_c4 and global_vars values are slots that hold a pointer: read them with mem.read_ptr. view_matrix is the matrix itself, csgo_input is the object itself, and local_pawn and local_controller are the live entity addresses.
mem.scan(module: string, pattern: string, on_done: function | table): ScanHandle
Searches a module for a byte pattern. It reads the module a few milliseconds per frame, so a big module such as client.dll takes a second or two but never stalls the overlay. The callback gets the first match, or nil when there is none.
Parameter
Type
Description
module
string
A module name.
pattern
string
Hex bytes with ? or ?? wildcards, for example "48 8B 0D ?? ?? ?? ??". At most 256 bytes and at least one fixed byte.
on_done
function | table
A function fn(address), or {on_done = fn, rip_offset = n, rip_length = n} to resolve a relative operand: the result is the address that the 32-bit relative value at match + rip_offset points to, for an instruction rip_length bytes long (default 7).
Returns
Description
ScanHandle
A handle for task.await, :cancel() and :is_done().