Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Pre-fill Scan Range

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
juntalis
Newbie cheater
Reputation: 2

Joined: 13 Mar 2013
Posts: 11

PostPosted: Thu Oct 23, 2014 8:19 pm    Post subject: Pre-fill Scan Range Reply with quote

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.

Code:

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)
      return frmMain.findComponentByName(name)
   end

   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)
   end

   -- 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)
      end
      if type(toaddr) ~= 'string' then
         toaddr = dec2hex(toaddr)
      end
      fromctrl.Lines.Text = fromaddr
      toctrl.Lines.Text = toaddr
   end
end)(getMainForm())

set_scanrange('20000000', '2A000000')


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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites