-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemoryapi.h
57 lines (47 loc) · 1.61 KB
/
memoryapi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef MEMORYAPI_H
#define MEMORYAPI_H
#include <QObject>
#include <QByteArray>
#include <QVector>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QDataStream>
#include <QDebug>
class MemoryRange;
class MemoryAPI
{
public:
MemoryAPI(){}
MemoryAPI(QString pathDump, QString pathIDX);
quint32 readPtr (const quint32 offset);
qint32 readInt (const quint32 offset);
float readFloat (const quint32 offset);
QString readStringAscii(const quint32 offset, const quint32 size);
QString readArmaString(quint32 offset);
void loadIDX (QString path);
void loadDump (QString path);
private:
QVector <MemoryRange> memoryRelations;
quint32 convertVirtToPhys(const quint32 virt) const;
QByteArray readVirtMem(const quint32 baseAddr, const quint32 size);
QFile dumpFile;
};
class MemoryRange
{
public:
MemoryRange() {}
MemoryRange(quint32 virt, quint32 phys, quint32 len) : baseVirtualAddress(virt), basePhysicalAddress(phys), size(len) {}
bool inRange(quint32 addr) const { return (addr >= baseVirtualAddress) && (addr < baseVirtualAddress + size); }
quint32 getVirtualAddress() const{ return baseVirtualAddress; }
quint32 getPhysicalAddress() const { return basePhysicalAddress; }
quint32 getSize()const { return size; }
void setVirtualAddress(quint32 addr){ baseVirtualAddress = addr; }
void setPhysicalAddress(quint32 addr){ basePhysicalAddress = addr; }
void setSize(quint32 len){ size = len; }
private:
quint32 baseVirtualAddress;
quint32 basePhysicalAddress;
quint32 size;
};
#endif // MEMORYAPI_H