@@ -1200,12 +1200,11 @@ struct VM {
12001200 // memoization
12011201 struct memo {
12021202 private:
1203- using result_t = bool ;
12041203 using points_t = u8 ;
12051204
12061205 public:
12071206 struct data_t {
1208- result_t result;
1207+ bool result;
12091208 points_t points;
12101209 };
12111210
@@ -1214,7 +1213,7 @@ struct VM {
12141213 static flagset cache_keys;
12151214
12161215 public:
1217- static void cache_store (const u16 technique_macro, const result_t result, const points_t points) {
1216+ static void cache_store (const u16 technique_macro, const bool result, const points_t points) {
12181217 cache_table[technique_macro] = { result, points };
12191218 cache_keys.set (technique_macro);
12201219 }
@@ -10269,7 +10268,7 @@ struct VM {
1026910268 return false ;
1027010269 }
1027110270
10272- [[nodiscard]] static bool is_setting_flag_set (const flagset& flags) {
10271+ [[nodiscard]] static bool is_setting_flag_set (const flagset& flags) {
1027310272 for (std::size_t i = settings_begin; i < settings_end; i++) {
1027410273 if (flags.test (i)) {
1027510274 return true ;
@@ -10963,10 +10962,13 @@ struct VM {
1096310962 // brand strings will be outputted if there's a conflict)
1096410963 const bool is_multiple = core::is_enabled (flags, MULTIPLE);
1096510964
10965+ // used for later
10966+ u16 score = 0 ;
10967+
1096610968 // are all the techiques already run? if not, run them
1096710969 // to fetch the necessary info to determine the brand
1096810970 if (!memo::all_present () || core::is_enabled (flags, NO_MEMO)) {
10969- core::run_all (flags);
10971+ score = core::run_all (flags);
1097010972 }
1097110973
1097210974 // check if the result is already cached and return that instead
@@ -11148,6 +11150,25 @@ struct VM {
1114811150 merge (TMP_VMWARE_HARD, TMP_WORKSTATION, TMP_VMWARE_HARD);
1114911151
1115011152
11153+ // this is added in case the lib detects a non-Hyper-X technique.
11154+ // A Hyper-X affiliated technique should make the overall score
11155+ // as 0, but this isn't the case if non-Hyper-X techniques were
11156+ // found. There may be a conflict between an Unknown and Hyper-V
11157+ // brand, which is exactly what this section is meant to handle.
11158+ // It will remove the Hyper-V artifact brand string from the
11159+ // std::map to pave the way for other brands to take precendence.
11160+ // One of the main reasons to do this is because it would look
11161+ // incredibly awkward if the brand was "Hyper-V artifacts (not an
11162+ // actual VM)", clearly stating that it's NOT a VM while the VM
11163+ // confirmation is true and percentage is 100%, as if that makes
11164+ // any sense whatsoever. That's what this part fixes.
11165+ if (brands.count (TMP_HYPERV_ARTIFACT) > 0 ) {
11166+ if (score > 0 ) {
11167+ brands.erase (TMP_HYPERV_ARTIFACT);
11168+ }
11169+ }
11170+
11171+
1115111172 // the brand element, which stores the NAME (const char*) and the SCORE (u8)
1115211173 using brand_element_t = std::pair<const char *, brand_score_t >;
1115311174
@@ -11165,6 +11186,9 @@ struct VM {
1116511186
1116611187 std::string ret_str = brands::NULL_BRAND;
1116711188
11189+
11190+
11191+
1116811192 // if the multiple setting flag is NOT set, return the
1116911193 // brand with the highest score. Else, return a std::string
1117011194 // of the brand message (i.e. "VirtualBox or VMware").
@@ -11183,6 +11207,8 @@ struct VM {
1118311207 ret_str = ss.str ();
1118411208 }
1118511209
11210+
11211+
1118611212 // cache the result if memoization is enabled
1118711213 if (core::is_disabled (flags, NO_MEMO)) {
1118811214 if (is_multiple) {
@@ -11193,6 +11219,7 @@ struct VM {
1119311219 memo::brand::store (ret_str);
1119411220 }
1119511221 }
11222+
1119611223
1119711224 // debug stuff to see the brand scoreboard, ignore this
1119811225#ifdef __VMAWARE_DEBUG__
0 commit comments