-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathxmsdos.h
140 lines (122 loc) · 4.45 KB
/
xmsdos.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* Copyright (c) 2017-2021 hors<horsicq@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef XMSDOS_H
#define XMSDOS_H
#include "xbinary.h"
#include "xmsdos_def.h"
class XMSDOS : public XBinary
{
Q_OBJECT
public:
struct MS_RICH_RECORD // For PE and LE
{
quint16 nId;
quint16 nVersion;
quint32 nCount;
};
enum TYPE
{
TYPE_UNKNOWN=0,
TYPE_EXE
// TODO EXTENDER?
};
explicit XMSDOS(QIODevice *pDevice=nullptr,bool bIsImage=false,qint64 nModuleAddress=-1);
virtual bool isValid();
static bool isValid(QIODevice *pDevice,bool bIsImage=false,qint64 nModuleAddress=-1);
static MODE getMode(QIODevice *pDevice,bool bIsImage=false,qint64 nModuleAddress=-1);
quint16 get_magic();
qint32 get_lfanew();
qint64 getDosHeaderOffset();
qint64 getDosHeaderSize();
qint64 getDosHeaderExOffset();
qint64 getDosHeaderExSize();
XMSDOS_DEF::IMAGE_DOS_HEADER getDosHeader();
XMSDOS_DEF::IMAGE_DOS_HEADEREX getDosHeaderEx();
void setDosHeader(XMSDOS_DEF::IMAGE_DOS_HEADER *pDosHeader);
void setDosHeaderEx(XMSDOS_DEF::IMAGE_DOS_HEADEREX *pDosHeaderEx);
void set_e_magic(quint16 nValue);
void set_e_cblp(quint16 nValue);
void set_e_cp(quint16 nValue);
void set_e_crlc(quint16 nValue);
void set_e_cparhdr(quint16 nValue);
void set_e_minalloc(quint16 nValue);
void set_e_maxalloc(quint16 nValue);
void set_e_ss(quint16 nValue);
void set_e_sp(quint16 nValue);
void set_e_csum(quint16 nValue);
void set_e_ip(quint16 nValue);
void set_e_cs(quint16 nValue);
void set_e_lfarlc(quint16 nValue);
void set_e_ovno(quint16 nValue);
void set_e_res(int nPosition,quint16 nValue);
void set_e_oemid(quint16 nValue);
void set_e_oeminfo(quint16 nValue);
void set_e_res2(int nPosition,quint16 nValue);
void set_e_lfanew(quint32 nValue);
quint16 get_e_magic();
quint16 get_e_cblp();
quint16 get_e_cp();
quint16 get_e_crlc();
quint16 get_e_cparhdr();
quint16 get_e_minalloc();
quint16 get_e_maxalloc();
quint16 get_e_ss();
quint16 get_e_sp();
quint16 get_e_csum();
quint16 get_e_ip();
quint16 get_e_cs();
quint16 get_e_lfarlc();
quint16 get_e_ovno();
quint16 get_e_res(int nPosition);
quint16 get_e_oemid();
quint16 get_e_oeminfo();
quint16 get_e_res2(int nPosition);
quint32 get_e_lfanew();
virtual _MEMORY_MAP getMemoryMap();
virtual qint64 getImageSize();
qint64 getModuleAddress();
static QMap<quint64,QString> getImageMagics();
static QMap<quint64,QString> getImageMagicsS();
bool isLE();
bool isLX();
bool isNE();
bool isPE();
// rich for PE and LE
bool isRichSignaturePresent();
QList<XMSDOS::MS_RICH_RECORD> getRichSignatureRecords();
qint32 getNumberOfRichIDs();
qint32 getNumberOfRichIDs(QList<MS_RICH_RECORD> *pListRichSignatureRecords);
bool isRichVersionPresent(quint32 nVersion);
bool isRichVersionPresent(quint32 nVersion,QList<MS_RICH_RECORD> *pListRichSignatureRecords);
// dos stub for LE, NE and PE
qint64 getDosStubSize();
qint64 getDosStubOffset();
QByteArray getDosStub();
bool isDosStubPresent();
virtual MODE getMode();
virtual QString getArch();
virtual bool isBigEndian();
virtual FT getFileType();
virtual qint32 getType();
virtual OSINFO getOsInfo();
virtual QString typeIdToString(int nType);
};
#endif // XMSDOS_H