Is it possible to find a program in the ram and save all it's taken memory into a file and some time later replace a part of ram with that file?
I want to do something like saving and loading Minesweeper.
Hmm, sorry. Try looking into virtual machines. There are a few good free ones out there.
The other way would be just to find a version of MineSweeper that can save and load its state for you. Or write your own. A good place to start is http://www.planet-minesweeper.com/
Seriously, you really have to know what you are doing to save and restore an arbitrary process's image. It isn't simple, and the rabbit hole is very deep.
Yeah, this is something that goes beyond the realm of everyday C++ - we're talking assembly or at the very least some very dangerous operations with memory pointers. I'd recommend a virtual machine like Duoas suggested. If not, keep crawling the internet - you can't be the only person who's had this idea :)
Can you provide more info on what exactly you need your program to do? You said saving/loading minesweeper... do you mean you are making a minesweeper game and want to save/load play sessions? Or, are you making a program that is separate from minesweeper and you want to save the state of the current minesweeper game? Or, is it something else entirely?
the part with accessing the right right memory adress blocks... (ok its the easier magic)...
but replacing a running pograms“ memory... this is the deeper black magic... u got to drive around some system internal security barriers for this... or it will result in an system error^^...
[EDIT]: found your deadlock:
Each process on 32-bit Microsoft Windows has its own virtual address space that enables addressing up to 4 gigabytes of memory. Each process on 64-bit Windows has a virtual address space of 8 terabytes. All threads of a process can access its virtual address space. However, threads cannot access memory that belongs to another process, which protects a process from being corrupted by another process.
... you got to tbe an experienced cracker for this^^...
Do you need to save everything or can you just save some of the objects? You should be able to just overload the stream operators for the objects you need to save to file, and when you call save just stream them all to the file. When you call load, you do the reverse. You may not be able to save every single thing about the state of the program this way, but you can save most of it.
well u can find the beginning and the end and whats between... but that for he will need a lot of exp... and even if he made it, he cant put the memory saved back into the running programm without causing multiple errors...
But, you could write an emulator to run the game in. Then have the emulator dump the memory and re-load it. Similar to a Virtual Machine's snapshot feature.
The Win32 Kernel does allow you to play with another process's memory if you have the right permissions.
The trick is that processes aren't necessarily mapped into memory the same way every time they are executed. Even if you sort that out properly, if you just blindly write old data into new space you can smash pointers. (Every process has a LUT of function pointers, data pointers, etc. for every module it uses --directly or indirectly.) So, even if you find the proper data segment, and you know all the new vs. old mappings, you still have to know exactly what you can change in that segment and what you can't --which requires some careful scanning.
(Add-on garbage collectors use techniques like this, but they have to be conservative to keep from accidentally changing something they shouldn't. You don't have that luxury when restoring a process's in-memory image.)
Just use a VM or download a minesweeper clone that can do what you want.