summaryrefslogtreecommitdiff
path: root/Database
diff options
context:
space:
mode:
Diffstat (limited to 'Database')
-rw-r--r--Database/database-types.h1
-rw-r--r--Database/database.h6
-rw-r--r--Database/internals/database-internal.cpp8
-rw-r--r--Database/internals/database-internal.h4
-rw-r--r--Database/internals/database-segment.h1
5 files changed, 15 insertions, 5 deletions
diff --git a/Database/database-types.h b/Database/database-types.h
index 49db9b8..8ea61e6 100644
--- a/Database/database-types.h
+++ b/Database/database-types.h
@@ -40,6 +40,7 @@ typedef union {
static inline Uint32 SEGID(absolute_ptr ptr) { return ptr.segment_id; }
static inline Uint32 SEGOFFSET(absolute_ptr ptr) { return ptr.ptr; }
+static inline absolute_ptr ABSPTR(Uint32 id, Uint32 ptr) { absolute_ptr r; r.segment_id = id; r.ptr = ptr; return r; }
/** A function description.
*/
diff --git a/Database/database.h b/Database/database.h
index be46598..222573d 100644
--- a/Database/database.h
+++ b/Database/database.h
@@ -22,6 +22,12 @@ class Database : public Base {
return 0;
}
Uint32 GetNextSegId() { return currentId++; }
+ Segment * CreateSegment(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size = 0, const Byte * data = 0) {
+ DatabaseCell * r = new DatabaseCell(this, cpu, cpu_base, origin, size, extra_size, data);
+ return r->getSegment();
+ }
+ void Serialize(Handle * out);
+ void Deserialize(Handle *in);
private:
DatabaseCell * start, * end;
Uint32 currentId;
diff --git a/Database/internals/database-internal.cpp b/Database/internals/database-internal.cpp
index e564c01..ce54f44 100644
--- a/Database/internals/database-internal.cpp
+++ b/Database/internals/database-internal.cpp
@@ -1,14 +1,16 @@
#include "database-internal.h"
#include "database.h"
-DatabaseCell::DatabaseCell(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, DatabaseCell * prev, Database * parent) : cpu(cpu), next(0), prev(prev), parent(parent) {
- prev->next = this;
+DatabaseCell::DatabaseCell(Database * parent, Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, const Byte * data) : cpu(cpu), next(0), parent(parent) {
+ prev = parent->getEnd();
+ if (prev)
+ prev->next = this;
parent->setEnd(this);
if (origin.raw_ptr) {
Segment * origin_seg = parent->getSegment(SEGID(origin));
segment = new Segment(size, cpu_base, parent->GetNextSegId(), extra_size, origin_seg->getPristineMemory() + SEGOFFSET(origin));
} else {
- segment = new Segment(size, cpu_base, parent->GetNextSegId(), extra_size);
+ segment = new Segment(size, cpu_base, parent->GetNextSegId(), extra_size, data);
}
}
diff --git a/Database/internals/database-internal.h b/Database/internals/database-internal.h
index 173eb62..4616d8c 100644
--- a/Database/internals/database-internal.h
+++ b/Database/internals/database-internal.h
@@ -17,9 +17,9 @@ class DatabaseCell : public Base {
public:
/** The constructor of a DatabaseCell. Note that if you specify the origin parameter,
* it'll create a sub-segment based on the first one. Note also that this doesn't support
- * the patching system, yet.
+ * the patching system, yet. data and origin are mutually exclusive.
*/
- DatabaseCell(Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size, DatabaseCell * prev, Database * parent);
+ DatabaseCell(Database * parent, Cpu * cpu, Uint64 cpu_base, absolute_ptr origin, Uint32 size, Uint32 extra_size = 0, const Byte * data = 0);
~DatabaseCell();
Uint32 getId() { return segment->getId(); }
void LoadMemory(Handle * src) { segment->LoadMemory(src); }
diff --git a/Database/internals/database-segment.h b/Database/internals/database-segment.h
index f01ac38..dc4d157 100644
--- a/Database/internals/database-segment.h
+++ b/Database/internals/database-segment.h
@@ -44,6 +44,7 @@ class Segment : public Base {
* @return the memory block of the segment.
*/
const Byte * getPristineMemory() { return plainmemory; }
+ const memory_tags_t * getMemoryTags() { return tags; }
void Patch(Uint32 ptr, Byte val);
void Restore(Uint32 ptr);
bool IsPatched(Uint32 ptr);