-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileContext.h
169 lines (124 loc) · 2.82 KB
/
FileContext.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*++
Copyright (c) 2007 - 2017, Matthieu Suiche
Copyright (c) 2012 - 2014, MoonSols Limited
Copyright (c) 2015 - 2017, Comae Technologies FZE
Copyright (c) 2017 - 2018, Comae Technologies DMCC
Module Name:
FileContext.h
Abstract:
This module contains the internal structure definitions and APIs used by
the Hibr2Bin.
Author:
Matthieu Suiche (m) 1-April-2016
Revision History:
--*/
#ifndef __FILE_CXT_H__
#define __FILE_CXT_H__
#define PAGE_SIZE 0x1000
#define MIN_READ_BUFFER_SIZE ((0x10 + 1) * PAGE_SIZE)
enum PlatformType {
PlatformNone = 0,
PlatformX86 = 1, // MACHINE_X86,
PlatformX64 = 2 // MACHINE_AMD64
};
class FileContext {
public:
FileContext()
{
}
FileContext(PlatformType Platform, ULONG Major, ULONG Minor)
{
SetPlatform(Platform);
SetMajorVersion(Major);
SetMinorVersion(Minor);
}
ULONG GetPlatform() { return m_Platform; }
VOID SetPlatform(PlatformType Platform) { m_Platform = Platform; }
ULONG GetMajorVersion() { return m_MajorVersion; }
VOID SetMajorVersion(ULONG MajorVersion) { m_MajorVersion = MajorVersion; }
ULONG GetMinorVersion() { return m_MinorVersion; }
VOID SetMinorVersion(ULONG MinorVersion) { m_MinorVersion = MinorVersion; }
HANDLE GetFileHandle() { return m_FileHandle; }
VOID SetFileHandle(HANDLE Handle) { m_FileHandle = Handle; }
BOOLEAN
OpenFile(
LPCWSTR FileName,
ULONG Type
);
BOOLEAN
OpenFile(
LPCWSTR FileName
) {
return OpenFile(FileName, 0);
}
BOOLEAN
CreateOutputFile(
LPWSTR FileName
);
PVOID
ReadFile(
ULONG64 Offset,
ULONG Size,
PVOID *m_Data
);
BOOLEAN
WriteFile(
PVOID Buffer,
DWORD NbOfBytesToWrite
);
PVOID
GetTempBuffer(
);
BOOLEAN
IsWin8AndAbove(
);
BOOLEAN
IsWin7AndAbove(
);
BOOLEAN
IsVistaAndAbove(
);
BOOLEAN
Is64Bits(
);
BOOLEAN
IsWinXP(
);
BOOLEAN
IsWinXP64(
);
BOOLEAN
IsWinVista(
);
BOOLEAN
IsWin7(
);
BOOLEAN
IsWin8(
);
BOOLEAN
IsWin81(
);
BOOLEAN
IsWin10(
);
VOID
Close(
);
ULONGLONG
GetFileSize(
VOID
);
~FileContext();
private:
PlatformType m_Platform;
ULONG m_MajorVersion;
ULONG m_MinorVersion;
HANDLE m_FileHandle = NULL;
HANDLE m_OutFileHandle = NULL;
PVOID m_ReadedData = NULL;
ULONG m_ReadedDataSize = 0;
PVOID m_PreAllocatedBuffer = NULL;
ULONG m_PreAllocatedBufferSize = MIN_READ_BUFFER_SIZE;
};
#endif