Merge branch 'master' of github.com:peterix/dfhack

develop
mizipzor 2010-02-20 01:58:49 +01:00
commit 71c27e65d8
21 changed files with 441 additions and 33 deletions

20
.gitignore vendored

@ -0,0 +1,20 @@
# linux backup files
*~
# compiled binaries
output/*
# this one is important, track it
!output/Memory.xml
# a file generated by cmake
library/config.h
# any build folders
build*/
#except for the real one
!build/
#ignore Kdevelop stuff
.kdev4

@ -37,6 +37,11 @@ TARGET_LINK_LIBRARIES(dfsuspend dfhack)
ADD_EXECUTABLE(dfitemdump dfitemdump.cpp) ADD_EXECUTABLE(dfitemdump dfitemdump.cpp)
TARGET_LINK_LIBRARIES(dfitemdump dfhack) TARGET_LINK_LIBRARIES(dfitemdump dfhack)
# hotkeynotedump - dumps the hotkeys and notes for the loaded map
# Author: belal
ADD_EXECUTABLE(dfhotkeynotedump hotkeynotedump.cpp)
TARGET_LINK_LIBRARIES(dfhotkeynotedump dfhack)
IF(UNIX) IF(UNIX)
# veinlook - look at the map... sort of # veinlook - look at the map... sort of
ADD_EXECUTABLE(dfveinlook veinlook.cpp) ADD_EXECUTABLE(dfveinlook veinlook.cpp)
@ -53,7 +58,6 @@ dfattachtest
dfbuildingsdump dfbuildingsdump
dfcreaturedump dfcreaturedump
dfitemdump dfitemdump
dfdigger
dfexpbench dfexpbench
dfmaterialtest dfmaterialtest
dfposition dfposition

@ -0,0 +1,61 @@
// Hotkey and Note Dump
// Or Hot Keynote Dump? :P
#include <iostream>
#include <climits>
#include <integers.h>
#include <vector>
using namespace std;
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFMemInfo.h>
int main (void)
{
vector<DFHack::t_matgloss> creaturestypes;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
return 1;
}
DFHack::memory_info mem = DF.getMemoryInfo();
// get stone matgloss mapping
uint32_t numNotes;
if(!DF.InitReadNotes(numNotes))
{
cerr << "Can't get notes" << endl;
return 1;
}
if(!DF.InitReadHotkeys())
{
cerr << "Can't get hotkeys" << endl;
return 1;
}
cout << "Notes" << endl;
for(uint32_t i = 0; i < numNotes; i++)
{
DFHack::t_note temp;
DF.ReadNote(i,temp);
cout << "x: " << temp.x << "\ty: " << temp.y << "\tz: " << temp.z <<
"\tsymbol: " << temp.symbol << "\tfg: " << temp.foreground << "\tbg: " << temp.background <<
"\ttext: " << temp.name << endl;
}
cout << "Hotkeys" << endl;
DFHack::t_hotkey hotkeys[NUM_HOTKEYS];
DF.ReadHotkeys(hotkeys);
for(uint32_t i =0;i< NUM_HOTKEYS;i++)
{
cout << "x: " << hotkeys[i].x << "\ty: " << hotkeys[i].y << "\tz: " << hotkeys[i].z <<
"\ttext: " << hotkeys[i].name << endl;
}
DF.FinishReadNotes();
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -1,7 +1,9 @@
#include <integers.h> #include <integers.h>
#include <string.h> // for memset #include <string.h> // for memset
#include <string> #include <string>
#include <fstream>
#include <iostream> #include <iostream>
#include <iomanip>
#include <vector> #include <vector>
#include <map> #include <map>
using namespace std; using namespace std;
@ -16,6 +18,7 @@ using namespace DFHack;
#include <signal.h> #include <signal.h>
string error; string error;
API * pDF = 0;
static void finish(int sig); static void finish(int sig);
@ -181,15 +184,52 @@ int pickColor(int tiletype)
case FIRE: case FIRE:
return COLOR_RED; return COLOR_RED;
} }
} }
string getGCCClassName (Process * p, uint32_t vptr) /*
address = absolute address of dump start
length = length in bytes
*/
void hexdump (DFHack::API& DF, uint32_t address, uint32_t length, int filenum)
{ {
int typeinfo = p->readDWord(vptr - 4); uint32_t reallength;
int typestring = p->readDWord(typeinfo + 4); uint32_t lines;
return p->readCString(typestring); lines = (length / 16) + 1;
reallength = lines * 16;
char *buf = new char[reallength];
ofstream myfile;
string name = "hexdump";
name += filenum;
name+= ".txt";
myfile.open (name.c_str());
DF.ReadRaw(address, reallength, (uint8_t *) buf);
for (int i = 0; i < lines; i++)
{
// leading offset
myfile << "0x" << hex << setw(4) << i*16 << " ";
// groups
for(int j = 0; j < 4; j++)
{
// bytes
for(int k = 0; k < 4; k++)
{
int idx = i * 16 + j * 4 + k;
myfile << hex << setw(2) << int(static_cast<unsigned char>(buf[idx])) << " ";
}
myfile << " ";
}
myfile << endl;
}
delete buf;
myfile.close();
} }
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
/* initialize your non-curses data structures here */ /* initialize your non-curses data structures here */
@ -241,17 +281,23 @@ main(int argc, char *argv[])
// init the API // init the API
DFHack::API DF("Memory.xml"); DFHack::API DF("Memory.xml");
pDF = &DF;
// attach // attach
if(!DF.Attach()) if(!DF.Attach())
{ {
error = "Can't find DF."; error = "Can't find DF.";
pDF = 0;
finish(0); finish(0);
} }
Process* p = DF.getProcess(); Process* p = DF.getProcess();
// init the map // init the map
DF.InitMap(); if(!DF.InitMap())
{
error = "Can't find a map to look at.";
pDF = 0;
finish(0);
}
DF.getSize(x_max_a,y_max_a,z_max_a); DF.getSize(x_max_a,y_max_a,z_max_a);
x_max = x_max_a; x_max = x_max_a;
@ -262,6 +308,7 @@ main(int argc, char *argv[])
if(!DF.ReadStoneMatgloss(stonetypes)) if(!DF.ReadStoneMatgloss(stonetypes))
{ {
error = "Can't read stone types."; error = "Can't read stone types.";
pDF = 0;
finish(0); finish(0);
} }
@ -269,19 +316,27 @@ main(int argc, char *argv[])
if(!DF.ReadGeology( layerassign )) if(!DF.ReadGeology( layerassign ))
{ {
error = "Can't read local geology."; error = "Can't read local geology.";
pDF = 0;
finish(0); finish(0);
} }
// FIXME: could fail on small forts
int cursorX = x_max/2 - 1; int cursorX = x_max/2 - 1;
int cursorY = y_max/2 - 1; int cursorY = y_max/2 - 1;
int cursorZ = z_max/2 - 1; int cursorZ = z_max/2 - 1;
// FIXME: could fail on small forts
bool dig = false;
bool dump = false;
int vein = 0; int vein = 0;
int filenum = 0;
uint32_t blockaddr = 0;
// walk the map! // walk the map!
for (;;) for (;;)
{ {
dig = false;
dump = false;
DF.Resume();
int c = getch(); /* refresh, accept single keystroke of input */ int c = getch(); /* refresh, accept single keystroke of input */
clrscr(); clrscr();
/* process the command keystroke */ /* process the command keystroke */
@ -308,6 +363,12 @@ main(int argc, char *argv[])
case '+': case '+':
vein ++; vein ++;
break; break;
case 'd':
dig = true;
break;
case 'o':
dump = true;
break;
case '-': case '-':
vein --; vein --;
break; break;
@ -318,13 +379,15 @@ main(int argc, char *argv[])
cursorY = max(cursorY, 0); cursorY = max(cursorY, 0);
cursorZ = max(cursorZ, 0); cursorZ = max(cursorZ, 0);
cursorX = min(cursorX, x_max - 3); cursorX = min(cursorX, x_max - 1);
cursorY = min(cursorY, y_max - 3); cursorY = min(cursorY, y_max - 1);
cursorZ = min(cursorZ, z_max - 3); cursorZ = min(cursorZ, z_max - 1);
DF.Suspend(); DF.Suspend();
for(int i = 0; i < 3; i++) for(int i = -1; i <= 1; i++)
for(int j = 0; j < 3; j++) {
for(int j = -1; j <= 1; j++)
{
if(DF.isValidBlock(cursorX+i,cursorY+j,cursorZ)) if(DF.isValidBlock(cursorX+i,cursorY+j,cursorZ))
{ {
// read data // read data
@ -334,26 +397,45 @@ main(int argc, char *argv[])
{ {
for(int y = 0; y < 16; y++) for(int y = 0; y < 16; y++)
{ {
if(dig)
{
if(tileTypeTable[tiletypes[x][y]].c == WALL && tileTypeTable[tiletypes[x][y]].m == VEIN
|| tileTypeTable[tiletypes[x][y]].c == TREE_OK || tileTypeTable[tiletypes[x][y]].c == TREE_DEAD)
{
designations[x][y].bits.dig = designation_default;
}
}
int color = COLOR_BLACK; int color = COLOR_BLACK;
color = pickColor(tiletypes[x][y]); color = pickColor(tiletypes[x][y]);
if(designations[x][y].bits.hidden) if(designations[x][y].bits.hidden)
{ {
puttile(x+i*16,y+j*16,tiletypes[x][y], color); puttile(x+(i+1)*16,y+(j+1)*16,tiletypes[x][y], color);
} }
else else
{ {
attron(A_STANDOUT); attron(A_STANDOUT);
puttile(x+i*16,y+j*16,tiletypes[x][y], color); puttile(x+(i+1)*16,y+(j+1)*16,tiletypes[x][y], color);
attroff(A_STANDOUT); attroff(A_STANDOUT);
} }
} }
} }
if(i == 1 && j == 1)
if(i == 0 && j == 0)
{ {
blockaddr = DF.getBlockPtr(cursorX+i,cursorY+j,cursorZ);
if(dump)
{
hexdump(DF,blockaddr,0x1DB8,filenum);
filenum++;
}
if(dig)
DF.WriteDesignations(cursorX+i,cursorY+j,cursorZ, (uint32_t *) designations);
veinVector.clear(); veinVector.clear();
DF.ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector); DF.ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector);
} }
} }
}
}
gotoxy(0,48); gotoxy(0,48);
cprintf("arrow keys, PGUP, PGDN = navigate"); cprintf("arrow keys, PGUP, PGDN = navigate");
gotoxy(0,49); gotoxy(0,49);
@ -361,13 +443,15 @@ main(int argc, char *argv[])
gotoxy(0,50); gotoxy(0,50);
if(vein == veinVector.size()) vein = veinVector.size() - 1; if(vein == veinVector.size()) vein = veinVector.size() - 1;
if(vein < -1) vein = -1; if(vein < -1) vein = -1;
cprintf("X %d/%d, Y %d/%d, Z %d/%d. Vein %d of %d",cursorX + 1,x_max,cursorY + 1,y_max,cursorZ + 1,z_max,vein+1,veinVector.size()); cprintf("X %d/%d, Y %d/%d, Z %d/%d. Vein %d of %d",cursorX+1,x_max,cursorY+1,y_max,cursorZ,z_max,vein+1,veinVector.size());
if(!veinVector.empty()) if(!veinVector.empty())
{ {
if(vein != -1 && vein < veinVector.size()) if(vein != -1 && vein < veinVector.size())
{ {
string str = getGCCClassName(p, veinVector[vein].vtable); //string str = getGCCClassName(p, veinVector[vein].vtable);
if(str == "34block_square_event_frozen_liquidst") string className = p->readClassName(veinVector[vein].vtable);
//string str = "34block_square_event_frozen_liquidst";
if(className == "block_square_event_frozen_liquid")
{ {
t_frozenliquidvein frozen; t_frozenliquidvein frozen;
uint32_t size = sizeof(t_frozenliquidvein); uint32_t size = sizeof(t_frozenliquidvein);
@ -386,7 +470,7 @@ main(int argc, char *argv[])
} }
} }
} }
else if (str == "28block_square_event_mineralst") else if (className == "block_square_event_mineral")
{ {
//iterate through vein rows //iterate through vein rows
for(uint32_t j = 0;j<16;j++) for(uint32_t j = 0;j<16;j++)
@ -402,19 +486,29 @@ main(int argc, char *argv[])
} }
} }
} }
gotoxy(0,52);
cprintf("%s",stonetypes[veinVector[vein].type].name);
} }
gotoxy(0,51); gotoxy(0,51);
cprintf("%s, address 0x%x",str.c_str(),veinVector[vein].address_of); cprintf("%s, address 0x%x",className.c_str(),veinVector[vein].address_of);
} }
} }
DF.Resume(); gotoxy (0,53);
cprintf("block address 0x%x",blockaddr);
wrefresh(stdscr); wrefresh(stdscr);
} }
pDF = 0;
finish(0); finish(0);
} }
static void finish(int sig) static void finish(int sig)
{ {
// ugly
if(pDF)
{
pDF->ForceResume();
pDF->Detach();
}
endwin(); endwin();
if(!error.empty()) if(!error.empty())
{ {

@ -83,6 +83,15 @@ public:
uint32_t item_material_offset; uint32_t item_material_offset;
uint32_t note_foreground_offset;
uint32_t note_background_offset;
uint32_t note_name_offset;
uint32_t note_xyz_offset;
uint32_t hotkey_start;
uint32_t hotkey_mode_offset;
uint32_t hotkey_xyz_offset;
uint32_t hotkey_size;
uint32_t dwarf_lang_table_offset; uint32_t dwarf_lang_table_offset;
ProcessEnumerator* pm; ProcessEnumerator* pm;
@ -98,6 +107,8 @@ public:
bool cursorWindowInited; bool cursorWindowInited;
bool viewSizeInited; bool viewSizeInited;
bool itemsInited; bool itemsInited;
bool notesInited;
bool hotkeyInited;
bool nameTablesInited; bool nameTablesInited;
@ -107,6 +118,7 @@ public:
DfVector *p_bld; DfVector *p_bld;
DfVector *p_veg; DfVector *p_veg;
DfVector *p_itm; DfVector *p_itm;
DfVector *p_notes;
}; };
API::API (const string path_to_xml) API::API (const string path_to_xml)
@ -122,6 +134,8 @@ API::API (const string path_to_xml)
d->cursorWindowInited = false; d->cursorWindowInited = false;
d->viewSizeInited = false; d->viewSizeInited = false;
d->itemsInited = false; d->itemsInited = false;
d->notesInited = false;
d->hotkeyInited = false;
d->pm = NULL; d->pm = NULL;
} }
@ -207,9 +221,18 @@ bool API::DestroyMap()
bool API::isValidBlock (uint32_t x, uint32_t y, uint32_t z) bool API::isValidBlock (uint32_t x, uint32_t y, uint32_t z)
{ {
if (x < 0 || x >= d->x_block_count || y < 0 || y >= d->y_block_count || z < 0 || z >= d->z_block_count)
return false;
return d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z] != 0; return d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z] != 0;
} }
uint32_t API::getBlockPtr (uint32_t x, uint32_t y, uint32_t z)
{
if (x < 0 || x >= d->x_block_count || y < 0 || y >= d->y_block_count || z < 0 || z >= d->z_block_count)
return 0;
return d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
}
// 256 * sizeof(uint16_t) // 256 * sizeof(uint16_t)
bool API::ReadTileTypes (uint32_t x, uint32_t y, uint32_t z, uint16_t *buffer) bool API::ReadTileTypes (uint32_t x, uint32_t y, uint32_t z, uint16_t *buffer)
{ {
@ -837,7 +860,7 @@ bool API::InitReadCreatures( uint32_t &numcreatures )
&& d->creature_labors_offset && d->creature_labors_offset
&& d->creature_happiness_offset && d->creature_happiness_offset
&& d->creature_traits_offset && d->creature_traits_offset
// && d->creature_likes_offset // && d->creature_likes_offset
) )
{ {
d->p_cre = new DfVector (d->p->readVector (creatures, 4)); d->p_cre = new DfVector (d->p->readVector (creatures, 4));
@ -853,7 +876,81 @@ bool API::InitReadCreatures( uint32_t &numcreatures )
return false; return false;
} }
} }
bool API::InitReadNotes( uint32_t &numnotes )
{
memory_info * minfo = d->offset_descriptor;
int notes = d->offset_descriptor->getAddress ("notes");
d->note_foreground_offset = minfo->getOffset ("note_foreground");
d->note_background_offset = minfo->getOffset ("note_background");
d->note_name_offset = minfo->getOffset ("note_name");
d->note_xyz_offset = minfo->getOffset ("note_xyz");
if (notes
&& d->note_foreground_offset
&& d->note_background_offset
&& d->note_name_offset
&& d->note_xyz_offset
)
{
d->p_notes = new DfVector (d->p->readVector (notes, 4));
//InitReadNameTables();
d->notesInited = true;
numnotes = d->p_notes->getSize();
return true;
}
else
{
d->notesInited = false;
numnotes = 0;
return false;
}
}
bool API::ReadNote (const int32_t &index, t_note & note)
{
if(!d->notesInited)
return false;
// read pointer from vector at position
uint32_t temp = * (uint32_t *) d->p_notes->at (index);
note.symbol = g_pProcess->readByte(temp);
note.foreground = g_pProcess->readWord(temp + d->note_foreground_offset);
note.background = g_pProcess->readWord(temp + d->note_background_offset);
d->p->readSTLString (temp + d->note_name_offset, note.name, 128);
g_pProcess->read (temp + d->note_xyz_offset, 3*sizeof (uint16_t), (uint8_t *) &note.x);
return true;
}
bool API::InitReadHotkeys( )
{
memory_info * minfo = d->offset_descriptor;
d->hotkey_start = minfo->getAddress("hotkey_start");
d->hotkey_mode_offset = minfo->getOffset ("hotkey_mode");
d->hotkey_xyz_offset = minfo->getOffset("hotkey_xyz");
d->hotkey_size = minfo->getHexValue("hotkey_size");
if (d->hotkey_start && d->hotkey_mode_offset && d->hotkey_size)
{
d->hotkeyInited = true;
return true;
}
else
{
d->hotkeyInited = false;
return false;
}
}
bool API::ReadHotkeys(t_hotkey hotkeys[])
{
if (!d->hotkeyInited)
return false;
uint32_t currHotkey = d->hotkey_start;
for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++)
{
d->p->readSTLString(currHotkey,hotkeys[i].name,10);
hotkeys[i].mode = g_pProcess->readWord(currHotkey+d->hotkey_mode_offset);
g_pProcess->read (currHotkey + d->hotkey_xyz_offset, 3*sizeof (int32_t), (uint8_t *) &hotkeys[i].x);
currHotkey+=d->hotkey_size;
}
return true;
}
// returns index of creature actually read or -1 if no creature can be found // returns index of creature actually read or -1 if no creature can be found
int32_t API::ReadCreatureInBox (int32_t index, t_creature & furball, int32_t API::ReadCreatureInBox (int32_t index, t_creature & furball,
const uint16_t &x1, const uint16_t &y1, const uint16_t &z1, const uint16_t &x1, const uint16_t &y1, const uint16_t &z1,
@ -1087,6 +1184,13 @@ void API::FinishReadCreatures()
d->creaturesInited = false; d->creaturesInited = false;
//FinishReadNameTables(); //FinishReadNameTables();
} }
void API::FinishReadNotes()
{
delete d->p_notes;
d->p_notes = NULL;
d->notesInited = false;
//FinishReadNameTables();
}
bool API::Attach() bool API::Attach()
{ {

@ -128,6 +128,10 @@ namespace DFHack
* Return false/0 on failure, buffer allocated by client app, 256 items long * Return false/0 on failure, buffer allocated by client app, 256 items long
*/ */
bool isValidBlock(uint32_t blockx, uint32_t blocky, uint32_t blockz); bool isValidBlock(uint32_t blockx, uint32_t blocky, uint32_t blockz);
/**
* Get the address of a block or 0 if block is not valid
*/
uint32_t getBlockPtr (uint32_t x, uint32_t y, uint32_t z);
bool ReadTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t) bool ReadTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t)
bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t) bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t)
@ -171,6 +175,13 @@ namespace DFHack
void WriteRaw (const uint32_t &offset, const uint32_t &size, uint8_t *source); void WriteRaw (const uint32_t &offset, const uint32_t &size, uint8_t *source);
bool InitViewAndCursor(); bool InitViewAndCursor();
bool InitReadNotes( uint32_t & numnotes );
bool ReadNote(const int32_t &index, t_note & note);
void FinishReadNotes();
bool InitReadHotkeys( );
bool ReadHotkeys(t_hotkey hotkeys[]);
bool getViewCoords (int32_t &x, int32_t &y, int32_t &z); bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
bool setViewCoords (const int32_t &x, const int32_t &y, const int32_t &z); bool setViewCoords (const int32_t &x, const int32_t &y, const int32_t &z);

@ -636,4 +636,14 @@ void SHMProcess::writeSTLString(const uint32_t address, const std::string writeS
full_barrier full_barrier
((shm_write_small *)d->my_shm)->pingpong = DFPP_WRITE_STL_STRING; ((shm_write_small *)d->my_shm)->pingpong = DFPP_WRITE_STL_STRING;
d->waitWhile(DFPP_WRITE_STL_STRING); d->waitWhile(DFPP_WRITE_STL_STRING);
}
string SHMProcess::readClassName (uint32_t vptr)
{
int typeinfo = readDWord(vptr - 0x4);
int typestring = readDWord(typeinfo + 0x4);
string raw = readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
return raw.substr(start,end-start - 2); // trim the 'st' from the end
} }

@ -581,4 +581,13 @@ const string WineProcess::readSTLString (uint32_t offset)
string ret = temp; string ret = temp;
delete temp; delete temp;
return ret; return ret;
}
string WineProcess::readClassName (uint32_t vptr)
{
int rtti = readDWord(vptr - 0x4);
int typeinfo = readDWord(rtti + 0xC);
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
} }

@ -526,4 +526,14 @@ const string NormalProcess::readSTLString (uint32_t offset)
string ret(temp); string ret(temp);
delete temp; delete temp;
return ret; return ret;
}
string NormalProcess::readClassName (uint32_t vptr)
{
int typeinfo = readDWord(vptr - 0x4);
int typestring = readDWord(typeinfo + 0x4);
string raw = readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
return raw.substr(start,end-start - 2); // trim the 'st' from the end
} }

@ -723,4 +723,13 @@ void SHMProcess::writeSTLString(const uint32_t address, const std::string writeS
full_barrier full_barrier
((shm_write_small *)d->my_shm)->pingpong = DFPP_WRITE_STL_STRING; ((shm_write_small *)d->my_shm)->pingpong = DFPP_WRITE_STL_STRING;
d->waitWhile(DFPP_WRITE_STL_STRING); d->waitWhile(DFPP_WRITE_STL_STRING);
}
string SHMProcess::readClassName (uint32_t vptr)
{
int rtti = readDWord(vptr - 0x4);
int typeinfo = readDWord(rtti + 0xC);
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
} }

@ -463,4 +463,13 @@ const string NormalProcess::readSTLString (uint32_t offset)
string ret = temp; string ret = temp;
delete temp; delete temp;
return ret; return ret;
}
string NormalProcess::readClassName (uint32_t vptr)
{
int rtti = readDWord(vptr - 0x4);
int typeinfo = readDWord(rtti + 0xC);
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
} }

@ -96,6 +96,8 @@ namespace DFHack
virtual void writeSTLString(const uint32_t address, const std::string writeString) = 0; virtual void writeSTLString(const uint32_t address, const std::string writeString) = 0;
// read a vector from memory // read a vector from memory
virtual DfVector readVector (uint32_t offset, uint32_t item_size) = 0; virtual DfVector readVector (uint32_t offset, uint32_t item_size) = 0;
// get class name of an object with rtti/type info
virtual string readClassName(uint32_t vptr) = 0;
virtual const std::string readCString (uint32_t offset) = 0; virtual const std::string readCString (uint32_t offset) = 0;
@ -152,6 +154,8 @@ namespace DFHack
void writeSTLString(const uint32_t address, const std::string writeString){}; void writeSTLString(const uint32_t address, const std::string writeString){};
// read a vector from memory // read a vector from memory
DfVector readVector (uint32_t offset, uint32_t item_size); DfVector readVector (uint32_t offset, uint32_t item_size);
// get class name of an object with rtti/type info
string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset); const std::string readCString (uint32_t offset);
@ -203,6 +207,8 @@ namespace DFHack
void writeSTLString(const uint32_t address, const std::string writeString); void writeSTLString(const uint32_t address, const std::string writeString);
// read a vector from memory // read a vector from memory
DfVector readVector (uint32_t offset, uint32_t item_size); DfVector readVector (uint32_t offset, uint32_t item_size);
// get class name of an object with rtti/type info
string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset); const std::string readCString (uint32_t offset);
@ -254,6 +260,8 @@ namespace DFHack
void writeSTLString(const uint32_t address, const std::string writeString){}; void writeSTLString(const uint32_t address, const std::string writeString){};
// read a vector from memory // read a vector from memory
DfVector readVector (uint32_t offset, uint32_t item_size); DfVector readVector (uint32_t offset, uint32_t item_size);
// get class name of an object with rtti/type info
string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset); const std::string readCString (uint32_t offset);

@ -73,11 +73,11 @@ bool ProcessEnumerator::findProcessess()
if(p->isIdentified()) if(p->isIdentified())
{ {
d->processes.push_back(p); d->processes.push_back(p);
return true; return true;
} }
else else
{ {
delete p; //FIXME delete p;
p = 0; p = 0;
} }
} }
@ -102,8 +102,8 @@ bool ProcessEnumerator::findProcessess()
} }
else else
{ {
delete q; //FIXME delete q;
q = 0; q = 0;
} }
} }
if(d->processes.size()) if(d->processes.size())
@ -134,7 +134,7 @@ void ProcessEnumerator::purge()
{ {
for(uint32_t i = 0;i < d->processes.size();i++) for(uint32_t i = 0;i < d->processes.size();i++)
{ {
delete d->processes[i]; //FIXME delete d->processes[i];
} }
d->processes.clear(); d->processes.clear();
} }

@ -753,5 +753,26 @@ struct t_viewscreen
//There is more info in these objects, but I don't know what it is yet //There is more info in these objects, but I don't know what it is yet
}; };
struct t_note
{
char symbol;
uint16_t foreground;
uint16_t background;
char name[128];
uint16_t x;
uint16_t y;
uint16_t z;
};
#define NUM_HOTKEYS 16
struct t_hotkey
{
char name[10];
int16_t mode;
int32_t x;
int32_t y;
int32_t z;
};
}// namespace DFHack }// namespace DFHack
#endif // TYPES_H_INCLUDED #endif // TYPES_H_INCLUDED

@ -13,4 +13,4 @@ You can turn off the include by defining SKIP_DFHACK_STDINT
#else #else
#include "stdint_win.h" #include "stdint_win.h"
#endif #endif
#endif #endif

@ -800,6 +800,18 @@
<Address name="window_y">0xcdc3dc</Address> <Address name="window_y">0xcdc3dc</Address>
<Address name="window_z">0xcdc3b8</Address> <Address name="window_z">0xcdc3b8</Address>
<Address name="window_dims">0x1676f14</Address> <Address name="window_dims">0x1676f14</Address>
<Address name="notes">0x012FDBAC</Address>
<Offset name="note_foreground">0x2</Offset>
<Offset name="note_background">0x4</Offset>
<Offset name="note_name">0x8</Offset>
<Offset name="note_xyz">0x24</Offset>
<Address name="hotkey_start">0x012FDBE4</Address>
<Offset name="hotkey_mode">0x1C</Offset>
<Offset name="hotkey_xyz">0x20</Offset>
<HexValue name="hotkey_size">0x2C</HexValue>
</Entry> </Entry>
<Entry version="v0.28.181.40d11" os="windows" rebase="0x2d388" id="40d11win" base="40d9win"> <Entry version="v0.28.181.40d11" os="windows" rebase="0x2d388" id="40d11win" base="40d9win">
<!-- identification --> <!-- identification -->
@ -811,6 +823,9 @@
<Address name="window_x">0xcdf5a0</Address> <Address name="window_x">0xcdf5a0</Address>
<Address name="window_y">0xd0d64c</Address> <Address name="window_y">0xd0d64c</Address>
<Address name="window_z">0xd0d628</Address> <Address name="window_z">0xd0d628</Address>
<Address name="notes">0x013E853C</Address>
<Address name="hotkey_start">0x013E8574</Address>
</Entry> </Entry>
<Entry version="v0.28.181.40d12" os="windows" id="40d12win" base="40d11win"> <Entry version="v0.28.181.40d12" os="windows" id="40d12win" base="40d11win">
<!-- identification --> <!-- identification -->
@ -1114,6 +1129,9 @@
<Address name="view_screen">0x014243C4</Address> <Address name="view_screen">0x014243C4</Address>
<Address name="current_cursor_creature">0x0178C994</Address> <Address name="current_cursor_creature">0x0178C994</Address>
<Address name="notes">0x014240A4</Address>
<Address name="hotkey_start">0x014240DC</Address>
<VTable name="viewscreen_vtable"> <VTable name="viewscreen_vtable">
<class vtable="0x0092014C" name="viewscreen_conversation" /> <class vtable="0x0092014C" name="viewscreen_conversation" />
<class vtable="0x0092752C" name="viewscreen_option" /> <class vtable="0x0092752C" name="viewscreen_option" />
@ -1502,6 +1520,18 @@
<Address name="matgloss">0x9374E88</Address> <Address name="matgloss">0x9374E88</Address>
<HexValue name="matgloss_skip">0xC</HexValue> <HexValue name="matgloss_skip">0xC</HexValue>
<!--<Address name="notes">0x09332C98</Address>-->
<Address name="notes">0x0931EA64</Address>
<Offset name="note_foreground">0x2</Offset>
<Offset name="note_background">0x4</Offset>
<Offset name="note_name">0x8</Offset>
<Offset name="note_xyz">0xC</Offset>
<Address name="hotkey_start">0x0931EA8C</Address>
<Offset name="hotkey_mode">0x4</Offset>
<Offset name="hotkey_xyz">0x8</Offset>
<HexValue name="hotkey_size">0x14</HexValue>
<!-- virtual tables extracted from DF --> <!-- virtual tables extracted from DF -->
<VTable name="building_vtable"> <VTable name="building_vtable">
<class vtable="0x08797448" name="building_construction" /> <class vtable="0x08797448" name="building_construction" />
@ -1603,6 +1633,8 @@
<VTable rebase="-0x5e360" name="building_vtable" /> <VTable rebase="-0x5e360" name="building_vtable" />
<Address name="cursor_xyz">0x88073d4</Address> <Address name="cursor_xyz">0x88073d4</Address>
<Address name="window_dims">0x9510050</Address> <Address name="window_dims">0x9510050</Address>
<Address name="notes">0x092AB244</Address>
</Entry> </Entry>
<!-- re-specified addresses here, offsets and hexvals remain same --> <!-- re-specified addresses here, offsets and hexvals remain same -->
<Entry version="v0.28.181.40d12" os="linux" base="40d9lin" id="40d12lin"> <Entry version="v0.28.181.40d12" os="linux" base="40d9lin" id="40d12lin">
@ -1643,6 +1675,10 @@
<Address name="matgloss">0x08F97A84</Address> <Address name="matgloss">0x08F97A84</Address>
<VTable rebase="-0xd6f00" name="building_vtable" /> <VTable rebase="-0xd6f00" name="building_vtable" />
<!--<class vtable="0x086C3968" name="door"/>--> <!--<class vtable="0x086C3968" name="door"/>-->
<Address name="notes">0x08F41644</Address>
<Address name="hotkey_start">0x08F4166C</Address>
</Entry> </Entry>
<Entry version="v0.28.181.40d13" os="linux" id="40d13lin" base="40d12lin" rebase="0x5020"> <Entry version="v0.28.181.40d13" os="linux" id="40d13lin" base="40d12lin" rebase="0x5020">
<!-- identification --> <!-- identification -->
@ -1900,6 +1936,9 @@
<Address name="view_screen">0x878caa4</Address> <!-- address of ptr to view screen object, 'public gview' in IDA Pro --> <Address name="view_screen">0x878caa4</Address> <!-- address of ptr to view screen object, 'public gview' in IDA Pro -->
<Address name="current_menu_state">0x8f4e940</Address> <!-- menu state - used to get out of menus with space key --> <Address name="current_menu_state">0x8f4e940</Address> <!-- menu state - used to get out of menus with space key -->
<Address name="notes">0x08F4E7C4</Address>
<Address name="hotkey_start">0x08F4E7EC</Address>
<!--<VTable name="building_vtable" rebase="0xAE20" />--> <!-- Door: 0x86D26E8 --> <!--<VTable name="building_vtable" rebase="0xAE20" />--> <!-- Door: 0x86D26E8 -->
<VTable name="viewscreen_vtable"> <VTable name="viewscreen_vtable">
<class vtable="0x086D5488" name="viewscreen_conversation" /> <class vtable="0x086D5488" name="viewscreen_conversation" />

@ -9,6 +9,5 @@ if [ $? -eq 0 ]; then
mv libs/libSDL* unused_libs/ mv libs/libSDL* unused_libs/
fi fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./libs" # Update library search path. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./libs" # Update library search path.
export LD_PRELOAD="./libs/dfconnect.so" # Hack DF! export LD_PRELOAD="./libs/libdfconnect.so" # Hack DF!
./dwarfort.exe $* # Go, go, go! :) ./dwarfort.exe $* # Go, go, go! :)

Binary file not shown.

@ -158,7 +158,7 @@ void SHM_Act (void)
case DFPP_CL_ERROR: case DFPP_CL_ERROR:
case DFPP_RUNNING: case DFPP_RUNNING:
fprintf(stderr, "no. of waits: %d\n", numwaits); //fprintf(stderr, "no. of waits: %d\n", numwaits);
//MessageBox(0,"Broke out of loop properly","FUN", MB_OK); //MessageBox(0,"Broke out of loop properly","FUN", MB_OK);
break; break;