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/) include_directories (${CMAKE_SOURCE_DIR}/library/private/)
SET(PROJECT_HDRS SET(PROJECT_HDRS
private/DFMemInfoManager.h private/VersionInfoFactory.h
private/ContextShared.h private/ContextShared.h
private/Internal.h private/Internal.h
include/dfhack/DFError.h include/dfhack/DFError.h
include/dfhack/DFMemInfo.h include/dfhack/VersionInfo.h
include/dfhack/DFProcessEnumerator.h include/dfhack/DFProcessEnumerator.h
include/dfhack/DFProcess.h include/dfhack/DFProcess.h
include/dfhack/DFTileTypes.h include/dfhack/DFTileTypes.h
@ -60,8 +60,8 @@ include/dfhack-c/DFContext_C.h
) )
SET(PROJECT_SRCS SET(PROJECT_SRCS
DFMemInfo.cpp VersionInfo.cpp
DFMemInfoManager.cpp VersionInfoFactory.cpp
DFContextManager.cpp DFContextManager.cpp
DFContext.cpp DFContext.cpp
DFProcessEnumerator.cpp DFProcessEnumerator.cpp

@ -4,7 +4,7 @@
#include <mod-maps.h> #include <mod-maps.h>
#include <mod-creature40d.h> #include <mod-creature40d.h>
#include "private/ContextShared.h" #include "private/ContextShared.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/modules/Materials.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); d->p->write (offset, size, source);
} }
memory_info *Context::getMemoryInfo() VersionInfo *Context::getMemoryInfo()
{ {
return d->offset_descriptor; return d->offset_descriptor;
} }

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

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

@ -23,7 +23,7 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h" #include "dfhack/DFError.h"
#include <errno.h> #include <errno.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
@ -44,7 +44,7 @@ class WineProcess::Private
self = self_; self = self_;
}; };
~Private(){}; ~Private(){};
memory_info * my_descriptor; VersionInfo * my_descriptor;
Process * self; Process * self;
pid_t my_handle; pid_t my_handle;
uint32_t my_pid; uint32_t my_pid;
@ -53,10 +53,10 @@ class WineProcess::Private
bool attached; bool attached;
bool suspended; bool suspended;
bool identified; 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)) : d(new Private(this))
{ {
char dir_name [256]; char dir_name [256];
@ -124,12 +124,12 @@ bool WineProcess::isIdentified()
return d->identified; 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; 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_file);
vector<memory_info *>::iterator it; vector<VersionInfo *>::iterator it;
// iterate over the list of memory locations // iterate over the list of memory locations
for ( it=known_versions.begin() ; it < known_versions.end(); it++ ) 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; continue;
} }
// are the md5 hashes the same? // 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 // 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; my_descriptor = m;
m->setParentProcess(dynamic_cast<Process *>( self )); m->setParentProcess(dynamic_cast<Process *>( self ));
my_handle = my_pid = pid; my_handle = my_pid = pid;
@ -173,7 +173,7 @@ WineProcess::~WineProcess()
delete d; delete d;
} }
memory_info * WineProcess::getDescriptor() VersionInfo * WineProcess::getDescriptor()
{ {
return d->my_descriptor; return d->my_descriptor;
} }

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

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

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

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

@ -23,11 +23,11 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h" #include "dfhack/DFError.h"
#include "dfhack/DFProcess.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_LVLS 20
#define NUM_RESERVE_MOODS 6 #define NUM_RESERVE_MOODS 6
using namespace DFHack; using namespace DFHack;
@ -81,10 +81,12 @@ namespace DFHack
std::vector<t_type *> subs; std::vector<t_type *> subs;
}; };
} }
/* /*
* Private data * Private data
*/ */
class memory_info::Private class VersionInfo::Private
{ {
public: public:
map <string, uint32_t> addresses; map <string, uint32_t> addresses;
@ -95,9 +97,9 @@ class memory_info::Private
vector<string> professions; vector<string> professions;
vector<string> jobs; vector<string> jobs;
vector<string> skills; vector<string> skills;
vector<DFHack::t_level> levels; vector<DFHack::t_level> levels;
vector< vector<string> > traits; vector< vector<string> > traits;
vector<string> moods; vector<string> moods;
map <uint32_t, string> labors; map <uint32_t, string> labors;
// storage for class and multiclass // storage for class and multiclass
@ -118,19 +120,21 @@ class memory_info::Private
OSType OS; OSType OS;
}; };
// normal constructor // normal constructor
memory_info::memory_info() VersionInfo::VersionInfo()
:d(new Private) :d(new Private)
{ {
d->base = 0; d->base = 0;
d->p = 0; d->p = 0;
d->classindex = 0; d->classindex = 0;
d->levels.reserve(NUM_RESERVE_LVLS); d->levels.reserve(NUM_RESERVE_LVLS);
d->moods.reserve(NUM_RESERVE_MOODS); d->moods.reserve(NUM_RESERVE_MOODS);
} }
// copy constructor // copy constructor
memory_info::memory_info(const memory_info &old) VersionInfo::VersionInfo(const VersionInfo &old)
:d(new Private) :d(new Private)
{ {
d->version = old.d->version; d->version = old.d->version;
@ -153,16 +157,19 @@ memory_info::memory_info(const memory_info &old)
d->skills = old.d->skills; d->skills = old.d->skills;
d->traits = old.d->traits; d->traits = old.d->traits;
d->labors = old.d->labors; d->labors = old.d->labors;
d->levels = old.d->levels; d->levels = old.d->levels;
d->moods = old.d->moods; d->moods = old.d->moods;
} }
void memory_info::setParentProcess(Process * _p)
void VersionInfo::setParentProcess(Process * _p)
{ {
d->p = _p; d->p = _p;
} }
// destructor // destructor
memory_info::~memory_info() VersionInfo::~VersionInfo()
{ {
// delete the vtables // delete the vtables
for(uint32_t i = 0; i < d->classes.size();i++) for(uint32_t i = 0; i < d->classes.size();i++)
@ -173,25 +180,26 @@ memory_info::~memory_info()
delete d; delete d;
} }
void memory_info::setVersion(const char * v)
void VersionInfo::setVersion(const char * v)
{ {
d->version = v; d->version = v;
} }
void memory_info::setVersion(const string &v) void VersionInfo::setVersion(const string &v)
{ {
d->version = v; d->version = v;
} }
string memory_info::getVersion() string VersionInfo::getVersion()
{ {
return d->version; return d->version;
} }
void memory_info::setOS(const char *os) void VersionInfo::setOS(const char *os)
{ {
string oss = os; string oss = os;
if(oss == "windows") 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") if(os == "windows")
d->OS = 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) 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; return d->OS;
} }
uint32_t memory_info::getBase () const uint32_t VersionInfo::getBase () const
{ {
return d->base; return d->base;
} }
void memory_info::setBase (const string &s) void VersionInfo::setBase (const string &s)
{ {
d->base = strtol(s.c_str(), NULL, 16); 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; 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); int32_t offset = strtol(value.c_str(), NULL, 16);
d->offsets[key] = offset; 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); uint32_t address = strtol(value.c_str(), NULL, 16);
d->addresses[key] = address; 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); uint32_t hexval = strtol(value.c_str(), NULL, 16);
d->hexvals[key] = hexval; 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; 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); uint32_t keyInt = strtol(key.c_str(), NULL, 10);
d->labors[keyInt] = value; 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); uint32_t keyInt = strtol(key.c_str(), NULL, 10);
if(d->professions.size() <= keyInt) if(d->professions.size() <= keyInt)
@ -290,7 +300,8 @@ void memory_info::setProfession (const string & key, const string & value)
d->professions[keyInt] = 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); uint32_t keyInt = strtol(key.c_str(), NULL, 10);
if(d->jobs.size() <= keyInt) if(d->jobs.size() <= keyInt)
@ -300,7 +311,8 @@ void memory_info::setJob (const string & key, const string & value)
d->jobs[keyInt] = 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); uint32_t keyInt = strtol(key.c_str(), NULL, 10);
if(d->skills.size() <= keyInt){ if(d->skills.size() <= keyInt){
@ -309,31 +321,34 @@ void memory_info::setSkill (const string & key, const string & value)
d->skills[keyInt] = value; d->skills[keyInt] = value;
} }
void memory_info::setLevel(const std::string &nLevel,
const std::string &nName, void VersionInfo::setLevel(const std::string &nLevel,
const std::string &nXp) const std::string &nName,
const std::string &nXp)
{ {
uint32_t keyInt = strtol(nLevel.c_str(), NULL, 10); uint32_t keyInt = strtol(nLevel.c_str(), NULL, 10);
if(d->levels.size() <= keyInt) if(d->levels.size() <= keyInt)
d->levels.resize(keyInt+1); d->levels.resize(keyInt+1);
d->levels[keyInt].level = keyInt; d->levels[keyInt].level = keyInt;
d->levels[keyInt].name = nName; d->levels[keyInt].name = nName;
d->levels[keyInt].xpNxtLvl = strtol(nXp.c_str(), NULL, 10); 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); uint32_t keyInt = strtol(id.c_str(), NULL, 10);
if(d->moods.size() <= keyInt) if(d->moods.size() <= keyInt)
d->moods.resize(keyInt+1); d->moods.resize(keyInt+1);
d->moods[keyInt] = mood; d->moods[keyInt] = mood;
} }
void memory_info::setTrait(const string & key,
void VersionInfo::setTrait(const string & key,
const string & value, const string & value,
const string & zero, const string & zero,
const string & one, const string & one,
@ -356,8 +371,9 @@ void memory_info::setTrait(const string & key,
d->traits[keyInt].push_back(value); 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. // 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) if(name == 0)
return 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; vector <t_type *>& vec = parent->subs;
for (uint32_t i=0; i<vec.size(); i++) 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; //cout << " classtype " << name << ", assign " << mcc->assign << ", vtable " << mcc->type << endl;
} }
// FIXME: stupid. we need a better container // 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); uint32_t vtable = d->p->readDWord(address);
// try to find the vtable in our cache // 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 //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. // FIXME: another stupid search.
for(uint32_t i = 0;i< d->classes.size();i++) 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; 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. // FIXME: another stupid search.
classID = -1; classID = -1;
@ -497,7 +516,8 @@ bool memory_info::resolveClassnameToClassID (const string classname, int32_t & c
return false; 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()) 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 // return pointer to our internal classID -> className mapping
const vector<string> * memory_info::getClassIDMapping() const vector<string> * VersionInfo::getClassIDMapping()
{ {
return &d->classnames; return &d->classnames;
} }
// change base of all addresses // 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; map<string, uint32_t>::iterator iter;
int32_t rebase = - (int32_t)d->base + new_base; 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 // 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; map<string, uint32_t>::iterator iter;
int32_t rebase = - (int32_t)d->base + new_base; 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 // change all vtable entries by offset
void memory_info::RebaseVTable(int32_t offset) void VersionInfo::RebaseVTable(int32_t offset)
{ {
vector<t_class *>::iterator iter; vector<t_class *>::iterator iter;
for(iter = d->classes.begin(); iter != d->classes.end(); 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 // 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); 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 // 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); map <string, int32_t>::iterator iter = d->offsets.find(key);
if(iter != d->offsets.end()) if(iter != d->offsets.end())
@ -574,8 +595,9 @@ int32_t memory_info::getOffset (const char *key)
throw Error::MissingMemoryDefinition("offset", key); throw Error::MissingMemoryDefinition("offset", key);
} }
// Get named numerical value // 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); map <string, uint32_t>::iterator iter = d->hexvals.find(key);
if(iter != d->hexvals.end()) if(iter != d->hexvals.end())
@ -587,7 +609,7 @@ uint32_t memory_info::getHexValue (const char *key)
// Get named address // 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); 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 // 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); map <string, int32_t>::iterator iter = d->offsets.find(key);
if(iter != d->offsets.end()) if(iter != d->offsets.end())
@ -610,8 +632,9 @@ int32_t memory_info::getOffset (const string &key)
throw Error::MissingMemoryDefinition("offset", key.c_str()); throw Error::MissingMemoryDefinition("offset", key.c_str());
} }
// Get named numerical value // 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); map <string, uint32_t>::iterator iter = d->hexvals.find(key);
if(iter != d->hexvals.end()) if(iter != d->hexvals.end())
@ -621,8 +644,9 @@ uint32_t memory_info::getHexValue (const string &key)
throw Error::MissingMemoryDefinition("hexvalue", key.c_str()); throw Error::MissingMemoryDefinition("hexvalue", key.c_str());
} }
// Get named string // 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); map <string, string>::iterator iter = d->strings.find(key);
if(iter != d->strings.end()) if(iter != d->strings.end())
@ -632,8 +656,9 @@ std::string memory_info::getString (const string &key)
throw Error::MissingMemoryDefinition("string", key.c_str()); throw Error::MissingMemoryDefinition("string", key.c_str());
} }
// Get Profession // Get Profession
string memory_info::getProfession (const uint32_t key) const string VersionInfo::getProfession (const uint32_t key) const
{ {
if(d->professions.size() > key) if(d->professions.size() > key)
{ {
@ -642,8 +667,9 @@ string memory_info::getProfession (const uint32_t key) const
throw Error::MissingMemoryDefinition("profession", key); throw Error::MissingMemoryDefinition("profession", key);
} }
// Get Job // Get Job
string memory_info::getJob (const uint32_t key) const string VersionInfo::getJob (const uint32_t key) const
{ {
if(d->jobs.size() > key) if(d->jobs.size() > key)
@ -653,7 +679,8 @@ string memory_info::getJob (const uint32_t key) const
throw Error::MissingMemoryDefinition("job", key); 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) if(d->skills.size() > key)
{ {
@ -662,15 +689,17 @@ string memory_info::getSkill (const uint32_t key) const
throw Error::MissingMemoryDefinition("skill", key); 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) if(d->levels.size() > level)
{ {
return d->levels[level]; return d->levels[level];
} }
throw Error::MissingMemoryDefinition("Level", level); throw Error::MissingMemoryDefinition("Level", level);
} }
// FIXME: ugly hack that needs to die // FIXME: ugly hack that needs to die
int absolute (int number) int absolute (int number)
{ {
@ -679,7 +708,8 @@ int absolute (int number)
return 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) 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); 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) if(d->traits.size() > traitIdx)
{ {
@ -713,12 +744,14 @@ string memory_info::getTraitName(const uint32_t traitIdx) const
throw Error::MissingMemoryDefinition("traitname", traitIdx); 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; return d->traits;
} }
string memory_info::getLabor (const uint32_t laborIdx)
string VersionInfo::getLabor (const uint32_t laborIdx)
{ {
if(d->labors.count(laborIdx)) if(d->labors.count(laborIdx))
{ {
@ -727,16 +760,18 @@ string memory_info::getLabor (const uint32_t laborIdx)
throw Error::MissingMemoryDefinition("labor", 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) if(d->moods.size() > moodID)
{ {
return d->moods[moodID]; return d->moods[moodID];
} }
throw Error::MissingMemoryDefinition("Mood", moodID); throw Error::MissingMemoryDefinition("Mood", moodID);
} }
std::string memory_info::PrintOffsets()
std::string VersionInfo::PrintOffsets()
{ {
ostringstream ss; ostringstream ss;
ss << "<Version name=\"" << getVersion() << "\">" << endl; ss << "<Version name=\"" << getVersion() << "\">" << endl;

@ -23,14 +23,14 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "DFMemInfoManager.h" #include "VersionInfoFactory.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h" #include "dfhack/DFError.h"
using namespace DFHack; using namespace DFHack;
MemInfoManager::~MemInfoManager() VersionInfoFactory::~VersionInfoFactory()
{ {
// for each in std::vector<memory_info*> meminfo;, delete // for each in std::vector<memory_info*> meminfo;, delete
for(uint32_t i = 0; i < meminfo.size();i++) for(uint32_t i = 0; i < meminfo.size();i++)
@ -40,7 +40,7 @@ MemInfoManager::~MemInfoManager()
meminfo.clear(); meminfo.clear();
} }
void MemInfoManager::ParseVTable(TiXmlElement* vtable, memory_info* mem) void VersionInfoFactory::ParseVTable(TiXmlElement* vtable, VersionInfo* mem)
{ {
TiXmlElement* pClassEntry; TiXmlElement* pClassEntry;
TiXmlElement* pClassSubEntry; TiXmlElement* pClassSubEntry;
@ -92,9 +92,7 @@ void MemInfoManager::ParseVTable(TiXmlElement* vtable, memory_info* mem)
} }
} }
void VersionInfoFactory::ParseEntry (TiXmlElement* entry, VersionInfo* mem, map <string ,TiXmlElement *>& knownEntries)
void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <string ,TiXmlElement *>& knownEntries)
{ {
TiXmlElement* pMemEntry; TiXmlElement* pMemEntry;
const char *cstr_version = entry->Attribute("version"); const char *cstr_version = entry->Attribute("version");
@ -208,14 +206,14 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <str
{ {
mem->setLabor(value,name); mem->setLabor(value,name);
} }
else if (type == "Level") else if (type == "Level")
{
mem->setLevel(value, name, pMemEntry->Attribute("xpNxtLvl"));
}
else if (type == "Mood")
{ {
mem->setLevel(value, name, pMemEntry->Attribute("xpNxtLvl")); mem->setMood(value, name);
} }
else if (type == "Mood")
{
mem->setMood(value, name);
}
else else
{ {
throw Error::MemoryXmlUnknownType(type.c_str()); throw Error::MemoryXmlUnknownType(type.c_str());
@ -223,14 +221,14 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <str
} // for } // for
} // method } // method
MemInfoManager::MemInfoManager(string path_to_xml) VersionInfoFactory::VersionInfoFactory(string path_to_xml)
{ {
error = false; error = false;
loadFile(path_to_xml); loadFile(path_to_xml);
} }
// load the XML file with offsets // 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() ); TiXmlDocument doc( path_to_xml.c_str() );
//bool loadOkay = doc.LoadFile(); //bool loadOkay = doc.LoadFile();
@ -242,7 +240,7 @@ bool MemInfoManager::loadFile(string path_to_xml)
TiXmlHandle hDoc(&doc); TiXmlHandle hDoc(&doc);
TiXmlElement* pElem; TiXmlElement* pElem;
TiXmlHandle hRoot(0); TiXmlHandle hRoot(0);
memory_info mem; VersionInfo mem;
// block: name // block: name
{ {
@ -285,7 +283,7 @@ bool MemInfoManager::loadFile(string path_to_xml)
} }
for(uint32_t i = 0; i< v_pEntries.size();i++) 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 //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); /* recursive */ParseEntry( v_pEntries[i] , mem , map_pNamedEntries);
meminfo.push_back(mem); meminfo.push_back(mem);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -25,7 +25,7 @@ distribution.
#include "Internal.h" #include "Internal.h"
#include "ContextShared.h" #include "ContextShared.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/VersionInfo.h"
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/DFVector.h" #include "dfhack/DFVector.h"
#include "dfhack/DFTypes.h" #include "dfhack/DFTypes.h"
@ -53,7 +53,7 @@ Vegetation::Vegetation(DFContextShared * d_)
d->owner = d_->p; d->owner = d_->p;
d->d = d_; d->d = d_;
d->Inited = d->Started = false; 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->vegetation_vector = mem->getAddress ("vegetation_vector");
d->tree_desc_offset = mem->getOffset ("tree_desc_offset"); d->tree_desc_offset = mem->getOffset ("tree_desc_offset");
d->Inited = true; 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 "ContextShared.h"
#include "dfhack/modules/World.h" #include "dfhack/modules/World.h"
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/DFMemInfo.h" #include "dfhack/VersionInfo.h"
#include "dfhack/DFTypes.h" #include "dfhack/DFTypes.h"
using namespace DFHack; using namespace DFHack;
@ -60,7 +60,7 @@ World::World(DFContextShared * _d)
d->d = _d; d->d = _d;
d->owner = _d->p; 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->year_offset = mem->getAddress( "current_year" );
d->tick_offset = mem->getAddress( "current_tick" ); d->tick_offset = mem->getAddress( "current_tick" );
d->Inited = d->Started = true; d->Inited = d->Started = true;

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

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

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

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

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

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

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

@ -56,7 +56,7 @@ int main (void)
{ {
cout << "Testing ProcessEnumerator" << endl; cout << "Testing ProcessEnumerator" << endl;
ProcessEnumerator Penum("Memory.xml"); ProcessEnumerator Penum("Memory.xml");
memory_info * mem; VersionInfo * mem;
do do
{ {
// make the ProcessEnumerator update its list of Processes // make the ProcessEnumerator update its list of Processes
@ -90,7 +90,7 @@ int main (void)
{ {
cout << "Testing ContextManager" << endl; cout << "Testing ContextManager" << endl;
ContextManager Cman("Memory.xml"); ContextManager Cman("Memory.xml");
memory_info * mem; VersionInfo * mem;
do do
{ {
// make the ContextManager update its list of Contexts // 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::Process* p = DF->getProcess();
DFHack::memory_info* mem = DF->getMemoryInfo(); DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Position * pos = DF->getPosition(); DFHack::Position * pos = DF->getPosition();
DFHack::Vegetation * v = DF->getVegetation(); DFHack::Vegetation * v = DF->getVegetation();
DFHack::Materials * mat = DF->getMaterials(); DFHack::Materials * mat = DF->getMaterials();

@ -21,7 +21,7 @@ using namespace DFHack;
int main ( int argc, char** argv ) int main ( int argc, char** argv )
{ {
DFHack::memory_info *mem; DFHack::VersionInfo *mem;
DFHack::Process *proc; DFHack::Process *proc;
uint32_t creature_pregnancy_offset; 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 // empty input, assume default. observe the length of the memory range vector
// these are hardcoded values, intended for my convenience only // 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()); start = min(11, (int)ranges.size());
end = min(14, (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()); start = min(2, (int)ranges.size());
end = min(4, (int)ranges.size()); end = min(4, (int)ranges.size());
@ -793,8 +793,8 @@ int main (void)
vector <DFHack::t_memrange> selected_ranges; vector <DFHack::t_memrange> selected_ranges;
getRanges(p,selected_ranges); getRanges(p,selected_ranges);
DFHack::memory_info *minfo = DF->getMemoryInfo(); DFHack::VersionInfo *minfo = DF->getMemoryInfo();
DFHack::memory_info::OSType os = minfo->getOS(); DFHack::VersionInfo::OSType os = minfo->getOS();
string prompt = string prompt =
"Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n" "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> #include <DFHack.h>
DFHack::Materials * Materials; DFHack::Materials * Materials;
DFHack::memory_info *mem; DFHack::VersionInfo *mem;
vector< vector<string> > englishWords; vector< vector<string> > englishWords;
vector< vector<string> > foreignWords; vector< vector<string> > foreignWords;

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

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

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