ForceResume call

develop
Petr Mrázek 2009-11-19 01:48:18 +00:00
parent 67adb64a46
commit 989fa8f887
6 changed files with 34 additions and 2 deletions

@ -1142,6 +1142,10 @@ bool API::Resume()
{
return d->p->resume();
}
bool API::ForceResume()
{
return d->p->forceresume();
}
bool API::isSuspended()
{
return d->p->isSuspended();

@ -63,8 +63,14 @@ namespace DFHack
bool Detach();
bool isAttached();
// stop DF from executing
bool Suspend();
// resume DF
bool Resume();
/**
* be careful with this one
*/
bool ForceResume();
bool isSuspended();
/**
* Matgloss. next four methods look very similar. I could use two and move the processing one level up...

@ -252,6 +252,11 @@ bool Process::suspend()
d->suspended = true;
}
bool Process::forceresume()
{
return resume();
}
bool Process::resume()
{
int status;

@ -186,6 +186,16 @@ bool Process::suspend()
return true;
}
bool Process::forceresume()
{
if(!d->attached)
return false;
while (ResumeThread(d->my_main_thread) > 1);
d->suspended = false;
return true;
}
bool Process::resume()
{
if(!d->attached)

@ -72,6 +72,7 @@ namespace DFHack
bool suspend();
bool resume();
bool forceresume();
bool isSuspended();
bool isAttached();

@ -24,15 +24,21 @@ int main (void)
getline(cin, blah);
DF.Resume();
cout << "Resumed, DF should be running" << endl;
getline(cin, blah);
DF.Suspend();
cout << "Suspended, DF should be suspended now" << endl;
getline(cin, blah);
DF.Resume();
cout << "Resumed, testing ForceResume. Suspend using SysInternals Process Explorer" << endl;
getline(cin, blah);
DF.ForceResume();
cout << "ForceResumed. DF should be running." << endl;
getline(cin, blah);
if(!DF.Detach())
{
cerr << "Can't detach from DF" << endl;