-
Notifications
You must be signed in to change notification settings - Fork 1
/
nabdasm.h
69 lines (58 loc) · 1.36 KB
/
nabdasm.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
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef NABDASM_H
#define NABDASM_H
#include <QCoreApplication>
#include <QMap>
typedef struct
{
int Offset;
QByteArray Bytes;
QString Opcode;
QString Comment;
} Instruction;
typedef struct
{
int Offset;
QByteArray Bytes;
int value;
QString type;
QString toString()
{
if(type == "integer")
return "0x" + hexOutput(value, 8);
else if(type == "false")
return "false";
else if(type == "string")
{
if(QString(Bytes).size() > 30)
return "\""+QString(Bytes).left(30)+"[...]\"";
else
return "\""+QString(Bytes)+"\"";
}
else
return "value";
}
QByteArray hexOutput(unsigned int i, int l)
{
QString s;
QString f = "";
s.setNum(i, 16);
if(l - s.size() > 0)
f.fill('0', l - s.size());
return s.prepend(f).toAscii().toUpper();
}
} Global;
class nabDasm
{
public:
nabDasm(QString, QString);
private:
unsigned int getUInt32(QByteArray);
unsigned int getUInt16(QByteArray);
QByteArray displayString(QByteArray);
QByteArray displayBytes(QByteArray);
QByteArray hexOutput(unsigned int);
QByteArray hexOutput(unsigned int, int);
QByteArray decOutput(unsigned int, int);
QMap<int, Global> globalsList;
};
#endif // NABDASM_H