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 


Allocating memory when hooked into Physical Memory

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

Joined: 09 Mar 2022
Posts: 19

PostPosted: Fri Jan 05, 2024 1:34 am    Post subject: Allocating memory when hooked into Physical Memory Reply with quote

I'm trying to make a script work when connected to Physical Memory, but every time I try to enable it, I get the following error: Failure allocating memory near XXXXXX. I've tried allocating nonpaged memory and specifying that location with the third parameter of alloc(), kalloc() in the auto assembler, and even globallalloc(). Everything results in the game either crashing or populating the aforementioned error. Any tips on how to fix this?
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: Fri Jan 05, 2024 3:02 am    Post subject: Reply with quote

memory addressing is relative to virtual memory, not physical memory. A physical address has no meaning to assembler code

you'll have to hook in the physical memory into the pagetale system of the target process and then use that entry to get the virtual address

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

Joined: 09 Mar 2022
Posts: 19

PostPosted: Fri Jan 05, 2024 8:40 pm    Post subject: Reply with quote

Dark Byte wrote:
memory addressing is relative to virtual memory, not physical memory. A physical address has no meaning to assembler code

you'll have to hook in the physical memory into the pagetale system of the target process and then use that entry to get the virtual address


The virtual address is not the issue; I'm able to find that easily. The issue is that I'm not able to edit the memory region around that virtual address. When hooking into Physical Memory, I'm able to then edit the address along with the region around it. I'm only not able to allocate memory when hooked into Physical Memory.
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 Jan 06, 2024 5:49 am    Post subject: Reply with quote

Can you open the process normally and allocate memory in there before switching to the physical memory?

Otherwise you'll still have to find out the pagetables for this process and fill in the physical memory address yourself for the virtual address you like

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

Joined: 09 Mar 2022
Posts: 19

PostPosted: Sat Jan 06, 2024 7:42 pm    Post subject: Reply with quote

Dark Byte wrote:
Can you open the process normally and allocate memory in there before switching to the physical memory?


Yes, I believe so.
Back to top
View user's profile Send private message
bismult
Newbie cheater
Reputation: 0

Joined: 09 Mar 2022
Posts: 19

PostPosted: Mon Jan 08, 2024 7:16 pm    Post subject: Reply with quote

Dark Byte wrote:
Can you open the process normally and allocate memory in there before switching to the physical memory?


I was doing some testing with this, but the game keeps on crashing every time I enable the actual function of the script. Luckily, I'm able to allocate memory in the process normally before hooking into physical memory. Is there something I'm missing?
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: Tue Jan 09, 2024 12:31 am    Post subject: Reply with quote

Is the jmp instruction correct?
(You can't let CE generate the bytes for the jmp for you, you'll have to calculate it yourself based on the virtual address origin and virtual address destination (CE would pick the physical address origin which would be wrong)

or do a 14 byte 'jmp far as those are independent on location

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

Joined: 09 Mar 2022
Posts: 19

PostPosted: Tue Jan 09, 2024 1:53 am    Post subject: Reply with quote

Dark Byte wrote:
Is the jmp instruction correct?
(You can't let CE generate the bytes for the jmp for you, you'll have to calculate it yourself based on the virtual address origin and virtual address destination (CE would pick the physical address origin which would be wrong)

or do a 14 byte 'jmp far as those are independent on location


14 byte jmp's cause me to crash as well. Since I can't allocate memory when hooked into physical memory, I'm hooking into the game, allocating memory at the physical address location, then hooking back into physical memory to activate the script. Is this causing issues?
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: Tue Jan 09, 2024 5:29 am    Post subject: Reply with quote

don't forget the jmp back to the original code as well as the jmp from the physical address will be different

and your code isn't going to jump to the physical address of the allocated memory but it has to jump to the virtual address

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

Joined: 09 Mar 2022
Posts: 19

PostPosted: Tue Jan 09, 2024 1:45 pm    Post subject: Reply with quote

Dark Byte wrote:
don't forget the jmp back to the original code as well as the jmp from the physical address will be different

and your code isn't going to jump to the physical address of the allocated memory but it has to jump to the virtual address


So I have to allocate memory near the virtual address, hook into physical memory and jmp to the virtual address of the allocated memory, execute the code, and jmp back to the physical address?
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