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 


How to increase 1 byte by 2..

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Thu Jun 06, 2013 4:04 pm    Post subject: How to increase 1 byte by 2.. Reply with quote

Hey,
I'm trying to do an Aobscan for some AoB.
I don't want to update the script, so I'm trying to do the following:
Aobscan for 00 ?? ?? 01 01 02 03 (example).

The following bytes are changing
Quote:
00 ?? ?? 01 01 02 03


I want to read the high lighted byte
Quote:
00 ?? ?? 01 01 02 03

And increase it by 2.
(Convert it to decimal, increase by 2, convert back to hex and then write bytes).

My issue is, to read that 1 byte.
Any help?

Code:
function Hack(sender)
   aob=AOBScan("00 ?? ?? 01 01 02 03")
   if (aob~=nil) then
      count=stringlist_getCount(aob)
     if (count~=0) then
         for i= 0, count-1 do
         hack=stringlist_getString(aob,i)
         print(string.format( '%x' , readBytes(hack, 4))) -- This prints only the first bytes (00) so useless
         end
     end
     object_destroy(aob)
     results=nil
   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


Last edited by DaSpamer on Thu Jun 06, 2013 6:04 pm; edited 2 times in total
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Thu Jun 06, 2013 4:46 pm    Post subject: Re: How to increase 2 bytes by 2.. Reply with quote

DaSpamer wrote:
I want to read the high lighted byte
Quote:
00 ?? ?? 01 01 02 03

And increase it by 2.
The thread title says you want to increase 2 bytes by 2, the quote above says you want to increase a single byte. Not knowing what you actually want to do, I shit a brick.

This brick:
Code:
YouWant2Bytes=false;

function Hack(sender)
    local aob=AOBScan("00 ?? ?? 01 01 02 03")
    if (aob~=nil) then
       local count=stringlist_getCount(aob)
      if (count~=0) then
          for i= 0, count-1 do
             local hack=getAddress(stringlist_getString(aob,i))+1;
             local Bytes;
             if (YouWant2Bytes) then
                Bytes=readBytes(hack,2,true);
                if (Bytes[1]>0xFD) then
                   Bytes[2]=Bytes[2]+1;
                end
                Bytes[1]=Bytes[1]+2;
                writeBytes(hack,Bytes[1],Bytes[2]);
             else
                 Bytes=readBytes(hack,1,true);
                 Bytes[1]=Bytes[1]+2;
                 writeBytes(hack,Bytes[1]);
             end

          end
      end
      object_destroy(aob)
      results=nil
    end
end
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Thu Jun 06, 2013 6:05 pm    Post subject: Reply with quote

Whoops sorry for misleading, will fix.

Also thanks,
I've never used Aobscan for this kind of thing.

_________________
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