Reputation: 3182
my goal is to save state of running process and later start from this point.
This is not necessary need to be state from this exact moment, let's say save after 5 seconds is good too. Problem is, i can't alter in code of this external program, i am even don't aware of it's architecture.
I have resources to save whole program to disk from memory, but i need some tips, where to start. I can't use any VM like Virtual Box to save state of whole operating system, and program can be written in c++ or c or c#...
Upvotes: 0
Views: 1605
Reputation: 31404
I'm going to agree with everyone else, that there is no way to do this on Windows.
You could use the debugging API to hook into the process and use ReadProcessMemory to save the program's memory to disk. But that is only it's user mode state, not it's kernel mode state - and you have no access to it's kernel mode state (including, but not limited to File Handles, GDI objects, Network Resources, Threads...) - that is hidden entirely inside the Windows kernel. Not to mention that if you somehow got that state, there is no way to restore it - you can't just create a blank process and then copy the memory back in and have it start where it left off.
That's a long way of saying there is no way to do it without OS support and Windows doesn't have that.
Are you sure you can't user a Virtual Machine, because that really is your only option.
Upvotes: 2
Reputation: 14112
Some operating systems have this feature. It is called checkpoint restart. Since it has to save operating system internal data, you will have to check to see if you particular operating system supports it. You can't do it with just an external program.
Upvotes: 0
Reputation: 161831
There is no way to do this in the general case. Windows has a save and resume capability for the entire OS (it used to be called hibernation, but I don't know the new name), but there is no facility to do this to one process.
Upvotes: 0