Tool for dumping the effective addresses/offsets of a running DF instance

develop
Petr Mrázek 2010-06-20 02:50:37 +02:00
parent 6c50b99050
commit 31167475de
4 changed files with 63 additions and 0 deletions

@ -734,3 +734,19 @@ std::string memory_info::getMood(const uint32_t moodID)
} }
throw Error::MissingMemoryDefinition("Mood", moodID); throw Error::MissingMemoryDefinition("Mood", moodID);
} }
std::string memory_info::PrintOffsets()
{
ostringstream ss;
map<string,uint32_t>::const_iterator iter;
for(iter = d->addresses.begin(); iter != d->addresses.end(); iter++)
{
ss << "address " << (*iter).first << " : " << hex << "0x" << (*iter).second << endl;
}
map<string,int32_t>::const_iterator iter2;
for(iter2 = d->offsets.begin(); iter2 != d->offsets.end(); iter2++)
{
ss << "offset " << (*iter2).first << " : " << hex << "0x" << (*iter2).second << endl;
}
return ss.str();
}

@ -145,6 +145,11 @@ namespace DFHack
* Get the internal classID->classname mapping (for speed). DO NOT MANIPULATE THE VECTOR! * Get the internal classID->classname mapping (for speed). DO NOT MANIPULATE THE VECTOR!
*/ */
const std::vector<std::string> * getClassIDMapping(); const std::vector<std::string> * getClassIDMapping();
/**
* Get a string with all addresses and offsets
*/
std::string PrintOffsets();
}; };
} }
#endif // MEMINFO_H_INCLUDED #endif // MEMINFO_H_INCLUDED

@ -13,6 +13,10 @@ TARGET_LINK_LIBRARIES(dfmoodump dfhack)
ADD_EXECUTABLE(dftest test.cpp) ADD_EXECUTABLE(dftest test.cpp)
TARGET_LINK_LIBRARIES(dftest dfhack) TARGET_LINK_LIBRARIES(dftest dfhack)
# just dump offsets of the current version
ADD_EXECUTABLE(dfdoffsets dumpoffsets.cpp)
TARGET_LINK_LIBRARIES(dfdoffsets dfhack)
# bauxite - turn all mechanisms into bauxite mechanisms # bauxite - turn all mechanisms into bauxite mechanisms
# Author: Alex Legg # Author: Alex Legg
#ADD_EXECUTABLE(dfbauxite dfbauxite.cpp) #ADD_EXECUTABLE(dfbauxite dfbauxite.cpp)

@ -0,0 +1,38 @@
#include <iostream>
#include <iomanip>
#include <climits>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
#include <DFHack.h>
using namespace DFHack;
int main (int numargs, const char ** args)
{
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
memory_info * minfo = DF->getMemoryInfo();
if(minfo)
cout << minfo->PrintOffsets();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}