Skip to content

Commit c15507f

Browse files
committed
fixed linux compatibility and renamed function
1 parent 420d599 commit c15507f

1 file changed

Lines changed: 31 additions & 29 deletions

File tree

src/vmaware.hpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,36 @@ struct VM {
19751975
return std::string();
19761976
}
19771977

1978+
1979+
[[nodiscard]] static bool is_running_under_translator() {
1980+
#if (WINDOWS)
1981+
u8 ver = get_windows_version();
1982+
if (ver == 10 || ver == 11) {
1983+
USHORT procMachine = 0, nativeMachine = 0;
1984+
if (IsWow64Process2(GetCurrentProcess(), &procMachine, &nativeMachine)) {
1985+
if (nativeMachine == IMAGE_FILE_MACHINE_ARM64 &&
1986+
(procMachine == IMAGE_FILE_MACHINE_AMD64 ||
1987+
procMachine == IMAGE_FILE_MACHINE_I386))
1988+
{
1989+
return true;
1990+
}
1991+
}
1992+
}
1993+
#endif
1994+
1995+
if (cpu::is_leaf_supported(cpu::leaf::hypervisor)) {
1996+
std::string vendor = cpu::cpu_manufacturer(cpu::leaf::hypervisor);
1997+
if (vendor == "VirtualApple" || // Apple Rosetta
1998+
vendor == "PowerVM Lx86") // IBM PowerVM Lx86
1999+
{
2000+
return true;
2001+
}
2002+
}
2003+
2004+
return false;
2005+
}
2006+
2007+
19782008
/**
19792009
* @brief Checks whether the system is running in a Hyper-V virtual machine or if the host system has Hyper-V enabled
19802010
* @note Hyper-V's presence on a host system can set certain hypervisor-related CPU flags that may appear similar to those in a virtualized environment, which can make it challenging to differentiate between an actual Hyper-V virtual machine (VM) and a host system with Hyper-V enabled.
@@ -2414,34 +2444,6 @@ struct VM {
24142444
}
24152445
}
24162446
}
2417-
2418-
[[nodiscard]] static bool is_running_under_emulator() {
2419-
#if (WINDOWS)
2420-
u8 ver = get_windows_version();
2421-
if (ver == 10 || ver == 11) {
2422-
USHORT procMachine = 0, nativeMachine = 0;
2423-
if (IsWow64Process2(GetCurrentProcess(), &procMachine, &nativeMachine)) {
2424-
if (nativeMachine == IMAGE_FILE_MACHINE_ARM64 &&
2425-
(procMachine == IMAGE_FILE_MACHINE_AMD64 ||
2426-
procMachine == IMAGE_FILE_MACHINE_I386))
2427-
{
2428-
return true;
2429-
}
2430-
}
2431-
}
2432-
#endif
2433-
2434-
if (cpu::is_leaf_supported(cpu::leaf::hypervisor)) {
2435-
std::string vendor = cpu::cpu_manufacturer(cpu::leaf::hypervisor);
2436-
if (vendor == "VirtualApple" || // Apple Rosetta
2437-
vendor == "PowerVM Lx86") // IBM PowerVM Lx86
2438-
{
2439-
return true;
2440-
}
2441-
}
2442-
2443-
return false;
2444-
}
24452447
#endif
24462448
};
24472449

@@ -7527,7 +7529,7 @@ struct VM {
75277529
return false;
75287530
}
75297531

7530-
if (util::is_running_under_emulator()) {
7532+
if (util::is_running_under_translator()) {
75317533
debug("Running inside binary translation layer.");
75327534
return false;
75337535
}

0 commit comments

Comments
 (0)