|
|
@ -30,6 +30,7 @@ distribution.
|
|
|
|
#include "DFPragma.h"
|
|
|
|
#include "DFPragma.h"
|
|
|
|
#include "DFExport.h"
|
|
|
|
#include "DFExport.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DFHack
|
|
|
|
namespace DFHack
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -93,12 +94,16 @@ namespace DFHack
|
|
|
|
uint32_t end;
|
|
|
|
uint32_t end;
|
|
|
|
uint32_t alloc_end;
|
|
|
|
uint32_t alloc_end;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Allows low-level access to the memory of an OS process. OS processes can be enumerated by \ref ProcessEnumerator
|
|
|
|
* Allows low-level access to the memory of an OS process. OS processes can be enumerated by \ref ProcessEnumerator
|
|
|
|
* \ingroup grp_context
|
|
|
|
* \ingroup grp_context
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class DFHACK_EXPORT Process
|
|
|
|
class DFHACK_EXPORT Process
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
std::map<uint32_t, std::string> classNameCache;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
/// this is the single most important destructor ever. ~px
|
|
|
|
/// this is the single most important destructor ever. ~px
|
|
|
|
virtual ~Process(){};
|
|
|
|
virtual ~Process(){};
|
|
|
@ -178,7 +183,14 @@ namespace DFHack
|
|
|
|
/// read a STL vector
|
|
|
|
/// read a STL vector
|
|
|
|
virtual void readSTLVector(const uint32_t address, t_vecTriplet & triplet) = 0;
|
|
|
|
virtual void readSTLVector(const uint32_t address, t_vecTriplet & triplet) = 0;
|
|
|
|
/// get class name of an object with rtti/type info
|
|
|
|
/// get class name of an object with rtti/type info
|
|
|
|
virtual std::string readClassName(uint32_t vptr) = 0;
|
|
|
|
virtual std::string doReadClassName(uint32_t vptr) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string readClassName(uint32_t vptr) {
|
|
|
|
|
|
|
|
std::map<uint32_t, std::string>::iterator it = classNameCache.find(vptr);
|
|
|
|
|
|
|
|
if (it != classNameCache.end())
|
|
|
|
|
|
|
|
return it->second;
|
|
|
|
|
|
|
|
return classNameCache[vptr] = doReadClassName(vptr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// read a null-terminated C string
|
|
|
|
/// read a null-terminated C string
|
|
|
|
virtual const std::string readCString (uint32_t offset) = 0;
|
|
|
|
virtual const std::string readCString (uint32_t offset) = 0;
|
|
|
@ -211,5 +223,20 @@ namespace DFHack
|
|
|
|
virtual bool SetAndWait (uint32_t state) = 0;
|
|
|
|
virtual bool SetAndWait (uint32_t state) = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DFHACK_EXPORT ClassNameCheck {
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
uint32_t vptr;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ClassNameCheck() : vptr(0) {}
|
|
|
|
|
|
|
|
ClassNameCheck(std::string _name) : name(_name), vptr(0) {}
|
|
|
|
|
|
|
|
ClassNameCheck &operator= (const ClassNameCheck &b) {
|
|
|
|
|
|
|
|
name = b.name; vptr = b.vptr; return *this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator() (Process *p, uint32_t ptr) {
|
|
|
|
|
|
|
|
if (vptr == 0 && p->readClassName(ptr) == name)
|
|
|
|
|
|
|
|
vptr = ptr;
|
|
|
|
|
|
|
|
return (vptr && vptr == ptr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|