Click to See Complete Forum and Search --> : How to save a "state" of a process
Achilles
March 11th, 2005, 10:23 PM
Hi All,
I want to suspend a process and save a "state" of this process so that I can resume the process from this point at a later time. Is it possible to save all the information of a running program/process so that next time if I lanch this program or create this process, I can load those previously saved information into memory and resume from that point. What I want to do exactly is just like making a checkpoint in some games. But I don't know what information should be saved and how to do this. I hope someone can give me a hint, thanks in advance!
Regards,
A.
Marc G
March 13th, 2005, 11:53 AM
I'm almost certain that will be impossible.
Just think about it. Especially for games, they write stuff to the graphics card, program pixel shaders on the graphics card, etc...
When a window is opened, a HWND is given to the window. The application knows this HWND, but when you restart the applicatio, this HWND is completely different, so the app won't work correctly. You can't force Windows to create a window with a given HWND. The same holds for other handles, like files etc
Hobson
March 13th, 2005, 12:50 PM
Hey Marc,
This technique is possible to do, and frequently used by game developers, and is called savegame file. Main question here is: what information we need to startup process from prevoius state? For a game you do not have to dump all registers, dump whole memory, often you cannot do that due to insufficient access privileges. Saving state of all necessary objects in the game is good enough.
Achilles, just think what data is necessary to invoke your proccess from previous state, and load it from file on startup. When process exits, save all necessary data to file, or registry, or whatever storage area you wish.
thats my opinion
Hob
Marc G
March 13th, 2005, 01:40 PM
Hey Marc,
This technique is possible to do, and frequently used by game developers, and is called savegame file. Main question here is: what information we need to startup process from prevoius state? For a game you do not have to dump all registers, dump whole memory, often you cannot do that due to insufficient access privileges. Saving state of all necessary objects in the game is good enough.
Achilles, just think what data is necessary to invoke your proccess from previous state, and load it from file on startup. When process exits, save all necessary data to file, or registry, or whatever storage area you wish.
thats my opinion
Hob
Of course... but I interpreted the question as he/she wanted to save the state of any application, not specifically his/her application....
So, Achilles: do you want to save the state of your own application or of another app of which you don't have the source code?
Hobson
March 13th, 2005, 01:57 PM
Oh yes, thats a way I did not think of. Very much depends of understanding a question :D But also this is at least partially possible I think, but not at application level. Windows XP hibernation works in this way, but it stores to disk not only process information, but also system state. I also assume that not every application would dehibernate without a problem.
Hob
Marc G
March 14th, 2005, 12:14 PM
Oh yes, thats a way I did not think of. Very much depends of understanding a question :D But also this is at least partially possible I think, but not at application level. Windows XP hibernation works in this way, but it stores to disk not only process information, but also system state. I also assume that not every application would dehibernate without a problem.
Hob
Yes, Windows Hibernate works that way, but it write the state of the entire operating system to disk. You can't hibernate only 1 program, because as I already said, you can't recreate a window with a given HWND (similar for file handles, mutexes, etc...)
SirNotApearingOnThisForum
March 15th, 2005, 02:04 AM
If you just wanted to suspend a thread for a certain amount of time one might be able to use the SuspendThread() function, documented here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/suspendthread.asp). If that's not what you're looking for, there might be something of interest in that list of related functions to the left.
barrensoul
March 16th, 2005, 01:47 PM
Saving the "state" of the process would be the equivelant of taking a snap shot of the ram/VM that is being used by that program at that instant and some how loading it again :) (this is an extremely inefficient method but it should work, in theory :D )
Marc G
March 17th, 2005, 02:40 PM
Saving the "state" of the process would be the equivelant of taking a snap shot of the ram/VM that is being used by that program at that instant and some how loading it again :) (this is an extremely inefficient method but it should work, in theory :D )
No, it won't work. Didn't you read my replies?
You can't recreate the windows with the exact same HWND as before, you can't create file handles with the exact same file handles as before, same for events, etc etc...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.