merge of peterix's branch

develop
belal 2010-02-19 10:59:22 -05:00
commit 3581c08a7a
17 changed files with 138 additions and 51 deletions

@ -1,5 +1,5 @@
// Hotkey and Note Dump // Hotkey and Note Dump
// Or Hot Keynote Dump? :P
#include <iostream> #include <iostream>
#include <climits> #include <climits>
#include <integers.h> #include <integers.h>
@ -48,10 +48,8 @@ int main (void)
DF.ReadHotkeys(hotkeys); DF.ReadHotkeys(hotkeys);
for(uint32_t i =0;i< NUM_HOTKEYS;i++) for(uint32_t i =0;i< NUM_HOTKEYS;i++)
{ {
if(hotkeys[i].mode != -1){ cout << "x: " << hotkeys[i].x << "\ty: " << hotkeys[i].y << "\tz: " << hotkeys[i].z <<
cout << "x: " << hotkeys[i].x << " y: " << hotkeys[i].y << " z: " << hotkeys[i].z << "\ttext: " << hotkeys[i].name << endl;
" text: " << hotkeys[i].name << endl;
}
} }
DF.FinishReadNotes(); DF.FinishReadNotes();
DF.Detach(); DF.Detach();

@ -16,6 +16,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);
@ -185,9 +186,21 @@ int pickColor(int tiletype)
string getGCCClassName (Process * p, uint32_t vptr) string getGCCClassName (Process * p, uint32_t vptr)
{ {
int typeinfo = p->readDWord(vptr - 4); int typeinfo = p->readDWord(vptr - 0x4);
int typestring = p->readDWord(typeinfo + 4); int typestring = p->readDWord(typeinfo + 0x4);
return p->readCString(typestring); string raw = p->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
}
string getMSVCClassName (Process * p, uint32_t vptr)
{
int rtti = p->readDWord(vptr - 0x4);
int typeinfo = p->readDWord(rtti + 0xC);
string raw = p->readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
} }
main(int argc, char *argv[]) main(int argc, char *argv[])
@ -241,17 +254,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 +281,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,6 +289,7 @@ 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);
} }
@ -283,6 +304,7 @@ main(int argc, char *argv[])
// walk the map! // walk the map!
for (;;) for (;;)
{ {
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 */
@ -371,8 +393,10 @@ main(int argc, char *argv[])
{ {
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);
@ -391,7 +415,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++)
@ -411,17 +435,23 @@ main(int argc, char *argv[])
cprintf("%s",stonetypes[veinVector[vein].type].name); 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();
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())
{ {

@ -907,7 +907,8 @@ bool API::InitReadNotes( uint32_t &numnotes )
} }
bool API::ReadNote (const int32_t &index, t_note & note) bool API::ReadNote (const int32_t &index, t_note & note)
{ {
assert (d->notesInited); if(!d->notesInited)
return false;
// read pointer from vector at position // read pointer from vector at position
uint32_t temp = * (uint32_t *) d->p_notes->at (index); uint32_t temp = * (uint32_t *) d->p_notes->at (index);
note.symbol = g_pProcess->readByte(temp); note.symbol = g_pProcess->readByte(temp);
@ -938,7 +939,8 @@ bool API::InitReadHotkeys( )
} }
bool API::ReadHotkeys(t_hotkey hotkeys[]) bool API::ReadHotkeys(t_hotkey hotkeys[])
{ {
assert (d->hotkeyInited); if (!d->hotkeyInited)
return false;
uint32_t currHotkey = d->hotkey_start; uint32_t currHotkey = d->hotkey_start;
for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++) for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++)
{ {

@ -637,3 +637,13 @@ void SHMProcess::writeSTLString(const uint32_t address, const std::string writeS
((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
}

@ -582,3 +582,12 @@ const string WineProcess::readSTLString (uint32_t offset)
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;
}

@ -527,3 +527,13 @@ const string NormalProcess::readSTLString (uint32_t offset)
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
}

@ -724,3 +724,12 @@ void SHMProcess::writeSTLString(const uint32_t address, const std::string writeS
((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;
}

@ -464,3 +464,12 @@ const string NormalProcess::readSTLString (uint32_t offset)
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);

5
output/.gitignore vendored

@ -1,3 +1,8 @@
<<<<<<< HEAD
Debug Debug
Release Release
=======
Debug
Release
>>>>>>> remotes/peterix/master
RelWithDebInfo RelWithDebInfo

@ -1520,7 +1520,8 @@
<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">0x09332C98</Address>-->
<Address name="notes">0x0931EA64</Address>
<Offset name="note_foreground">0x2</Offset> <Offset name="note_foreground">0x2</Offset>
<Offset name="note_background">0x4</Offset> <Offset name="note_background">0x4</Offset>
<Offset name="note_name">0x8</Offset> <Offset name="note_name">0x8</Offset>

@ -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;

@ -31,13 +31,10 @@ TARGET_LINK_LIBRARIES(dfbauxite dfhack)
ADD_EXECUTABLE(dfdigger digger.cpp) ADD_EXECUTABLE(dfdigger digger.cpp)
TARGET_LINK_LIBRARIES(dfdigger dfhack) TARGET_LINK_LIBRARIES(dfdigger dfhack)
# itemdesignator - change some item designations (dump, forbid, on-fire) for all items of a given type and material # itemdesignator - change some item designations (dump, forbid, on-fire) for all items of a given type and material
ADD_EXECUTABLE(dfitemdesignator itemdesignator.cpp) ADD_EXECUTABLE(dfitemdesignator itemdesignator.cpp)
TARGET_LINK_LIBRARIES(dfitemdesignator dfhack) TARGET_LINK_LIBRARIES(dfitemdesignator dfhack)
ADD_EXECUTABLE(dffindnameindexes findnameindexes.cpp)
TARGET_LINK_LIBRARIES(dffindnameindexes dfhack)
IF(UNIX) IF(UNIX)
install(TARGETS install(TARGETS