develop
Petr Mrázek 2010-06-18 01:07:54 +02:00
parent c53b643886
commit 893deb73df
1 changed files with 51 additions and 23 deletions

@ -36,40 +36,68 @@ class holder
class address class address
{ {
public: public:
uint64_t addr_; uint64_t addr_;
unsigned int valid : 1; unsigned int valid : 1;
virtual void print(SegmentedFinder& sff) virtual void print(SegmentedFinder& sff)
{ {
cout << hex << "0x" << addr_ << endl; cout << hex << "0x" << addr_ << endl;
}; };
address(const uint64_t addr) address(const uint64_t addr)
{ {
addr_ = addr; addr_ = addr;
valid = false; valid = false;
} }
address & operator=(const uint64_t in) virtual address & operator=(const uint64_t in)
{ {
addr_ = in; addr_ = in;
valid = false; valid = false;
return *this; return *this;
} }
bool isValid(SegmentedFinder& sff) virtual bool isValid(SegmentedFinder& sff)
{
if(valid) return true;
if(sff.getSegmentForAddress(addr_))
{ {
if(valid) return true; valid = 1;
if(sff.getSegmentForAddress(addr_))
{
valid = 1;
}
} }
}
virtual bool equals (SegmentedFinder & sf, address & rhs)
{
return rhs.addr_ == addr_;
}
}; };
// pointer to a null-terminated byte string
class Cstr: public address class Cstr: public address
{ {
void print(SegmentedFinder & sf) void print(SegmentedFinder & sf)
{ {
cout << hex << "0x" << addr_ << ": \"" << sf.Translate<char>(addr_) << "\"" << endl; cout << hex << "0x" << addr_ << ": \"" << sf.Translate<char>(addr_) << "\"" << endl;
} }
bool equals(SegmentedFinder & sf,const char * rhs)
{
uint32_t addr2 = *(sf.Translate<uint32_t>(addr_));
return strcmp(sf.Translate<const char>(addr2), rhs) == 0;
}
template <class Predicate, class inType>
bool equalsP(SegmentedFinder & sf,inType rhs)
{
return Predicate(addr_, sf, rhs);
}
bool isValid(SegmentedFinder& sf)
{
if (address::isValid(sf))
{
// read the pointer
uint32_t addr2 = *(sf.Translate<uint32_t>(addr_));
// is it a real pointer? a pretty weak test, but whatever.
if(sf.getSegmentForAddress(addr2))
return true;
}
return false;
}
}; };
// STL STRING // STL STRING
#ifdef LINUX_BUILD #ifdef LINUX_BUILD
class STLstr: public address class STLstr: public address