Skip to content

Commit 239ab88

Browse files
authored
Merge pull request #632 from NotRequiem/main
fix: fixed functions being called twice in some cases due to core logic
2 parents fec3ce3 + b2fbb82 commit 239ab88

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/vmaware.hpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5054,7 +5054,7 @@ struct VM {
50545054
ProcessorInformation = 11
50555055
};
50565056

5057-
const HMODULE hPowr = GetModuleHandleA("powrprof.dll");
5057+
const HMODULE hPowr = LoadLibraryA("powrprof.dll");
50585058
if (!hPowr) return 0;
50595059

50605060
const char* names[] = { "CallNtPowerInformation" };
@@ -11777,22 +11777,21 @@ struct VM {
1177711777
if (flag_bit < technique_end) {
1177811778
const core::technique& pair = core::technique_table[flag_bit];
1177911779

11780-
if (auto run_fn = pair.run) {
11780+
if (auto run_fn = pair.run) {
1178111781
core::last_detected_brand = nullptr;
11782-
core::last_detected_score = 0;
11782+
core::last_detected_score = 0;
11783+
11784+
const bool result = run_fn();
11785+
11786+
const u8 points_to_add = (core::last_detected_score > 0) ? core::last_detected_score : pair.points;
11787+
const char* detected_brand = (core::last_detected_brand) ? core::last_detected_brand : brands::NULL_BRAND;
1178311788

11784-
bool result = run_fn();
1178511789
if (result) {
11786-
#ifdef __VMAWARE_DEBUG__
11787-
total_points += pair.points;
11788-
#endif
1178911790
detected_count_num++;
11790-
u8 points_to_add = (core::last_detected_score > 0) ? core::last_detected_score : pair.points;
11791-
const char* detected_brand = (core::last_detected_brand) ? core::last_detected_brand : brands::NULL_BRAND;
11792-
11793-
memo::cache_store(flag_bit, result, points_to_add, detected_brand);
11794-
return result;
1179511791
}
11792+
11793+
memo::cache_store(flag_bit, result, result ? points_to_add : 0, detected_brand);
11794+
return result;
1179611795
}
1179711796
else {
1179811797
throw_error("Flag is not known or not implemented");
@@ -11819,9 +11818,6 @@ struct VM {
1181911818
// is the multiple setting flag enabled?
1182011819
const bool is_multiple = core::is_enabled(flags, MULTIPLE);
1182111820

11822-
// run all the techniques
11823-
const u16 score = core::run_all(flags);
11824-
1182511821
// check if the result is already cached and return that instead
1182611822
if (is_multiple) {
1182711823
if (memo::multi_brand::is_cached()) {
@@ -11836,6 +11832,9 @@ struct VM {
1183611832
}
1183711833
}
1183811834

11835+
// run all the techniques
11836+
const u16 score = core::run_all(flags);
11837+
1183911838
#if (VMA_CPP <= 14)
1184011839
constexpr const char* TMP_QEMU = "QEMU";
1184111840
constexpr const char* TMP_KVM = "KVM";

0 commit comments

Comments
 (0)