 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Dec 18, 2018 2:48 am Post subject: (ASM) How to check if multiple pointers are valid? |
|
|
I want to check if several pointers are valid before reading data from them(when I say invalid memory addresses, they are the ones shown as "?? ?? ??" in CE):
Code: |
mov ecx,dword ptr[rcx+100]
mov ecx,dword ptr[rcx+200]
mov ecx,dword ptr[rcx+300]
mov ecx,dword ptr[rcx+400]
|
How to check each of them in an efficient way?
I have read the related posts on this forum, there are two solutions according to them:
1. test ecx,ecx
2. isbadreadptr
The first solution doesn't work for me, because sometimes dword ptr[rcx+300] is invalid and crashes the game.
The second doesn't work for me either, it keeps crashing the game when calling "isbadreadptr" and I don't know why.
Code: |
check1:
push rcx <--- I need the data in rcx for the second check
push 4
lea eax,dword ptr[rcx+100]
push eax
call isbadreadptr
add rsp,10
pop rcx
cmp eax,0
jne code
jmp check2
check2:
push rcx
push 4
lea eax,dword ptr[rcx+200]
push eax
call isbadreadptr <--------crashes here
add rsp,10
pop rcx
cmp eax,0
jne code
jmp check3
|
Thanks in advance.
_________________
**************
A simple example is better then ten links.  |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25779 Location: The netherlands
|
Posted: Tue Dec 18, 2018 3:45 am Post subject: |
|
|
Code: |
push rax
push rbx
push rcx
{$try}
mov eax,dword ptr[rcx+100]
mov ebx,dword ptr[rcx+200]
mov ecx,dword ptr[rcx+300]
//everything ok, do your stuff
jmp done
{$except}
//it failed somewhere
done:
pop rcx
pop rbx
pop rax
|
_________________
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 |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4695
|
Posted: Tue Dec 18, 2018 9:34 am Post subject: |
|
|
Use {$try} / {$except} as in DB's example.
Your call crashes because you're not using proper 64-bit calling conventions.
https://docs.microsoft.com/en-us/cpp/build/overview-of-x64-calling-conventions
- rcx, rdx, r8, and r9 are the first four parameters to functions (everything else goes in the stack)
- The stack must have 32 bytes of scratch space for the first four parameters
- The stack must be aligned on a 16-byte boundary at the call
There's some other stuff, but these three are your problem.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Dec 18, 2018 9:47 am Post subject: |
|
|
Thanks for the replies, I tried to use DB's method, but the game still crashes.
Here is my code:
Code: |
newmem:
push rax
push rbx
push rsi
push rdi
xor rbx,rbx
{$try}
mov eax,dword ptr[rcx+100]
mov ebx,dword ptr[rax+200]
mov esi,dword ptr[rbx+300]
mov edi,dword ptr[esi+400]
mov eax,["game.exe"+5487912] <---this address is always valid
cmp eax,edi
jne code
{do something here, I commented this part out for testing purpose, so this part is not the problem}
{$except}
code:
pop rdi
pop rsi
pop rbx
pop rax
mov esi,00000010
jmp return
|
Edit, I changed the code to this, and it still crashes,
Code: |
newmem:
push rax
push rbx
push rsi
push rdi
xor rbx,rbx
{$try}
mov eax,dword ptr[rcx+100]
mov ebx,dword ptr[rax+200]
mov esi,dword ptr[rbx+300]
mov edi,dword ptr[rsi+400]
mov eax,["game.exe"+5487912]
jmp code
{$except}
code:
pop rdi
pop rsi
pop rbx
pop rax
mov esi,00000010
jmp return
|
Is there a way provided by CE to track the registers' status right before the crash happens? Such as the data in the registers before the crash, so I can see what went wrong.
_________________
**************
A simple example is better then ten links.  |
|
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
|
|