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 


cmp to distinguish player from CPU crashes around 5% of time

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Autem
Expert Cheater
Reputation: 1

Joined: 30 Jan 2023
Posts: 156

PostPosted: Tue Apr 25, 2023 8:09 pm    Post subject: cmp to distinguish player from CPU crashes around 5% of time Reply with quote

Any idea why a cmp to determine which character is the human player would work most of the time, but on rare occasions that line that makes the cmp would crash the game?

I confirmed that the pointer is leading to the right addresses/values during a short window of time where it kept crashing the game. I was assuming maybe the address wasn't valid or something.

Is there something where maybe the pointer is occasionally out of range of the script? If so how can I adjust? Any other ideas why it might fail 5% of the time even when the address it's checking is correct and has the right value?

This is the problem area...
Code:
push rax
mov rax,[rcx+28]
cmp [rax+48B0],8   // crashes 5% of the time
pop rax
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Wed Apr 26, 2023 12:08 am    Post subject: Reply with quote

Probably because `rax+48B0` is an invalid address 5% of the time. 48B0 is a really big offset- whatever structure rax points to probably isn't that big. The fact that it works at all is likely due to luck regarding the pseudo-randomness of the memory allocator.

You could use {$try} / {$except} to help debug it. I wouldn't recommend using that as a solution, but I've seen people use jankier solutions...

_________________
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
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Wed Apr 26, 2023 4:50 am    Post subject: Reply with quote

As ParkourPenguin explained, the offset is rather large, so although the pointer may work for your main character most (or all) of the time, the other entities may not have structures that large (or some may have slightly different structures), so when those structures for the other entities get compared, the address may not always be valid at that offset, so the target crashes.

As a general rule, I do not like to compare using pointers like this. Typically, you can find an instruction that is exclusive to whatever it is that you are trying to filter, and use that.

As an example, let's say that you find player health. When you check to see what is accessing it, you may see several instructions populate the list. If you right-click that window and check to see if the instructions are accessing any other addresses, you might find that there is an instruction that is only accessing player and nothing else. You can use that for your filter and it is highly likely to remain reliable.

Alternatively, using health again as an example, you might find that all instructions are accessing multiple entities, and that there are no instructions that are exclusive to your player. In this case, you might try to use the data structure dissection tool on your health address (with correct offset), and from there, you might find that there are other values inside of that structure that do have an instruction that is exclusive to player. You can use that as your filter, as well.

You can also check the register values for unique identifiers by using the commonalities feature.

There are many ways to find identifiers for your filter; some may be more reliable than others. I usually try to avoid using pointers unless it's obvious and I know that it will be reliable.
Back to top
View user's profile Send private message
Strigger
How do I cheat?
Reputation: 0

Joined: 23 Apr 2023
Posts: 6

PostPosted: Wed Apr 26, 2023 5:42 am    Post subject: Re: cmp to distinguish player from CPU crashes around 5% of Reply with quote

Autem wrote:

This is the problem area...
Code:
push rax
mov rax,[rcx+28]
cmp [rax+48B0],8   // crashes 5% of the time
pop rax

You could try this, i was having this issue earlier
Code:
push rax
{$try}
mov rax,[rcx+28]
cmp [rax+48B0],8
{$except}
pop rax
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 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