 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Autem Expert Cheater
Reputation: 1
Joined: 30 Jan 2023 Posts: 156
|
Posted: Tue Apr 25, 2023 8:09 pm Post subject: cmp to distinguish player from CPU crashes around 5% of time |
|
|
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 |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4700
|
Posted: Wed Apr 26, 2023 12:08 am Post subject: |
|
|
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 |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Wed Apr 26, 2023 4:50 am Post subject: |
|
|
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 |
|
 |
Strigger How do I cheat?
Reputation: 0
Joined: 23 Apr 2023 Posts: 6
|
Posted: Wed Apr 26, 2023 5:42 am Post subject: Re: cmp to distinguish player from CPU crashes around 5% of |
|
|
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 |
|
 |
|
|
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
|
|