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 do I directly change a value in an ASM Script?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
MisterSirCode
How do I cheat?
Reputation: 0

Joined: 16 Jun 2021
Posts: 2

PostPosted: Wed Jun 16, 2021 6:06 am    Post subject: How do I directly change a value in an ASM Script? Reply with quote

I've been making basic ASM cheat scripts for like... a few months now? Im curious how I can create "Button Cheats" that change a value or activate some code when you enable them?

So, for example, in terraria, I want this script to instantly add max life to the player.

Currently, Im able to modify what it sends when a player uses a life crystal, so itll give max health, instead of just +20

But I want to be able to use the cheat WITHOUT having a life crystal to activate the memory code.

Any ideas?

Script:

Code:

{ Game   : Terraria.exe
  Version:
  Date   : 2021-06-16
  Author : taylo

  This script does blah blah blah
}

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat

 
 
aobscan(INJECT,83 86 D0 03 00 00 14) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  add dword ptr [esi+000003D0],14
  jmp return

INJECT:
  jmp newmem
  nop 2
return:
registersymbol(INJECT)

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
INJECT:
  db 83 86 D0 03 00 00 14

unregistersymbol(INJECT)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: Terraria.Player::ItemCheck_UseLifeCrystal+3F

Terraria.Player::ItemCheck_UseLifeCrystal+D: 75 68                          - jne Terraria.Player::ItemCheck_UseLifeCrystal+77
Terraria.Player::ItemCheck_UseLifeCrystal+F: 83 BE B0 05 00 00 00           - cmp dword ptr [esi+000005B0],00
Terraria.Player::ItemCheck_UseLifeCrystal+16: 7E 5F                          - jle Terraria.Player::ItemCheck_UseLifeCrystal+77
Terraria.Player::ItemCheck_UseLifeCrystal+18: 81 BE D0 03 00 00 90 01 00 00  - cmp [esi+000003D0],00000190
Terraria.Player::ItemCheck_UseLifeCrystal+22: 7D 53                          - jnl Terraria.Player::ItemCheck_UseLifeCrystal+77
Terraria.Player::ItemCheck_UseLifeCrystal+24: 83 BE B8 05 00 00 00           - cmp dword ptr [esi+000005B8],00
Terraria.Player::ItemCheck_UseLifeCrystal+2B: 75 4A                          - jne Terraria.Player::ItemCheck_UseLifeCrystal+77
Terraria.Player::ItemCheck_UseLifeCrystal+2D: 8B 82 AC 00 00 00              - mov eax,[edx+000000AC]
Terraria.Player::ItemCheck_UseLifeCrystal+33: 89 86 B8 05 00 00              - mov [esi+000005B8],eax
Terraria.Player::ItemCheck_UseLifeCrystal+39: 89 86 BC 05 00 00              - mov [esi+000005BC],eax
// ---------- INJECTING HERE ----------
Terraria.Player::ItemCheck_UseLifeCrystal+3F: 83 86 D0 03 00 00 14           - add dword ptr [esi+000003D0],14
// ---------- DONE INJECTING  ----------
Terraria.Player::ItemCheck_UseLifeCrystal+46: 83 86 D4 03 00 00 14           - add dword ptr [esi+000003D4],14
Terraria.Player::ItemCheck_UseLifeCrystal+4D: 83 86 D8 03 00 00 14           - add dword ptr [esi+000003D8],14
Terraria.Player::ItemCheck_UseLifeCrystal+54: A1 E8 0E 9E 07                 - mov eax,[079E0EE8]
Terraria.Player::ItemCheck_UseLifeCrystal+59: 3B 46 0C                       - cmp eax,[esi+0C]
Terraria.Player::ItemCheck_UseLifeCrystal+5C: 75 0F                          - jne Terraria.Player::ItemCheck_UseLifeCrystal+6D
Terraria.Player::ItemCheck_UseLifeCrystal+5E: 6A 01                          - push 01
Terraria.Player::ItemCheck_UseLifeCrystal+60: 8B CE                          - mov ecx,esi
Terraria.Player::ItemCheck_UseLifeCrystal+62: BA 14 00 00 00                 - mov edx,00000014
Terraria.Player::ItemCheck_UseLifeCrystal+67: FF 15 94 B7 54 08              - call dword ptr [0854B794]
Terraria.Player::ItemCheck_UseLifeCrystal+6D: 8B CE                          - mov ecx,esi
}
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Wed Jun 16, 2021 6:20 am    Post subject: Reply with quote

Hook the game's code to store the base address needed then you can use lua to write to an address later.

So the AA script would have something like this.
Code:
mov [myRegistoredSymbol],esi


And the lua script (in a separate AA script) would have something like this.
Code:
{$lua}
writeInteger('[myRegistoredSymbol]+3D0', 100)
{$asm}

_________________
Back to top
View user's profile Send private message Visit poster's website
MisterSirCode
How do I cheat?
Reputation: 0

Joined: 16 Jun 2021
Posts: 2

PostPosted: Wed Jun 16, 2021 6:45 am    Post subject: Reply with quote

TheyCallMeTim13 wrote:
Hook the game's code to store the base address needed then you can use lua to write to an address later.

So the AA script would have something like this.
Code:
mov [myRegistoredSymbol],esi


And the lua script (in a separate AA script) would have something like this.
Code:
{$lua}
writeInteger('[myRegistoredSymbol]+3D0', 100)
{$asm}


But how would I "Hook the games code" and "store the base address"?

I understand the second part
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon Jun 21, 2021 5:28 pm    Post subject: Reply with quote

You should probably start with the CE tutorial if you don't know how to hook the game's code, you are doing that in the script you posted. Then you can look up "injection copy" for more detailed information on storing the base address.
_________________
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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