Joined: 13 Mar 2013
|Posted: Thu Oct 23, 2014 8:19 pm Post subject: Pre-fill Scan Range
|Some programs always allocate memory as the same fixed address. (pcsx2, for instance, does so at 20000000) When dealing with those programs a lot, it becomes convenient to pre-fill the scan range with the fixed range.
set_scanrange = (function(frmMain)
-- Enclosed in an anonymous function call in order to
-- cache the result of getMainForm while avoiding the
-- need to pollute the script's locals.
local function find(name)
local function dec2hex(nValue, maybe_size)
local size = maybe_size or 0
local fmt = '%'
if type(nValue) == 'string' then nValue = tonumber(nValue) end
if size ~= 0 then fmt = fmt .. '0' .. tostring(size) end
fmt = fmt .. 'X'
return string.format(fmt, nValue)
-- Pretty sure we can cache the results of the 'find'
-- calls, but whatever.
return function(fromaddr, toaddr)
local fromctrl = find('FromAddress')
local toctrl = find('ToAddress')
if type(fromaddr) ~= 'string' then
fromaddr = dec2hex(fromaddr)
if type(toaddr) ~= 'string' then
toaddr = dec2hex(toaddr)
fromctrl.Lines.Text = fromaddr
toctrl.Lines.Text = toaddr
Note: This only works once Cheat Engine has attached to a process, so you'll most likely need to add the call to the handler for onOpenProcess.