From b2fbb8247600ba7601496ecc712c7921882d3461 Mon Sep 17 00:00:00 2001 From: Requiem Date: Sat, 21 Feb 2026 13:28:55 +0100 Subject: [PATCH] fix: fixed functions being called twice in some cases due to core logic --- src/vmaware.hpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/vmaware.hpp b/src/vmaware.hpp index a55a9609..89e2c6e9 100644 --- a/src/vmaware.hpp +++ b/src/vmaware.hpp @@ -5049,7 +5049,7 @@ struct VM { ProcessorInformation = 11 }; - const HMODULE hPowr = GetModuleHandleA("powrprof.dll"); + const HMODULE hPowr = LoadLibraryA("powrprof.dll"); if (!hPowr) return 0; const char* names[] = { "CallNtPowerInformation" }; @@ -11772,22 +11772,21 @@ struct VM { if (flag_bit < technique_end) { const core::technique& pair = core::technique_table[flag_bit]; - if (auto run_fn = pair.run) { + if (auto run_fn = pair.run) { core::last_detected_brand = nullptr; - core::last_detected_score = 0; + core::last_detected_score = 0; + + const bool result = run_fn(); + + const u8 points_to_add = (core::last_detected_score > 0) ? core::last_detected_score : pair.points; + const char* detected_brand = (core::last_detected_brand) ? core::last_detected_brand : brands::NULL_BRAND; - bool result = run_fn(); if (result) { - #ifdef __VMAWARE_DEBUG__ - total_points += pair.points; - #endif detected_count_num++; - u8 points_to_add = (core::last_detected_score > 0) ? core::last_detected_score : pair.points; - const char* detected_brand = (core::last_detected_brand) ? core::last_detected_brand : brands::NULL_BRAND; - - memo::cache_store(flag_bit, result, points_to_add, detected_brand); - return result; } + + memo::cache_store(flag_bit, result, result ? points_to_add : 0, detected_brand); + return result; } else { throw_error("Flag is not known or not implemented"); @@ -11814,9 +11813,6 @@ struct VM { // is the multiple setting flag enabled? const bool is_multiple = core::is_enabled(flags, MULTIPLE); - // run all the techniques - const u16 score = core::run_all(flags); - // check if the result is already cached and return that instead if (is_multiple) { if (memo::multi_brand::is_cached()) { @@ -11831,6 +11827,9 @@ struct VM { } } + // run all the techniques + const u16 score = core::run_all(flags); + #if (VMA_CPP <= 14) constexpr const char* TMP_QEMU = "QEMU"; constexpr const char* TMP_KVM = "KVM";