More search tool stuffs

develop
Petr Mrázek 2010-06-19 18:08:10 +02:00
parent bbb29fe3d5
commit 30db6ad632
2 changed files with 44 additions and 2 deletions

@ -33,8 +33,7 @@ class SegmentFinder
template < class needleType, class hayType, typename comparator > template < class needleType, class hayType, typename comparator >
uint64_t FindInRange (needleType needle, comparator oper, uint64_t start, uint64_t length) uint64_t FindInRange (needleType needle, comparator oper, uint64_t start, uint64_t length)
{ {
mr_.buffer + start - mr_.start; uint64_t stopper = min((mr_.end - mr_.start) - sizeof(hayType), (start - mr_.start) - sizeof(hayType) + length);
uint64_t stopper = min((mr_.end - mr_.start) - sizeof(hayType), (start - mr_.start) - sizeof(hayType));
//loop //loop
for(uint64_t offset = start - mr_.start; offset < stopper; offset +=1) for(uint64_t offset = start - mr_.start; offset < stopper; offset +=1)
{ {
@ -287,6 +286,19 @@ bool vectorAll (SegmentedFinder* s, vecTriplet *x, int )
return false; return false;
} }
struct Bytestream
{
uint32_t length;
void * object;
};
bool findBytestream (SegmentedFinder* s, uint32_t *addr, Bytestream * compare )
{
if(memcmp(addr, compare->object, compare->length) == 0)
return true;
return false;
}
bool findString (SegmentedFinder* s, uint32_t *addr, const char * compare ) bool findString (SegmentedFinder* s, uint32_t *addr, const char * compare )
{ {
// read string pointer, translate to local scheme // read string pointer, translate to local scheme

@ -690,6 +690,36 @@ void automatedLangtables(DFHack::Context * DF, vector <DFHack::t_memrange>& rang
printFoundStrVec(toad_first,"toad-first creature types",sf); printFoundStrVec(toad_first,"toad-first creature types",sf);
printFound(elephant_first,"elephant-first creature types"); printFound(elephant_first,"elephant-first creature types");
printFound(to_filter,"all creature types"); printFound(to_filter,"all creature types");
uint64_t to_use = 0;
if(!elephant_first.empty())
{
to_use = elephant_first[0];
vecTriplet *vtCretypes = sf.Translate<vecTriplet>(to_use);
uint32_t elephant = sf.Read<uint32_t>(vtCretypes->start);
uint64_t Eoffset;
cout << "Elephant: rawname = 0x0" << endl;
Eoffset = sf.FindInRange<uint8_t,uint8_t> ('E',equalityP<uint8_t>, elephant, 0x300 );
if(Eoffset)
{
cout << "Elephant: big E = 0x" << hex << Eoffset - elephant << endl;
}
Eoffset = sf.FindInRange<const char *,vecTriplet> ("FEMALE",vectorStringFirst, elephant, 0x300 );
if(Eoffset)
{
cout << "Elephant: caste vector = 0x" << hex << Eoffset - elephant << endl;
}
//cout << "Amber color:" << hex << "0x" << colorObj << endl;
// TODO: find string 'amber', the floats
}
if(!toad_first.empty())
{
to_use = toad_first[0];
}
if(to_use)
{
}
} }
int main (void) int main (void)