Skip to content

Memory

Reading and writing is memory.readU32, memory.writeF32 and co. This page is the bigger tools. The async ones give promises, so await them in a task.

Like Cheat Engine. memory.scan looks on a worker and gives the scan, then next narrows it.

local memory = wraith.memory
wraith.spawn(function()
local scan = memory.scan({ type = "i32", value = 100 }):await()
-- Take a hit, then
scan:next("decreased"):await()
scan:next("exact", 90):await()
health = scan:results(1)[1]
end)

type is u8 to u64, i8 to i64, f32, f64, string, utf16 or bytes for a pattern like "48 8B ?? C3". Pass module or start and length to look in less. next takes exact, changed, unchanged, increased, decreased, greater, less or between with a low and a high. scan.count says how many are left. Results are freed when the plugin stops, or with scan:destroy().

for _, r in ipairs(memory.regions({ module = "game.exe" })) do print(r.start, r.length, r.writable) end
local old = memory.protect(address, 16, "read_write")

regions({ all = true }) lists memory you can’t read too. Wraith puts protection back when the plugin stops.

memory.watch uses one of the CPU’s four debug registers. The callback runs at the start of the next frame, with where the instruction is.

memory.watch(health, 4, "write", function(hit)
print("written by", hit.instruction, wraith.code.disassemble(hit.instruction)[1].text)
end):next(function(w) watch = w end)

Stop it with watch:stop(). "read" only counts loads, and "access" is either.

Made with ♥ by Asgard