Skip to content

Commit 4f816fe

Browse files
committed
Merge branch 'dev' of https://github.com/kernelwernel/VMAware into dev
2 parents 670c4c3 + 47a8979 commit 4f816fe

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/vmaware.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6566,7 +6566,7 @@ struct VM {
65666566
for (int i = 0; i < 3; i++) {
65676567
DWORD count = parse_memory_map(NULL, resource_keys[i], L".Translated");
65686568
if (count == 0) {
6569-
return false; // Error or no VM detected
6569+
return false;
65706570
}
65716571
if (i == 0) phys_count = count;
65726572
if (i == 1) reserved_count = count;
@@ -8446,6 +8446,9 @@ struct VM {
84468446
const bool sleep_variance_detected = average_cycles >= threshold;
84478447
const bool spammer_detected = (measurement / 1000) > 55000;
84488448

8449+
debug("Classic check - Average cycles: ", average_cycles, " (threshold: ", threshold, ")");
8450+
debug("Spammer check - Average cycles: ", (measurement / 1000), " (threshold: 55000)");
8451+
84498452
#if (WINDOWS)
84508453
// Windows-specific QPC check: Compare trapping vs non-trapping instruction timing
84518454
LARGE_INTEGER startQPC, endQPC;
@@ -8468,6 +8471,7 @@ struct VM {
84688471
LONGLONG dummyTime = endQPC.QuadPart - startQPC.QuadPart;
84698472

84708473
const bool qpc_check = (dummyTime != 0) && ((cpuIdTime / dummyTime) > 1100);
8474+
debug("QPC check - CPUID: ", cpuIdTime, "ns, Dummy: ", dummyTime, "ns, Ratio: ", (cpuIdTime / dummyTime));
84718475

84728476
// TSC sync check across cores. Try reading the invariant TSC on two different cores to attempt to detect vCPU timers being shared
84738477
unsigned aux;
@@ -8476,7 +8480,9 @@ struct VM {
84768480
SetThreadAffinityMask(GetCurrentThread(), 2);
84778481
u64 tsc_core2 = __rdtscp(&aux); // Core 2 TSC
84788482
SetThreadAffinityMask(GetCurrentThread(), old_mask);
8483+
84798484
const bool tsc_sync_check = std::llabs(static_cast<long long>(tsc_core2 - tsc_core1)) > 10000000LL;
8485+
debug("TSC sync check - Core1: ", tsc_core1, " Core2: ", tsc_core2, " Diff: ", tsc_core2 - tsc_core1);
84808486

84818487
return sleep_variance_detected || spammer_detected || qpc_check || tsc_sync_check;
84828488
#else

0 commit comments

Comments
 (0)