Skip to content

Commit

Permalink
unify inmemoryscanner
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Mayer committed Sep 20, 2023
1 parent 33ebdc8 commit 9c17995
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions plugins/inmemoryscanner/src/lib/Dumping.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace InMemoryScanner
{
}

std::string getMemFileName()
[[nodiscard]] std::string getMemFileName()
{
return processName.substr(0, maxProcNameLength)
.append("-")
Expand All @@ -69,7 +69,7 @@ namespace InMemoryScanner
.append(uid);
}

std::string toString()
[[nodiscard]] std::string toString()
{
return std::string("{")
.append(R"("ProcessName": ")")
Expand Down Expand Up @@ -155,13 +155,13 @@ namespace InMemoryScanner
int memoryRegionCounter{};
std::mutex counterLock{};

static std::unique_ptr<MemoryRegionInformation>
[[nodiscard]] static std::unique_ptr<MemoryRegionInformation>
createMemoryRegionInformation(const std::string& processName,
pid_t pid,
const VmiCore::MemoryRegion& memoryRegionDescriptor,
int regionId);

int getNextRegionId();
[[nodiscard]] int getNextRegionId();

void appendRegionInfo(const std::string& regionInfo);
};
Expand Down
4 changes: 2 additions & 2 deletions plugins/inmemoryscanner/src/lib/Scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace InMemoryScanner
std::unique_ptr<YaraInterface> yaraEngine,
std::unique_ptr<IDumping> dumping);

static std::unique_ptr<std::string> getFilenameFromPath(const std::string& path);
[[nodiscard]] static std::unique_ptr<std::string> getFilenameFromPath(const std::string& path);

void scanProcess(std::shared_ptr<const VmiCore::ActiveProcessInformation> processInformation);

Expand All @@ -39,7 +39,7 @@ namespace InMemoryScanner
Semaphore<std::mutex, std::condition_variable> semaphore =
Semaphore<std::mutex, std::condition_variable>(YR_MAX_THREADS);

bool shouldRegionBeScanned(const VmiCore::MemoryRegion& memoryRegionDescriptor);
[[nodiscard]] bool shouldRegionBeScanned(const VmiCore::MemoryRegion& memoryRegionDescriptor);

void scanMemoryRegion(pid_t pid,
const std::string& processName,
Expand Down
5 changes: 3 additions & 2 deletions plugins/inmemoryscanner/src/lib/Yara.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ namespace InMemoryScanner
private:
YR_RULES* rules = nullptr;

static int yaraCallback(YR_SCAN_CONTEXT* context, int message, void* message_data, void* user_data);
[[nodiscard]] static int
yaraCallback(YR_SCAN_CONTEXT* context, int message, void* message_data, void* user_data);

static int handleRuleMatch(YR_SCAN_CONTEXT* context, YR_RULE* rule, std::vector<Rule>* results);
[[nodiscard]] static int handleRuleMatch(YR_SCAN_CONTEXT* context, YR_RULE* rule, std::vector<Rule>* results);
};
}
2 changes: 1 addition & 1 deletion plugins/inmemoryscanner/src/lib/YaraInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace InMemoryScanner
public:
virtual ~YaraInterface() = default;

virtual std::unique_ptr<std::vector<Rule>> scanMemory(std::vector<uint8_t>& buffer) = 0;
[[nodiscard]] virtual std::unique_ptr<std::vector<Rule>> scanMemory(std::vector<uint8_t>& buffer) = 0;

protected:
YaraInterface() = default;
Expand Down

0 comments on commit 9c17995

Please sign in to comment.