Skip to content

Commit 1d1eccb

Browse files
committed
Merge branch 'dev' of https://github.com/kernelwernel/VMAware into dev
2 parents 94ebb79 + 931d8b7 commit 1d1eccb

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

src/vmaware.hpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,32 @@
219219

220220
#ifndef __VMAWARE_DEBUG__
221221
#if defined(_DEBUG) /* MSVC Debug */ \
222+
|| defined(DEBUG) /* user or build-system */
223+
#define __VMAWARE_DEBUG__
224+
#if defined(_DEBUG) /* MSVC Debug */ \
222225
|| defined(DEBUG) /* user or build-system */
223226
#define __VMAWARE_DEBUG__
224227
#endif
225228
#endif
229+
#endif
226230

231+
#if defined(_WIN32) || defined(_WIN64)
227232
#if defined(_WIN32) || defined(_WIN64)
228233
#ifndef WIN32_LEAN_AND_MEAN
229234
#define WIN32_LEAN_AND_MEAN
235+
#define WIN32_LEAN_AND_MEAN
230236
#endif
231237

238+
232239
#define WINDOWS 1
233240
#define LINUX 0
234241
#define APPLE 0
242+
#elif (defined(__linux__))
235243
#elif (defined(__linux__))
236244
#define WINDOWS 0
237245
#define LINUX 1
238246
#define APPLE 0
247+
#elif (defined(__APPLE__) || defined(__APPLE_CPP__) || defined(__MACH__) || defined(__DARWIN))
239248
#elif (defined(__APPLE__) || defined(__APPLE_CPP__) || defined(__MACH__) || defined(__DARWIN))
240249
#define WINDOWS 0
241250
#define LINUX 0
@@ -248,68 +257,96 @@
248257

249258
#ifdef _MSC_VER
250259
#define MSVC 1
260+
#define MSVC 1
251261
#endif
252262

253263
#if defined(_MSVC_LANG)
254264
#define VMA_CPLUSPLUS _MSVC_LANG
265+
#else
255266
#else
256267
#define VMA_CPLUSPLUS __cplusplus
257268
#endif
269+
#endif
258270

259271
#if VMA_CPLUSPLUS >= 202302L
260272
#define VMA_CPP 23
261273
#elif VMA_CPLUSPLUS >= 202002L
262274
#define VMA_CPP 20
275+
#define VMA_CPP 20
263276
#elif VMA_CPLUSPLUS >= 201703L
264277
#define VMA_CPP 17
278+
#define VMA_CPP 17
265279
#elif VMA_CPLUSPLUS >= 201402L
266280
#define VMA_CPP 14
281+
#define VMA_CPP 14
267282
#elif VMA_CPLUSPLUS >= 201103L
268283
#define VMA_CPP 11
284+
#define VMA_CPP 11
269285
#elif VMA_CPLUSPLUS >= 199711L
270286
#define VMA_CPP 98 /* C++98 or C++03 */
287+
#define VMA_CPP 98 /* C++98 or C++03 */
271288
#else
272289
#error "Unsupported C++ standard (pre-C++98 or unknown)."
273290
#endif
291+
#endif
274292

275293
#if (VMA_CPP < 11 && !WINDOWS)
276294
#error "VMAware only supports C++11 or above, set your compiler flag to '-std=c++20' for gcc/clang, or '/std:c++20' for MSVC"
277295
#endif
278296

297+
#if defined(__x86_64__) || defined(_M_X64)
298+
#endif
299+
279300
#if defined(__x86_64__) || defined(_M_X64)
280301
#define x86_64 1
302+
#else
281303
#else
282304
#define x86_64 0
283305
#endif
284306

285307
#if defined(__i386__) || defined(_M_IX86)
286308
#define x86_32 1
309+
#else
287310
#else
288311
#define x86_32 0
289312
#endif
290313

291314
#if x86_32 || x86_64
292315
#define x86 1
316+
#define x86 1
293317
#else
294318
#define x86 0
295319
#endif
320+
#endif
296321

297322
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__ARM_LINUX_COMPILER__)
298323
#define ARM64 1
324+
#define ARM64 1
299325
#else
300326
#define ARM64 0
301327
#endif
328+
#endif
302329

303330
#if (defined(__arm__) || defined(_M_ARM)) && !ARM64
304331
#define ARM32 1
332+
#else
305333
#else
306334
#define ARM32 0
307335
#endif
336+
#endif
308337

338+
#if ARM32 || ARM64
309339
#if ARM32 || ARM64
310340
#define ARM 1
311341
#else
312342
#define ARM 0
343+
#define ARM 0
344+
#endif
345+
346+
#if (!APPLE && (VMA_CPP >= 20) && (!CLANG || __clang_major__ >= 16))
347+
#define SOURCE_LOCATION_SUPPORTED 1
348+
#else
349+
#define SOURCE_LOCATION_SUPPORTED 0
313350
#endif
314351

315352
#if (!APPLE && (VMA_CPP >= 20) && (!CLANG || __clang_major__ >= 16))
@@ -321,20 +358,28 @@
321358
#if defined(__clang__)
322359
#define GCC 0
323360
#define CLANG 1
361+
#define GCC 0
362+
#define CLANG 1
324363
#elif defined(__GNUC__)
325364
#define GCC 1
326365
#define CLANG 0
366+
#define GCC 1
367+
#define CLANG 0
327368
#else
328369
#define GCC 0
329370
#define CLANG 0
371+
#define GCC 0
372+
#define CLANG 0
330373
#endif
331374

332375
#if !(defined(WINDOWS) || defined(LINUX) || defined(APPLE))
333376
#warning "Unknown OS detected, tests will be severely limited"
377+
#warning "Unknown OS detected, tests will be severely limited"
334378
#endif
335379

336380
#if (VMA_CPP >= 23)
337381
#include <limits>
382+
#include <limits>
338383
#endif
339384
#if (VMA_CPP >= 20)
340385
#include <bit>
@@ -348,6 +393,7 @@
348393
#include <system_error>
349394
#endif
350395
#ifdef __VMAWARE_DEBUG__
396+
#include <iomanip>
351397
#include <iomanip>
352398
#include <ios>
353399
#include <locale>
@@ -385,7 +431,20 @@
385431
#include <devpkey.h>
386432
#include <devguid.h>
387433
#include <winevt.h>
434+
#include <windows.h>
435+
#include <intrin.h>
436+
#include <winioctl.h>
437+
#include <winternl.h>
438+
#include <powerbase.h>
439+
#include <setupapi.h>
440+
#include <initguid.h>
441+
#include <devpkey.h>
442+
#include <devguid.h>
443+
#include <winevt.h>
388444

445+
#pragma comment(lib, "setupapi.lib")
446+
#pragma comment(lib, "powrprof.lib")
447+
#pragma comment(lib, "mincore.lib")
389448
#pragma comment(lib, "setupapi.lib")
390449
#pragma comment(lib, "powrprof.lib")
391450
#pragma comment(lib, "mincore.lib")
@@ -11112,6 +11171,7 @@ struct VM {
1111211171
*/
1111311172
static bool check(
1111411173
const enum_flags flag_bit
11174+
#if (SOURCE_LOCATION_SUPPORTED)
1111511175
#if (SOURCE_LOCATION_SUPPORTED)
1111611176
, [[maybe_unused]] const std::source_location& loc = std::source_location::current()
1111711177
#endif
@@ -11511,6 +11571,7 @@ struct VM {
1151111571
const u8 percent,
1151211572
bool(*detection_func)()
1151311573
#if (SOURCE_LOCATION_SUPPORTED)
11574+
#if (SOURCE_LOCATION_SUPPORTED)
1151411575
, const std::source_location& loc = std::source_location::current()
1151511576
#endif
1151611577
) {
@@ -11708,6 +11769,7 @@ struct VM {
1170811769
static void modify_score(
1170911770
const enum_flags flag,
1171011771
const u8 percent
11772+
#if (SOURCE_LOCATION_SUPPORTED)
1171111773
#if (SOURCE_LOCATION_SUPPORTED)
1171211774
, const std::source_location& loc = std::source_location::current()
1171311775
#endif

0 commit comments

Comments
 (0)