Skip to content

Commit 6e2ceb7

Browse files
committed
fix: extra checks for brand processing and reverted to function overloads
1 parent 2b86319 commit 6e2ceb7

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/vmaware.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4472,9 +4472,9 @@ struct VM {
44724472
// run all the techniques
44734473
const u16 score = core::run_all(flags);
44744474

4475-
brand_array_t active_brands = {};
4476-
4475+
brand_list_t active_brands = {};
44774476
brand_list_t brand_return = {};
4477+
active_brands.reserve(MAX_BRANDS);
44784478
brand_return.reserve(MAX_BRANDS);
44794479

44804480
size_t active_count = 0;
@@ -4536,9 +4536,11 @@ struct VM {
45364536
return brand_return;
45374537
}
45384538

4539-
// remove Hyper-V artifacts if found with other brands
4539+
// remove Hyper-V artifacts and Unknown if found with other brands
45404540
if (active_count > 1) {
45414541
remove(brand_enum::HYPERV_ARTIFACT);
4542+
remove(brand_enum::NULL_BRAND);
4543+
remove(brand_enum::UNKNOWN);
45424544
}
45434545

45444546
// this bitset acts as an abstraction layer for the merging stage of this function.
@@ -4714,22 +4716,18 @@ struct VM {
47144716
case brand_enum::CONNECTIX: return VM::brands::CONNECTIX;
47154717
case brand_enum::NULL_BRAND: return VM::brands::NULL_BRAND; // do not modify placement of this, it's used as an anchor point to count the number of brands
47164718
}
4719+
4720+
return "Invalid";
47174721
}
47184722

47194723
static std::string fetch_brand_name(const brand_list_t& list, const size_t index) {
47204724
return brand_enum_to_string(list[index].first);
47214725
};
47224726

47234727
static std::string brand_multiple(const flagset& flags = core::generate_default()) {
4724-
if (memo::multi_brand::is_cached()) {
4725-
return memo::multi_brand::fetch();
47264728
if (memo::multi_brand::is_cached()) {
47274729
return memo::multi_brand::fetch();
47284730
}
4729-
if (memo::multi_brand::is_cached()) {
4730-
return memo::multi_brand::fetch();
4731-
}
4732-
}
47334731

47344732
const brand_list_t& list = brands::brand_list(flags);
47354733
const std::string& buffer = brand_multiple(list);
@@ -12116,11 +12114,11 @@ struct VM {
1211612114
template <typename ...Args>
1211712115
static std::string brand(Args ...args) {
1211812116
const flagset flags = core::arg_handler(args...);
12119-
return internal_brand(flags);
12117+
return brand(flags);
1212012118
}
1212112119

1212212120

12123-
static std::string internal_brand(const flagset& flags = core::generate_default()) {
12121+
static std::string brand(const flagset& flags = core::generate_default()) {
1212412122
// is the multiple setting flag enabled?
1212512123
const bool is_multiple = core::is_enabled(flags, MULTIPLE);
1212612124

@@ -12562,6 +12560,8 @@ struct VM {
1256212560
case brand_enum::NULL_BRAND: return "Unknown";
1256312561
case brand_enum::UNKNOWN: return "Invalid";
1256412562
}
12563+
12564+
return "Invalid";
1256512565
}
1256612566

1256712567

@@ -12578,7 +12578,7 @@ struct VM {
1257812578

1257912579

1258012580
static std::string conclusion(const flagset &flags = core::generate_default()) {
12581-
std::string brand_tmp = internal_brand(flags);
12581+
std::string brand_tmp = brand(flags);
1258212582
const u8 percent_tmp = percentage(flags);
1258312583
const bool has_hardener = is_hardened();
1258412584

@@ -12761,7 +12761,7 @@ struct VM {
1276112761

1276212762
// having this design avoids some niche errors
1276312763
void initialise(const flagset &flags) {
12764-
brand = VM::internal_brand(flags);
12764+
brand = VM::brand(flags);
1276512765
type = VM::type(flags);
1276612766
conclusion = VM::conclusion(flags);
1276712767
is_vm = VM::detect(flags);

0 commit comments

Comments
 (0)