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 back the value after disabled

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

Joined: 26 Feb 2010
Posts: 48

PostPosted: Thu Jan 20, 2022 6:36 am    Post subject: Changing back the value after disabled Reply with quote

I don't how how explain this well but I'm playing RTS game and want the offset of an base addresses. I want every of my units to restore the original value after I disable the script.

Here is the code, I put a description of what I want to happen.

Code:
[ENABLE]

aobscanmodule(somescan,SomeGame.exe,8B 8E E8 06 00 00 8B) // should be unique
alloc(newmem,$100)

label(code)
label(return)

newmem:
cmp [esi+0000013C],1
jne code
cmp [esi+648],1
jne code
push ecx
mov ecx,["SomeGame"+1DAEC48]
mov [esi+000006E8],ecx
pop ecx
mov [esi+0000013C],1 //<------------ marker that this line of code is executed once
jmp return

code:
  mov ecx,[esi+000006E8]
  jmp return

somescan:
  jmp newmem
  nop
return:
registersymbol(somescan)

[DISABLE]
// I need to change back it to [esi+0000013C] to 0 here but I have no idea how
// so if I re-enable it will execute again
somescan:
  db 8B 8E E8 06 00 00

unregistersymbol(somescan)
dealloc(newmem)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Thu Jan 20, 2022 9:45 am    Post subject: Reply with quote

Which game?
Back to top
View user's profile Send private message
greatveemon
Cheater
Reputation: 0

Joined: 26 Feb 2010
Posts: 48

PostPosted: Thu Jan 20, 2022 12:50 pm    Post subject: Reply with quote

LeFiXER wrote:
Which game?


some game from 2000,
sorry, but does the name of the game matter?
i just want that address offset to change back after disabling it.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Thu Jan 20, 2022 1:39 pm    Post subject: Reply with quote

You'll need to keep track of every single address you modify and use that in the disable section. e.g. allocate a large buffer, presume it's an array of pointers (length-prefixed or null-terminated), and append new addresses to the end. When the script is disabled, use Lua to go through that list and write 0 to those addresses if they're still valid. That last part is important since if the game decides to free that memory or repurpose it, writing 0 could crash the game or have other side effects.

If you can write any integer you want to esi+13C, then let it be a generation counter. Start the value at 0, and increment it every time you enable the script. If it's not the same as the current generation, then you didn't execute the code yet.

PS: You don't need to push/pop ecx. The original code, `mov ecx,[esi+000006E8]`, overwrites ecx. i.e. the game isn't using whatever value is in ecx just prior to this, so there's no need to back it up.

_________________
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
greatveemon
Cheater
Reputation: 0

Joined: 26 Feb 2010
Posts: 48

PostPosted: Thu Jan 20, 2022 2:13 pm    Post subject: Reply with quote

ParkourPenguin wrote:


If you can write any integer you want to esi+13C, then let it be a generation counter. Start the value at 0, and increment it every time you enable the script. If it's not the same as the current generation, then you didn't execute the code yet..


Sorry, kinda still noob in this stuff. But how do I'll perform this? if the the esi+13C compare value is fixed.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Thu Jan 20, 2022 3:36 pm    Post subject: Reply with quote

Something like this:
Code:
[ENABLE]
{$lua}
if syntaxcheck then return 'define(generation,0)' end
if _my_AA_script_gen then
  _my_AA_script_gen = (_my_AA_script_gen + 1) & 0xFFFFFFFF
else
  _my_AA_script_gen = 0
end

return ('define(generation,%X)'):format(_my_AA_script_gen)
{$asm}
...

newmem:
  cmp [esi+0000013C],generation
  ...
  mov [esi+0000013C],generation
...

_________________
I don't know where I'm going, but I'll figure it out when I get there.


Last edited by ParkourPenguin on Thu Jan 20, 2022 4:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
greatveemon
Cheater
Reputation: 0

Joined: 26 Feb 2010
Posts: 48

PostPosted: Thu Jan 20, 2022 4:42 pm    Post subject: Reply with quote

Sorry, I'm still confuse, Is that a supposed to be pseudocode? And I thought it will keep incrementing but there it seems it will keep resetting it to zero
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Thu Jan 20, 2022 4:52 pm    Post subject: Reply with quote

That's CE AutoAssembler code. The stuff in the {$lua} block gets executed before the script gets assembled, and the string it returns (if any) is substituted into the script. The ellipses (...) is just your other code I omitted for brevity.

I don't know why you think it keeps resetting the variable to 0. It works fine for me.
I did forget one line at the beginning of the {$lua} block:
Code:
{$lua}
if syntaxcheck then return 'define(generation,0)' end
...

_________________
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
greatveemon
Cheater
Reputation: 0

Joined: 26 Feb 2010
Posts: 48

PostPosted: Thu Jan 20, 2022 5:14 pm    Post subject: Reply with quote

ParkourPenguin wrote:
That's CE AutoAssembler code. The stuff in the {$lua} block gets executed before the script gets assembled, and the string it returns (if any) is substituted into the script. The ellipses (...) is just your other code I omitted for brevity.

I don't know why you think it keeps resetting the variable to 0. It works fine for me.
I did forget one line at the beginning of the {$lua} block:
Code:
{$lua}
if syntaxcheck then return 'define(generation,0)' end
...


just got confused on lua syntax. Didn't know you could do this without declaring a variable.

so like this?

Code:
[ENABLE]
{$lua}
if syntaxcheck then return 'define(generation,0)' end
if _my_AA_script_gen then
  _my_AA_script_gen = (_my_AA_script_gen + 1) & 0xFFFFFFFF
else
  _my_AA_script_gen = 0
end

return ('define(generation,%X)'):format(_my_AA_script_gen)
{$asm}
aobscanmodule(somecode,SomeGame.exe,8B 8E E8 06 00 00 8B)
alloc(newmem,$100)

label(code)
label(return)

newmem:
cmp [esi+13C],generation
je code
cmp [esi+648],1
jne code
push ecx
mov ecx,["SomeGame.exe"+1DAEC48]
mov [esi+000006E8],ecx
pop ecx
mov [esi+13C],generation
jmp return

code:
  mov ecx,[esi+000006E8]
  jmp return

somecode:
  jmp newmem
  nop
return:
registersymbol(somecode)

[DISABLE]

somecode:
  db 8B 8E E8 06 00 00

unregistersymbol(somecode)
dealloc(newmem)
Back to top
View user's profile Send private message
Akina
How do I cheat?
Reputation: 0

Joined: 06 Sep 2016
Posts: 4

PostPosted: Sat Apr 02, 2022 9:50 pm    Post subject: Reply with quote

Without using lua

Code:

[ENABLE]
aobscanmodule(somescan,SomeGame.exe,8B 8E E8 06 00 00 8B)
alloc(newmem,$100)
label(code)
label(return)

alloc(restore,4)            //<------------
registersymbol(restore)     //<------------

newmem:
cmp [esi+0000013C],1
jne code
cmp [esi+648],1
jne code
push ecx
mov ecx,["SomeGame"+1DAEC48]
mov [esi+000006E8],ecx
pop ecx
mov [restore],esi           //<------------
mov [esi+0000013C],1
jmp return

code:
mov ecx,[esi+000006E8]
jmp return

somescan:
jmp newmem
nop
return:
registersymbol(somescan)

[DISABLE]
["restore"]+13C:                //<------------ esi+13c
db 00                           //<------------Write 0

somescan:
db 8B 8E E8 06 00 00

dealloc(restore)                //<------------
unregistersymbol(somescan)
dealloc(newmem)
[/code]
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Apr 03, 2022 5:05 am    Post subject: Reply with quote

greatveemon wrote:

sorry, but does the name of the game matter?


I would say yes given that the rules surrounding online games are that it is not permitted to talk about hacking online games here.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25287
Location: The netherlands

PostPosted: Sun Apr 03, 2022 1:09 pm    Post subject: This post has 1 review(s) Reply with quote

LeFiXER wrote:
greatveemon wrote:

sorry, but does the name of the game matter?


I would say yes given that the rules surrounding online games are that it is not permitted to talk about hacking online games here.

as long as the name is not mentioned and the disassembly of the game (originalcode) isn't too largs it's ok

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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