Remove DfVector, break MSVC builds until further notice.

develop
Petr Mrázek 2012-01-04 01:45:11 +01:00
parent 5b528694b7
commit 86464b99cc
34 changed files with 281 additions and 393 deletions

@ -39,7 +39,6 @@ include/SDL_keyboard.h
include/SDL_keysym.h
include/TileTypes.h
include/Types.h
include/Vector.h
include/VersionInfo.h
include/VersionInfoFactory.h
include/Virtual.h

@ -154,9 +154,9 @@ void virtual_identity::Init(Core *core)
// Read pre-filled vtable ptrs
OffsetGroup *ptr_table = core->vinfo->getGroup("vtable");
for (virtual_identity *p = list; p; p = p->next) {
uint32_t tmp;
void * tmp;
if (ptr_table->getSafeAddress(p->getName(),tmp))
p->vtable_ptr = (void*)tmp;
p->vtable_ptr = tmp;
}
}
@ -169,7 +169,7 @@ DF_KNOWN_GLOBALS
void DFHack::InitDataDefGlobals(Core *core) {
OffsetGroup *global_table = core->vinfo->getGroup("global");
uint32_t tmp;
void * tmp;
#define SIMPLE_GLOBAL(name,tname) \
if (global_table->getSafeAddress(#name,tmp)) df::global::name = (tname*)tmp;

@ -111,8 +111,8 @@ Process::~Process()
string Process::doReadClassName (void * vptr)
{
//FIXME: BAD!!!!!
int typeinfo = Process::readDWord((uint32_t)vptr - 0x4);
int typestring = Process::readDWord(typeinfo + 0x4);
void * typeinfo = Process::readPtr(vptr - 0x4);
void * typestring = Process::readPtr(typeinfo + 0x4);
string raw = readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
@ -138,8 +138,8 @@ void Process::getMemRanges( vector<t_memrange> & ranges )
(char*)&permissions,
&offset, &device1, &device2, &node,
(char*)&temp.name);
temp.start = start;
temp.end = end;
temp.start = (void *) start;
temp.end = (void *) end;
temp.read = permissions[0] == 'r';
temp.write = permissions[1] == 'w';
temp.execute = permissions[2] == 'x';
@ -214,7 +214,7 @@ bool Process::setPermisions(const t_memrange & range,const t_memrange &trgrange)
if(trgrange.read)protect|=PROT_READ;
if(trgrange.write)protect|=PROT_WRITE;
if(trgrange.execute)protect|=PROT_EXEC;
result=mprotect((void *)range.start, range.end-range.start,protect);
result=mprotect((void *)range.start, (size_t)range.end-(size_t)range.start,protect);
return result==0;
}

@ -158,6 +158,8 @@ namespace DFHack
{
typedef pair <INVAL_TYPE, uint32_t> nullableUint32;
typedef map <string, nullableUint32 >::iterator uint32_Iter;
typedef pair <INVAL_TYPE, void *> nullableVoidPtr;
typedef map <string, nullableVoidPtr >::iterator voidptr_Iter;
typedef pair <INVAL_TYPE, int32_t> nullableInt32;
typedef map <string, nullableInt32 >::iterator int32_Iter;
typedef pair <INVAL_TYPE, string> nullableString;
@ -166,7 +168,7 @@ namespace DFHack
class OffsetGroupPrivate
{
public:
map <string, nullableUint32 > addresses;
map <string, nullableVoidPtr > addresses;
map <string, nullableUint32 > hexvals;
map <string, nullableInt32 > offsets;
map <string, nullableString > strings;
@ -183,7 +185,7 @@ void OffsetGroup::createOffset(const string & key)
void OffsetGroup::createAddress(const string & key)
{
OGd->addresses[key] = nullableUint32(NOT_SET, 0);
OGd->addresses[key] = nullableVoidPtr(NOT_SET, 0);
}
void OffsetGroup::createHexValue(const string & key)
@ -227,10 +229,10 @@ void OffsetGroup::setOffsetValidity (const string & key, const INVAL_TYPE inval)
void OffsetGroup::setAddress (const string & key, const string & value, const INVAL_TYPE inval)
{
uint32_Iter it = OGd->addresses.find(key);
voidptr_Iter it = OGd->addresses.find(key);
if(it != OGd->addresses.end())
{
uint32_t address = strtol(value.c_str(), NULL, 16);
void * address = (void *) strtol(value.c_str(), NULL, 16);
if((*it).second.second == address)
std::cout << "Pointless address setting: " << this->getFullName() + key << endl;
(*it).second.second = address;
@ -244,7 +246,7 @@ void OffsetGroup::setAddressValidity (const string & key, const INVAL_TYPE inval
{
if(inval != NOT_SET)
{
uint32_Iter it = OGd->addresses.find(key);
voidptr_Iter it = OGd->addresses.find(key);
if(it != OGd->addresses.end())
{
(*it).second.first = inval;
@ -305,9 +307,9 @@ void OffsetGroup::setStringValidity (const string & key, const INVAL_TYPE inval)
}
// Get named address
uint32_t OffsetGroup::getAddress (const string & key)
void * OffsetGroup::getAddress (const string & key)
{
uint32_Iter iter = OGd->addresses.find(key);
voidptr_Iter iter = OGd->addresses.find(key);
if(iter != OGd->addresses.end())
{
@ -321,9 +323,9 @@ uint32_t OffsetGroup::getAddress (const string & key)
}
// Get named offset, return bool instead of throwing exceptions
bool OffsetGroup::getSafeAddress (const string & key, uint32_t & out)
bool OffsetGroup::getSafeAddress (const string & key, void * & out)
{
uint32_Iter iter = OGd->addresses.find(key);
voidptr_Iter iter = OGd->addresses.find(key);
if(iter != OGd->addresses.end() && (*iter).second.first == IS_VALID)
{
out = (*iter).second.second;
@ -410,7 +412,7 @@ OffsetGroup * OffsetGroup::createGroup(const std::string &name)
void OffsetGroup::RebaseAddresses(int32_t offset)
{
for(uint32_Iter iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
for(voidptr_Iter iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
{
if(iter->second.first)
OGd->addresses[iter->first].second = iter->second.second + offset;
@ -470,18 +472,19 @@ std::string OffsetGroup::getFullName()
std::string OffsetGroup::PrintOffsets(int indentation)
{
voidptr_Iter addriter;
uint32_Iter iter;
ostringstream ss;
indentr i(indentation);
typedef pair <uint32_t, pair< string, nullableUint32 > > horrible;
typedef pair <void *, pair< string, nullableVoidPtr > > horrible;
vector < horrible > addrsorter;
for(iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
for(addriter = OGd->addresses.begin(); addriter != OGd->addresses.end(); addriter++)
{
if(!(*iter).second.first)
addrsorter.push_back( make_pair( 0, *iter ) );
if(!(*addriter).second.first)
addrsorter.push_back( make_pair( (void *)0, *addriter ) );
else
{
addrsorter.push_back( make_pair( (*iter).second.second, *iter ) );
addrsorter.push_back( make_pair( (*addriter).second.second, *addriter ) );
}
}
std::sort(addrsorter.begin(), addrsorter.end(), compare_pair_first<>());
@ -569,7 +572,7 @@ void OffsetGroup::setInvalid(INVAL_TYPE invalidity)
if(invalidity == NOT_SET)
return;
uint32_Iter iter;
voidptr_Iter iter;
for(iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
{
if((*iter).second.first)
@ -581,17 +584,18 @@ void OffsetGroup::setInvalid(INVAL_TYPE invalidity)
if((*iter2).second.first)
(*iter2).second.first = invalidity;
}
for(iter = OGd->hexvals.begin(); iter != OGd->hexvals.end(); iter++)
{
if((*iter).second.first)
(*iter).second.first = invalidity;
}
strings_Iter iter3;
for(iter3 = OGd->strings.begin(); iter3 != OGd->strings.end(); iter3++)
uint32_Iter iter3;
for(iter3 = OGd->hexvals.begin(); iter3 != OGd->hexvals.end(); iter3++)
{
if((*iter3).second.first)
(*iter3).second.first = invalidity;
}
strings_Iter iter5;
for(iter5 = OGd->strings.begin(); iter5 != OGd->strings.end(); iter5++)
{
if((*iter5).second.first)
(*iter5).second.first = invalidity;
}
groups_Iter iter4;
for(iter4 = OGd->groups.begin(); iter4 != OGd->groups.end(); iter4++)
{
@ -603,7 +607,7 @@ std::vector<OffsetKey> OffsetGroup::getKeys() const
std::vector<OffsetKey> ret;
OffsetKey K;
K.keytype=IS_ADDRESS;
for(uint32_Iter iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
for(voidptr_Iter iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
@ -1015,7 +1019,7 @@ void VersionInfo::setClassChild (t_class * parent, const char * name, const char
// FIXME: This in now DEPRECATED!
bool VersionInfo::resolveObjectToClassID(const uint32_t address, int32_t & classid)
bool VersionInfo::resolveObjectToClassID(const void * address, int32_t & classid)
{
uint32_t vtable = d->p->readDWord(address);
// try to find the vtable in our cache

@ -72,8 +72,8 @@ namespace DFHack
*/
struct DFHACK_EXPORT t_memrange
{
uint64_t start;
uint64_t end;
void * start;
void * end;
// memory range name (if any)
char name[1024];
// permission to read
@ -84,7 +84,7 @@ namespace DFHack
bool execute : 1;
// is a shared region
bool shared : 1;
inline bool isInRange( uint64_t address)
inline bool isInRange( void * address)
{
if (address >= start && address < end) return true;
return false;
@ -104,99 +104,110 @@ namespace DFHack
Process(VersionInfoFactory * known_versions);
~Process();
/// read a 8-byte integer
uint64_t readQuad(const uint32_t address)
uint64_t readQuad(const void * address)
{
return *(uint64_t *)address;
}
/// read a 8-byte integer
void readQuad(const uint32_t address, uint64_t & value)
void readQuad(const void * address, uint64_t & value)
{
value = *(uint64_t *)address;
};
/// write a 8-byte integer
void writeQuad(const uint32_t address, const uint64_t value)
void writeQuad(const void * address, const uint64_t value)
{
(*(uint64_t *)address) = value;
};
/// read a 4-byte integer
uint32_t readDWord(const uint32_t address)
uint32_t readDWord(const void * address)
{
return *(uint32_t *)address;
}
/// read a 4-byte integer
void readDWord(const uint32_t address, uint32_t & value)
void readDWord(const void * address, uint32_t & value)
{
value = *(uint32_t *)address;
};
/// write a 4-byte integer
void writeDWord(const uint32_t address, const uint32_t value)
void writeDWord(const void * address, const uint32_t value)
{
(*(uint32_t *)address) = value;
};
/// read a pointer
void * readPtr(const void * address)
{
return *(void **)address;
}
/// read a pointer
void readPtr(const void * address, void * & value)
{
value = *(void **)address;
};
/// read a float
float readFloat(const uint32_t address)
float readFloat(const void * address)
{
return *(float*)address;
}
/// write a float
void readFloat(const uint32_t address, float & value)
void readFloat(const void * address, float & value)
{
value = *(float*)address;
};
/// read a 2-byte integer
uint16_t readWord(const uint32_t address)
uint16_t readWord(const void * address)
{
return *(uint16_t *)address;
}
/// read a 2-byte integer
void readWord(const uint32_t address, uint16_t & value)
void readWord(const void * address, uint16_t & value)
{
value = *(uint16_t *)address;
};
/// write a 2-byte integer
void writeWord(const uint32_t address, const uint16_t value)
void writeWord(const void * address, const uint16_t value)
{
(*(uint16_t *)address) = value;
};
/// read a byte
uint8_t readByte(const uint32_t address)
uint8_t readByte(const void * address)
{
return *(uint8_t *)address;
}
/// read a byte
void readByte(const uint32_t address, uint8_t & value)
void readByte(const void * address, uint8_t & value)
{
value = *(uint8_t *)address;
};
/// write a byte
void writeByte(const uint32_t address, const uint8_t value)
void writeByte(const void * address, const uint8_t value)
{
(*(uint8_t *)address) = value;
};
/// read an arbitrary amount of bytes
void read( uint32_t address, uint32_t length, uint8_t* buffer)
void read(void * address, uint32_t length, uint8_t* buffer)
{
memcpy(buffer, (void *) address, length);
};
/// write an arbitrary amount of bytes
void write(uint32_t address, uint32_t length, uint8_t* buffer)
void write(void * address, uint32_t length, uint8_t* buffer)
{
memcpy((void *) address, buffer, length);
};
/// read an STL string
const std::string readSTLString (uint32_t offset)
const std::string readSTLString (void * offset)
{
std::string * str = (std::string *) offset;
return *str;
};
/// read an STL string
size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity)
size_t readSTLString (void * offset, char * buffer, size_t bufcapacity)
{
if(!bufcapacity || bufcapacity == 1)
return 0;
@ -209,7 +220,7 @@ namespace DFHack
* write an STL string
* @return length written
*/
size_t writeSTLString(const uint32_t address, const std::string writeString)
size_t writeSTLString(const void * address, const std::string writeString)
{
std::string * str = (std::string *) address;
str->assign(writeString);
@ -219,7 +230,7 @@ namespace DFHack
* attempt to copy a string from source address to target address. may truncate or leak, depending on platform
* @return length copied
*/
size_t copySTLString(const uint32_t address, const uint32_t target)
size_t copySTLString(const void * address, const uint32_t target)
{
std::string * strsrc = (std::string *) address;
std::string * str = (std::string *) target;
@ -239,7 +250,7 @@ namespace DFHack
}
/// read a null-terminated C string
const std::string readCString (uint32_t offset)
const std::string readCString (void * offset)
{
return std::string((char *) offset);
};

@ -1,96 +0,0 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#pragma once
#ifndef DFVECTOR_H_INCLUDED
#define DFVECTOR_H_INCLUDED
#include "Pragma.h"
#include "Export.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include <string.h>
#include <vector>
namespace DFHack
{
template <class T>
class DFHACK_EXPORT DfVector
{
private:
std::vector<T> * real_vec;
public:
DfVector(uint32_t address)
{
real_vec = (std::vector<T> *) address;
};
~DfVector()
{
};
// get offset of the specified index
inline const T& operator[] (uint32_t index)
{
// FIXME: vector out of bounds exception
//assert(index < size);
return real_vec->at(index);
};
// get offset of the specified index
inline const T& at (uint32_t index)
{
//assert(index < size);
return real_vec->at(index);
};
// update value at index
bool set(uint32_t index, T value)
{
if (index >= real_vec->size())
return false;
real_vec->at(index) = value;
return true;
}
// remove value
bool remove(uint32_t index)
{
if (index >= real_vec->size())
return false;
// Remove the item
real_vec->erase(real_vec->begin() + index);
return true;
}
// get vector size
inline uint32_t size ()
{
return real_vec->size();
};
// get vector start
inline const T * start ()
{
return real_vec->data();
};
};
}
#endif // DFVECTOR_H_INCLUDED

@ -88,13 +88,13 @@ namespace DFHack
OffsetGroup * createGroup ( const std::string & name );
int32_t getOffset (const std::string & key);
uint32_t getAddress (const std::string & key);
void * getAddress (const std::string & key);
uint32_t getHexValue (const std::string & key);
std::string getString (const std::string & key);
OffsetGroup * getGroup ( const std::string & name );
bool getSafeOffset (const std::string & key, int32_t & out);
bool getSafeAddress (const std::string & key, uint32_t & out);
bool getSafeAddress (const std::string & key, void * & out);
void setOffset (const std::string& key, const std::string& value, const DFHack::INVAL_TYPE inval = IS_VALID);
void setOffsetValidity(const std::string& key, const DFHack::INVAL_TYPE inval = IS_VALID);
@ -189,7 +189,7 @@ namespace DFHack
* uses memory reading directly, needs suspend. input = address of the object
* fails if it's unable to read from memory
*/
bool resolveObjectToClassID (const uint32_t address, int32_t & classID);
bool resolveObjectToClassID (const void * address, int32_t & classID);
/**
* Get a ClassID when you know the classname. can fail if the class is not in the cache

@ -42,7 +42,7 @@ namespace DFHack
*/
struct t_building
{
uint32_t origin;
void * origin;
uint32_t vtable;
uint32_t x1;
uint32_t y1;

@ -74,7 +74,7 @@ namespace DFHack
uint32_t unk6;
/// Address of the read object in DF memory. Added by DFHack.
uint32_t origin;
t_construction * origin;
};
#pragma pack (pop)
class DFContextShared;

@ -97,7 +97,7 @@ namespace DFHack
struct dfh_engraving
{
t_engraving s;
uint32_t origin;
t_engraving * origin;
};
/**
* The Engravings module - allows reading engravings :D

@ -149,7 +149,7 @@ namespace DFHack
/// placeholder
bool discovered;
/// this is NOT part of the DF feature, but an address of the feature as seen by DFhack.
uint32_t origin;
void * origin;
};

@ -18,7 +18,7 @@ namespace DFHack
*/
struct t_spawnPoint
{
uint32_t origin;
void * origin;
int16_t race;
uint16_t type;
uint16_t x;

@ -32,7 +32,6 @@ using namespace std;
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "Types.h"
#include "Error.h"
#include "modules/Buildings.h"
@ -58,13 +57,12 @@ struct t_building_df40d
struct Buildings::Private
{
uint32_t buildings_vector;
uint32_t custom_workshop_vector;
vector <void *> * custom_workshop_vector;
uint32_t building_custom_workshop_type;
uint32_t custom_workshop_type;
uint32_t custom_workshop_name;
int32_t custom_workshop_id;
DfVector <uint32_t> * p_bld;
vector <t_building_df40d *> * p_bld;
Process * owner;
bool Inited;
bool hasCustomWorkshops;
@ -88,7 +86,7 @@ Buildings::Buildings()
d->Inited = true;
try
{
d->buildings_vector = OG_build->getAddress ("buildings_vector");
d->p_bld = (decltype(d->p_bld)) OG_build->getAddress ("buildings_vector");
}
catch(DFHack::Error::AllMemdef &e)
{
@ -99,7 +97,7 @@ Buildings::Buildings()
{
try
{
d->custom_workshop_vector = OG_build->getAddress("custom_workshop_vector");
d->custom_workshop_vector =(decltype(d->custom_workshop_vector)) OG_build->getAddress ("custom_workshop_vector");
d->building_custom_workshop_type = OG_build->getOffset("building_custom_workshop_type");
d->custom_workshop_type = OG_build->getOffset("custom_workshop_type");
d->custom_workshop_name = OG_build->getOffset("custom_workshop_name");
@ -124,7 +122,6 @@ bool Buildings::Start(uint32_t & numbuildings)
{
if(!d->Inited)
return false;
d->p_bld = new DfVector <uint32_t> (d->buildings_vector);
numbuildings = d->p_bld->size();
d->Started = true;
return true;
@ -134,37 +131,25 @@ bool Buildings::Read (const uint32_t index, t_building & building)
{
if(!d->Started)
return false;
t_building_df40d bld_40d;
// read pointer from vector at position
uint32_t temp = d->p_bld->at (index);
//d->p_bld->read(index,(uint8_t *)&temp);
//read building from memory
d->owner->read (temp, sizeof (t_building_df40d), (uint8_t *) &bld_40d);
t_building_df40d *bld_40d = d->p_bld->at (index);
// transform
int32_t type = -1;
d->owner->getDescriptor()->resolveObjectToClassID (temp, type);
building.origin = temp;
building.vtable = bld_40d.vtable;
building.x1 = bld_40d.x1;
building.x2 = bld_40d.x2;
building.y1 = bld_40d.y1;
building.y2 = bld_40d.y2;
building.z = bld_40d.z;
building.material = bld_40d.material;
d->owner->getDescriptor()->resolveObjectToClassID (bld_40d, type);
building.origin = bld_40d;
building.vtable = bld_40d->vtable;
building.x1 = bld_40d->x1;
building.x2 = bld_40d->x2;
building.y1 = bld_40d->y1;
building.y2 = bld_40d->y2;
building.z = bld_40d->z;
building.material = bld_40d->material;
building.type = type;
return true;
}
bool Buildings::Finish()
{
if(d->p_bld)
{
delete d->p_bld;
d->p_bld = NULL;
}
d->Started = false;
return true;
}
@ -177,14 +162,14 @@ bool Buildings::ReadCustomWorkshopTypes(map <uint32_t, string> & btypes)
return false;
Process * p = d->owner;
DfVector <uint32_t> p_matgloss (d->custom_workshop_vector);
uint32_t size = p_matgloss.size();
uint32_t size = d->custom_workshop_vector->size();
btypes.clear();
for (uint32_t i = 0; i < size;i++)
{
string out = p->readSTLString (p_matgloss[i] + d->custom_workshop_name);
uint32_t type = p->readDWord (p_matgloss[i] + d->custom_workshop_type);
void * obj = d->custom_workshop_vector->at(i);
string out = p->readSTLString (obj + d->custom_workshop_name);
uint32_t type = p->readDWord (obj + d->custom_workshop_type);
#ifdef DEBUG
cout << out << ": " << type << endl;
#endif

@ -33,7 +33,6 @@ using namespace std;
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "Types.h"
#include "modules/Constructions.h"
#include "ModuleFactory.h"
@ -43,10 +42,7 @@ using namespace DFHack;
struct Constructions::Private
{
uint32_t construction_vector;
// translation
DfVector <uint32_t> * p_cons;
vector <t_construction *> * p_cons;
Process * owner;
bool Inited;
bool Started;
@ -62,10 +58,9 @@ Constructions::Constructions()
Core & c = Core::getInstance();
d = new Private;
d->owner = c.p;
d->p_cons = 0;
d->Inited = d->Started = false;
VersionInfo * mem = c.vinfo;
d->construction_vector = mem->getGroup("Constructions")->getAddress ("vector");
d->p_cons = (decltype(d->p_cons)) mem->getGroup("Constructions")->getAddress ("vector");
d->Inited = true;
}
@ -78,7 +73,6 @@ Constructions::~Constructions()
bool Constructions::Start(uint32_t & numconstructions)
{
d->p_cons = new DfVector <uint32_t> (d->construction_vector);
numconstructions = d->p_cons->size();
d->Started = true;
return true;
@ -89,24 +83,14 @@ bool Constructions::Read (const uint32_t index, t_construction & construction)
{
if(!d->Started) return false;
// read pointer from vector at position
uint32_t temp = d->p_cons->at (index);
//read construction from memory
d->owner->read (temp, sizeof (t_construction), (uint8_t *) &construction);
// transform
construction.origin = temp;
t_construction * orig = d->p_cons->at(index);
construction = *orig;
construction.origin = orig;
return true;
}
bool Constructions::Finish()
{
if(d->p_cons)
{
delete d->p_cons;
d->p_cons = NULL;
}
d->Started = false;
return true;
}

@ -31,8 +31,7 @@ distribution.
using namespace std;
#include "VersionInfo.h"
//#include "MemAccess.h"
#include "Vector.h"
#include "MemAccess.h"
#include "Types.h"
#include "modules/Engravings.h"
#include "ModuleFactory.h"
@ -43,8 +42,7 @@ using namespace DFHack;
struct Engravings::Private
{
uint32_t engraving_vector;
// translation
DfVector <uint32_t> * p_engr;
vector <t_engraving *> * p_engr;
Process * owner;
bool Inited;
@ -61,9 +59,8 @@ Engravings::Engravings()
Core & c = Core::getInstance();
d = new Private;
d->owner = c.p;
d->p_engr = 0;
d->Inited = d->Started = false;
d->engraving_vector = c.vinfo->getGroup("Engravings")->getAddress ("vector");
d->p_engr = (decltype(d->p_engr)) c.vinfo->getGroup("Engravings")->getAddress ("vector");
d->Inited = true;
}
@ -76,7 +73,8 @@ Engravings::~Engravings()
bool Engravings::Start(uint32_t & numengravings)
{
d->p_engr = new DfVector <uint32_t> (d->engraving_vector);
if(!d->Inited)
return false;
numengravings = d->p_engr->size();
d->Started = true;
return true;
@ -88,13 +86,10 @@ bool Engravings::Read (const uint32_t index, dfh_engraving & engraving)
if(!d->Started) return false;
// read pointer from vector at position
uint32_t temp = d->p_engr->at (index);
//read construction from memory
d->owner->read (temp, sizeof (t_engraving), (uint8_t *) &(engraving.s));
engraving.s = *d->p_engr->at (index);
// transform
engraving.origin = temp;
engraving.origin = d->p_engr->at (index);
return true;
}
@ -108,11 +103,6 @@ bool Engravings::Write (const dfh_engraving & engraving)
bool Engravings::Finish()
{
if(d->p_engr)
{
delete d->p_engr;
d->p_engr = NULL;
}
d->Started = false;
return true;
}

@ -37,7 +37,6 @@ using namespace std;
#include "Error.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "ModuleFactory.h"
#include "Core.h"

@ -91,16 +91,23 @@ struct Gui::Private
}
bool Started;
uint32_t window_x_offset;
uint32_t window_y_offset;
uint32_t window_z_offset;
uint32_t cursor_xyz_offset;
uint32_t designation_xyz_offset;
uint32_t mouse_xy_offset;
uint32_t window_dims_offset;
int32_t * window_x_offset;
int32_t * window_y_offset;
int32_t * window_z_offset;
struct xyz
{
int32_t x;
int32_t y;
int32_t z;
} * cursor_xyz_offset, * designation_xyz_offset;
struct xy
{
int32_t x;
int32_t y;
} * mouse_xy_offset, * window_dims_offset;
bool StartedScreen;
uint32_t screen_tiles_ptr_offset;
void * screen_tiles_ptr_offset;
Process * owner;
};
@ -157,19 +164,33 @@ Gui::Gui()
try
{
OG_Position = mem->getGroup("Position");
d->window_x_offset = OG_Position->getAddress ("window_x");
d->window_y_offset = OG_Position->getAddress ("window_y");
d->window_z_offset = OG_Position->getAddress ("window_z");
d->cursor_xyz_offset = OG_Position->getAddress ("cursor_xyz");
d->window_dims_offset = OG_Position->getAddress ("window_dims");
d->window_x_offset = (int32_t *) OG_Position->getAddress ("window_x");
d->window_y_offset = (int32_t *) OG_Position->getAddress ("window_y");
d->window_z_offset = (int32_t *) OG_Position->getAddress ("window_z");
d->cursor_xyz_offset = (Private::xyz *) OG_Position->getAddress ("cursor_xyz");
d->window_dims_offset = (Private::xy *) OG_Position->getAddress ("window_dims");
d->Started = true;
}
catch(Error::All &){};
OG_Position->getSafeAddress("mouse_xy", d->mouse_xy_offset);
OG_Position->getSafeAddress("designation_xyz", d->designation_xyz_offset);
try
{
d->screen_tiles_ptr_offset = OG_Position->getAddress ("screen_tiles_pointer");
d->mouse_xy_offset = (Private::xy *) OG_Position->getAddress ("mouse_xy");
}
catch(Error::All &)
{
d->mouse_xy_offset = 0;
};
try
{
d->designation_xyz_offset = (Private::xyz *) OG_Position->getAddress ("designation_xyz");
}
catch(Error::All &)
{
d->designation_xyz_offset = 0;
};
try
{
d->screen_tiles_ptr_offset = (void *) OG_Position->getAddress ("screen_tiles_pointer");
d->StartedScreen = true;
}
catch(Error::All &){};
@ -299,10 +320,10 @@ bool Gui::getScreenTiles (int32_t width, int32_t height, t_screen screen[])
{
if(!d->StartedScreen) return false;
uint32_t screen_addr = d->owner->readDWord(d->screen_tiles_ptr_offset);
void * screen_addr = (void *) d->owner->readDWord(d->screen_tiles_ptr_offset);
uint8_t* tiles = new uint8_t[width*height*4/* + 80 + width*height*4*/];
d->owner->read (screen_addr, (width*height*4/* + 80 + width*height*4*/), (uint8_t *) tiles);
d->owner->read (screen_addr, (width*height*4/* + 80 + width*height*4*/), tiles);
for(int32_t iy=0; iy<height; iy++)
{

@ -36,7 +36,6 @@ using namespace std;
#include "Types.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "modules/Materials.h"
#include "modules/Items.h"
#include "modules/Units.h"
@ -58,7 +57,7 @@ class Items::Private
std::map<int32_t, df_item *> idLookupTable;
uint32_t refVectorOffset;
uint32_t idFieldOffset;
uint32_t itemVectorAddress;
void * itemVectorAddress;
ClassNameCheck isOwnerRefClass;
ClassNameCheck isContainerRefClass;

@ -37,7 +37,6 @@ using namespace std;
#include "Error.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "ModuleFactory.h"
#include "Core.h"
@ -96,7 +95,7 @@ struct Maps::Private
FEATURES
*/
// FIXME: replace with a struct pointer, eventually. needs to be mapped out first
uint32_t world_data;
void * world_data;
uint32_t local_f_start; // offset from world_data
// FIXME: replace by virtual function call
uint32_t local_material;
@ -122,7 +121,7 @@ struct Maps::Private
set <uint32_t> unknown_veins;
// map between feature address and the read object
map <uint32_t, t_feature> local_feature_store;
map <void *, t_feature> local_feature_store;
map <DFCoord, vector <t_feature *> > m_local_feature;
vector <t_feature> v_global_feature;
@ -142,7 +141,7 @@ Maps::Maps()
// get the offsets once here
OffsetGroup *OG_Maps = mem->getGroup("Maps");
off.world_data = OG_Maps->getAddress("world_data");
off.world_data = (void *) OG_Maps->getAddress("world_data");
{
mdata = (map_data *) OG_Maps->getAddress ("map_data");
off.world_size_x = OG_Maps->getOffset ("world_size_x_from_wdata");
@ -508,13 +507,13 @@ bool Maps::StartFeatures()
Process * p = d->owner;
Private::t_offsets &off = d->offsets;
uint32_t base = 0;
uint32_t global_feature_vector = 0;
void * base = 0;
void * global_feature_vector = 0;
uint32_t world = p->readDWord(off.world_data);
void * world = p->readPtr( (void *) off.world_data);
if(!world) return false;
base = p->readDWord(world + off.local_f_start);
global_feature_vector = p->readDWord(off.world_data) + off.global_vector;
base = p->readPtr(world + off.local_f_start);
global_feature_vector = p->readDWord(off.world_data) + (void *) off.global_vector;
// deref pointer to the humongo-structure
if(!base)
@ -549,22 +548,21 @@ bool Maps::StartFeatures()
// base = pointer to local feature structure (inside world data struct)
// bigregion is 16x16 regions. for each bigregion in X dimension:
uint32_t mega_column = p->readDWord(base + bigregion_x * 4);
void * mega_column = p->readPtr(base + bigregion_x * 4);
// 16B structs, second DWORD of the struct is a pointer
uint32_t loc_f_array16x16 = p->readDWord(mega_column + offset_elem + (sizeof_elem * bigregion_y));
void * loc_f_array16x16 = p->readPtr(mega_column + offset_elem + (sizeof_elem * bigregion_y));
if(loc_f_array16x16)
{
uint32_t feat_vector = loc_f_array16x16 + sizeof_16vec * sub_x + sizeof_vec * sub_y;
DfVector<uint32_t> p_features(feat_vector);
uint32_t size = p_features.size();
vector <void *> * p_features = (vector <void *> *) (loc_f_array16x16 + sizeof_16vec * sub_x + sizeof_vec * sub_y);
uint32_t size = p_features->size();
DFCoord pc(blockX,blockY);
std::vector<t_feature *> tempvec;
for(uint32_t i = 0; i < size; i++)
{
uint32_t cur_ptr = p_features[i];
void * cur_ptr = p_features->at(i);
map <uint32_t, t_feature>::iterator it;
map <void *, t_feature>::iterator it;
it = d->local_feature_store.find(cur_ptr);
// do we already have the feature?
if(it != d->local_feature_store.end())
@ -579,7 +577,7 @@ bool Maps::StartFeatures()
// create, add to store
t_feature tftemp;
tftemp.discovered = false; //= p->readDWord(cur_ptr + 4);
tftemp.origin = cur_ptr;
tftemp.origin = (t_feature *) cur_ptr;
string name = p->readClassName((void *)p->readDWord( cur_ptr ));
if(name == "feature_init_deep_special_tubest")
{
@ -611,17 +609,15 @@ bool Maps::StartFeatures()
const uint32_t global_feature_funcptr = off.global_funcptr;
const uint32_t glob_main_mat_offset = off.global_material;
const uint32_t glob_sub_mat_offset = off.global_submaterial;
DfVector<uint32_t> p_features (global_feature_vector);
vector <void *> * p_features = (vector <void *> *) global_feature_vector;
d->v_global_feature.clear();
uint32_t size = p_features.size();
uint32_t size = p_features->size();
d->v_global_feature.reserve(size);
for(uint32_t i = 0; i < size; i++)
{
t_feature temp;
uint32_t feat_ptr = p->readDWord(p_features[i] + global_feature_funcptr );
void * feat_ptr = p->readPtr(p_features->at(i) + global_feature_funcptr );
temp.origin = feat_ptr;
//temp.discovered = p->readDWord( feat_ptr + 4 ); // maybe, placeholder
temp.discovered = false;
// FIXME: use the memory_info cache mechanisms
@ -896,17 +892,18 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
Process *p = d->owner;
// get needed addresses and offsets. Now this is what I call crazy.
uint16_t worldSizeX, worldSizeY;
uint32_t regions, geoblocks_vector_addr;
void *regions;
void *geoblocks_vector_addr;
Private::t_offsets &off = d->offsets;
// get world size
uint32_t world = p->readDWord(off.world_data);
void * world = p->readPtr(off.world_data);
p->readWord (world + off.world_size_x, worldSizeX);
p->readWord (world + off.world_size_y, worldSizeY);
regions = p->readDWord ( world + off.world_regions); // ptr2_region_array
regions = p->readPtr ( world + off.world_regions); // ptr2_region_array
geoblocks_vector_addr = world + off.world_geoblocks_vector;
// read the geoblock vector
DfVector <uint32_t> geoblocks (geoblocks_vector_addr);
vector <void *> & geoblocks = *(vector <void *> *)(geoblocks_vector_addr);
// iterate over 8 surrounding regions + local region
for (int i = eNorthWest; i < eBiomeCount; i++)
@ -925,8 +922,8 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
/// regions are a 2d array. consists of pointers to arrays of regions
/// regions are of region_size size
// get pointer to column of regions
uint32_t geoX;
p->readDWord (regions + bioRX*4, geoX);
void * geoX;
p->readPtr (regions + bioRX*4, geoX);
// get index into geoblock vector
uint16_t geoindex;
@ -935,11 +932,11 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
/// geology blocks are assigned to regions from a vector
// get the geoblock from the geoblock vector using the geoindex
// read the matgloss pointer from the vector into temp
uint32_t geoblock_off = geoblocks[geoindex];
void * geoblock_off = geoblocks[geoindex];
/// geology blocks have a vector of layer descriptors
// get the vector with pointer to layers
DfVector <uint32_t> geolayers (geoblock_off + off.geolayer_geoblock_offset); // let's hope
vector <void *> & geolayers = *(vector <void *> *)(geoblock_off + off.geolayer_geoblock_offset);
// make sure we don't load crap
assert (geolayers.size() > 0 && geolayers.size() <= 16);
@ -949,7 +946,7 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
for (uint32_t j = 0;j < geolayers.size();j++)
{
// read pointer to a layer
uint32_t geol_offset = geolayers[j];
void * geol_offset = geolayers[j];
// read word at pointer + 2, store in our geology vectors
d->v_geology[i].push_back (p->readWord (geol_offset + off.type_inside_geolayer));
}

@ -35,7 +35,6 @@ using namespace std;
#include "modules/Materials.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "Error.h"
#include "ModuleFactory.h"
#include "Core.h"
@ -52,8 +51,8 @@ class Materials::Private
public:
Process * owner;
OffsetGroup * OG_Materials;
uint32_t vector_races;
uint32_t vector_other;
void * vector_races;
void * vector_other;
};
Materials::Materials()
@ -67,10 +66,10 @@ Materials::Materials()
df_inorganic = 0;
OffsetGroup *OG_Materials = d->OG_Materials = c.vinfo->getGroup("Materials");
{
OG_Materials->getSafeAddress("inorganics",(uint32_t &)df_inorganic);
OG_Materials->getSafeAddress("organics_all",(uint32_t &)df_organic);
OG_Materials->getSafeAddress("organics_plants",(uint32_t &)df_plants);
OG_Materials->getSafeAddress("organics_trees",(uint32_t &)df_trees);
OG_Materials->getSafeAddress("inorganics",(void * &)df_inorganic);
OG_Materials->getSafeAddress("organics_all",(void * &)df_organic);
OG_Materials->getSafeAddress("organics_plants",(void * &)df_plants);
OG_Materials->getSafeAddress("organics_trees",(void * &)df_trees);
d->vector_races = OG_Materials->getAddress("creature_type_vector");
}
}
@ -111,16 +110,16 @@ bool t_matglossInorganic::isGem()
}
// good for now
inline bool ReadNamesOnly(Process* p, uint32_t address, vector<t_matgloss> & names)
inline bool ReadNamesOnly(Process* p, void * address, vector<t_matgloss> & names)
{
DfVector <uint32_t> p_matgloss (address);
uint32_t size = p_matgloss.size();
vector <string *> * p_names = (vector <string *> *) address;
uint32_t size = p_names->size();
names.clear();
names.reserve (size);
for (uint32_t i = 0; i < size;i++)
{
t_matgloss mat;
mat.id = *(std::string *)p_matgloss[i];
mat.id = *p_names->at(i);
names.push_back(mat);
}
return true;
@ -159,21 +158,21 @@ bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorg
bool Materials::CopyOrganicMaterials (std::vector<t_matgloss> & organic)
{
if(df_organic)
return ReadNamesOnly(d->owner, (uint32_t) df_organic, organic );
return ReadNamesOnly(d->owner, (void *) df_organic, organic );
else return false;
}
bool Materials::CopyWoodMaterials (std::vector<t_matgloss> & tree)
{
if(df_trees)
return ReadNamesOnly(d->owner, (uint32_t) df_trees, tree );
return ReadNamesOnly(d->owner, (void *) df_trees, tree );
else return false;
}
bool Materials::CopyPlantMaterials (std::vector<t_matgloss> & plant)
{
if(df_plants)
return ReadNamesOnly(d->owner, (uint32_t) df_plants, plant );
return ReadNamesOnly(d->owner, (void *) df_plants, plant );
else return false;
}
@ -185,7 +184,7 @@ bool Materials::ReadCreatureTypes (void)
bool Materials::ReadOthers(void)
{
Process * p = d->owner;
uint32_t matBase = d->OG_Materials->getAddress ("other");
void * matBase = d->OG_Materials->getAddress ("other");
uint32_t i = 0;
std::string * ptr;
@ -194,7 +193,7 @@ bool Materials::ReadOthers(void)
while(1)
{
t_matglossOther mat;
ptr = (std::string *) p->readDWord(matBase + i*4);
ptr = (std::string *) p->readPtr(matBase + i*4);
if(ptr==0)
break;
mat.id = *ptr;
@ -208,7 +207,7 @@ bool Materials::ReadDescriptorColors (void)
{
Process * p = d->owner;
OffsetGroup * OG_Descriptors = p->getDescriptor()->getGroup("Materials")->getGroup("descriptors");
DfVector <uint32_t> p_colors (OG_Descriptors->getAddress ("colors_vector"));
vector <void *> & p_colors = *(vector<void*> *) OG_Descriptors->getAddress ("colors_vector");
uint32_t size = p_colors.size();
color.clear();
@ -237,7 +236,7 @@ bool Materials::ReadCreatureTypesEx (void)
uint32_t sizeof_string = OG_string->getHexValue ("sizeof");
OffsetGroup * OG_Mats = mem->getGroup("Materials");
DfVector <uint32_t> p_races (OG_Mats->getAddress ("creature_type_vector"));
vector <void *> & p_races = *(vector<void*> *) OG_Mats->getAddress ("creature_type_vector");
OffsetGroup * OG_Creature = OG_Mats->getGroup("creature");
uint32_t castes_vector_offset = OG_Creature->getOffset ("caste_vector");
@ -287,13 +286,13 @@ bool Materials::ReadCreatureTypesEx (void)
mat.tilecolor.back = p->readWord( p_races[i] + tile_color_offset + 2 );
mat.tilecolor.bright = p->readWord( p_races[i] + tile_color_offset + 4 );
DfVector <uint32_t> p_castes(p_races[i] + castes_vector_offset);
vector <void *> & p_castes = *(vector<void*> *) (p_races[i] + castes_vector_offset);
sizecas = p_castes.size();
for (uint32_t j = 0; j < sizecas;j++)
{
/* caste name */
t_creaturecaste caste;
uint32_t caste_start = p_castes[j];
void * caste_start = p_castes[j];
caste.id = p->readSTLString (caste_start);
caste.singular = p->readSTLString (caste_start + sizeof_string);
caste.plural = p->readSTLString (caste_start + 2 * sizeof_string);
@ -303,13 +302,13 @@ bool Materials::ReadCreatureTypesEx (void)
{
/* color mod reading */
// Caste + offset > color mod vector
DfVector <uint32_t> p_colormod(caste_start + caste_colormod_offset);
vector <void *> & p_colormod = *(vector<void*> *) (caste_start + caste_colormod_offset);
sizecolormod = p_colormod.size();
caste.ColorModifier.resize(sizecolormod);
for(uint32_t k = 0; k < sizecolormod;k++)
{
// color mod [0] -> color list
DfVector <uint32_t> p_colorlist(p_colormod[k]);
vector <uint32_t> & p_colorlist = *(vector<uint32_t> *) (p_colormod[k]);
sizecolorlist = p_colorlist.size();
caste.ColorModifier[k].colorlist.resize(sizecolorlist);
for(uint32_t l = 0; l < sizecolorlist; l++)
@ -320,7 +319,7 @@ bool Materials::ReadCreatureTypesEx (void)
caste.ColorModifier[k].enddate = p->readDWord( p_colormod[k] + color_modifier_enddate_offset );
}
/* body parts */
DfVector <uint32_t> p_bodypart(caste_start + caste_bodypart_offset);
vector <void *> & p_bodypart = *(vector<void*> *) (caste_start + caste_bodypart_offset);
caste.bodypart.empty();
sizebp = p_bodypart.size();
for(uint32_t k = 0; k < sizebp; k++)
@ -338,7 +337,7 @@ bool Materials::ReadCreatureTypesEx (void)
}
mat.castes.push_back(caste);
}
DfVector <uint32_t> p_extract(p_races[i] + extract_vector_offset);
vector <void *> & p_extract = *(vector<void*> *) (p_races[i] + extract_vector_offset);
for(uint32_t j = 0; j < p_extract.size(); j++)
{
t_creatureextract extract;

@ -33,7 +33,6 @@ using namespace std;
#include "modules/Translation.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "Types.h"
#include "ModuleFactory.h"
#include "Core.h"
@ -46,8 +45,8 @@ Module* DFHack::createTranslation()
struct Translation::Private
{
uint32_t genericAddress;
uint32_t transAddress;
void * genericAddress;
void * transAddress;
uint32_t word_table_offset;
uint32_t sizeof_string;
@ -97,15 +96,15 @@ bool Translation::Start()
return false;
Process * p = c.p;
Finish();
DfVector <uint32_t> genericVec (d->genericAddress);
DfVector <uint32_t> transVec (d->transAddress);
vector <void *> & genericVec = *(vector <void *> *) d->genericAddress;
vector <void *> & transVec = *(vector <void *> *) d->transAddress;
DFDict & translations = d->dicts.translations;
DFDict & foreign_languages = d->dicts.foreign_languages;
translations.resize(10);
for (uint32_t i = 0;i < genericVec.size();i++)
{
uint32_t genericNamePtr = genericVec.at(i);
void * genericNamePtr = genericVec[i];
for(int j=0; j<10;j++)
{
string word = p->readSTLString (genericNamePtr + j * d->sizeof_string);
@ -116,11 +115,11 @@ bool Translation::Start()
foreign_languages.resize(transVec.size());
for (uint32_t i = 0; i < transVec.size();i++)
{
uint32_t transPtr = transVec.at(i);
DfVector <uint32_t> trans_names_vec (transPtr + d->word_table_offset);
void * transPtr = transVec.at(i);
vector <void *> & trans_names_vec = *(vector <void *> *) (transPtr + d->word_table_offset);
for (uint32_t j = 0;j < trans_names_vec.size();j++)
{
uint32_t transNamePtr = trans_names_vec.at(j);
void * transNamePtr = trans_names_vec[j];
string name = p->readSTLString (transNamePtr);
foreign_languages[i].push_back (name);
}

@ -36,7 +36,6 @@ using namespace std;
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "Error.h"
#include "Types.h"
@ -54,8 +53,8 @@ struct Units::Private
bool Inited;
bool Started;
uint32_t dwarf_race_index_addr;
uint32_t dwarf_civ_id_addr;
void * dwarf_race_index_addr;
void * dwarf_civ_id_addr;
bool IdMapReady;
std::map<int32_t, int32_t> IdMap;
@ -86,8 +85,8 @@ Units::Units()
try
{
creatures = (vector <df_unit *> *) OG_Creatures->getAddress ("vector");
d->dwarf_race_index_addr = OG_Creatures->getAddress("current_race");
d->dwarf_civ_id_addr = OG_Creatures->getAddress("current_civ");
d->dwarf_race_index_addr = (void *) OG_Creatures->getAddress("current_race");
d->dwarf_civ_id_addr = (void *) OG_Creatures->getAddress("current_civ");
}
catch(Error::All&){};
d->Inited = true;

@ -32,7 +32,6 @@ using namespace std;
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "Types.h"
#include "modules/Vegetation.h"
#include "modules/Translation.h"

@ -40,7 +40,7 @@ using namespace DFHack;
struct Vermin::Private
{
uint32_t spawn_points_vector;
void * spawn_points_vector;
uint32_t race_offset;
uint32_t type_offset;
uint32_t position_offset;
@ -140,7 +140,7 @@ bool SpawnPoints::Read (const uint32_t index, t_spawnPoint & sp)
return false;
// read pointer from vector at position
uint32_t temp = (uint32_t) p_sp->at (index);
void * temp = p_sp->at (index);
sp.origin = temp;
sp.race = v->d->owner->readWord(temp + v->d->race_offset);
@ -161,7 +161,7 @@ bool SpawnPoints::Write (const uint32_t index, t_spawnPoint & sp)
return false;
// read pointer from vector at position
uint32_t temp = (uint32_t) p_sp->at (index);
void * temp = p_sp->at (index);
v->d->owner->writeWord(temp + v->d->race_offset, sp.race);
v->d->owner->writeWord(temp + v->d->type_offset, sp.type);

@ -54,22 +54,22 @@ struct World::Private
bool Inited;
bool PauseInited;
uint32_t pause_state_offset;
void * pause_state_offset;
bool StartedTime;
uint32_t year_offset;
uint32_t tick_offset;
void * year_offset;
void * tick_offset;
bool StartedWeather;
uint32_t weather_offset;
void * weather_offset;
bool StartedMode;
uint32_t gamemode_offset;
uint32_t controlmode_offset;
uint32_t controlmodecopy_offset;
void * gamemode_offset;
void * controlmode_offset;
void * controlmodecopy_offset;
bool StartedFolder;
uint32_t folder_name_offset;
void * folder_name_offset;
Process * owner;
};

@ -12,7 +12,6 @@ using namespace std;
#include "Types.h"
#include "VersionInfo.h"
#include "MemAccess.h"
#include "Vector.h"
#include "modules/Materials.h"
#include "modules/Items.h"
#include "modules/Units.h"
@ -44,9 +43,9 @@ namespace Kitchen
std::vector<t_materialIndex>& materialIndices; // the material index vector of the kitchen exclusion list
std::vector<t_exclusionType>& exclusionTypes; // the exclusion type vector of the kitchen excluions list
static uint32_t addr(const DFHack::Core& core, int index)
static void * addr(const DFHack::Core& core, int index)
{
static uint32_t start = core.vinfo->getAddress("kitchen_limits");
static void * start = core.vinfo->getAddress("kitchen_limits");
return start + sizeof(std::vector<int>) * index;
};
};

@ -15,20 +15,20 @@ public:
ANYBYTE=0x101,DWORD_,ANYDWORD,ADDRESS
};
Hexsearch(const SearchArgType &args,uint64_t startpos,uint64_t endpos);
Hexsearch(const SearchArgType &args,void * startpos,void * endpos);
~Hexsearch();
void Reset(){pos_=startpos_;};
void SetStart(uint64_t pos){pos_=pos;};
void SetStart(void * pos){pos_=pos;};
uint64_t FindNext();
std::vector<uint64_t> FindAll();
void * FindNext();
std::vector<void *> FindAll();
private:
bool Compare(int a,int b);
void ReparseArgs();
SearchArgType args_;
uint64_t pos_,startpos_,endpos_;
void * pos_,* startpos_,* endpos_;
std::vector<int> BadCharShifts,GoodSuffixShift;
void PrepareGoodSuffixTable();
void PrepareBadCharShift();

@ -1,7 +1,7 @@
#include "hexsearch.h"
Hexsearch::Hexsearch(const SearchArgType &args,uint64_t startpos,uint64_t endpos):args_(args),pos_(startpos),startpos_(startpos),endpos_(endpos)
Hexsearch::Hexsearch(const SearchArgType &args,void * startpos,void * endpos):args_(args),pos_(startpos),startpos_(startpos),endpos_(endpos)
{
ReparseArgs();
}
@ -52,7 +52,7 @@ void Hexsearch::ReparseArgs()
}
}
}
uint64_t Hexsearch::FindNext() //TODO rewrite using Boyer-Moore algorithm
void * Hexsearch::FindNext() //TODO rewrite using Boyer-Moore algorithm
{
DFHack::Core &inst=DFHack::Core::getInstance();
DFHack::Process *p=inst.p;
@ -81,16 +81,16 @@ uint64_t Hexsearch::FindNext() //TODO rewrite using Boyer-Moore algorithm
return pos_-args_.size();
}
}
pos_++;
pos_ = pos_ + 1;
}
delete [] buf;
return 0;
}
std::vector<uint64_t> Hexsearch::FindAll()
std::vector<void *> Hexsearch::FindAll()
{
std::vector<uint64_t> ret;
uint64_t cpos=pos_;
std::vector<void *> ret;
void * cpos=pos_;
while(cpos!=0)
{
cpos=FindNext();

@ -2,14 +2,14 @@
int lua::Hexsearch::find(lua_State *L)
{
lua::state st(L);
uint64_t pos=p->FindNext();
void * pos=p->FindNext();
st.push(pos);
return 1;
}
int lua::Hexsearch::findall(lua_State *L)
{
lua::state st(L);
std::vector<uint64_t> pos=p->FindAll();
std::vector<void *> pos=p->FindAll();
st.newtable();
for(unsigned i=0;i<pos.size();i++)
{
@ -22,10 +22,10 @@ int lua::Hexsearch::findall(lua_State *L)
lua::Hexsearch::Hexsearch(lua_State *L,int id):tblid(id)
{
lua::state st(L);
uint64_t start,end;
void * start,* end;
::Hexsearch::SearchArgType args;
start=st.as<uint32_t>(1);
end=st.as<uint32_t>(2);
start= (void *)st.as<uint32_t>(1);
end=(void *)st.as<uint32_t>(2);
for(int i=3;i<=st.gettop();i++)
{
args.push_back(st.as<int>(i));

@ -32,7 +32,7 @@ static int LoadMod(lua_State *L)
buf=new char[size];
f.GetText(buf);
//std::cout<<"poking @:"<<std::hex<<pos<<"size :"<<size<<std::endl;
DFHack::Core::getInstance().p->write(pos,size,(uint8_t*)buf);
DFHack::Core::getInstance().p->write((void *) pos,size,(uint8_t*)buf);
delete [] buf;
st.push(pos);
st.push(size);

@ -14,7 +14,7 @@ static int lua_Process_readDWord(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
uint32_t ret=c->readDWord(st.as<uint32_t>(1));
uint32_t ret=c->readDWord( (void *) st.as<uint32_t>(1));
st.push(ret);
return 1;
}
@ -22,14 +22,14 @@ static int lua_Process_writeDWord(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
c->writeDWord(st.as<uint32_t>(1),st.as<uint32_t>(2));
c->writeDWord((void *) st.as<uint32_t>(1),st.as<uint32_t>(2));
return 0;
}
static int lua_Process_readFloat(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
float ret=c->readFloat(st.as<uint32_t>(1));
float ret=c->readFloat((void *) st.as<uint32_t>(1));
st.push(ret);
return 1;
}
@ -38,7 +38,7 @@ static int lua_Process_readWord(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
uint16_t ret=c->readWord(st.as<uint32_t>(1));
uint16_t ret=c->readWord((void *) st.as<uint32_t>(1));
st.push(ret);
return 1;
}
@ -47,14 +47,14 @@ static int lua_Process_writeWord(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
c->writeWord(st.as<uint32_t>(1),st.as<uint16_t>(2));
c->writeWord((void *) st.as<uint32_t>(1),st.as<uint16_t>(2));
return 0;
}
static int lua_Process_readByte(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
uint8_t ret=c->readByte(st.as<uint32_t>(1));
uint8_t ret=c->readByte((void *) st.as<uint32_t>(1));
st.push(ret);
return 1;
}
@ -63,7 +63,7 @@ static int lua_Process_writeByte(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
c->writeByte(st.as<uint32_t>(1),st.as<uint8_t>(2));
c->writeByte((void *) st.as<uint32_t>(1),st.as<uint8_t>(2));
return 0;
}
static int lua_Process_read(lua_State *S)
@ -77,7 +77,7 @@ static int lua_Process_read(lua_State *S)
buf=(uint8_t*)lua_touserdata(st,3);
else
buf=new uint8_t[len];
c->read(st.as<uint32_t>(1),len,buf);
c->read((void *) st.as<uint32_t>(1),len,buf);
st.pushlightuserdata(buf);
return 1;
}
@ -85,14 +85,14 @@ static int lua_Process_write(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
c-> write(st.as<uint32_t>(1),st.as<uint32_t>(2),static_cast<uint8_t*>(lua_touserdata(st,3)));
c-> write((void *) st.as<uint32_t>(1),st.as<uint32_t>(2),static_cast<uint8_t*>(lua_touserdata(st,3)));
return 0;
}
static int lua_Process_readSTLString (lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
std::string r=c->readSTLString(st.as<uint32_t>(1));
std::string r=c->readSTLString((void *) st.as<uint32_t>(1));
st.push(r);
return 1;
}
@ -101,14 +101,14 @@ static int lua_Process_writeSTLString(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
c->writeSTLString(st.as<uint32_t>(1),st.as<std::string>(2));
c->writeSTLString((void *) st.as<uint32_t>(1),st.as<std::string>(2));
return 0;
}
static int lua_Process_copySTLString(lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
c->copySTLString(st.as<uint32_t>(1),st.as<uint32_t>(2));
c->copySTLString((void *) st.as<uint32_t>(1),st.as<uint32_t>(2));
return 0;
}
static int lua_Process_doReadClassName(lua_State *S)
@ -131,7 +131,7 @@ static int lua_Process_readCString (lua_State *S)
{
lua::state st(S);
DFHack::Process* c=GetProcessPtr(st);
std::string r=c->readCString(st.as<uint32_t>(1));
std::string r=c->readCString((void *) st.as<uint32_t>(1));
st.push(r);
return 1;
}
@ -226,10 +226,10 @@ static int lua_Process_setPermisions(lua_State *S)
DFHack::t_memrange range,trange;
st.getfield("start",1);
range.start=st.as<uint64_t>();
range.start= (void *)st.as<uint64_t>();
st.pop();
st.getfield("end",1);
range.end=st.as<uint64_t>();
range.end= (void *)st.as<uint64_t>();
st.pop();
st.getfield("read",2);

@ -16,7 +16,7 @@ int OffsetGroup::getOffset(lua_State *L)
int OffsetGroup::getAddress(lua_State *L)
{
lua::state st(L);
uint32_t ret=p->getAddress(st.as<std::string>(1));
uint32_t ret= (uint32_t)p->getAddress(st.as<std::string>(1));
st.push(ret);
return 1;
}
@ -57,7 +57,7 @@ int OffsetGroup::getSafeOffset(lua_State *L)
int OffsetGroup::getSafeAddress(lua_State *L)
{
lua::state st(L);
uint32_t out;
void * out;
bool ret=p->getSafeAddress(st.as<std::string>(1),out);
st.push(ret);
st.push(out);
@ -286,7 +286,7 @@ static int __lua_resolveObjectToClassID(lua_State *S)
{
lua::state st(S);
int32_t ret;
bool output=DFHack::Core::getInstance().vinfo->resolveObjectToClassID(st.as<uint32_t>(1),ret);
bool output=DFHack::Core::getInstance().vinfo->resolveObjectToClassID((void *)st.as<uint32_t>(1),ret);
st.push(output);
st.push(ret);
return 2;
@ -329,7 +329,7 @@ static int __lua_getOffset(lua_State *S)
static int __lua_getAddress(lua_State *S)
{
lua::state st(S);
uint32_t ret=DFHack::Core::getInstance().vinfo->getAddress(st.as<std::string>(1));
void * ret=DFHack::Core::getInstance().vinfo->getAddress(st.as<std::string>(1));
st.push(ret);
return 1;
}
@ -392,7 +392,7 @@ static int __lua_getSafeOffset(lua_State *S)
static int __lua_getSafeAddress(lua_State *S)
{
lua::state st(S);
uint32_t out;
void * out;
bool ret=DFHack::Core::getInstance().vinfo->getSafeAddress(st.as<std::string>(1),out);
st.push(ret);
st.push(out);

@ -17,7 +17,7 @@ static tthread::mutex* mymutex=0;
struct memory_data
{
size_t addr;
void * addr;
size_t len;
size_t refresh;
int state;
@ -57,7 +57,7 @@ bool isAddr(uint32_t *trg,vector<t_memrange> & ranges)
{
if(trg[0]%4==0)
for(size_t i=0;i<ranges.size();i++)
if(ranges[i].isInRange(trg[0]))
if(ranges[i].isInRange((void *)trg[0]))
return true;
return false;
@ -131,7 +131,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c )
timeLast = time2;
c->p->read(memdata.addr,memdata.len,memdata.buf);
outputHex(memdata.buf,memdata.lbuf,memdata.len,memdata.addr,c,memdata.ranges);
outputHex(memdata.buf,memdata.lbuf,memdata.len,(size_t)memdata.addr,c,memdata.ranges);
memcpy(memdata.lbuf, memdata.buf, memdata.len);
if(memdata.refresh==0)
Deinit();
@ -143,7 +143,7 @@ DFhackCExport command_result memview (Core * c, vector <string> & parameters)
{
mymutex->lock();
c->p->getMemRanges(memdata.ranges);
memdata.addr=convert(parameters[0],true);
memdata.addr=(void *)convert(parameters[0],true);
if(memdata.addr==0)
{
Deinit();

@ -19,9 +19,9 @@ using namespace DFHack;
struct t_vecTriplet
{
uint32_t start;
uint32_t end;
uint32_t alloc_end;
void * start;
void * end;
void * alloc_end;
};
DFhackCExport command_result df_vectors (Core * c,
@ -74,7 +74,7 @@ static bool mightBeVec(vector<t_memrange> &heap_ranges,
// Vector length might not be a multiple of 4 if, for example,
// it's a vector of uint8_t or uint16_t. However, the actual memory
// allocated to the vector should be 4 byte aligned.
if ((vec->start % 4 != 0) || (vec->alloc_end % 4 != 0))
if (((int)vec->start % 4 != 0) || ((int)vec->alloc_end % 4 != 0))
return false;
for (size_t i = 0; i < heap_ranges.size(); i++)
@ -88,7 +88,7 @@ static bool mightBeVec(vector<t_memrange> &heap_ranges,
return false;
}
static bool inAnyRange(vector<t_memrange> &ranges, uint32_t ptr)
static bool inAnyRange(vector<t_memrange> &ranges, void * ptr)
{
for (size_t i = 0; i < ranges.size(); i++)
{
@ -141,7 +141,7 @@ static void vectorsUsage(Console &con)
static void printVec(Console &con, const char* msg, t_vecTriplet *vec,
uint32_t start, uint32_t pos)
{
uint32_t length = vec->end - vec->start;
uint32_t length = (int)vec->end - (int)vec->start;
uint32_t offset = pos - start;
con.print("%8s offset %06p, addr %010p, start %010p, length %u\n",
@ -193,15 +193,15 @@ DFhackCExport command_result df_vectors (Core * c, vector <string> & parameters)
{
t_memrange &range = heap_ranges[i];
if (!range.isInRange(start))
if (!range.isInRange((void *)start))
continue;
// Found the range containing the start
if (!range.isInRange(end))
if (!range.isInRange((void *)end))
{
con.print("Scanning %u bytes would read past end of memory "
"range.\n", bytes);
uint32_t diff = end - range.end;
uint32_t diff = end - (int)range.end;
con.print("Cutting bytes down by %u.\n", diff);
end = (uint32_t) range.end;
@ -242,7 +242,7 @@ DFhackCExport command_result df_vectors (Core * c, vector <string> & parameters)
{
uint32_t ptr = * ( (uint32_t*) pos);
if (inAnyRange(heap_ranges, ptr))
if (inAnyRange(heap_ranges, (void *) ptr))
{
t_vecTriplet* vec = (t_vecTriplet*) ptr;
@ -320,7 +320,7 @@ DFhackCExport command_result df_clearvec (Core * c, vector <string> & parameters
continue;
}
if (!inAnyRange(heap_ranges, addr))
if (!inAnyRange(heap_ranges, (void *) addr))
{
con << addr_str << " not in any valid address range." << std::endl;
continue;
@ -338,7 +338,7 @@ DFhackCExport command_result df_clearvec (Core * c, vector <string> & parameters
addr = * ( (uint32_t*) addr);
vec = (t_vecTriplet*) addr;
if (inAnyRange(heap_ranges, addr) && mightBeVec(heap_ranges, vec))
if (inAnyRange(heap_ranges, (void *) addr) && mightBeVec(heap_ranges, vec))
{
valid = true;
ptr = true;