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 change other values in scripts

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
TPRammus
Advanced Cheater
Reputation: 0

Joined: 05 Jan 2016
Posts: 61
Location: Germany

PostPosted: Thu May 26, 2016 6:47 pm    Post subject: How to change other values in scripts Reply with quote

Hey!

I recently saw this post: forum.cheatengine.org/viewtopic.php?t=574172&sid=2df4f226c2de65f9afdb512168b948e0

And I am wondering how you can change the value of an address in a script.
I mean something like that: Every time when you shoot (when the 'decrease bullets' part is ran) your HP gets set to 100.

regards, TPRammus
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Thu May 26, 2016 7:59 pm    Post subject: Reply with quote

  1. Find the address of your HP (static pointer or registered symbol).
  2. Find some instruction that's run when you shoot.
  3. Write the value 100 to the address of your HP in a code injection using that instruction.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
TPRammus
Advanced Cheater
Reputation: 0

Joined: 05 Jan 2016
Posts: 61
Location: Germany

PostPosted: Fri May 27, 2016 9:36 am    Post subject: Reply with quote

ParkourPenguin wrote:
  1. Find the address of your HP (static pointer or registered symbol).
  2. Find some instruction that's run when you shoot.
  3. Write the value 100 to the address of your HP in a code injection using that instruction.


Thank you for your answer but I dont know how the commands/instructions are. What if the addess of the health is 004F15AB and his pointers are C, 17 and 16?

And what do you mean with registered symbol?

regards, TPRammus
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4299

PostPosted: Fri May 27, 2016 9:53 am    Post subject: Reply with quote

You can copy the base address of the structure your HP is in to some memory region that's been registered as a symbol and get the address that way. For example, if the instruction mov eax,[esi+34] accesses the address of your HP, then you could do this:
Code:
aobscan(inject,8B 46 34...)
alloc(newmem,1024)
globalalloc(HPstruct,4)
label(return)

newmem:
  mov [HPstruct],esi
  mov eax,[esi+34]
  // other original code
  jmp return

inject:
  jmp newmem
  // nop as necessary
return:

After the game runs that section of asm, the address [HPstruct]+34 will be the address of your HP, and you can write to it like this:
Code:
writeInteger("[HPstruct]+34", 100)

Some things could go wrong with this method: that section of asm may not be run that often or it could also access other addresses. The first one is situational and can be solved by choosing a different injection point. The second has ways of solving it as well, but it's usually easier to choose a different injection point.


For pointers, assuming you intended to say the base address of a pointer to your health is at 004F15AB and the base address of the module it's in is at 00400000, then you can write to your health like this:
Code:
writeInteger("[[[game.exe+F15AB]+C]+17]+16", 100)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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