diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml index d34825c3e..9925c8924 100644 --- a/data/Memory-ng.xml +++ b/data/Memory-ng.xml @@ -674,6 +674,22 @@ + + + + + + @@ -938,6 +954,11 @@ + + + + + @@ -1217,7 +1238,6 @@
-
@@ -1459,6 +1479,27 @@
+ + + + + + + + + + + + + 0x01482874 - current race
@@ -1472,10 +1513,110 @@
-
+
-
+
+ + +
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+ + + + + + + + + + + + + + +
+ + + +
+ + + + +
+
+ + + + YES +
+
+
+
+
+
NO! + + YES + YES + YES + YES + + YES + MAYBE + YES + + YES + + + + + YES + + + + + + + + + this is crap it seems + + +
+ + + +
+ @@ -1718,6 +1859,24 @@ + + + + + + + + + + + + + + CHMOD + + + + @@ -1756,6 +1915,9 @@
+ +
+
diff --git a/library/DFProcess-linux-wine.cpp b/library/DFProcess-linux-wine.cpp index 8e8e3c1f5..891a4f820 100644 --- a/library/DFProcess-linux-wine.cpp +++ b/library/DFProcess-linux-wine.cpp @@ -53,6 +53,9 @@ class WineProcess::Private bool attached; bool suspended; bool identified; + uint32_t STLSTR_buf_off; + uint32_t STLSTR_size_off; + uint32_t STLSTR_cap_off; bool validate(char * exe_file, uint32_t pid, char * mem_file, vector & known_versions); }; @@ -155,6 +158,10 @@ bool WineProcess::Private::validate(char* exe_file, uint32_t pid, char* mem_file // tell WineProcess about the /proc/PID/mem file memFile = mem_file; identified = true; + OffsetGroup * strGrp = m->getGroup("string")->getGroup("MSVC"); + STLSTR_buf_off = strGrp->getOffset("buffer"); + STLSTR_size_off = strGrp->getOffset("size"); + STLSTR_cap_off = strGrp->getOffset("capacity"); return true; } } @@ -563,21 +570,10 @@ const std::string WineProcess::readCString (uint32_t offset) size_t WineProcess::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity) { - /* - MSVC++ string - ptr allocator - union - { - char[16] start; - char * start_ptr - } - Uint32 length - Uint32 capacity - */ - uint32_t start_offset = offset + 4; - size_t length = readDWord(offset + 20); + uint32_t start_offset = offset + d->STLSTR_buf_off; + size_t length = readDWord(offset + d->STLSTR_size_off); + size_t capacity = readDWord(offset + d->STLSTR_cap_off); - size_t capacity = readDWord(offset + 24); size_t read_real = min(length, bufcapacity-1);// keep space for null termination // read data from inside the string structure @@ -597,20 +593,10 @@ size_t WineProcess::readSTLString (uint32_t offset, char * buffer, size_t bufcap const string WineProcess::readSTLString (uint32_t offset) { - /* - MSVC++ string - ptr allocator - union - { - char[16] start; - char * start_ptr - } - Uint32 length - Uint32 capacity - */ - uint32_t start_offset = offset + 4; - uint32_t length = readDWord(offset + 20); - uint32_t capacity = readDWord(offset + 24); + uint32_t start_offset = offset + d->STLSTR_buf_off; + size_t length = readDWord(offset + d->STLSTR_size_off); + size_t capacity = readDWord(offset + d->STLSTR_cap_off); + char * temp = new char[capacity+1]; // read data from inside the string structure diff --git a/library/DFProcess-windows.cpp b/library/DFProcess-windows.cpp index a658b49a7..0b3d7959d 100644 --- a/library/DFProcess-windows.cpp +++ b/library/DFProcess-windows.cpp @@ -48,6 +48,9 @@ class NormalProcess::Private bool attached; bool suspended; bool identified; + uint32_t STLSTR_buf_off; + uint32_t STLSTR_size_off; + uint32_t STLSTR_cap_off; }; NormalProcess::NormalProcess(uint32_t pid, vector & known_versions) @@ -134,7 +137,10 @@ NormalProcess::NormalProcess(uint32_t pid, vector & known_versio vector threads; getThreadIDs( threads ); d->my_main_thread = OpenThread(THREAD_ALL_ACCESS, FALSE, (DWORD) threads[0]); - + OffsetGroup * strGrp = m->getGroup("string")->getGroup("MSVC"); + d->STLSTR_buf_off = strGrp->getOffset("buffer"); + d->STLSTR_size_off = strGrp->getOffset("size"); + d->STLSTR_cap_off = strGrp->getOffset("capacity"); found = true; break; // break the iterator loop } @@ -430,21 +436,9 @@ const string NormalProcess::readCString (const uint32_t offset) size_t NormalProcess::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity) { - /* - MSVC++ string - ptr allocator - union - { - char[16] start; - char * start_ptr -} -Uint32 length -Uint32 capacity -*/ - uint32_t start_offset = offset + 4; - size_t length = readDWord(offset + 20); - - size_t capacity = readDWord(offset + 24); + uint32_t start_offset = offset + d->STLSTR_buf_off; + size_t length = readDWord(offset + d->STLSTR_size_off); + size_t capacity = readDWord(offset + d->STLSTR_cap_off); size_t read_real = min(length, bufcapacity-1);// keep space for null termination // read data from inside the string structure @@ -464,20 +458,9 @@ Uint32 capacity const string NormalProcess::readSTLString (uint32_t offset) { - /* - MSVC++ string - ptr allocator - union - { - char[16] start; - char * start_ptr - } - Uint32 length - Uint32 capacity - */ - uint32_t start_offset = offset + 4; - uint32_t length = readDWord(offset + 20); - uint32_t capacity = readDWord(offset + 24); + uint32_t start_offset = offset + d->STLSTR_buf_off; + size_t length = readDWord(offset + d->STLSTR_size_off); + size_t capacity = readDWord(offset + d->STLSTR_cap_off); char * temp = new char[capacity+1]; // read data from inside the string structure diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 2ad78361e..608e7b663 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -402,19 +402,23 @@ bool Materials::ReadCreatureTypesEx (void) p->readSTLString (caste_start + sizeof_string, caste.singular, sizeof(caste.singular)); p->readSTLString (caste_start + 2 * sizeof_string, caste.plural, sizeof(caste.plural)); p->readSTLString (caste_start + 3 * sizeof_string, caste.adjective, sizeof(caste.adjective)); + cout << "Caste " << caste.rawname << " " << caste.singular << ": 0x" << hex << caste_start << endl; if(have_advanced) { /* color mod reading */ + // Caste + offset > color mod vector DfVector p_colormod(p, 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 p_colorlist(p, p_colormod[k]); sizecolorlist = p_colorlist.size(); caste.ColorModifier[k].colorlist.resize(sizecolorlist); for(uint32_t l = 0; l < sizecolorlist; l++) caste.ColorModifier[k].colorlist[l] = p_colorlist[l]; + // color mod [color_modifier_part_offset] = string part p->readSTLString( p_colormod[k] + color_modifier_part_offset, caste.ColorModifier[k].part, sizeof(caste.ColorModifier[k].part)); caste.ColorModifier[k].startdate = p->readDWord( p_colormod[k] + color_modifier_startdate_offset ); caste.ColorModifier[k].enddate = p->readDWord( p_colormod[k] + color_modifier_enddate_offset ); diff --git a/tools/playground/SegmentedFinder.h b/tools/playground/SegmentedFinder.h index c50cc4c6f..98de87711 100644 --- a/tools/playground/SegmentedFinder.h +++ b/tools/playground/SegmentedFinder.h @@ -311,4 +311,11 @@ bool findString (SegmentedFinder* s, uint32_t *addr, const char * compare ) return false; } +bool findStrBuffer (SegmentedFinder* s, uint32_t *addr, const char * compare ) +{ + if(strcmp((const char *)addr, compare) == 0) + return true; + return false; +} + #endif // SEGMENTED_FINDER_H \ No newline at end of file diff --git a/tools/playground/incrementalsearch.cpp b/tools/playground/incrementalsearch.cpp index 68ce20014..918577944 100644 --- a/tools/playground/incrementalsearch.cpp +++ b/tools/playground/incrementalsearch.cpp @@ -482,6 +482,22 @@ void FindPtrVectorsByObjectAddress(DFHack::ContextManager & DFMgr, vector & ranges) +{ + vector found; + string select; + while (Incremental(found,"buffer",select,"buffer","buffers")) + { + DFMgr.Refresh(); + DFHack::Context * DF = DFMgr.getSingleContext(); + DF->Attach(); + SegmentedFinder sf(ranges,DF); + sf.Find< const char * ,uint32_t>(select.c_str(),1,found, findStrBuffer); + DF->Detach(); + } +} + + void FindStrings(DFHack::ContextManager & DFMgr, vector & ranges) { @@ -799,12 +815,13 @@ int main (void) string prompt = "Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n" " 4=string, 5=automated offset search, 6=vector by address in its array,\n" - " 7=pointer vector by address of an object, 8=vector>first object>string\n"; + " 7=pointer vector by address of an object, 8=vector>first object>string\n" + " 9=string buffers\n"; int mode; do { getNumber(prompt,mode, 1, false); - } while (mode < 1 || mode > 8 ); + } while (mode < 1 || mode > 9 ); switch (mode) { case 1: @@ -838,6 +855,10 @@ int main (void) DF->Detach(); FindVectorByFirstObjectRawname(DFMgr, selected_ranges); break; + case 9: + DF->Detach(); + FindStrBufs(DFMgr, selected_ranges); + break; default: cout << "not implemented :(" << endl; }