@@ -775,8 +775,8 @@ struct VM {
775775
776776 // this is specifically meant for VM::detected_count() to
777777 // get the total number of techniques that detected a VM
778- static u8 detected_count_num;
779- static u16 technique_count; // get total number of techniques
778+ static std::atomic<u8> detected_count_num;
779+ static std::atomic< u16> technique_count; // get total number of techniques
780780
781781 static std::vector<enum_flags> disabled_techniques;
782782
@@ -12009,9 +12009,10 @@ struct VM {
1200912009
1201012010 static std::array<brand_entry, MAX_BRANDS> brand_scoreboard;
1201112011
12012- // Temporary storage to capture which brand was detected by the currently running technique
12013- static brand_enum last_detected_brand;
12014- static u8 last_detected_score;
12012+ // Temporary storage to capture which brand was detected by the currently running technique.
12013+ // thread_local ensures each thread running run_all() has its own independent copy.
12014+ static thread_local brand_enum last_detected_brand;
12015+ static thread_local u8 last_detected_score;
1201512016
1201612017 // 1. one brand, custom score
1201712018 static inline bool add(const brand_enum p_brand, u8 score) noexcept {
@@ -13181,8 +13182,8 @@ std::size_t VM::memo::leaf_cache::next_index = 0;
1318113182VM::brand_list_t VM::memo::brand_list::cache = {};
1318213183bool VM::memo::brand_list::cached = false;
1318313184
13184- enum VM::brand_enum VM::core::last_detected_brand = VM::brand_enum::NULL_BRAND;
13185- VM::u8 VM::core::last_detected_score = 0;
13185+ thread_local enum VM::brand_enum VM::core::last_detected_brand = VM::brand_enum::NULL_BRAND;
13186+ thread_local VM::u8 VM::core::last_detected_score = 0;
1318613187
1318713188// these are basically the base values for the core::arg_handler function.
1318813189// It's like a bucket that will collect all the bits enabled. If for example
@@ -13193,7 +13194,7 @@ VM::flagset VM::core::flag_collector;
1319313194VM::flagset VM::core::disabled_flag_collector;
1319413195
1319513196
13196- VM::u8 VM::detected_count_num = 0 ;
13197+ std::atomic< VM::u8> VM::detected_count_num{0} ;
1319713198
1319813199std::vector<VM::enum_flags> VM::disabled_techniques = []() {
1319913200 std::vector<VM::enum_flags> c;
@@ -13202,7 +13203,7 @@ std::vector<VM::enum_flags> VM::disabled_techniques = []() {
1320213203}();
1320313204
1320413205// this value is incremented each time VM::add_custom is called
13205- VM::u16 VM::technique_count = base_technique_count;
13206+ std::atomic< VM::u16> VM::technique_count{VM:: base_technique_count} ;
1320613207
1320713208// this is initialised as empty, because this is where custom techniques can be added at runtime
1320813209std::vector<VM::core::custom_technique> VM::core::custom_table = {
0 commit comments