Rename memory_info and its factory class.

develop
Petr Mrázek 2010-08-20 14:10:05 +02:00
parent 3b29fddf7b
commit 1bceac2343
45 changed files with 473 additions and 439 deletions

@ -27,11 +27,11 @@ include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/)
include_directories (${CMAKE_SOURCE_DIR}/library/private/)
SET(PROJECT_HDRS
private/DFMemInfoManager.h
private/VersionInfoFactory.h
private/ContextShared.h
private/Internal.h
include/dfhack/DFError.h
include/dfhack/DFMemInfo.h
include/dfhack/VersionInfo.h
include/dfhack/DFProcessEnumerator.h
include/dfhack/DFProcess.h
include/dfhack/DFTileTypes.h
@ -60,8 +60,8 @@ include/dfhack-c/DFContext_C.h
)
SET(PROJECT_SRCS
DFMemInfo.cpp
DFMemInfoManager.cpp
VersionInfo.cpp
VersionInfoFactory.cpp
DFContextManager.cpp
DFContext.cpp
DFProcessEnumerator.cpp

@ -4,7 +4,7 @@
#include <mod-maps.h>
#include <mod-creature40d.h>
#include "private/ContextShared.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/modules/Materials.h"

@ -199,7 +199,7 @@ void Context::WriteRaw (const uint32_t offset, const uint32_t size, uint8_t *sou
d->p->write (offset, size, source);
}
memory_info *Context::getMemoryInfo()
VersionInfo *Context::getMemoryInfo()
{
return d->offset_descriptor;
}

@ -23,7 +23,7 @@ distribution.
*/
#include "Internal.h"
#include "DFMemInfoManager.h"
#include "VersionInfoFactory.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFProcessEnumerator.h"

@ -23,7 +23,7 @@ distribution.
*/
#include "Internal.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
#include <errno.h>
@ -63,7 +63,7 @@ class SHMProcess::Private
self = self_;
};
~Private(){};
memory_info * memdescriptor;
VersionInfo * memdescriptor;
Process * self;
pid_t process_ID;
char *shm_addr;
@ -79,7 +79,7 @@ class SHMProcess::Private
bool identified;
bool useYield;
bool validate(std::vector< memory_info* >& known_versions);
bool validate(std::vector< VersionInfo* >& known_versions);
bool Aux_Core_Attach(bool & versionOK, pid_t & PID);
//bool waitWhile (uint32_t state);
@ -258,7 +258,7 @@ bool SHMProcess::Private::GetLocks()
return false;
}
SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions)
SHMProcess::SHMProcess(uint32_t PID, vector< VersionInfo* >& known_versions)
: d(new Private(this))
{
d->process_ID = PID;
@ -303,7 +303,7 @@ bool SHMProcess::isIdentified()
return d->identified;
}
bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
bool SHMProcess::Private::validate(vector <VersionInfo *> & known_versions)
{
char exe_link_name [256];
char target_name[1024];
@ -323,7 +323,7 @@ bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
md5wrapper md5;
// get hash of the running DF process
string hash = md5.getHashFromFile(target_name);
vector<memory_info *>::iterator it;
vector<VersionInfo *>::iterator it;
// cerr << exe_file << " " << hash << endl;
// iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
@ -331,7 +331,7 @@ bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
try{
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
{
memory_info *m = new memory_info(**it);
VersionInfo *m = new VersionInfo(**it);
memdescriptor = m;
m->setParentProcess(dynamic_cast<Process *>( self ));
identified = true;
@ -358,7 +358,7 @@ SHMProcess::~SHMProcess()
delete d;
}
memory_info * SHMProcess::getDescriptor()
VersionInfo * SHMProcess::getDescriptor()
{
return d->memdescriptor;
}

@ -23,7 +23,7 @@ distribution.
*/
#include "Internal.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
#include <errno.h>
#include <sys/ptrace.h>
@ -44,7 +44,7 @@ class WineProcess::Private
self = self_;
};
~Private(){};
memory_info * my_descriptor;
VersionInfo * my_descriptor;
Process * self;
pid_t my_handle;
uint32_t my_pid;
@ -53,10 +53,10 @@ class WineProcess::Private
bool attached;
bool suspended;
bool identified;
bool validate(char * exe_file, uint32_t pid, char * mem_file, vector <memory_info *> & known_versions);
bool validate(char * exe_file, uint32_t pid, char * mem_file, vector <VersionInfo *> & known_versions);
};
WineProcess::WineProcess(uint32_t pid, vector <memory_info *> & known_versions)
WineProcess::WineProcess(uint32_t pid, vector <VersionInfo *> & known_versions)
: d(new Private(this))
{
char dir_name [256];
@ -124,12 +124,12 @@ bool WineProcess::isIdentified()
return d->identified;
}
bool WineProcess::Private::validate(char* exe_file, uint32_t pid, char* mem_file, std::vector< memory_info* >& known_versions)
bool WineProcess::Private::validate(char* exe_file, uint32_t pid, char* mem_file, std::vector< VersionInfo* >& known_versions)
{
md5wrapper md5;
// get hash of the running DF process
string hash = md5.getHashFromFile(exe_file);
vector<memory_info *>::iterator it;
vector<VersionInfo *>::iterator it;
// iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
@ -144,11 +144,11 @@ bool WineProcess::Private::validate(char* exe_file, uint32_t pid, char* mem_file
continue;
}
// are the md5 hashes the same?
if(memory_info::OS_WINDOWS == (*it)->getOS() && hash == thishash)
if(VersionInfo::OS_WINDOWS == (*it)->getOS() && hash == thishash)
{
// keep track of created memory_info object so we can destroy it later
memory_info *m = new memory_info(**it);
VersionInfo *m = new VersionInfo(**it);
my_descriptor = m;
m->setParentProcess(dynamic_cast<Process *>( self ));
my_handle = my_pid = pid;
@ -173,7 +173,7 @@ WineProcess::~WineProcess()
delete d;
}
memory_info * WineProcess::getDescriptor()
VersionInfo * WineProcess::getDescriptor()
{
return d->my_descriptor;
}

@ -23,7 +23,7 @@ distribution.
*/
#include "Internal.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
#include <errno.h>
#include <sys/ptrace.h>
@ -44,7 +44,7 @@ class NormalProcess::Private
};
~Private(){};
Window* my_window;
memory_info * my_descriptor;
VersionInfo * my_descriptor;
pid_t my_handle;
uint32_t my_pid;
string memFile;
@ -53,10 +53,10 @@ class NormalProcess::Private
bool suspended;
bool identified;
Process * self;
bool validate(char * exe_file, uint32_t pid, char * mem_file, vector <memory_info *> & known_versions);
bool validate(char * exe_file, uint32_t pid, char * mem_file, vector <VersionInfo *> & known_versions);
};
NormalProcess::NormalProcess(uint32_t pid, vector< memory_info* >& known_versions)
NormalProcess::NormalProcess(uint32_t pid, vector< VersionInfo* >& known_versions)
: d(new Private(this))
{
char dir_name [256];
@ -108,12 +108,12 @@ bool NormalProcess::isIdentified()
return d->identified;
}
bool NormalProcess::Private::validate(char * exe_file,uint32_t pid, char * memFile, vector <memory_info *> & known_versions)
bool NormalProcess::Private::validate(char * exe_file,uint32_t pid, char * memFile, vector <VersionInfo *> & known_versions)
{
md5wrapper md5;
// get hash of the running DF process
string hash = md5.getHashFromFile(exe_file);
vector<memory_info *>::iterator it;
vector<VersionInfo *>::iterator it;
// iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
@ -122,10 +122,10 @@ bool NormalProcess::Private::validate(char * exe_file,uint32_t pid, char * memFi
{
if(hash == (*it)->getString("md5")) // are the md5 hashes the same?
{
memory_info * m = *it;
if (memory_info::OS_LINUX == m->getOS())
VersionInfo * m = *it;
if (VersionInfo::OS_LINUX == m->getOS())
{
memory_info *m2 = new memory_info(*m);
VersionInfo *m2 = new VersionInfo(*m);
my_descriptor = m2;
m2->setParentProcess(dynamic_cast<Process *>( self ));
my_handle = my_pid = pid;
@ -161,7 +161,7 @@ NormalProcess::~NormalProcess()
delete d;
}
memory_info * NormalProcess::getDescriptor()
VersionInfo * NormalProcess::getDescriptor()
{
return d->my_descriptor;
}

@ -23,7 +23,7 @@ distribution.
*/
#include "Internal.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
#include "shms.h"
#include "mod-core.h"
@ -48,7 +48,7 @@ class SHMProcess::Private
attachmentIdx = -1;
};
~Private(){};
memory_info * memdescriptor;
VersionInfo * memdescriptor;
SHMProcess * self;
uint32_t process_ID;
char *shm_addr;
@ -62,7 +62,7 @@ class SHMProcess::Private
bool identified;
bool useYield;
bool validate(std::vector< memory_info* >& known_versions);
bool validate(std::vector< VersionInfo* >& known_versions);
bool Aux_Core_Attach(bool & versionOK, uint32_t & PID);
bool SetAndWait (uint32_t state);
@ -274,7 +274,7 @@ bool SHMProcess::Private::AreLocksOk()
}
*/
SHMProcess::SHMProcess(uint32_t PID, vector <memory_info *> & known_versions)
SHMProcess::SHMProcess(uint32_t PID, vector <VersionInfo *> & known_versions)
: d(new Private())
{
d->process_ID = PID;
@ -314,7 +314,7 @@ bool SHMProcess::isIdentified()
{
return d->identified;
}
bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
bool SHMProcess::Private::validate(vector <VersionInfo *> & known_versions)
{
// try to identify the DF version
IMAGE_NT_HEADERS32 pe_header;
@ -345,7 +345,7 @@ bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
self->read(base + pe_offset+ sizeof(pe_header), sizeof(sections) , (uint8_t *)&sections );
// iterate over the list of memory locations
vector<memory_info *>::iterator it;
vector<VersionInfo *>::iterator it;
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
{
uint32_t pe_timestamp;
@ -359,7 +359,7 @@ bool SHMProcess::Private::validate(vector <memory_info *> & known_versions)
}
if (pe_timestamp == pe_header.FileHeader.TimeDateStamp)
{
memory_info *m = new memory_info(**it);
VersionInfo *m = new VersionInfo(**it);
m->RebaseAll(base);
memdescriptor = m;
m->setParentProcess(self);
@ -385,7 +385,7 @@ SHMProcess::~SHMProcess()
delete d;
}
memory_info * SHMProcess::getDescriptor()
VersionInfo * SHMProcess::getDescriptor()
{
return d->memdescriptor;
}

@ -23,7 +23,7 @@ distribution.
*/
#include "Internal.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
using namespace DFHack;
@ -40,7 +40,7 @@ class NormalProcess::Private
suspended = false;
};
~Private(){};
memory_info * my_descriptor;
VersionInfo * my_descriptor;
HANDLE my_handle;
HANDLE my_main_thread;
uint32_t my_pid;
@ -50,7 +50,7 @@ class NormalProcess::Private
bool identified;
};
NormalProcess::NormalProcess(uint32_t pid, vector <memory_info *> & known_versions)
NormalProcess::NormalProcess(uint32_t pid, vector <VersionInfo *> & known_versions)
: d(new Private())
{
HMODULE hmod = NULL;
@ -96,11 +96,11 @@ NormalProcess::NormalProcess(uint32_t pid, vector <memory_info *> & known_versio
}
// see if there's a version entry that matches this process
vector<memory_info*>::iterator it;
vector<VersionInfo*>::iterator it;
for ( it=known_versions.begin() ; it < known_versions.end(); it++ )
{
// filter by OS
if(memory_info::OS_WINDOWS != (*it)->getOS())
if(VersionInfo::OS_WINDOWS != (*it)->getOS())
continue;
uint32_t pe_timestamp;
// filter by timestamp, skip entries without a timestamp
@ -120,7 +120,7 @@ NormalProcess::NormalProcess(uint32_t pid, vector <memory_info *> & known_versio
printf("Match found! Using version %s.\n", (*it)->getVersion().c_str());
d->identified = true;
// give the process a data model and memory layout fixed for the base of first module
memory_info *m = new memory_info(**it);
VersionInfo *m = new VersionInfo(**it);
m->RebaseAll(base);
// keep track of created memory_info object so we can destroy it later
d->my_descriptor = m;
@ -167,7 +167,7 @@ NormalProcess::~NormalProcess()
delete d;
}
memory_info * NormalProcess::getDescriptor()
VersionInfo * NormalProcess::getDescriptor()
{
return d->my_descriptor;
}

@ -23,11 +23,11 @@ distribution.
*/
#include "Internal.h"
#include "DFMemInfoManager.h"
#include "VersionInfoFactory.h"
#include "dfhack/DFProcessEnumerator.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
using namespace DFHack;
@ -39,7 +39,7 @@ class DFHack::ProcessEnumerator::Private
{
public:
Private(){};
MemInfoManager *meminfo;
VersionInfoFactory *meminfo;
PROC_V Processes;
PID2PROC ProcMap;
Process *GetProcessObject(ProcessID ID);
@ -358,7 +358,7 @@ Process * ProcessEnumerator::operator[](uint32_t index)
ProcessEnumerator::ProcessEnumerator( string path_to_xml )
: d(new Private())
{
d->meminfo = new MemInfoManager(path_to_xml);
d->meminfo = new VersionInfoFactory(path_to_xml);
}
void ProcessEnumerator::purge()

@ -23,11 +23,11 @@ distribution.
*/
#include "Internal.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
#include "dfhack/DFProcess.h"
//Inital amount of space in levels vector (since we usually know the number, efficent!)
//Inital amount of space in levels vector (since we usually know the number, efficient!)
#define NUM_RESERVE_LVLS 20
#define NUM_RESERVE_MOODS 6
using namespace DFHack;
@ -81,10 +81,12 @@ namespace DFHack
std::vector<t_type *> subs;
};
}
/*
* Private data
*/
class memory_info::Private
class VersionInfo::Private
{
public:
map <string, uint32_t> addresses;
@ -118,8 +120,9 @@ class memory_info::Private
OSType OS;
};
// normal constructor
memory_info::memory_info()
VersionInfo::VersionInfo()
:d(new Private)
{
d->base = 0;
@ -129,8 +132,9 @@ memory_info::memory_info()
d->moods.reserve(NUM_RESERVE_MOODS);
}
// copy constructor
memory_info::memory_info(const memory_info &old)
VersionInfo::VersionInfo(const VersionInfo &old)
:d(new Private)
{
d->version = old.d->version;
@ -156,13 +160,16 @@ memory_info::memory_info(const memory_info &old)
d->levels = old.d->levels;
d->moods = old.d->moods;
}
void memory_info::setParentProcess(Process * _p)
void VersionInfo::setParentProcess(Process * _p)
{
d->p = _p;
}
// destructor
memory_info::~memory_info()
VersionInfo::~VersionInfo()
{
// delete the vtables
for(uint32_t i = 0; i < d->classes.size();i++)
@ -173,25 +180,26 @@ memory_info::~memory_info()
delete d;
}
void memory_info::setVersion(const char * v)
void VersionInfo::setVersion(const char * v)
{
d->version = v;
}
void memory_info::setVersion(const string &v)
void VersionInfo::setVersion(const string &v)
{
d->version = v;
}
string memory_info::getVersion()
string VersionInfo::getVersion()
{
return d->version;
}
void memory_info::setOS(const char *os)
void VersionInfo::setOS(const char *os)
{
string oss = os;
if(oss == "windows")
@ -203,7 +211,7 @@ void memory_info::setOS(const char *os)
}
void memory_info::setOS(const string &os)
void VersionInfo::setOS(const string &os)
{
if(os == "windows")
d->OS = OS_WINDOWS;
@ -214,7 +222,7 @@ void memory_info::setOS(const string &os)
}
void memory_info::setOS(OSType os)
void VersionInfo::setOS(OSType os)
{
if(os >= OS_WINDOWS && os < OS_BAD)
{
@ -225,62 +233,64 @@ void memory_info::setOS(OSType os)
}
memory_info::OSType memory_info::getOS() const
VersionInfo::OSType VersionInfo::getOS() const
{
return d->OS;
}
uint32_t memory_info::getBase () const
uint32_t VersionInfo::getBase () const
{
return d->base;
}
void memory_info::setBase (const string &s)
void VersionInfo::setBase (const string &s)
{
d->base = strtol(s.c_str(), NULL, 16);
}
void memory_info::setBase (const uint32_t b)
void VersionInfo::setBase (const uint32_t b)
{
d->base = b;
}
void memory_info::setOffset (const string & key, const string & value)
void VersionInfo::setOffset (const string & key, const string & value)
{
int32_t offset = strtol(value.c_str(), NULL, 16);
d->offsets[key] = offset;
}
void memory_info::setAddress (const string & key, const string & value)
void VersionInfo::setAddress (const string & key, const string & value)
{
uint32_t address = strtol(value.c_str(), NULL, 16);
d->addresses[key] = address;
}
void memory_info::setHexValue (const string & key, const string & value)
void VersionInfo::setHexValue (const string & key, const string & value)
{
uint32_t hexval = strtol(value.c_str(), NULL, 16);
d->hexvals[key] = hexval;
}
void memory_info::setString (const string & key, const string & value)
void VersionInfo::setString (const string & key, const string & value)
{
d->strings[key] = value;
}
void memory_info::setLabor(const string & key, const string & value)
void VersionInfo::setLabor(const string & key, const string & value)
{
uint32_t keyInt = strtol(key.c_str(), NULL, 10);
d->labors[keyInt] = value;
}
void memory_info::setProfession (const string & key, const string & value)
void VersionInfo::setProfession (const string & key, const string & value)
{
uint32_t keyInt = strtol(key.c_str(), NULL, 10);
if(d->professions.size() <= keyInt)
@ -290,7 +300,8 @@ void memory_info::setProfession (const string & key, const string & value)
d->professions[keyInt] = value;
}
void memory_info::setJob (const string & key, const string & value)
void VersionInfo::setJob (const string & key, const string & value)
{
uint32_t keyInt = strtol(key.c_str(), NULL, 10);
if(d->jobs.size() <= keyInt)
@ -300,7 +311,8 @@ void memory_info::setJob (const string & key, const string & value)
d->jobs[keyInt] = value;
}
void memory_info::setSkill (const string & key, const string & value)
void VersionInfo::setSkill (const string & key, const string & value)
{
uint32_t keyInt = strtol(key.c_str(), NULL, 10);
if(d->skills.size() <= keyInt){
@ -309,7 +321,8 @@ void memory_info::setSkill (const string & key, const string & value)
d->skills[keyInt] = value;
}
void memory_info::setLevel(const std::string &nLevel,
void VersionInfo::setLevel(const std::string &nLevel,
const std::string &nName,
const std::string &nXp)
{
@ -323,7 +336,8 @@ void memory_info::setLevel(const std::string &nLevel,
d->levels[keyInt].xpNxtLvl = strtol(nXp.c_str(), NULL, 10);
}
void memory_info::setMood(const std::string &id, const std::string &mood)
void VersionInfo::setMood(const std::string &id, const std::string &mood)
{
uint32_t keyInt = strtol(id.c_str(), NULL, 10);
@ -333,7 +347,8 @@ void memory_info::setMood(const std::string &id, const std::string &mood)
d->moods[keyInt] = mood;
}
void memory_info::setTrait(const string & key,
void VersionInfo::setTrait(const string & key,
const string & value,
const string & zero,
const string & one,
@ -356,8 +371,9 @@ void memory_info::setTrait(const string & key,
d->traits[keyInt].push_back(value);
}
// FIXME: next three methods should use some kind of custom container so it doesn't have to search so much.
t_class * memory_info::setClass (const char * name, uint32_t vtable, uint32_t typeoffset)
t_class * VersionInfo::setClass (const char * name, uint32_t vtable, uint32_t typeoffset)
{
if(name == 0)
return 0;
@ -392,7 +408,7 @@ t_class * memory_info::setClass (const char * name, uint32_t vtable, uint32_t ty
}
void memory_info::setClassChild (t_class * parent, const char * name, const char * type)
void VersionInfo::setClassChild (t_class * parent, const char * name, const char * type)
{
vector <t_type *>& vec = parent->subs;
for (uint32_t i=0; i<vec.size(); i++)
@ -412,8 +428,9 @@ void memory_info::setClassChild (t_class * parent, const char * name, const char
//cout << " classtype " << name << ", assign " << mcc->assign << ", vtable " << mcc->type << endl;
}
// FIXME: stupid. we need a better container
bool memory_info::resolveObjectToClassID(const uint32_t address, int32_t & classid)
bool VersionInfo::resolveObjectToClassID(const uint32_t address, int32_t & classid)
{
uint32_t vtable = d->p->readDWord(address);
// try to find the vtable in our cache
@ -464,8 +481,9 @@ bool memory_info::resolveObjectToClassID(const uint32_t address, int32_t & class
}
}
//ALERT: doesn't care about multiclasses
bool memory_info::resolveClassnameToVPtr(const string classname, uint32_t & vptr)
bool VersionInfo::resolveClassnameToVPtr(const string classname, uint32_t & vptr)
{
// FIXME: another stupid search.
for(uint32_t i = 0;i< d->classes.size();i++)
@ -481,7 +499,8 @@ bool memory_info::resolveClassnameToVPtr(const string classname, uint32_t & vptr
return false;
}
bool memory_info::resolveClassnameToClassID (const string classname, int32_t & classID)
bool VersionInfo::resolveClassnameToClassID (const string classname, int32_t & classID)
{
// FIXME: another stupid search.
classID = -1;
@ -497,7 +516,8 @@ bool memory_info::resolveClassnameToClassID (const string classname, int32_t & c
return false;
}
bool memory_info::resolveClassIDToClassname (const int32_t classID, string & classname)
bool VersionInfo::resolveClassIDToClassname (const int32_t classID, string & classname)
{
if (classID >=0 && (uint32_t)classID < d->classnames.size())
{
@ -509,14 +529,14 @@ bool memory_info::resolveClassIDToClassname (const int32_t classID, string & cla
// return pointer to our internal classID -> className mapping
const vector<string> * memory_info::getClassIDMapping()
const vector<string> * VersionInfo::getClassIDMapping()
{
return &d->classnames;
}
// change base of all addresses
void memory_info::RebaseAddresses(const int32_t new_base)
void VersionInfo::RebaseAddresses(const int32_t new_base)
{
map<string, uint32_t>::iterator iter;
int32_t rebase = - (int32_t)d->base + new_base;
@ -528,7 +548,7 @@ void memory_info::RebaseAddresses(const int32_t new_base)
// change base of all addresses *and* vtable entries
void memory_info::RebaseAll(int32_t new_base)
void VersionInfo::RebaseAll(int32_t new_base)
{
map<string, uint32_t>::iterator iter;
int32_t rebase = - (int32_t)d->base + new_base;
@ -541,7 +561,7 @@ void memory_info::RebaseAll(int32_t new_base)
// change all vtable entries by offset
void memory_info::RebaseVTable(int32_t offset)
void VersionInfo::RebaseVTable(int32_t offset)
{
vector<t_class *>::iterator iter;
for(iter = d->classes.begin(); iter != d->classes.end(); iter++)
@ -550,8 +570,9 @@ void memory_info::RebaseVTable(int32_t offset)
}
}
// Get named address
uint32_t memory_info::getAddress (const char *key)
uint32_t VersionInfo::getAddress (const char *key)
{
map <string, uint32_t>::iterator iter = d->addresses.find(key);
@ -564,7 +585,7 @@ uint32_t memory_info::getAddress (const char *key)
// Get named offset
int32_t memory_info::getOffset (const char *key)
int32_t VersionInfo::getOffset (const char *key)
{
map <string, int32_t>::iterator iter = d->offsets.find(key);
if(iter != d->offsets.end())
@ -574,8 +595,9 @@ int32_t memory_info::getOffset (const char *key)
throw Error::MissingMemoryDefinition("offset", key);
}
// Get named numerical value
uint32_t memory_info::getHexValue (const char *key)
uint32_t VersionInfo::getHexValue (const char *key)
{
map <string, uint32_t>::iterator iter = d->hexvals.find(key);
if(iter != d->hexvals.end())
@ -587,7 +609,7 @@ uint32_t memory_info::getHexValue (const char *key)
// Get named address
uint32_t memory_info::getAddress (const string &key)
uint32_t VersionInfo::getAddress (const string &key)
{
map <string, uint32_t>::iterator iter = d->addresses.find(key);
@ -600,7 +622,7 @@ uint32_t memory_info::getAddress (const string &key)
// Get named offset
int32_t memory_info::getOffset (const string &key)
int32_t VersionInfo::getOffset (const string &key)
{
map <string, int32_t>::iterator iter = d->offsets.find(key);
if(iter != d->offsets.end())
@ -610,8 +632,9 @@ int32_t memory_info::getOffset (const string &key)
throw Error::MissingMemoryDefinition("offset", key.c_str());
}
// Get named numerical value
uint32_t memory_info::getHexValue (const string &key)
uint32_t VersionInfo::getHexValue (const string &key)
{
map <string, uint32_t>::iterator iter = d->hexvals.find(key);
if(iter != d->hexvals.end())
@ -621,8 +644,9 @@ uint32_t memory_info::getHexValue (const string &key)
throw Error::MissingMemoryDefinition("hexvalue", key.c_str());
}
// Get named string
std::string memory_info::getString (const string &key)
std::string VersionInfo::getString (const string &key)
{
map <string, string>::iterator iter = d->strings.find(key);
if(iter != d->strings.end())
@ -632,8 +656,9 @@ std::string memory_info::getString (const string &key)
throw Error::MissingMemoryDefinition("string", key.c_str());
}
// Get Profession
string memory_info::getProfession (const uint32_t key) const
string VersionInfo::getProfession (const uint32_t key) const
{
if(d->professions.size() > key)
{
@ -642,8 +667,9 @@ string memory_info::getProfession (const uint32_t key) const
throw Error::MissingMemoryDefinition("profession", key);
}
// Get Job
string memory_info::getJob (const uint32_t key) const
string VersionInfo::getJob (const uint32_t key) const
{
if(d->jobs.size() > key)
@ -653,7 +679,8 @@ string memory_info::getJob (const uint32_t key) const
throw Error::MissingMemoryDefinition("job", key);
}
string memory_info::getSkill (const uint32_t key) const
string VersionInfo::getSkill (const uint32_t key) const
{
if(d->skills.size() > key)
{
@ -662,7 +689,8 @@ string memory_info::getSkill (const uint32_t key) const
throw Error::MissingMemoryDefinition("skill", key);
}
DFHack::t_level memory_info::getLevelInfo(const uint32_t level) const
DFHack::t_level VersionInfo::getLevelInfo(const uint32_t level) const
{
if(d->levels.size() > level)
{
@ -671,6 +699,7 @@ DFHack::t_level memory_info::getLevelInfo(const uint32_t level) const
throw Error::MissingMemoryDefinition("Level", level);
}
// FIXME: ugly hack that needs to die
int absolute (int number)
{
@ -679,7 +708,8 @@ int absolute (int number)
return number;
}
string memory_info::getTrait (const uint32_t traitIdx, const uint32_t traitValue) const
string VersionInfo::getTrait (const uint32_t traitIdx, const uint32_t traitValue) const
{
if(d->traits.size() > traitIdx)
{
@ -704,7 +734,8 @@ string memory_info::getTrait (const uint32_t traitIdx, const uint32_t traitValue
throw Error::MissingMemoryDefinition("trait", traitIdx);
}
string memory_info::getTraitName(const uint32_t traitIdx) const
string VersionInfo::getTraitName(const uint32_t traitIdx) const
{
if(d->traits.size() > traitIdx)
{
@ -713,12 +744,14 @@ string memory_info::getTraitName(const uint32_t traitIdx) const
throw Error::MissingMemoryDefinition("traitname", traitIdx);
}
std::vector< std::vector<std::string> > const& memory_info::getAllTraits()
std::vector< std::vector<std::string> > const& VersionInfo::getAllTraits()
{
return d->traits;
}
string memory_info::getLabor (const uint32_t laborIdx)
string VersionInfo::getLabor (const uint32_t laborIdx)
{
if(d->labors.count(laborIdx))
{
@ -727,7 +760,8 @@ string memory_info::getLabor (const uint32_t laborIdx)
throw Error::MissingMemoryDefinition("labor", laborIdx);
}
std::string memory_info::getMood(const uint32_t moodID)
std::string VersionInfo::getMood(const uint32_t moodID)
{
if(d->moods.size() > moodID)
{
@ -736,7 +770,8 @@ std::string memory_info::getMood(const uint32_t moodID)
throw Error::MissingMemoryDefinition("Mood", moodID);
}
std::string memory_info::PrintOffsets()
std::string VersionInfo::PrintOffsets()
{
ostringstream ss;
ss << "<Version name=\"" << getVersion() << "\">" << endl;

@ -23,14 +23,14 @@ distribution.
*/
#include "Internal.h"
#include "DFMemInfoManager.h"
#include "VersionInfoFactory.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
using namespace DFHack;
MemInfoManager::~MemInfoManager()
VersionInfoFactory::~VersionInfoFactory()
{
// for each in std::vector<memory_info*> meminfo;, delete
for(uint32_t i = 0; i < meminfo.size();i++)
@ -40,7 +40,7 @@ MemInfoManager::~MemInfoManager()
meminfo.clear();
}
void MemInfoManager::ParseVTable(TiXmlElement* vtable, memory_info* mem)
void VersionInfoFactory::ParseVTable(TiXmlElement* vtable, VersionInfo* mem)
{
TiXmlElement* pClassEntry;
TiXmlElement* pClassSubEntry;
@ -92,9 +92,7 @@ void MemInfoManager::ParseVTable(TiXmlElement* vtable, memory_info* mem)
}
}
void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <string ,TiXmlElement *>& knownEntries)
void VersionInfoFactory::ParseEntry (TiXmlElement* entry, VersionInfo* mem, map <string ,TiXmlElement *>& knownEntries)
{
TiXmlElement* pMemEntry;
const char *cstr_version = entry->Attribute("version");
@ -223,14 +221,14 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <str
} // for
} // method
MemInfoManager::MemInfoManager(string path_to_xml)
VersionInfoFactory::VersionInfoFactory(string path_to_xml)
{
error = false;
loadFile(path_to_xml);
}
// load the XML file with offsets
bool MemInfoManager::loadFile(string path_to_xml)
bool VersionInfoFactory::loadFile(string path_to_xml)
{
TiXmlDocument doc( path_to_xml.c_str() );
//bool loadOkay = doc.LoadFile();
@ -242,7 +240,7 @@ bool MemInfoManager::loadFile(string path_to_xml)
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem;
TiXmlHandle hRoot(0);
memory_info mem;
VersionInfo mem;
// block: name
{
@ -285,7 +283,7 @@ bool MemInfoManager::loadFile(string path_to_xml)
}
for(uint32_t i = 0; i< v_pEntries.size();i++)
{
memory_info *mem = new memory_info();
VersionInfo *mem = new VersionInfo();
//FIXME: add a set of entries processed in a step of this cycle, use it to check for infinite loops
/* recursive */ParseEntry( v_pEntries[i] , mem , map_pNamedEntries);
meminfo.push_back(mem);

@ -17,7 +17,7 @@
#include "dfhack/DFError.h"
#include "dfhack/DFContextManager.h"
#include "dfhack/DFContext.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFTypes.h"

@ -40,7 +40,7 @@ namespace DFHack
class Vegetation;
class Buildings;
class Constructions;
class memory_info;
class VersionInfo;
class DFContextShared;
class WindowIO;
class Process;
@ -71,7 +71,7 @@ namespace DFHack
/// forces resume on Windows. This can be a bad thing with multiple tools running!
bool ForceResume();
memory_info *getMemoryInfo();
VersionInfo *getMemoryInfo();
Process* getProcess();
void ReadRaw (const uint32_t offset, const uint32_t size, uint8_t *target);

@ -12,7 +12,7 @@
using namespace std;
#include <dfhack/DFProcess.h>
#include <dfhack/DFMemInfo.h>
#include <dfhack/VersionInfo.h>
#include <dfhack/DFVector.h>
void DumpObjStr0Vector (const char * name, DFHack::Process *p, uint32_t addr)

@ -31,7 +31,7 @@ distribution.
namespace DFHack
{
class memory_info;
class VersionInfo;
class Process;
class Window;
@ -160,7 +160,7 @@ namespace DFHack
virtual void getMemRanges(std::vector<t_memrange> & ranges ) = 0;
/// get the flattened Memory.xml entry of this process
virtual memory_info *getDescriptor() = 0;
virtual VersionInfo *getDescriptor() = 0;
/// get the DF Process ID
virtual int getPID() = 0;
/// get module index by name and version. bool 1 = error
@ -182,7 +182,7 @@ namespace DFHack
private:
Private * const d;
public:
NormalProcess(uint32_t pid, std::vector <memory_info *> & known_versions);
NormalProcess(uint32_t pid, std::vector <VersionInfo *> & known_versions);
~NormalProcess();
bool attach();
bool detach();
@ -228,7 +228,7 @@ namespace DFHack
bool getThreadIDs(std::vector<uint32_t> & threads );
void getMemRanges(std::vector<t_memrange> & ranges );
memory_info *getDescriptor();
VersionInfo *getDescriptor();
int getPID();
// get module index by name and version. bool 1 = error
bool getModuleIndex (const char * name, const uint32_t version, uint32_t & OUTPUT) { OUTPUT=0; return false;};
@ -246,7 +246,7 @@ namespace DFHack
Private * const d;
public:
SHMProcess(uint32_t PID, std::vector <memory_info *> & known_versions);
SHMProcess(uint32_t PID, std::vector <VersionInfo *> & known_versions);
~SHMProcess();
// Set up stuff so we can read memory
bool attach();
@ -293,7 +293,7 @@ namespace DFHack
bool getThreadIDs(std::vector<uint32_t> & threads );
void getMemRanges(std::vector<t_memrange> & ranges );
memory_info *getDescriptor();
VersionInfo *getDescriptor();
int getPID();
// get module index by name and version. bool 1 = error
bool getModuleIndex (const char * name, const uint32_t version, uint32_t & OUTPUT);
@ -311,7 +311,7 @@ namespace DFHack
Private * const d;
public:
WineProcess(uint32_t pid, std::vector <memory_info *> & known_versions);
WineProcess(uint32_t pid, std::vector <VersionInfo *> & known_versions);
~WineProcess();
bool attach();
bool detach();
@ -357,7 +357,7 @@ namespace DFHack
bool getThreadIDs(std::vector<uint32_t> & threads );
void getMemRanges(std::vector<t_memrange> & ranges );
memory_info *getDescriptor();
VersionInfo *getDescriptor();
int getPID();
// get module index by name and version. bool 1 = error
bool getModuleIndex (const char * name, const uint32_t version, uint32_t & OUTPUT) {OUTPUT=0; return false;};

@ -30,7 +30,7 @@ distribution.
namespace DFHack
{
class memory_info;
class VersionInfo;
class Process;
class BadProcesses;
/**

@ -29,6 +29,7 @@ distribution.
#include "DFExport.h"
namespace DFHack
{
class VersionInfo;
class Process;
template <class T>
class DFHACK_EXPORT DfVector
@ -41,7 +42,7 @@ namespace DFHack
DfVector(Process * p, uint32_t address)
{
uint32_t triplet[3];
memory_info * mem = p->getDescriptor();
VersionInfo * mem = p->getDescriptor();
uint32_t offs = mem->getOffset("vector_triplet");
p->read(address + offs, sizeof(triplet), (uint8_t *) &triplet);

@ -37,7 +37,7 @@ namespace DFHack
class Process;
struct t_class;
class DFHACK_EXPORT memory_info
class DFHACK_EXPORT VersionInfo
{
private:
class Private;
@ -49,9 +49,9 @@ namespace DFHack
OS_LINUX,
OS_BAD
};
memory_info();
memory_info(const memory_info&);
~memory_info();
VersionInfo();
VersionInfo(const VersionInfo&);
~VersionInfo();
void RebaseAddresses(const int32_t new_base);
void RebaseAll(const int32_t new_base);

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
#include "dfhack/DFTypes.h"
@ -71,7 +71,7 @@ Buildings::Buildings(DFContextShared * d_)
d->d = d_;
d->owner = d_->p;
d->Inited = d->Started = false;
memory_info * mem = d->d->offset_descriptor;
VersionInfo * mem = d->d->offset_descriptor;
d->custom_workshop_vector = mem->getAddress("custom_workshop_vector");
d->building_custom_workshop_type = mem->getOffset("building_custom_workshop_type");
d->custom_workshop_type = mem->getOffset("custom_workshop_type");

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
#include "dfhack/DFTypes.h"
@ -52,7 +52,7 @@ Constructions::Constructions(DFContextShared * d_)
d->owner = d_->p;
d->p_cons = 0;
d->Inited = d->Started = false;
memory_info * mem = d->d->offset_descriptor;
VersionInfo * mem = d->d->offset_descriptor;
d->construction_vector = mem->getAddress ("construction_vector");
d->Inited = true;
}

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
#include "dfhack/DFError.h"
@ -69,7 +69,7 @@ Creatures::Creatures(DFContextShared* _d)
d->d->InitReadNames(); // throws on error
try
{
memory_info * minfo = d->d->offset_descriptor;
VersionInfo * minfo = d->d->offset_descriptor;
Creatures2010::creature_offsets &creatures = d->creatures;
creatures.vector = minfo->getAddress ("creature_vector");
creatures.pos_offset = minfo->getOffset ("creature_position");
@ -171,7 +171,7 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
}
*/
// non-SHM slow path
memory_info * minfo = d->d->offset_descriptor;
VersionInfo * minfo = d->d->offset_descriptor;
// read pointer from vector at position
uint32_t temp = d->p_cre->at (index);
@ -525,7 +525,7 @@ bool Creatures::WriteJob(const t_creature * furball, std::vector<t_material> con
if(!d->Inited) return false;
if(!furball->current_job.active) return false;
Process * p = d->owner;
memory_info * minfo = d->d->offset_descriptor;
VersionInfo * minfo = d->d->offset_descriptor;
DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + minfo->getOffset("job_materials_vector"));
@ -595,7 +595,7 @@ bool Creatures::ReadJob(const t_creature * furball, vector<t_material> & mat)
if(!d->Inited) return false;
if(!furball->current_job.active) return false;
Process * p = d->owner;
memory_info * minfo = d->d->offset_descriptor;
VersionInfo * minfo = d->d->offset_descriptor;
DfVector <uint32_t> cmats(p, furball->current_job.occupationPtr + minfo->getOffset("job_materials_vector"));
mat.resize(cmats.size());

@ -26,7 +26,7 @@ distribution.
#include "ContextShared.h"
#include "dfhack/modules/Gui.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFTypes.h"
using namespace DFHack;
@ -51,7 +51,7 @@ Gui::Gui(DFContextShared * _d)
d->owner = _d->p;
d->Inited = d->Started = true;
memory_info * mem = d->d->offset_descriptor;
VersionInfo * mem = d->d->offset_descriptor;
d->current_menu_state_offset = mem->getAddress("current_menu_state");
d->pause_state_offset = mem->getAddress ("pause_state");
d->view_screen_offset = mem->getAddress ("view_screen");

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/DFTypes.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
#include "dfhack/modules/Materials.h"

@ -29,7 +29,7 @@ distribution.
#include "ContextShared.h"
#include "dfhack/modules/Maps.h"
#include "dfhack/DFError.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
@ -68,7 +68,7 @@ Maps::Maps(DFContextShared* _d)
Process *p = d->owner = _d->p;
d->Inited = d->Started = false;
DFHack::memory_info * mem = p->getDescriptor();
DFHack::VersionInfo * mem = p->getDescriptor();
Server::Maps::maps_offsets &off = d->offsets;
// get the offsets once here
@ -646,7 +646,7 @@ __int16 __userpurge GetGeologicalRegion<ax>(__int16 block_X<cx>, int X<ebx>, __i
bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
{
MAPS_GUARD
memory_info * minfo = d->d->offset_descriptor;
VersionInfo * minfo = d->d->offset_descriptor;
Process *p = d->owner;
// get needed addresses and offsets. Now this is what I call crazy.
uint16_t worldSizeX, worldSizeY;
@ -721,7 +721,7 @@ bool Maps::ReadLocalFeatures( std::map <planecoord, std::vector<t_feature *> > &
return false;
Process * p = d->owner;
memory_info * mem = p->getDescriptor();
VersionInfo * mem = p->getDescriptor();
// deref pointer to the humongo-structure
uint32_t base = p->readDWord(mem->getAddress("local_feature_start_ptr"));
if(!base)
@ -814,7 +814,7 @@ bool Maps::ReadGlobalFeatures( std::vector <t_feature> & features)
return false;
Process * p = d->owner;
memory_info * mem = p->getDescriptor();
VersionInfo * mem = p->getDescriptor();
uint32_t global_feature_vector = mem->getAddress("global_feature_vector");
uint32_t global_feature_funcptr = mem->getOffset("global_feature_funcptr_");

@ -26,7 +26,7 @@ distribution.
#include "ContextShared.h"
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Materials.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
@ -305,7 +305,7 @@ bool Materials::ReadDescriptorColors (void)
bool Materials::ReadCreatureTypesEx (void)
{
Process *p = d->owner;
memory_info *mem = d->owner->getDescriptor();
VersionInfo *mem = d->owner->getDescriptor();
DfVector <uint32_t> p_races (p, mem->getAddress ("creature_type_vector"));
uint32_t castes_vector_offset = mem->getOffset ("creature_type_caste_vector");
uint32_t extract_vector_offset = mem->getOffset ("creature_type_extract_vector");

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/modules/Position.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
using namespace DFHack;
@ -59,7 +59,7 @@ Position::Position(DFContextShared * d_)
d->owner = d_->p;
d->Inited = true;
d->StartedHotkeys = d->Started = d->StartedScreen = false;
memory_info * mem;
VersionInfo * mem;
try
{
mem = d->d->offset_descriptor;

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/modules/Translation.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
#include "dfhack/DFTypes.h"
@ -52,7 +52,7 @@ Translation::Translation(DFContextShared * d_)
d = new Private;
d->d = d_;
d->Inited = d->Started = false;
memory_info * mem = d->d->offset_descriptor;
VersionInfo * mem = d->d->offset_descriptor;
d->genericAddress = mem->getAddress ("language_vector");
d->transAddress = mem->getAddress ("translation_vector");
d->word_table_offset = mem->getOffset ("word_table");

@ -25,7 +25,7 @@ distribution.
#include "Internal.h"
#include "ContextShared.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h"
#include "dfhack/DFTypes.h"
@ -53,7 +53,7 @@ Vegetation::Vegetation(DFContextShared * d_)
d->owner = d_->p;
d->d = d_;
d->Inited = d->Started = false;
memory_info * mem = d->d->offset_descriptor;
VersionInfo * mem = d->d->offset_descriptor;
d->vegetation_vector = mem->getAddress ("vegetation_vector");
d->tree_desc_offset = mem->getOffset ("tree_desc_offset");
d->Inited = true;

@ -38,7 +38,7 @@ FIXME: Japa said that he had to do this with the time stuff he got from here
#include "ContextShared.h"
#include "dfhack/modules/World.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h"
#include "dfhack/VersionInfo.h"
#include "dfhack/DFTypes.h"
using namespace DFHack;
@ -60,7 +60,7 @@ World::World(DFContextShared * _d)
d->d = _d;
d->owner = _d->p;
memory_info * mem = d->d->offset_descriptor;
VersionInfo * mem = d->d->offset_descriptor;
d->year_offset = mem->getAddress( "current_year" );
d->tick_offset = mem->getAddress( "current_tick" );
d->Inited = d->Started = true;

@ -48,7 +48,7 @@ namespace DFHack
class ProcessEnumerator;
class Process;
class memory_info;
class VersionInfo;
struct t_name;
class DFContextShared
{
@ -68,7 +68,7 @@ namespace DFHack
ProcessEnumerator* pm;
Process* p;
char * shm_start;
memory_info* offset_descriptor;
VersionInfo* offset_descriptor;
string xml;
// Modules

@ -30,20 +30,20 @@ distribution.
class TiXmlElement;
namespace DFHack
{
class memory_info;
class MemInfoManager
class VersionInfo;
class VersionInfoFactory
{
friend class ProcessEnumerator;
public:
MemInfoManager(string path_to_xml);
~MemInfoManager();
VersionInfoFactory(string path_to_xml);
~VersionInfoFactory();
// memory info entries loaded from a file
bool loadFile( string path_to_xml);
bool isInErrorState() const {return error;};
std::vector<memory_info*> meminfo;
std::vector<VersionInfo*> meminfo;
private:
void ParseVTable(TiXmlElement* vtable, memory_info* mem);
void ParseEntry (TiXmlElement* entry, memory_info* mem, map <string ,TiXmlElement *>& knownEntries);
void ParseVTable(TiXmlElement* vtable, VersionInfo* mem);
void ParseEntry (TiXmlElement* entry, VersionInfo* mem, map <string ,TiXmlElement *>& knownEntries);
bool error;
};
}

@ -54,7 +54,7 @@ int main (int argc,const char* argv[])
return 1;
}
DFHack::memory_info * mem = DF->getMemoryInfo();
DFHack::VersionInfo * mem = DF->getMemoryInfo();
DFHack::Buildings * Bld = DF->getBuildings();
DFHack::Position * Pos = DF->getPosition();

@ -19,7 +19,7 @@ enum likeType
};
DFHack::Materials * Materials;
DFHack::memory_info *mem;
DFHack::VersionInfo *mem;
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
DFHack::Creatures * Creatures = NULL;
@ -154,7 +154,7 @@ void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature)
}
DFHack::Translation *Tran = DF->getTranslation();
DFHack::memory_info *mem = DF->getMemoryInfo();
DFHack::VersionInfo *mem = DF->getMemoryInfo();
string transName = Tran->TranslateName(creature.name,false);
if(!transName.empty())

@ -37,7 +37,7 @@ int main ()
return 1;
}
DFHack::memory_info * mem = DF->getMemoryInfo();
DFHack::VersionInfo * mem = DF->getMemoryInfo();
Materials = DF->getMaterials();
Materials->ReadAllMaterials();
p = DF->getProcess();

@ -25,7 +25,7 @@ int main (void)
return 1;
}
DFHack::memory_info * mem = DF->getMemoryInfo();
DFHack::VersionInfo * mem = DF->getMemoryInfo();
DFHack::Position * Pos = DF->getPosition();
// get stone matgloss mapping
/*

@ -35,7 +35,7 @@ int main (int numargs, const char ** args)
}
DFHack::Process* p = DF->getProcess();
DFHack::memory_info* mem = DF->getMemoryInfo();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Materials *Materials = DF->getMaterials();
cout << "----==== Inorganic ====----" << endl;

@ -56,7 +56,7 @@ int main (void)
{
cout << "Testing ProcessEnumerator" << endl;
ProcessEnumerator Penum("Memory.xml");
memory_info * mem;
VersionInfo * mem;
do
{
// make the ProcessEnumerator update its list of Processes
@ -90,7 +90,7 @@ int main (void)
{
cout << "Testing ContextManager" << endl;
ContextManager Cman("Memory.xml");
memory_info * mem;
VersionInfo * mem;
do
{
// make the ContextManager update its list of Contexts

@ -37,7 +37,7 @@ int main (int numargs, const char ** args)
}
DFHack::Process* p = DF->getProcess();
DFHack::memory_info* mem = DF->getMemoryInfo();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Position * pos = DF->getPosition();
DFHack::Vegetation * v = DF->getVegetation();
DFHack::Materials * mat = DF->getMaterials();

@ -21,7 +21,7 @@ using namespace DFHack;
int main ( int argc, char** argv )
{
DFHack::memory_info *mem;
DFHack::VersionInfo *mem;
DFHack::Process *proc;
uint32_t creature_pregnancy_offset;

@ -181,12 +181,12 @@ bool getRanges(DFHack::Process * p, vector <DFHack::t_memrange>& selected_ranges
{
// empty input, assume default. observe the length of the memory range vector
// these are hardcoded values, intended for my convenience only
if(p->getDescriptor()->getOS() == DFHack::memory_info::OS_WINDOWS)
if(p->getDescriptor()->getOS() == DFHack::VersionInfo::OS_WINDOWS)
{
start = min(11, (int)ranges.size());
end = min(14, (int)ranges.size());
}
else if(p->getDescriptor()->getOS() == DFHack::memory_info::OS_LINUX)
else if(p->getDescriptor()->getOS() == DFHack::VersionInfo::OS_LINUX)
{
start = min(2, (int)ranges.size());
end = min(4, (int)ranges.size());
@ -793,8 +793,8 @@ int main (void)
vector <DFHack::t_memrange> selected_ranges;
getRanges(p,selected_ranges);
DFHack::memory_info *minfo = DF->getMemoryInfo();
DFHack::memory_info::OSType os = minfo->getOS();
DFHack::VersionInfo *minfo = DF->getMemoryInfo();
DFHack::VersionInfo::OSType os = minfo->getOS();
string prompt =
"Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n"

@ -6,7 +6,7 @@ using namespace std;
#include <DFHack.h>
DFHack::Materials * Materials;
DFHack::memory_info *mem;
DFHack::VersionInfo *mem;
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;

@ -32,7 +32,7 @@ int main ()
return 1;
}
DFHack::memory_info * mem = DF->getMemoryInfo();
DFHack::VersionInfo * mem = DF->getMemoryInfo();
p = DF->getProcess();
uint32_t item_vec_offset = 0;
try

@ -27,7 +27,7 @@ int main (int numargs, const char ** args)
#endif
return 1;
}
memory_info * minfo = DF->getMemoryInfo();
VersionInfo * minfo = DF->getMemoryInfo();
if(minfo)
cout << minfo->PrintOffsets();
#ifndef LINUX_BUILD

@ -32,7 +32,7 @@ int main (int numargs, const char ** args)
}
DFHack::Position *Pos = DF->getPosition();
DFHack::memory_info* mem = DF->getMemoryInfo();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Maps *Maps = DF->getMaps();
DFHack::Process * p = DF->getProcess();
uint32_t designatus = mem->getOffset("map_data_designation");