Make Linux Process validation not fail with MissingMemoryDefinition

develop
Petr Mrázek 2010-02-28 06:21:50 +01:00
parent f4f566e7c4
commit 05250b4eb5
3 changed files with 45 additions and 31 deletions

@ -224,14 +224,20 @@ bool SHMProcess::Private::validate(char * exe_file, uint32_t pid, vector <memory
// iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
{
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
try{
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
{
memory_info * m = *it;
my_descriptor = m;
my_pid = pid;
identified = true;
cerr << "identified " << m->getVersion() << endl;
return true;
}
}
catch (Error::MissingMemoryDefinition&)
{
memory_info * m = *it;
my_descriptor = m;
my_pid = pid;
identified = true;
cerr << "identified " << m->getVersion() << endl;
return true;
continue;
}
}
return false;

@ -23,6 +23,7 @@ distribution.
*/
#include "DFCommonInternal.h"
#include <errno.h>
#include <DFError.h>
#include <sys/ptrace.h>
using namespace DFHack;
@ -80,15 +81,6 @@ WineProcess::WineProcess(uint32_t pid, vector <memory_info *> & known_versions)
// make sure we have a null terminated string...
target_name[target_result] = 0;
// is this the regular linux DF?
if (strstr(target_name, "dwarfort.exe") != NULL)
{
// create linux process, add it to the vector
d->identified = d->validate(target_name,pid,mem_name,known_versions );
d->my_window = new DFWindow(this);
return;
}
// FIXME: this fails when the wine process isn't started from the 'current working directory'. strip path data from cmdline
// is this windows version of Df running in wine?
if(strstr(target_name, "wine-preloader")!= NULL)
@ -139,8 +131,17 @@ bool WineProcess::Private::validate(char* exe_file, uint32_t pid, char* mem_file
// iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
{
string thishash;
try
{
thishash = (*it)->getString("md5");
}
catch (Error::MissingMemoryDefinition& e)
{
continue;
}
// are the md5 hashes the same?
if(memory_info::OS_WINDOWS == (*it)->getOS() && hash == (*it)->getString("md5"))
if(memory_info::OS_WINDOWS == (*it)->getOS() && hash == thishash)
{
memory_info * m = *it;
my_descriptor = m;

@ -114,23 +114,30 @@ bool NormalProcess::Private::validate(char * exe_file,uint32_t pid, char * memFi
// iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
{
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
try
{
memory_info * m = *it;
if (memory_info::OS_LINUX == m->getOS())
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
{
my_descriptor = m;
my_handle = my_pid = pid;
memory_info * m = *it;
if (memory_info::OS_LINUX == m->getOS())
{
my_descriptor = m;
my_handle = my_pid = pid;
}
else
{
// some error happened, continue with next process
continue;
}
// tell NormalProcess about the /proc/PID/mem file
this->memFile = memFile;
identified = true;
return true;
}
else
{
// some error happened, continue with next process
continue;
}
// tell NormalProcess about the /proc/PID/mem file
this->memFile = memFile;
identified = true;
return true;
}
catch (Error::MissingMemoryDefinition&)
{
continue;
}
}
return false;