Skip to content

Commit 8817d8d

Browse files
committed
readme changes and added minor thread safety
1 parent 842514d commit 8817d8d

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<img align="center" src="https://img.shields.io/github/downloads/kernelwernel/VMAware/total">
66
<img align="center" src="https://img.shields.io/badge/License-MIT-yellow.svg">
77
<a href="https://deepwiki.com/kernelwernel/VMAware"><img align="center" src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
8-
<a href="https://discord.gg/hNVHChp7PX"><img align="center" src="https://dcbadge.limes.pink/api/server/https://discord.gg/hNVHChp7PX?style=flat"></a>
98
<a href="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml">
109
<img align="center" src="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml/badge.svg" alt="CodeQL Analysis">
1110
</a>

README_CN.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<img align="center" src="https://img.shields.io/github/downloads/kernelwernel/VMAware/total">
66
<img align="center" src="https://img.shields.io/badge/License-MIT-yellow.svg">
77
<a href="https://deepwiki.com/kernelwernel/VMAware"><img align="center" src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
8-
<a href="https://discord.gg/hNVHChp7PX"><img align="center" src="https://dcbadge.limes.pink/api/server/https://discord.gg/hNVHChp7PX?style=flat"></a>
98
<a href="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml">
109
<img align="center" src="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml/badge.svg" alt="CodeQL Analysis">
1110
</a>

README_FR.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<img align="center" src="https://img.shields.io/github/downloads/kernelwernel/VMAware/total">
66
<img align="center" src="https://img.shields.io/badge/License-MIT-yellow.svg">
77
<a href="https://deepwiki.com/kernelwernel/VMAware"><img align="center" src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
8-
<a href="https://discord.gg/hNVHChp7PX"><img align="center" src="https://dcbadge.limes.pink/api/server/https://discord.gg/hNVHChp7PX?style=flat"></a>
98
<a href="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml">
109
<img align="center" src="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml/badge.svg" alt="CodeQL Analysis">
1110
</a>

README_KR.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<img align="center" src="https://img.shields.io/github/downloads/kernelwernel/VMAware/total">
66
<img align="center" src="https://img.shields.io/badge/License-MIT-yellow.svg">
77
<a href="https://deepwiki.com/kernelwernel/VMAware"><img align="center" src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
8-
<a href="https://discord.gg/hNVHChp7PX"><img align="center" src="https://dcbadge.limes.pink/api/server/https://discord.gg/hNVHChp7PX?style=flat"></a>
98
<a href="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml">
109
<img align="center" src="https://github.com/kernelwernel/VMAware/actions/workflows/code_ql_analysis.yml/badge.svg" alt="CodeQL Analysis">
1110
</a>

src/vmaware.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
1318113182
VM::brand_list_t VM::memo::brand_list::cache = {};
1318213183
bool 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;
1319313194
VM::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

1319813199
std::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
1320813209
std::vector<VM::core::custom_technique> VM::core::custom_table = {

0 commit comments

Comments
 (0)