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 


Script crashes game when cmp isn't equal help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
PinPoint
Expert Cheater
Reputation: 10

Joined: 07 Apr 2016
Posts: 223
Location: Scotland

PostPosted: Sat Apr 23, 2016 9:20 am    Post subject: Script crashes game when cmp isn't equal help Reply with quote

Im working on a script for unlimited health and it can only be active when you are in a battle as the memory is allocated elswhere everywhere else. so I found an address that is always a set value when in battle so i want to compare this value and execute a command if it is equal an nothing if it's not. Also I want to be able to freeze this value and keep the script on without hotkeys etc.

I have this code which works when im in battle but as soon as the value of the compared address changes the game crashes. what can I do to stop the crashing?

Code:
[ENABLE]
globalalloc(_freeze,2048)
createthread(_freeze)
label(_end)
registersymbol(_end)
label(return)

_freeze:
cmp dword ptr [ePSXe.exe+75be58],#256
jne return
mov [ePSXe.exe+7608C4],#1000
mov [ePSXe.exe+760994],#1000
mov [ePSXe.exe+760A64],#1000
mov [ePSXe.exe+760B34],#1000



push #500
call sleep
cmp [_end],01
jne _freeze
ret

_end:
dd 0

return:

[DISABLE]
_end:
dd 01
unregistersymbol(_end)


Edit:
just noticed another probelm with this. Although it does work in battle, it changes 4 bytes worth of values even though its a 2 byte address. even when i used
ePSXe.exe+7608C4:
db E8 03
it actually done "db E8 03 00 00"

so I used
ePSXe.exe+7608C4:
db E8 03 63 00
and it still done db E8 03 00 00
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Sat Apr 23, 2016 11:04 am    Post subject: Reply with quote

It could be crashing because that instruction accesses some other address when a battle ends (or whenever that value changes).
Try replacing cmp dword ptr... with cmp byte ptr... and see if that helps.
Use a breakpoint to get more information on when and where it crashes. Use conditional breakpoints if it's run too frequently.

Use mov word ptr [...],#1000 if the m32 is suppose to be 2 bytes long.

If you wrote down that db code along with the other code still active, then it makes sense the bytes will still be E8 03 00 00. You're moving the dword 1000 into that m32 instead of the word 1000 therefore setting the upper word to 0.

_________________
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
PinPoint
Expert Cheater
Reputation: 10

Joined: 07 Apr 2016
Posts: 223
Location: Scotland

PostPosted: Sat Apr 23, 2016 12:31 pm    Post subject: Reply with quote

ParkourPenguin wrote:
It could be crashing because that instruction accesses some other address when a battle ends (or whenever that value changes).
Try replacing cmp dword ptr... with cmp byte ptr... and see if that helps.
Use a breakpoint to get more information on when and where it crashes. Use conditional breakpoints if it's run too frequently.

Use mov word ptr [...],#1000 if the m32 is suppose to be 2 bytes long.

If you wrote down that db code along with the other code still active, then it makes sense the bytes will still be E8 03 00 00. You're moving the dword 1000 into that m32 instead of the word 1000 therefore setting the upper word to 0.


Thanks man it all worked. had to change
cmp byte ptr [ePSXe.exe+75be58],#256
to
cmp byte ptr [ePSXe.exe+75be59],01
as there were graphical errors outside of battle.

what instruction were you meaning at the start of your post? I did't go through the dissembler to get instructions etc. its just an address I have in my cheat table that I wanted compared.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Sat Apr 23, 2016 12:55 pm    Post subject: Reply with quote

Oh... nevermind. I only looked at the asm in the script; I didn't pay attention to the fact that you're creating your own thread to run this code. I figured you were hooking some instruction. My bad.
_________________
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
PinPoint
Expert Cheater
Reputation: 10

Joined: 07 Apr 2016
Posts: 223
Location: Scotland

PostPosted: Sat Apr 23, 2016 12:59 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Oh... nevermind. I only looked at the asm in the script; I didn't pay attention to the fact that you're creating your own thread to run this code. I figured you were hooking some instruction. My bad.


its actually not working now.... it did for 2 battles then started crashing again

is the method i'm using correct? or are there better ways of trying to accomplish what im trying to do?

EDIT:
nvm, I changed the code a bit and its working fine after a good few battles

Code:
[ENABLE]
globalalloc(battlecheck,4096)
CREATETHREAD(battlecheck)

registersymbol(end)

label(inf_health)
label(end)



battlecheck:
mov eax,[ePSXe.exe+75be59]
cmp eax,01//checks if in battle
je inf_health
jmp battlecheck //if not in battle jump back to battlecheck

inf_health:
//Infinate HP positions 1-4
mov word ptr [ePSXe.exe+7608C4],#2000//set value of address to 2000
mov word ptr [ePSXe.exe+760994],#2000
mov word ptr [ePSXe.exe+760A64],#2000
mov word ptr [ePSXe.exe+760B34],#2000

//freezes the values
push #500
call sleep
cmp [end],01
jne battlecheck
ret

end:
dd 0



[DISABLE]
end:
dd 01


I think before when I was jumping to return there was nothing there for it to do so it crashed?
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 Discussions 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