diff --git a/plugins/inmemoryscanner/src/lib/Scanner.cpp b/plugins/inmemoryscanner/src/lib/Scanner.cpp index 9c11a7a1..c424367a 100644 --- a/plugins/inmemoryscanner/src/lib/Scanner.cpp +++ b/plugins/inmemoryscanner/src/lib/Scanner.cpp @@ -132,9 +132,9 @@ namespace InMemoryScanner // The semaphore protects the yara rules from being accessed more than YR_MAX_THREADS (32 atm.) times in // parallel. - semaphore.wait(); + semaphore.acquire(); auto results = yaraInterface->scanMemory(memoryRegionDescriptor.base, mappedRegions); - semaphore.notify(); + semaphore.release(); logger->debug("End scanMemory"); diff --git a/plugins/inmemoryscanner/src/lib/Scanner.h b/plugins/inmemoryscanner/src/lib/Scanner.h index 57a6af70..b0932ff4 100644 --- a/plugins/inmemoryscanner/src/lib/Scanner.h +++ b/plugins/inmemoryscanner/src/lib/Scanner.h @@ -4,9 +4,8 @@ #include "Dumping.h" #include "IYaraInterface.h" #include "OutputXML.h" -#include "Semaphore.h" -#include #include +#include #include #include #include // NOLINT(modernize-deprecated-headers) @@ -37,8 +36,7 @@ namespace InMemoryScanner std::unique_ptr dumping; std::unique_ptr logger; std::unique_ptr inMemResultsLogger; - Semaphore semaphore = - Semaphore(YR_MAX_THREADS); + std::counting_semaphore<> semaphore{YR_MAX_THREADS}; [[nodiscard]] bool shouldRegionBeScanned(const VmiCore::MemoryRegion& memoryRegionDescriptor);