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 


putting a condition on an assembly instruction

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

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Tue Nov 24, 2020 8:55 am    Post subject: putting a condition on an assembly instruction Reply with quote

Code:

[ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:


originalcode:
fstp dword ptr [ebx+000000AC]

exit:
jmp returnhere

"game.exe"+7C234:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
dealloc(newmem)
"game.exe"+7C234:
fstp dword ptr [ebx+000000AC]

this is the script(in the form of original code), what I wanna do is, compare a value(16) to another address and if it is not equal, then execute this(fstp dword ptr [ebx+000000AC]) instrcution. for that I modified the script as:
Code:

[ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)

newmem:
fstp dword ptr [ebx+000000AC]

originalcode:
cmp [[mod.dll+00391C34]+244],10
jne newmem
nop
nop
nop
nop
nop
nop

exit:
jmp returnhere

"game.exe"+7C234:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
dealloc(newmem)
"game.exe"+7C234:
fstp dword ptr [ebx+000000AC]


it simply crashes the game, any help will be appreciated.
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 98

Joined: 14 Jul 2007
Posts: 3340

PostPosted: Tue Nov 24, 2020 10:37 am    Post subject: Reply with quote

Might be crashing due to pointer being invalid, or, FPU not being popped.
Try this.

Code:
[ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
label(popFPU)

newmem:

originalcode:
push eax
mov eax,[mod.dll+00391C34]
cmp [eax+244],10
pop eax
jne short popFPU
fstp dword ptr [ebx+000000AC]
exit:
jmp returnhere
popFPU:
fstp st(0)
jmp short exit

"game.exe"+7C234:
jmp newmem
nop
returnhere:

[DISABLE]
"game.exe"+7C234:
fstp dword ptr [ebx+000000AC]
dealloc(newmem)


PS
This is not a LUA script Wink
Back to top
View user's profile Send private message
Thunder_Bird
Cheater
Reputation: 0

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Thu Nov 26, 2020 3:56 am    Post subject: Reply with quote

Thanks doode worked <3
Back to top
View user's profile Send private message
jgoemat
Master Cheater
Reputation: 23

Joined: 25 Sep 2011
Posts: 264

PostPosted: Wed Jan 13, 2021 1:19 pm    Post subject: Reply with quote

It seems to me like your code would always execute it at least once, and get stuck in an endless loop executing the instruction over and over if the value isn't 10:


ce1.png
 Description:
 Filesize:  18 KB
 Viewed:  1442 Time(s)

ce1.png


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