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 


Disabling an assembly script?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Sun Jul 19, 2015 7:09 am    Post subject: Disabling an assembly script? Reply with quote

So, I have my script where once it's enabled I save values onto custom memory allocations...

Code:
newmem:
cmp [save],00
je saves
jmp calculate
//=============================================================================
saves:
//save origins
fld [esi+20]
fstp [speed]

fld [esi+34]
fstp [accel]

fld [esi+38]
fstp [deaccel]

fld [esi+28]
fstp [back]

fld [esi+24]
fstp [strafe]

fld [esi+80]
fstp [jump]

mov [save],01
//-----------------------------------------------------------------------------
calculate:


But how would I revert them once the script has been disabled?
I've tried just doing this:

Code:
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
//put back to normal
fld [speed]
fstp [esi+20]

fld [accel]
fstp [esi+34]

fld [deaccel]
fstp [esi+38]

fld [back]
fstp [esi+28]

fld [strafe]
fstp [esi+24]

fld [jump]
fstp [esi+80]
//


But it locks up and won't actually disable...
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Jul 19, 2015 7:30 am    Post subject: Reply with quote

Allocate a new variable stats and save the value of ESI into it.
Code:
alloc(stats,4)
registersymbol(stats)
newmem:
cmp [save],00
je saves
jmp calculate
//=============================================================================
saves:
mov [stats],esi
//save origins
fld [esi+20]
fstp [speed]

Then use Lua to update the corresponding addresses within [DISABLE].
Code:
[DISABLE]
{$lua}
local addr = readPointer("stats")
writeFloat(addr+0x20, readFloat("speed"))
writeFloat(addr+0x34, readFloat("accel"))
writeFloat(addr+0x38, readFloat("deaccel"))
writeFloat(addr+0x28, readFloat("back"))
writeFloat(addr+0x24, readFloat("strafe"))
writeFloat(addr+0x80, readFloat("jump"))
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Sun Jul 19, 2015 8:25 am    Post subject: Reply with quote

Zanzer wrote:
Allocate a new variable stats and save the value of ESI into it.
Code:
alloc(stats,4)
registersymbol(stats)
newmem:
cmp [save],00
je saves
jmp calculate
//=============================================================================
saves:
mov [stats],esi
//save origins
fld [esi+20]
fstp [speed]

Then use Lua to update the corresponding addresses within [DISABLE].
Code:
[DISABLE]
{$lua}
local addr = readPointer("stats")
writeFloat(addr+0x20, readFloat("speed"))
writeFloat(addr+0x34, readFloat("accel"))
writeFloat(addr+0x38, readFloat("deaccel"))
writeFloat(addr+0x28, readFloat("back"))
writeFloat(addr+0x24, readFloat("strafe"))
writeFloat(addr+0x80, readFloat("jump"))


Hmm, doesn't seem to work; here's what my disable part looks like:

Code:
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
{$lua}
local addr = readPointer("stats")
writeFloat(addr+0x20, readFloat("speed"))
writeFloat(addr+0x34, readFloat("accel"))
writeFloat(addr+0x38, readFloat("deaccel"))
writeFloat(addr+0x28, readFloat("back"))
writeFloat(addr+0x24, readFloat("strafe"))
writeFloat(addr+0x80, readFloat("jump"))

dealloc(newmem)
dealloc(half)
dealloc(container)
dealloc(jumpHeightMultiplier)
dealloc(speed)
dealloc(accel)
dealloc(deaccel)
dealloc(back)
dealloc(strafe)
dealloc(jump)
dealloc(save)
dealloc(stats)
unregistersymbol(half)
unregistersymbol(container)
unregistersymbol(jumpHeightMultiplier)
unregistersymbol(speed)
unregistersymbol(accel)
unregistersymbol(deaccel)
unregistersymbol(back)
unregistersymbol(strafe)
unregistersymbol(jump)
unregistersymbol(save)
unregistersymbol(stats)
"Game.dll"+EB824:
jp Game.gCCharacterMovement_PS::GetCurrentMaxSpeedOfDir+3F
fld dword ptr [esi+20]
//Alt: db 7A 19 D9 46 20
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Jul 19, 2015 9:29 am    Post subject: Reply with quote

add
Code:

{asm}

above the first dealloc

_________________
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
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Sun Jul 19, 2015 9:45 am    Post subject: Reply with quote

Dark Byte wrote:
add
Code:

{asm}

above the first dealloc


Hmm, game still crashes.
Like this?
Code:

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
{$lua}
local addr = readPointer("stats")
writeFloat(addr+0x20, readFloat("speed"))
writeFloat(addr+0x34, readFloat("accel"))
writeFloat(addr+0x38, readFloat("deaccel"))
writeFloat(addr+0x28, readFloat("back"))
writeFloat(addr+0x24, readFloat("strafe"))
writeFloat(addr+0x80, readFloat("jump"))
{asm} //<<<<<<<<<<<<<<<<<<<<<<<
dealloc(newmem)
dealloc(half)
dealloc(container)
dealloc(jumpHeightMultiplier)
...


EDIT: Out of curiosity I added a "$" to it; now it works! But it doesn't revert the old values back...

Here's the whole script; maybe my fomular is screwed up? This inject point is executed repeatedly btw (I think like 1 every 1/5th a second).

Code:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

label(saves)
label(calculate)

alloc(half,16)
alloc(container,16)
alloc(jumpHeightMultiplier,16)
alloc(speed,4)
alloc(accel,4)
alloc(deaccel,4)
alloc(back,4)
alloc(strafe,4)
alloc(jump,4)
alloc(save,4)
alloc(stats,4)
registersymbol(half)
registersymbol(container)
registersymbol(jumpHeightMultiplier)
registersymbol(speed)
registersymbol(accel)
registersymbol(deaccel)
registersymbol(back)
registersymbol(strafe)
registersymbol(jump)
registersymbol(save)
registersymbol(stats)

half:
dd (float)2

jumpHeightMultiplier:
dd (float)1.5

newmem:
cmp [save],00
je saves
jmp calculate
//=============================================================================
saves:
mov [stats],esi
//save origins
fld [esi+20]
fstp [speed]

fld [esi+34]
fstp [accel]

fld [esi+38]
fstp [deaccel]

fld [esi+28]
fstp [back]

fld [esi+24]
fstp [strafe]

fld [esi+80]
fstp [jump]

mov [save],01
//-----------------------------------------------------------------------------
calculate:
//foward speed
fld [speed]
fiadd [endurance]

mov [container],(float)150

fsub [container]
fstp [esi+20]
//-----------------------------------------------------------------------------
//acceleration
fld [accel]
fiadd [endurance]
fstp [esi+34]
//-----------------------------------------------------------------------------
//deacceleration
fld [deaccel]
fisub [endurance]
fstp [esi+38]
//-----------------------------------------------------------------------------
//speed backwards
fild [endurance]
fdiv [half]
fadd [back]
fstp [esi+28]
//-----------------------------------------------------------------------------
//speed strafe
fild [endurance]
fdiv [half]
fadd [strafe]
fstp [esi+24]
//-----------------------------------------------------------------------------
//jump height
fild [strength]
fmul [jumpHeightMultiplier]
fadd [jump]
fstp [esi+80]

//=============================================================================
originalcode:
jp Game.gCCharacterMovement_PS::GetCurrentMaxSpeedOfDir+3F
fld dword ptr [esi+20]

exit:
jmp returnhere

"Game.dll"+EB824:
jmp newmem
returnhere:


 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
{$lua}
local addr = readPointer("stats")
writeFloat(addr+0x20, readFloat("speed"))
writeFloat(addr+0x34, readFloat("accel"))
writeFloat(addr+0x38, readFloat("deaccel"))
writeFloat(addr+0x28, readFloat("back"))
writeFloat(addr+0x24, readFloat("strafe"))
writeFloat(addr+0x80, readFloat("jump"))
{$asm}
dealloc(newmem)
dealloc(half)
dealloc(container)
dealloc(jumpHeightMultiplier)
dealloc(speed)
dealloc(accel)
dealloc(deaccel)
dealloc(back)
dealloc(strafe)
dealloc(jump)
dealloc(save)
dealloc(stats)
unregistersymbol(half)
unregistersymbol(container)
unregistersymbol(jumpHeightMultiplier)
unregistersymbol(speed)
unregistersymbol(accel)
unregistersymbol(deaccel)
unregistersymbol(back)
unregistersymbol(strafe)
unregistersymbol(jump)
unregistersymbol(save)
unregistersymbol(stats)
"Game.dll"+EB824:
jp Game.gCCharacterMovement_PS::GetCurrentMaxSpeedOfDir+3F
fld dword ptr [esi+20]
//Alt: db 7A 19 D9 46 20
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Jul 19, 2015 11:18 am    Post subject: Reply with quote

Did you start from a fresh game once you got the script working?
Did it properly execute the "saves" routine in your script?
Script looks correct.

Does this injection code execute many times per second?
I wonder if the Lua is setting the value, but then the injected code gets executed again and overwrites it.
May need to add some skip everything logic that becomes true at the beginning of the [DISABLE].
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Sun Jul 19, 2015 11:53 am    Post subject: Reply with quote

Zanzer wrote:
Did you start from a fresh game once you got the script working?
Did it properly execute the "saves" routine in your script?
Script looks correct.

Does this injection code execute many times per second?
I wonder if the Lua is setting the value, but then the injected code gets executed again and overwrites it.
May need to add some skip everything logic that becomes true at the beginning of the [DISABLE].

The values reset everytime I reload, or restart the game.
Yup, injection code is executed like 5 times a second.

Well, the idea is that once the values have been saved, the "save" variable gets a 1, which stops the save section from getting executed; but once the user wants to disable the cheat I want it to just overwrite the player's movement's with what has been saved.

Everything works fine; the values are saved to the "stats" variable and the "saved" section is executed once. Game doesn't even crash when I disable the lua stuff. It's just that once the script is disabled, the movement values are not changed to what they should be; so once I enable the script again it just adds on top of what has been already added.

Problem seems to be with the lua; maybe there's a way to do it with asms? I don't know anything about lua.

Since the values never change, I suppose I could add a bunch of "cmps", but that'd make things very confusing...?

EDIT: Well, I decided to just add cmps, that fixed it, works fine now; thanks for the help anyway.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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