Logging data from arbitrary binary using Cheat Engine
Created on:
Reading time: less than a minute
TODO: - List versions used
Words go here and here
from https://github.com/stavae/mirror-SpectrometerSim/releases some more wordy words go here
An example of using interpreted text
#if _32x_
loadlibrary(luaclient-i386.dll)
#else
loadlibrary(luaclient-x86_64.dll)
#endif
luacall(openLuaServer('CELUASERVER'))
CELUA_ServerName:
db 'CELUASERVER',0
[ENABLE]
{$lua}
if syntaxcheck then return end
-- Get timezone (from http://lua-users.org/wiki/TimeZone)
local function get_timezone()
local now = os.time()
return os.difftime(now, os.time(os.date("!*t", now)))
end
timezone = get_timezone()
-- Return a timezone string in ISO 8601:2000 standard form (+hhmm or -hhmm)
local function get_tzoffset(timezone)
local h, m = math.modf(timezone / 3600)
return string.format("%+.4d", 100 * h + 60 * m)
end
tzoffset = get_tzoffset(timezone)
-- Actual log function
function do_log()
file = io.open("out.log", "a")
local offset = readInteger(getAddress("SpectrometerSim_Win32.exe+22A084"))
local amplitude = readFloat(getAddress("SpectrometerSim_Win32.exe+221A90"))
-- Alternatively 'os.date("!%Y-%m-%dT%H:%M:%S")' would return UTC time
file:write(os.date("%Y-%m-%dT%H:%M:%S"), tzoffset, ",", offset, ",", amplitude, "\n")
file:close()
end
{$asm}
define(address,"SpectrometerSim_Win32.exe"+1D9FDC)
define(bytes,E8 5F 5B EC FF)
assert(address,bytes)
alloc(newmem,$1000)
alloc(luafunctionid,4)
alloc(luafunctionname,256)
label(code)
label(return)
luafunctionname:
db 'do_log()',0
newmem:
// Call the lua function (differs for x64 and x32 binaries!)
push 1 // Dummy value to pass to 'parameter' of our function (unused)
push luafunctionname
call CELUA_ExecuteFunction
code:
call SpectrometerSim_Win32.exe+9FB40
jmp return
address:
jmp newmem
return:
[DISABLE]
address:
db bytes
// call SpectrometerSim_Win32.exe+9FB40
dealloc(newmem)