-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.h
More file actions
444 lines (392 loc) · 14.2 KB
/
config.h
File metadata and controls
444 lines (392 loc) · 14.2 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
#ifndef _CONFIG_H
#define _CONFIG_H
// Return values enum
enum class OpResult {
Success,
SuccessPartial,
FailIncompleteData,
FailLoadLib,
FailFreeLib,
FailInterlockedIncrement,
FailInterlockedDecrement,
FailRtlInitUnicodeString,
FailDisablePrivilege,
FailEnablePrivilege,
FailNoPtr,
FailBadReadPtr,
FailAlloc,
FailConversion,
FailGetFunctionPtr,
FailInitializeSecurityDescriptor,
FailSetSecurityDescriptorDacl,
FailSetSecurityDescriptorSacl,
FailSetSecurityDescriptorOwner,
FailSetSecurityDescriptorGroup,
FailNoBuffer,
FailBifferRead,
FailBifferWrite,
FailFileRead,
FailFileWrite,
FailFileClose,
FailFileCopy,
FailFileDelete,
FailCloseHandle,
FailPathIncorrect,
FailSamePath,
FailPathNotExist,
FailPathExist,
FailGetFileSize,
FailDetermineFolderOrFile,
FailNotFolder,
FailNotFile,
FailCouldNotDetermineFolderFile,
FailCkeckAttribotes,
FailCalcHash,
FailRemoveObject,
FailFileHsndleIncorrect,
ACLFailConvertObjectToString = 100,
ACLFailConvertStringToObject,
ACLFailGetSecurityDescriptorDACL,
ACLFailGetSecurityDescriptorSACL,
ACLFailDACLMissing,
ACLFailSACLMissing,
ACLFailGetOwner,
ACLFaiIGetSecurityDescriptor,
ACLFailSetSecurityDescriptorOwner,
ACLFailSetSecurityDescriptorDACL,
ACLFailSetSecurityDescriptorSACL,
ACLFailDACLRemoveACESID,
ACLFailGetACE,
ACLFailAddACE,
ACLFailInitACL,
ACLFailGetAclInformation,
ACLFailCreateAbsoluteSD,
ACLFailMakeAbsoluteSD,
ACLFailMakeSelfRelativeSD,
ACLFailIncorrectACLData,
ACLFailACETypeUnrecognized,
ACLFailBuildACE,
CompressFailSetCompressor = 200,
CompressFailGetCompressedBufferSize,
CompressFailGetDecompressedBufferSize,
CompressFailCompress,
CompressFailDecompress,
CompressFailCreateID,
CompressFailCreateStrID,
CompressFailIncorrectCompressor,
CompressFailCompressorNotAllowed,
CompressFailResourceSozrRxceeded,
CompressFailNotAllowedChar,
CryptFailCalcBufferHash = 300,
CryptFailCalcFileHash,
FSFailRemoveFolder = 400,
FSFailRenoveFile,
FSFailGetVolumeNameForVolumeMountPoint,
FSFailFindVolumeClose,
FSFailInvalidFileAttributes,
FSFailCreateDirectory,
FSFailSHFileOperation,
FSFailGetDriveSpace,
FSFailGetFolderSizeOnDrive,
FSFailNotEnoughSpace,
FSFailRename,
FSFailSetFileSecurity,
FSFailNTCreateFile,
FSFailNTCreateEvent,
FSFailNTClearEvent,
FSSFailGetDriveGeometry,
NetFailIncorrectAddress = 500,
NetFailLookupIPV4Address,
NetFailLookupIPV4Addresses,
NetFailWSAStartup,
NetFailWSACleanup,
NetFailPing,
NetFailIPV6NotAvailable,
NetFailGetHostByNameHostNotFound,
NetFailGetHostByNameNoAddress,
NetFailGetHostByNameNoRecovery,
NetFailGetHostByNameTryAgain,
NetFailGetAddrInfo,
NetFailNoResult,
ProcFailInvalidHandle = 600,
rocFailCreateProcess,
ProcFailListProcs,
ProcFailEnumThreads,
ProcFailGetTokenInformation,
ProcFailLookupPrivilegeName,
ProcFailCreatePipe,
ProcFailSetHandleInformation,
ProcFailFindWindow,
ProcFailGetWindowThreadProcessId,
ProcFailCommonFail,
SvcFailInvalidHandle = 800,
SvcFailEnumSvcs,
SvcFailInsrall,
SvcFailRemove,
SvcFailStart,
SvcFailStartAlreadyStarted,
SvcFailStop,
SvcFailStopAlreadyStopped,
SvcFailObtainSCMHandle,
SysFailrRunCommandPiped,
SysFailNoRunCommandPipedOutput,
SysFailParseQWInstaOutput,
Fail
};
enum class BinPlatform : unsigned char {
DOS,
OSdiv2,
Unix,
Windows,
PlatformUnknown
};
enum class BinBitDepth : unsigned char {
X16,
X32,
X64,
BitDepthUnknown
};
// #define _GLIBCXX_USE_C99
// Common Defines
typedef long NTSTATUS;
#define ARFUNX
#if defined(_MSC_VER)
#define hminline __forceinline
#else
#define hminline inline
#endif
// Macro Defines
// malloc with ease
#define MALLOC_NULLIFY(x, type, sz) type* x = (type*)malloc(sz); if(x) { *x = { 0 }; }
// malloc with ease
#define MALLOC_NULLIFY_MS(x, type, sz) type* x = (type*)malloc(sz * sizeof(type)); \
if(x) { memset(x, 0, sz * sizeof(type)); }
// malloc with ease
#define MALLOC_NULLIFY_NO_REDEFINE(x, type, sz) x = (type*)malloc(sz); if(x) { *x = { 0 }; }
// malloc with ease
#define MALLOC_NULLIFY_NO_REDEFINE_NO_CONV(x, sz) x = malloc(sz); if(x) { *x = { 0 }; }
// new with ease
#define NEW_NULLIFY(x, type) type* x = 0; x = new type; if(x) { *x = { 0 }; }
// new with ease
#define NEW_ARR_NULLIFY_NO_REDEFINE(x, type, sz) x = new type[sz]; if(x) { *x = { 0 }; }
// new with ease
#define NEW_ARR_NULLIFY(x, type, sz) type* x = 0; x = new type[sz]; if(x) { *x = { 0 }; }
// new with ease
#define NEW_ARR_NULLIFY_MS(x, type, sz) type* x = 0; x = new type[sz]; if(x) { memset(x, 0, sz * sizeof(type)); }
// new with ease
#define NEW_ARR_NULLIFY_ET(x, type, sz) type x = 0; x = new type[sz]; if(x) { *x = { 0 }; }
// safety first! no errors trying to at least delete this pointer further
#define SAFE_DELETE(x) delete x; x = 0
// safety first! no errors trying to at least delete this pointer further
#define SAFE_ARR_DELETE(x) delete[] x; x = 0
// safety first! no errors trying to at least free this pointer further
#define SAFE_FREE(x) free(x); x = 0
// safety first! no errors trying to at least free this pointer further
#define SAFE_NetApiBufferFree(x) ::NetApiBufferFree(x); x = 0
// safety first! no errors trying to at least free this pointer further
#define SAFE_LOCALFREE(x) ::LocalFree((::HLOCAL)x); x =0
// can be used for short, unsigned short, word, unsigned word (2-byte types)
#define BYTESWAP16(n) (((n&0xFF00)>>8)|((n&0x00FF)<<8))
// can be used for int or unsigned int or float (4-byte types)
#define BYTESWAP32(n) ((BYTESWAP16((n&0xFFFF0000)>>16))|((BYTESWAP16(n&0x0000FFFF))<<16))
// can be used for unsigned long long or double (8-byte types)
#define BYTESWAP64(n) ((BYTESWAP32((n&0xFFFFFFFF00000000)>>32))|((BYTESWAP32(n&0x00000000FFFFFFFF))<<32))
#define RtlPointerToOffset(B,P) ((unsigned long)( ((char*)(P)) - ((char*)(B))) )
#define NtCurrentThread() ((::HANDLE)(unsigned long long) - 2)
#ifdef _UNICODE
#define ResType2Str(a) (wchar_t*)a
#else
#define ResType2Str(a) (char*)a
#endif
//#ifndef _NTPSAPI_H
// // Processes
// #if (PHNT_MODE != PHNT_MODE_KERNEL)
// #define NtCurrentThread() ((HANDLE)(LONG_PTR)-2)
// #endif
//#endif
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#ifndef _MSC_VER
#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(((unsigned long long)(a)) & 0xFF)) | ((unsigned short)((unsigned char)(((unsigned long long)(b)) & 0xFF))) << 8))
#define MAKELONG(a, b) ((long)(((unsigned short)(((unsigned long long)(a)) & 0xFFFF)) | ((unsigned long)((unsigned short)(((unsigned long long)(b)) & 0xFFFF))) << 16))
#define LOWORD(l) ((unsigned short)(((unsigned long long)(l)) & 0xFFFF))
#define HIWORD(l) ((unsigned short)((((unsigned long long)(l)) >> 16) & 0xFFFF))
#define LOBYTE(w) ((unsigned char)(((unsigned long long)(w)) & 0xFF))
#define HIBYTE(w) ((unsigned char)((((unsigned long long)(w)) >> 8) & 0xFF))
#endif
// C++ version
/* With MSVS build with flags:
/std:c++latest /Zc:__cplusplus
Project properties => C/C++ => Command Line => Additional flags */
#if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
#if (__cplusplus == 202101L)
#define STDVER 23
#elif (__cplusplus == 202002L) || (__cplusplus == 202004L)
#define STDVER 20
#elif (__cplusplus == 201703L)
#define STDVER 17
#elif (__cplusplus == 201402L)
#define STDVER 14
#elif (__cplusplus == 201103L)
#define STDVER 11
#elif (__cplusplus == 199711L)
#define STDVER 98
#endif
#endif
// Disable warnings
#pragma warning(disable : 4244)
#pragma warning(disable : 4996)
// Libs
#if (defined(_WIN32) || defined(_WIN64))
#pragma comment(lib, "Wtsapi32.lib")
#pragma comment(lib, "Rstrtmgr.lib")
#pragma comment(lib, "Secur32.lib")
#pragma comment(lib, "Kernel32.lib")
#pragma comment(lib, "Wininet.lib")
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "Dnsapi.lib")
#pragma comment(lib, "netapi32.lib")
#pragma comment(lib, "Advapi32.lib")
#pragma comment(lib, "wbemuuid.lib")
#pragma comment(lib, "Propsys.lib")
#pragma comment(lib, "Shlwapi.lib")
#endif
// FSHelper Defines
#ifdef _WIN64
#define ftellc _ftelli64
#define fseekc _fseeki64
#define ftellsztype __int64
#define fseeksztype __int64
#else
#define ftellc ftell
#define fseekc fseek
#define ftellsztype long
#define fseeksztype long
#endif
#define DE_SAMEFILE 0x71
#define DE_MANYSRC1DEST 0x72
#define DE_DIFFDIR 0x73
#define DE_ROOTDIR 0x74
#define DE_OPCANCELLED 0x75
#define DE_DESTSUBTREE 0x76
#define DE_ACCESSDENIEDSRC 0x78
#define DE_PATHTOODEEP 0x79
#define DE_MANYDEST 0x7A
#define DE_INVALIDFILES 0x7C
#define DE_DESTSAMETREE 0x7D
#define DE_FLDDESTISFILE 0x7E
#define DE_FILEDESTISFLD 0x80
#define DE_FILENAMETOOLONG 0x81
#define DE_DEST_IS_CDROM 0x82
#define DE_DEST_IS_DVD 0x83
#define DE_DEST_IS_CDRECORD 0x84
#define DE_FILE_TOO_LARGE 0x85
#define DE_SRC_IS_CDROM 0x86
#define DE_SRC_IS_DVD 0x87
#define DE_SRC_IS_CDRECORD 0x88
#define DE_ERROR_MAX 0xB7
#define DE_UNKNOWN 0x402
#define DE_ERRORONDEST 0x10000
#define DE_CANTRENAME 0x10074
#define WM_USER 0x0400
// StrHelper defines
#define STR_DIRECTCONV
#define FSH_SHORTNAMELENGTH 12 // symbols
#define FSH_PHYSDRIVEBUFLEN 256
#define FSH_FULLPHYSDRIVESTRING
#define STATUS_SUCCESS (NTSTATUS)0x00000000L
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
#define FILE_OPEN 0x00000001
#define FILE_OPEN_BY_FILE_ID 0×00002000
#define OBJ_CASE_INSENSITIVE 0x00000040L
#define OBJ_EXCLUSIVE 0x00000020L
#define OBJ_KERNEL_HANDLE 0x00000200L
#define FILE_DIRECTORY_FILE 0x00000001
#define FILE_NON_DIRECTORY_FILE 0x00000040
#define FSH_TEMPBUFSZ 2048
#define FSH_SBBUFSZ 512
#define FSH_MAXFILEPATH 8192
#ifdef _WIN64
#define FSH_READBUFSZ 65536
#else
#define FSH_READBUFSZ 32768
#endif
#ifdef _WIN64
#define FSH_WRITEBUFSZ 20 // 65536
#else
#define FSH_WRITEBUFSZ 32768
#endif
#define InitializeObjectAttributes( p, n, a, r, s ) { \
(p)->uLength = sizeof( ObjectAttributes ); \
(p)->hRootDirectory = r; \
(p)->uAttributes = a; \
(p)->pObjectName = n; \
(p)->pSecurityDescriptor = s; \
(p)->pSecurityQualityOfService = 0; \
}
// Prochelper defines
#define PH_OUTCMDBUFSIZE 4096
// NetHelper Defines
#ifdef _DEBUG
#define DNSHELPER_SHOWERRORMSGBOX
#endif
// Syshelprr defines
#define SH_STRBUFSZ 1024
#define STATUS_PRIVILEGE_NOT_HELD 0xC0000061
#define STATUS_BUFFER_TOO_SMALL 0xC0000023
// Hardware getter defines
#define HW_LINESDRIVE 2
#define HW_LINESCOMMON 4
// DBHelper defines
// max database connections
#define MSSQLNULLSIZE 6
#define MSSQLMAXCONN 64
#define MSSQLDISPLAYMAX 64
#define MSSQLDISPLAYFORMATEXTRA 3 // Per column extra display bytes (| <data> )
#define MSSQLDISPLAYFORMAT L"%c %*.*s "
#define MSSQLDISPLAYFORMATC L"%c %-*.*s "
// min connection out buffer size, symbols
#define MSSQLMINOUTBUF 1024
// max connection out buffer size, symbols
#define MSSQLMAXOUTBUF 2048
#define MSSQLMAXINFOBUF 1024
#define MSSQLCONNTOOMANY -1
// WMI Helper defines
#undef WH_SKIPARRAYS
#define WH_SKIPEMPTYVALS
#define WH_TRIMDATA
#define WH_MIMAWAITTIMEOUT 500
#define WH_MAXAWAITTIMEOUT 3000
#define WH_ARRAYELBUF 1024
// Compress Helper defines
#define COMPRESS_BLOSC_INVALIDVAL -1
#define COMPRESS_BLOSC_COMPRESSLVLMIN 0
#define COMPRESS_BLOSC_COMPRESSLVLMAX 9
#define COMPRESS_BLOSC_TYPESZMIN 1
#define COMPRESS_BLOSC_TYPESZMAX 256
#define COMPRESS_BLOSC_THREADSMIN 1
#define COMPRESS_BLOSC_THREADSMAX 12
#define COMPRESS_BLOSC_MAXBLOCKSZ 4096
#define COMPRESS_MAX_RESOURCESZ 209715200 // 200 mb
#define COMPRESS_PWDMAXLEN 16 // symbols
#define COMPRESS_RESOURCEIDMAXIDLEN 16 // symbols
#define COMPRESS_PWDLENMIN 6 // symbols
#define COMPRESS_PWDLENMAX 32 // symbols
#define COMPRESS_MAXRESOURCES 200000
#define COMPRESS_MINCONTAINERID 100000
#define COMPRESS_MAXCONTAINERID (COMPRESS_MINCONTAINERID + COMPRESS_MAXRESOURCES)
#define COMPRESS_MINRESOURCEID (100000 + COMPRESS_MAXCONTAINERID)
#define COMPRESS_MAXRESOURCEID (COMPRESS_MAXRESOURCES + COMPRESS_MINRESOURCEID)
#define COMPRESS_MINHEADERID (100000 + COMPRESS_MAXRESOURCEID)
#define COMPRESS_MAXHEADERID (COMPRESS_MAXRESOURCES + COMPRESS_MIHEADERID)
#define COMPRESS_STRID_MAXCHARS 8
#define COMPRESS_ID_STRUCT_MIN 0
#define COMPRESS_ID_STRUCT_MAX 1000
#define COMPRESS_ID_RESOURCE_MIN 1001
#define COMPRESS_ID_RESOURCE_MAX 64000
// Crypthelper defines
#define CH_MAXLENMD5 32
#define CH_MAXLENSHA1 40
#define CH_MAXLENSHA256 64
#endif // _CONFIG_H