|
|
@ -38,24 +38,22 @@ namespace {
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
MicrosoftSTL stl;
|
|
|
|
MicrosoftSTL stl;
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
WineProcess(uint32_t pid, std::vector <VersionInfo *> & known_versions);
|
|
|
|
WineProcess(uint32_t pid, VersionInfoFactory * factory);
|
|
|
|
|
|
|
|
|
|
|
|
const std::string readSTLString (uint32_t offset);
|
|
|
|
const std::string readSTLString (uint32_t offset);
|
|
|
|
size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity);
|
|
|
|
size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity);
|
|
|
|
void writeSTLString(const uint32_t address, const std::string writeString){};
|
|
|
|
void writeSTLString(const uint32_t address, const std::string writeString){};
|
|
|
|
// get class name of an object with rtti/type info
|
|
|
|
// get class name of an object with rtti/type info
|
|
|
|
std::string readClassName(uint32_t vptr);
|
|
|
|
std::string readClassName(uint32_t vptr);
|
|
|
|
private:
|
|
|
|
|
|
|
|
bool validate(char * exe_file,uint32_t pid, char * memFile, vector <VersionInfo *> & known_versions);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Process* DFHack::createWineProcess(uint32_t pid, vector <VersionInfo *> & known_versions)
|
|
|
|
Process* DFHack::createWineProcess(uint32_t pid, VersionInfoFactory * factory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new WineProcess(pid, known_versions);
|
|
|
|
return new WineProcess(pid, factory);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WineProcess::WineProcess(uint32_t pid, vector <VersionInfo *> & known_versions) : LinuxProcessBase(pid)
|
|
|
|
WineProcess::WineProcess(uint32_t pid, VersionInfoFactory * factory) : LinuxProcessBase(pid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char dir_name [256];
|
|
|
|
char dir_name [256];
|
|
|
|
char exe_link_name [256];
|
|
|
|
char exe_link_name [256];
|
|
|
@ -71,6 +69,7 @@ WineProcess::WineProcess(uint32_t pid, vector <VersionInfo *> & known_versions)
|
|
|
|
sprintf(dir_name,"/proc/%d/", pid);
|
|
|
|
sprintf(dir_name,"/proc/%d/", pid);
|
|
|
|
sprintf(exe_link_name,"/proc/%d/exe", pid);
|
|
|
|
sprintf(exe_link_name,"/proc/%d/exe", pid);
|
|
|
|
sprintf(mem_name,"/proc/%d/mem", pid);
|
|
|
|
sprintf(mem_name,"/proc/%d/mem", pid);
|
|
|
|
|
|
|
|
memFile = mem_name;
|
|
|
|
sprintf(cwd_name,"/proc/%d/cwd", pid);
|
|
|
|
sprintf(cwd_name,"/proc/%d/cwd", pid);
|
|
|
|
sprintf(cmdline_name,"/proc/%d/cmdline", pid);
|
|
|
|
sprintf(cmdline_name,"/proc/%d/cmdline", pid);
|
|
|
|
|
|
|
|
|
|
|
@ -101,51 +100,23 @@ WineProcess::WineProcess(uint32_t pid, vector <VersionInfo *> & known_versions)
|
|
|
|
// put executable name and path together
|
|
|
|
// put executable name and path together
|
|
|
|
sprintf(exe_link,"%s/%s",target_name,cmdline.c_str());
|
|
|
|
sprintf(exe_link,"%s/%s",target_name,cmdline.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
// create wine process, add it to the vector
|
|
|
|
|
|
|
|
identified = validate(exe_link,pid,mem_name,known_versions);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool WineProcess::validate(char * exe_file,uint32_t pid, char * memFile, vector <VersionInfo *> & known_versions)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
md5wrapper md5;
|
|
|
|
md5wrapper md5;
|
|
|
|
// get hash of the running DF process
|
|
|
|
// get hash of the running DF process
|
|
|
|
string hash = md5.getHashFromFile(exe_file);
|
|
|
|
string hash = md5.getHashFromFile(exe_link);
|
|
|
|
vector<VersionInfo *>::iterator it;
|
|
|
|
// create linux process, add it to the vector
|
|
|
|
|
|
|
|
VersionInfo * vinfo = factory->getVersionInfoByMD5(hash);
|
|
|
|
// iterate over the list of memory locations
|
|
|
|
if(vinfo)
|
|
|
|
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (hash == (*it)->getMD5()) // are the md5 hashes the same?
|
|
|
|
my_descriptor = new VersionInfo(*vinfo);
|
|
|
|
{
|
|
|
|
|
|
|
|
if (OS_WINDOWS == (*it)->getOS())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// keep track of created memory_info object so we can destroy it later
|
|
|
|
|
|
|
|
my_descriptor = new VersionInfo(**it);
|
|
|
|
|
|
|
|
my_descriptor->setParentProcess(this);
|
|
|
|
my_descriptor->setParentProcess(this);
|
|
|
|
// tell Process about the /proc/PID/mem file
|
|
|
|
|
|
|
|
memFile = memFile;
|
|
|
|
|
|
|
|
identified = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stl.init(this);
|
|
|
|
stl.init(this);
|
|
|
|
return true;
|
|
|
|
identified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Error::AllMemdef&)
|
|
|
|
return;
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t WineProcess::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity)
|
|
|
|
size_t WineProcess::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return stl.readSTLString(offset, buffer, bufcapacity);
|
|
|
|
return stl.readSTLString(offset, buffer, bufcapacity);
|
|
|
@ -158,5 +129,5 @@ const string WineProcess::readSTLString (uint32_t offset)
|
|
|
|
|
|
|
|
|
|
|
|
string WineProcess::readClassName (uint32_t vptr)
|
|
|
|
string WineProcess::readClassName (uint32_t vptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stl.readClassName(vptr);
|
|
|
|
return stl.readClassName(vptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|