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 


Could not jump back from user allocated memory

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

Joined: 13 May 2019
Posts: 11

PostPosted: Sat Jun 15, 2019 11:04 am    Post subject: Could not jump back from user allocated memory Reply with quote

I used VirtualAllocEx to allocate for a memory with size 0x100, at a random address. it returned me back with address at Address=1E0E8B0000

My game (witcher3.exe) address is something like 0x7FF73B44D3CB.

The problem is: I dissembled some code in the allocated memory space (1E0E8B0000) and can jump from game code (0x7FF73B44D3CB) to it. But, I could NOT jump BACK from the allocated memory space to game code.

What could be the cause?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jun 15, 2019 11:42 am    Post subject: Reply with quote

what jump code do you use?

simple 0xe9 is not going to work with that distance

and if you do a proper jump, do you jump back to the correct location? e.g hookplace+14 and NOT hookplace+5

_________________
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
fuguipingan
Newbie cheater
Reputation: 0

Joined: 13 May 2019
Posts: 11

PostPosted: Sat Jun 15, 2019 8:21 pm    Post subject: Reply with quote

I didn't remember the hex code for jmp....

Frankly, I was using x64dbg. I wrote "jmp <address>" and it was encoded by x64dbg automatically to hex. If distance was the cause, what confuses me is why forward jump works but the backward jump didn't: error message reads "could not resolve address".

It could not be reproduced either because the "alloc" method I uses gives random address, now most of the time the forward jump could not resolve.

--
In cheat engine I encountered similar issues with auto assemble/code injection template: forward jump works, but backward jump fails (throws exception saying memory access violation)

--
For the jump-back address, I copied the next instruction of hookplace. It should be correct. (I compared the hookplace_original_instruction and hookplace_replacement_instruction, same length and no overflow of bytes.)

--
Or, may be I used "alloc" incorrectly? (either x64dbg or the cheatengine alloc)
I am trying to practise a common scenario of code-cave, here is my understanding:
1. I alloc some memory.
a. is there tips for using alloc: is 0x1000 too big a size?,
b. shall I use game.exe as start address? alloc(0x1000, "game.exe")?
c. Is it normal that alloc fails often and I shall experiment with different size and start address, also need to verify it is not TOO FAR distance?
d. does "call" covers further distance than "jmp"?

2. I jmp to the allocated memory and write my code. then jmp/ ret back to next code.





Dark Byte wrote:
what jump code do you use?

simple 0xe9 is not going to work with that distance

and if you do a proper jump, do you jump back to the correct location? e.g hookplace+14 and NOT hookplace+5
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jun 15, 2019 10:32 pm    Post subject: Reply with quote

Do you save enough of the original instructions?
you need at least 14 bytes (and makebsure they are full instructions, and if they are rip relative adjust them)

0x1000 is the minimum you csn allocate

alloc needs 3 parameters: name, size, prefered range

_________________
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
fuguipingan
Newbie cheater
Reputation: 0

Joined: 13 May 2019
Posts: 11

PostPosted: Tue Jun 18, 2019 11:05 am    Post subject: Reply with quote

Thanks for the pointers about rip relative offsets). I searched for some articles about rip relative addressing. Now I am able to jump back and forth by putting the abs address into register first, then jmp rax, like that.


Dark Byte wrote:
Do you save enough of the original instructions?
you need at least 14 bytes (and makebsure they are full instructions, and if they are rip relative adjust them)

0x1000 is the minimum you csn allocate

alloc needs 3 parameters: name, size, prefered range
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