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 


Why does changing rsp, Crash my game in a new thread?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Loset
Cheater
Reputation: 0

Joined: 18 Apr 2015
Posts: 34

PostPosted: Wed May 01, 2019 1:25 pm    Post subject: Why does changing rsp, Crash my game in a new thread? Reply with quote

Code:
[ENABLE]
//alloc(newmem,256)
alloc(threadMem,512)
alloc(context,256)
alloc(argumentArray, 256)
alloc(var1,16)
alloc(nativeRes, 512)
registersymbol(context)
registersymbol(threadMem)
registersymbol(argumentArray)
registersymbol(var1)
registersymbol(nativeRes)

threadMem:
mov [context],argumentArray
mov [context+8],0x00
mov [var1], 0x43A66C31C68491C0
mov [argumentArray], var1
push rsp
//mov rsp, nativeRes <---- This causes crash
mov rdx, context
mov rcx,0x43A66C31C68491C0
pop rsp
ret

createThread(threadMem)
//newmem:
//push rax
//mov rax,context
//push ebx
//mov rbx,0x43A66C31C68491C0




[DISABLE]
//dealloc(newmem)
dealloc(context)
dealloc(threadMem)
dealloc(argumentArray)
dealloc(var1)
dealloc(nativeRes)
unregistersymbol(context)
unregistersymbol(threadMem)
unregistersymbol(argumentArray)
unregistersymbol(var1)
unregistersymbol(nativeRes)


With the code above I'm creating a struct I need to call a function later,
but as soon as I mov to rsp, I crash, Not sure why? this is a new thread I'm running it in.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Wed May 01, 2019 8:55 pm    Post subject: Reply with quote

rsp is the stack pointer. It's what's used for push/pop instructions. When you move a random value into it, that changes where push/pop instructions access memory. Use some other register.
_________________
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
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25794
Location: The netherlands

PostPosted: Wed May 01, 2019 8:58 pm    Post subject: Reply with quote

pop RSP will read the value stored at nativeRes and place that in RSP. Since it's uninitialized, it's likely 0

You need to store the original RSP value in either a register or in nativeRes or another known memory location
Code:

alloc(oldrsp,8)
mov [oldrsp],rsp
.. do stuff..
mov rsp,[oldrsp]


Also, RSP tends to go down, so I recommend changing RSP nativeRes+1f8

_________________
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
View user's profile Send private message MSN Messenger
Loset
Cheater
Reputation: 0

Joined: 18 Apr 2015
Posts: 34

PostPosted: Fri May 03, 2019 5:02 am    Post subject: Reply with quote

Dark Byte wrote:
pop RSP will read the value stored at nativeRes and place that in RSP. Since it's uninitialized, it's likely 0

You need to store the original RSP value in either a register or in nativeRes or another known memory location
Code:

alloc(oldrsp,8)
mov [oldrsp],rsp
.. do stuff..
mov rsp,[oldrsp]


Also, RSP tends to go down, so I recommend changing RSP nativeRes+1f8


I can't use other register as the game uses rsp to know where to take values from.

Thanks for the advice Dark Byte, Will try.

Also another thing, I tried to debug it before coming here but couldn't get it to work

Code:

{$lua}
debug_setBreakpoint(threadMem)
{$asm}


breakpoints was always on address 0, Like it didn't even detect the symbol,
And even if I tried manually setting breakpoint on the address, And then with CE to createThread there, It didn't land on the breakpoint =\
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 Gamehacking 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