|
-
March 11th, 2005, 11:23 PM
#1
How to save a "state" of a process
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.
-
March 13th, 2005, 12:53 PM
#2
Re: How to save a "state" of a process
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
-
March 13th, 2005, 01:50 PM
#3
Re: How to save a "state" of a process
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
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
March 13th, 2005, 02:40 PM
#4
Re: How to save a "state" of a process
 Originally Posted by Hobson
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?
-
March 13th, 2005, 02:57 PM
#5
Re: How to save a "state" of a process
Oh yes, thats a way I did not think of. Very much depends of understanding a question 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
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
March 14th, 2005, 01:14 PM
#6
Re: How to save a "state" of a process
 Originally Posted by Hobson
Oh yes, thats a way I did not think of. Very much depends of understanding a question  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...)
-
March 15th, 2005, 03:04 AM
#7
Re: How to save a "state" of a process
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. If that's not what you're looking for, there might be something of interest in that list of related functions to the left.
-
March 16th, 2005, 02:47 PM
#8
Re: How to save a "state" of a process
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 )
In C, you merely shoot yourself in the foot.
In C++, you accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical care is impossible, because you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there."
-
March 17th, 2005, 03:40 PM
#9
Re: How to save a "state" of a process
 Originally Posted by barrensoul
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  )
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...
Last edited by Marc G; December 20th, 2005 at 09:17 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|