Fixes for crash bugs and memory corruption.

develop
Petr Mrázek 2010-02-25 17:37:40 +01:00
parent 230af4310f
commit de5b2ecb4e
5 changed files with 32 additions and 28 deletions

@ -1022,6 +1022,8 @@ bool API::ReadSettlement(const int32_t &index, t_settlement & settlement)
{
if(!d->settlementsInited)
return false;
if(!d->p_settlements->getSize())
return false;
// read pointer from vector at position
uint32_t temp = * (uint32_t *) d->p_settlements->at (index);
settlement.origin = temp;
@ -1034,11 +1036,13 @@ bool API::ReadCurrentSettlement(t_settlement & settlement)
{
if(!d->settlementsInited)
return false;
if(!d->p_current_settlement->getSize())
return false;
uint32_t temp = * (uint32_t *) d->p_current_settlement->at(0);
settlement.origin = temp;
g_pProcess->read(temp + d->settlement_name_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.name);
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.world_x);
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int32_t), (uint8_t *) &settlement.local_x1);
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x);
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1);
return true;
}

@ -94,7 +94,12 @@ memory_info::memory_info(const memory_info &old)
d->hexvals = old.d->hexvals;
d->strings = old.d->strings;
d->base = old.d->base;
d->classes = old.d->classes;
//d->classes = old.d->classes;
for(int i = 0; i < old.d->classes.size(); i++)
{
t_class * copy = new t_class(*old.d->classes[i]);
d->classes.push_back(copy);
}
d->classindex = old.d->classindex;
d->professions = old.d->professions;
d->jobs = old.d->jobs;
@ -107,7 +112,7 @@ memory_info::memory_info(const memory_info &old)
memory_info::~memory_info()
{
// delete the vtables
for(int i = 0; i < d->classes.size();i++)
for(uint32_t i = 0; i < d->classes.size();i++)
{
delete d->classes[i];
}

@ -72,6 +72,7 @@ namespace DFHack
{
delete subs[i];
}
subs.clear();
}
string classname;
uint32_t vtable;

@ -476,10 +476,6 @@ bool SHMProcess::detach()
{
return false;
}
if(d->suspended)
{
resume();
}
// detach segment
UnmapViewOfFile(d->my_shm);
// release it for some other client

@ -68,9 +68,7 @@ bool ProcessEnumerator::findProcessess()
// Get the list of process identifiers.
DWORD ProcArray[2048], memoryNeeded, numProccesses;
{
Process *p = new SHMProcess(d->meminfo->meminfo);
delete p;
p = new SHMProcess(d->meminfo->meminfo);
Process * p = new SHMProcess(d->meminfo->meminfo);
if(p->isIdentified())
{
d->processes.push_back(p);