Skip to content

Commit b49517a

Browse files
committed
1.5 release
1 parent a0852dc commit b49517a

3 files changed

Lines changed: 69 additions & 114 deletions

File tree

src/cli.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#include "Windows.h"
3737
#endif
3838

39-
constexpr const char* ver = "1.4";
40-
constexpr const char* date = "May 2024";
39+
constexpr const char* ver = "1.5";
40+
constexpr const char* date = "June 2024";
4141
constexpr const char* bold = "\033[1m";
4242
constexpr const char* ansi_exit = "\x1B[0m";
4343
constexpr const char* red = "\x1B[38;2;239;75;75m";

src/vmaware.hpp

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ██║ ██║██╔████╔██║███████║██║ █╗ ██║███████║██████╔╝█████╗
55
* ╚██╗ ██╔╝██║╚██╔╝██║██╔══██║██║███╗██║██╔══██║██╔══██╗██╔══╝
66
* ╚████╔╝ ██║ ╚═╝ ██║██║ ██║╚███╔███╔╝██║ ██║██║ ██║███████╗
7-
* ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ 1.4 (May 2024)
7+
* ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ 1.5 (June 2024)
88
*
99
* C++ VM detection library
1010
*
@@ -21,14 +21,14 @@
2121
*
2222
*
2323
* ================================ SECTIONS ==================================
24-
* - enums for publicly accessible techniques => line 293
25-
* - struct for internal cpu operations => line 485
26-
* - struct for internal memoization => line 857
27-
* - struct for internal utility functions => line 941
28-
* - struct for internal core components => line 6916
29-
* - start of internal VM detection techniques => line 1686
30-
* - start of public VM detection functions => line 7265
31-
* - start of externally defined variables => line 7602
24+
* - enums for publicly accessible techniques => line 292
25+
* - struct for internal cpu operations => line 484
26+
* - struct for internal memoization => line 856
27+
* - struct for internal utility functions => line 940
28+
* - struct for internal core components => line 6907
29+
* - start of internal VM detection techniques => line 1718
30+
* - start of public VM detection functions => line 7259
31+
* - start of externally defined variables => line 7596
3232
*
3333
*
3434
* ================================ EXAMPLE ==================================
@@ -6905,47 +6905,6 @@ struct VM {
69056905
}
69066906

69076907

6908-
/**
6909-
* @brief Check for AMD CPUs that don't match their thread count
6910-
* @category All, x86
6911-
* @link https://en.wikipedia.org/wiki/List_of_AMD_Ryzen_processors
6912-
*/
6913-
/*
6914-
[[nodiscard]] static bool amd_thread_mismatch() try {
6915-
#if (!x86)
6916-
return false;
6917-
#else
6918-
if (!cpu::is_amd()) {
6919-
return false;
6920-
}
6921-
6922-
if (cpu::has_hyperthreading()) {
6923-
return false;
6924-
}
6925-
6926-
const cpu::model_struct model = cpu::get_model();
6927-
6928-
if (!model.found) {
6929-
return false;
6930-
}
6931-
6932-
if (!model.is_ryzen) {
6933-
return false;
6934-
}
6935-
6936-
debug("AMD_THREAD_MISMATCH: CPU model = ", model.string);
6937-
#endif
6938-
}
6939-
catch (...) {
6940-
debug("AMD_THREAD_MISMATCH: catched error, returned false");
6941-
return false;
6942-
}
6943-
*/
6944-
6945-
6946-
6947-
6948-
69496908
struct core {
69506909
MSVC_DISABLE_WARNING(PADDING)
69516910
struct technique {
@@ -7105,10 +7064,11 @@ struct VM {
71057064

71067065
const u8 version = util::get_windows_version();
71077066

7108-
if (
7109-
(version == 0) ||
7110-
(version < 10)
7111-
) {
7067+
if (version == 0) {
7068+
return true;
7069+
}
7070+
7071+
if (version < 10) {
71127072
debug("HYPERV_CHECK: returned false through insufficient windows version (version ", static_cast<u32>(version), ")");
71137073
return false;
71147074
}

src/vmaware_MIT.hpp

Lines changed: 53 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ██║ ██║██╔████╔██║███████║██║ █╗ ██║███████║██████╔╝█████╗
55
* ╚██╗ ██╔╝██║╚██╔╝██║██╔══██║██║███╗██║██╔══██║██╔══██╗██╔══╝
66
* ╚████╔╝ ██║ ╚═╝ ██║██║ ██║╚███╔███╔╝██║ ██║██║ ██║███████╗
7-
* ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ 1.4 (May 2024)
7+
* ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ 1.5 (June 2024)
88
*
99
* C++ VM detection library
1010
*
@@ -43,14 +43,14 @@
4343
*
4444
*
4545
* ================================ SECTIONS ==================================
46-
* - enums for publicly accessible techniques => line 293
47-
* - struct for internal cpu operations => line 485
48-
* - struct for internal memoization => line 857
49-
* - struct for internal utility functions => line 941
50-
* - struct for internal core components => line 6916
51-
* - start of internal VM detection techniques => line 1686
52-
* - start of public VM detection functions => line 7265
53-
* - start of externally defined variables => line 7602
46+
* - enums for publicly accessible techniques => line 314
47+
* - struct for internal cpu operations => line 506
48+
* - struct for internal memoization => line 878
49+
* - struct for internal utility functions => line 962
50+
* - struct for internal core components => line 6929
51+
* - start of internal VM detection techniques => line 1740
52+
* - start of public VM detection functions => line 7281
53+
* - start of externally defined variables => line 7618
5454
*
5555
*
5656
* ================================ EXAMPLE ==================================
@@ -1636,6 +1636,33 @@ struct VM {
16361636
return (tmp && isWow64);
16371637
}
16381638

1639+
// backup function in case the main get_windows_version function fails
1640+
[[nodiscard]] static u8 get_windows_version_backup() {
1641+
u8 ret = 0;
1642+
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW) = nullptr;
1643+
OSVERSIONINFOEXW osInfo{};
1644+
1645+
HMODULE ntdllModule = GetModuleHandleA("ntdll");
1646+
1647+
if (ntdllModule == nullptr) {
1648+
return false;
1649+
}
1650+
1651+
*(FARPROC*)&RtlGetVersion = GetProcAddress(ntdllModule, "RtlGetVersion");
1652+
1653+
if (RtlGetVersion == nullptr) {
1654+
return false;
1655+
}
1656+
1657+
if (RtlGetVersion != nullptr) {
1658+
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
1659+
RtlGetVersion(&osInfo);
1660+
ret = static_cast<u8>(osInfo.dwMajorVersion);
1661+
}
1662+
1663+
return ret;
1664+
}
1665+
16391666
// credits to @Requiem for the code, thanks man :)
16401667
[[nodiscard]] static u8 get_windows_version() {
16411668
typedef NTSTATUS(WINAPI* RtlGetVersionFunc)(PRTL_OSVERSIONINFOW);
@@ -1666,19 +1693,19 @@ struct VM {
16661693

16671694
HMODULE ntdll = LoadLibraryW(L"ntdll.dll");
16681695
if (!ntdll) {
1669-
return 0;
1696+
return util::get_windows_version_backup();
16701697
}
16711698

16721699
RtlGetVersionFunc pRtlGetVersion = (RtlGetVersionFunc)GetProcAddress(ntdll, "RtlGetVersion");
16731700
if (!pRtlGetVersion) {
1674-
return 0;
1701+
return util::get_windows_version_backup();
16751702
}
16761703

16771704
RTL_OSVERSIONINFOW osvi;
16781705
osvi.dwOSVersionInfoSize = sizeof(osvi);
16791706

16801707
if (pRtlGetVersion(&osvi) != 0) {
1681-
return 0;
1708+
return util::get_windows_version_backup();
16821709
}
16831710

16841711
u8 major_version = 0;
@@ -1689,8 +1716,14 @@ struct VM {
16891716

16901717
FreeLibrary(ntdll);
16911718

1719+
if (major_version == 0) {
1720+
return util::get_windows_version_backup();
1721+
}
1722+
16921723
return major_version;
16931724
}
1725+
1726+
16941727
#endif
16951728
};
16961729

@@ -6424,47 +6457,6 @@ struct VM {
64246457
}
64256458

64266459

6427-
/**
6428-
* @brief Check for AMD CPUs that don't match their thread count
6429-
* @category All, x86
6430-
* @link https://en.wikipedia.org/wiki/List_of_AMD_Ryzen_processors
6431-
*/
6432-
/*
6433-
[[nodiscard]] static bool amd_thread_mismatch() try {
6434-
#if (!x86)
6435-
return false;
6436-
#else
6437-
if (!cpu::is_amd()) {
6438-
return false;
6439-
}
6440-
6441-
if (cpu::has_hyperthreading()) {
6442-
return false;
6443-
}
6444-
6445-
const cpu::model_struct model = cpu::get_model();
6446-
6447-
if (!model.found) {
6448-
return false;
6449-
}
6450-
6451-
if (!model.is_ryzen) {
6452-
return false;
6453-
}
6454-
6455-
debug("AMD_THREAD_MISMATCH: CPU model = ", model.string);
6456-
#endif
6457-
}
6458-
catch (...) {
6459-
debug("AMD_THREAD_MISMATCH: catched error, returned false");
6460-
return false;
6461-
}
6462-
*/
6463-
6464-
6465-
6466-
6467-
64686460
struct core {
64696461
MSVC_DISABLE_WARNING(PADDING)
64706462
struct technique {
@@ -6618,15 +6610,18 @@ struct VM {
66186610
return false;
66196611
#else
66206612
if (core::enabled(flags, VM::DISCARD_HYPERV_DEFAULT)) {
6613+
debug("HYPERV_CHECK: returned false through flag check");
66216614
return false;
66226615
}
66236616

66246617
const u8 version = util::get_windows_version();
66256618

6626-
if (
6627-
(version == 0) ||
6628-
(version < 10)
6629-
) {
6619+
if (version == 0) {
6620+
return true;
6621+
}
6622+
6623+
if (version < 10) {
6624+
debug("HYPERV_CHECK: returned false through insufficient windows version (version ", static_cast<u32>(version), ")");
66306625
return false;
66316626
}
66326627

@@ -6644,7 +6639,7 @@ struct VM {
66446639
tmp_brand == "Microsoft Virtual PC/Hyper-V"
66456640
);
66466641

6647-
debug("is Hyper-V brand check = ", result);
6642+
debug("HYPERV_CHECK: is Hyper-V brand check = ", result);
66486643

66496644
return result;
66506645
#endif

0 commit comments

Comments
 (0)