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 


Changing AoB's values through a lua script?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Nicholas Cage
Newbie cheater
Reputation: 0

Joined: 18 Apr 2014
Posts: 16
Location: no

PostPosted: Fri May 30, 2014 11:06 pm    Post subject: Changing AoB's values through a lua script? Reply with quote

Yeah.
I'm wondering.
Example:
I have the AoB 00 40 1C 46 00 00 7A 44 01 00 00 00 00 00 7A C4, and I want to change it to 00 40 1C C6 00 00 7A 44 01 00 00 00 00 00 7A C4, but through a script - how would I do it?
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Nicholas Cage
Newbie cheater
Reputation: 0

Joined: 18 Apr 2014
Posts: 16
Location: no

PostPosted: Sat May 31, 2014 8:23 pm    Post subject: Reply with quote

Come on people, please.
I really need to know this quick.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Sat May 31, 2014 9:04 pm    Post subject: Reply with quote

aobscan(foo, bytes)
foo:
db changedbytes

_________________
A nagy kapu mellett, mindig van egy kis kapu.
----------------------
Come on...
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Jun 01, 2014 6:51 am    Post subject: Reply with quote

Although there's endless scripts of how to do so.. even a AOBSwap function which does it for you by only supplying scan and replace aobs, heres a simple way to do so.

Kindly use search button, and don't request help until you checked each result and result.

Code:
local scan = '00 40 1C 46 00 00 7A 44 01 00 00 00 00 00 7A C4';
local replace = '00 40 1C C6 00 00 7A 44 01 00 00 00 00 00 7A C4';
local replace_table = {}; -- writeBytes function requires either a table with hex values or parameters with hex values... this converts the string above to a table.
for byte in string.gfind(replace, "[^%s]+") do
   table.insert(replace_table, tonumber('0x'..byte));
end
print(unpack(replace_table)); -- Output of table..(table values are parsed as integer).
local data = AOBScan(scan);
if (data) then
   local count = data.getCount();
   for i=0, count-1 do
      local address = data.getString(i);
      writeBytes(address, replace_table);
   end
end


Incase you're not using space between bytes, heres a small tweak to use with or without space, just call the function with aob.
Code:
function AOB_to_Table(aob)
   local space = (string.find(aob, '%s'))~=nil and true or false
   local output = {};
   if (space) then
      for byte in string.gfind(aob, "[^%s]+") do
         table.insert(output, tonumber('0x'..byte));
      end
   else
      for i=1,aob:len(), 2 do
         table.insert(output, tonumber('0x' .. string.sub(aob,i,i+1)));
      end
   end
   return output;
end
local scan = '00 40 1C 46 00 00 7A 44 01 00 00 00 00 00 7A C4';
-- local replace = '00 40 1C C6 00 00 7A 44 01 00 00 00 00 00 7A C4';
local replace = '00401CC600007A440100000000007AC4';
local replace_table = AOB_to_Table(replace); -- detects if space is used or not... and returns aob table..
local data = AOBScan(scan);
if (data) then
   local count = data.getCount();
   for i=0, count-1 do
      local address = data.getString(i);
      writeBytes(address, replace_table)
   end
end

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
AiriK
How do I cheat?
Reputation: 0

Joined: 14 Nov 2014
Posts: 1

PostPosted: Fri Nov 14, 2014 4:09 am    Post subject: Reply with quote

DaSpamer wrote:


Code:
local scan = '00 40 1C 46 00 00 7A 44 01 00 00 00 00 00 7A C4';
local replace = '00 40 1C C6 00 00 7A 44 01 00 00 00 00 00 7A C4';
local replace_table = {}; -- writeBytes function requires either a table with hex values or parameters with hex values... this converts the string above to a table.
for byte in string.gfind(replace, "[^%s]+") do
   table.insert(replace_table, tonumber('0x'..byte));
end
print(unpack(replace_table)); -- Output of table..(table values are parsed as integer).
local data = AOBScan(scan);
if (data) then
   local count = data.getCount();
   for i=0, count-1 do
      local address = data.getString(i);
      writeBytes(address, replace_table);
   end
end




does this work with ?? bytes?
im trying to change '01 15 00 00 ?? 00 00 00 01 15 00 00 05 00 00 00 0F 0A 00 00 ?? ?? ?? ?? 01 15 00 00 1A 00 00 00 01 15 00 00 A0 28'
into '01 15 00 00 ?? 00 00 00 01 15 00 00 05 00 00 00 0F 0A 00 00 ?? ?? ?? ?? 01 15 00 00 1A 00 00 00 01 15 00 00 00 00'
but its not working, it changes some else address and make the game crash
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Fri Nov 14, 2014 11:45 am    Post subject: This post has 1 review(s) Reply with quote

There is other scripts.. but anyway made this one
does not care about space, or invalid character (it ignores it).
Code:
function AOBSwap(aob_s, aob_r)
   local clean   = function (str)
      local array = {};
      for byte in string.gfind((string.gsub(str,"([^ABCDEFabcdef0123456789?])",'')), '..') do
         table.insert(array,byte);
      end
      return array;
   end
   local aob_s_arr,aob_r_arr = clean(aob_s),clean(aob_r);
   local aobs = AOBScan(table.concat(aob_s_arr, " "));
   if (aobs) then
      for entry = 0, aobs.Count -1 do
         for offset,value in pairs(aob_r_arr) do
            if (value and tonumber(value)) then
               writeBytes(aobs.getString(entry)..'+' .. string.format("%x",offset-1), tonumber(value,16));
            end
         end
      end
      aobs.destroy();
      return true
   end
   return false
end

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
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 Lua Scripting 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 can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites