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 


[Help] Process memory mapping

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

Joined: 25 Feb 2007
Posts: 596

PostPosted: Tue Jul 01, 2014 5:18 pm    Post subject: [Help] Process memory mapping Reply with quote

I'm looking to create an application that loads/saves memory states for a game using memory dumps. To do that I was thinking I need to create some sort of memory map based on what memory spaces are allocated when the game is running. Can anyone point me in the right direction on how I can do this? I was thinking of somehow hooking the functions the game uses to allocate memory while its running but I'm not entirely sure how to get around to do that.
Any insight is appreciated.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Tue Jul 01, 2014 5:38 pm    Post subject: Reply with quote

hooking those functions won't do any good as there's nothing you can use it for. When the game allocates memory, it writes down the result in another memory location. So when you load back the state, that memory address still holds that value specifying that specific address, and a hook won't tell you where it stored the result

With VirtualQueryEx you can get a layout of the memory as well.
VirtualAllocEx is most likely what you need, as it allows you to specify a specific base address (dividable by 64kb)

anyhow, i'm assuming this is for one specific game where you only save/load a specific state of the game that only works at specific points in the game? If not, look into writing a whole virtual machine with virtual hardware that you can access (or hook a lot more that you wish)

The reason for that is that you also need to load and store texture memory, gpu thread code, window handles, harddisk file handles and their current position, capture DMA transfers that are in progress, and some other stuff you have no access to in windows

_________________
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
homer_simpson
Grandmaster Cheater
Reputation: 0

Joined: 25 Feb 2007
Posts: 596

PostPosted: Tue Jul 01, 2014 6:08 pm    Post subject: Reply with quote

Thank you for the quick reply. Yes, it's supposed to only work on a specific point of the game.

I'm not too sure about going through the trouble of creating a virtual machine for a small project like this, maybe if it were a bigger, more ambitious project.

Anywho, if I were to use VirtualQueryEx, is there any way to tell which specific memory regions are being used at that specific point of the game?
I tried setting a breakpoint on VirtualAllocEx while the game process is running but before the game loaded and it didn't get hit.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Jul 01, 2014 9:03 pm    Post subject: Reply with quote

VirtualAllocEx is for allocating remote memory. The game will more than likely never call it. Instead it may be using:
- new
- malloc
- VirtualAlloc

Or any other similar memory allocation call that is local to its own process.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Jul 03, 2014 8:09 am    Post subject: Reply with quote

atom0s wrote:
VirtualAllocEx is for allocating remote memory. The game will more than likely never call it. Instead it may be using:
- new
- malloc
- VirtualAlloc

Or any other similar memory allocation call that is local to its own process.


Don't forget to enforce them to use WriteProcessMemory.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Thu Jul 03, 2014 1:57 pm    Post subject: Reply with quote

while i'm kinda sure this is a troll, it does bring up one method that can help you along a bit better
you could hook the allocation routines and make it return readonly memory. Then hook the exception handler and redirect every write to a special write logger and actually write it with WriteProcessMemory (it'll be slow) but it could be useful for something

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming 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