Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace std::list with std::vector in MemoryRegionExtractor #137

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vmicore/src/include/vmicore/os/IMemoryRegionExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define VMICORE_IMEMORYREGIONEXTRACTOR_H

#include "MemoryRegion.h"
#include <list>
#include <memory>
#include <vector>

namespace VmiCore
{
Expand All @@ -12,7 +12,7 @@ namespace VmiCore
public:
virtual ~IMemoryRegionExtractor() = default;

[[nodiscard]] virtual std::unique_ptr<std::list<MemoryRegion>> extractAllMemoryRegions() const = 0;
[[nodiscard]] virtual std::unique_ptr<std::vector<MemoryRegion>> extractAllMemoryRegions() const = 0;

protected:
IMemoryRegionExtractor() = default;
Expand Down
4 changes: 2 additions & 2 deletions vmicore/src/lib/os/linux/MMExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace VmiCore::Linux
{
}

std::unique_ptr<std::list<MemoryRegion>> MMExtractor::extractAllMemoryRegions() const
std::unique_ptr<std::vector<MemoryRegion>> MMExtractor::extractAllMemoryRegions() const
{
auto regions = std::make_unique<std::list<MemoryRegion>>();
auto regions = std::make_unique<std::vector<MemoryRegion>>();

for (auto area = vmiInterface->read64VA(mm, vmiInterface->convertPidToDtb(SYSTEM_PID)); area != 0;
area = vmiInterface->read64VA(area + vmiInterface->getKernelStructOffset("vm_area_struct", "vm_next"),
Expand Down
2 changes: 1 addition & 1 deletion vmicore/src/lib/os/linux/MMExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace VmiCore::Linux
const std::shared_ptr<ILogging>& logging,
uint64_t mm);

[[nodiscard]] std::unique_ptr<std::list<MemoryRegion>> extractAllMemoryRegions() const override;
[[nodiscard]] std::unique_ptr<std::vector<MemoryRegion>> extractAllMemoryRegions() const override;

private:
std::shared_ptr<ILibvmiInterface> vmiInterface;
Expand Down
4 changes: 2 additions & 2 deletions vmicore/src/lib/os/windows/VadTreeWin10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace VmiCore::Windows
{
}

std::unique_ptr<std::list<MemoryRegion>> VadTreeWin10::extractAllMemoryRegions() const
std::unique_ptr<std::vector<MemoryRegion>> VadTreeWin10::extractAllMemoryRegions() const
{
auto regions = std::make_unique<std::list<MemoryRegion>>();
auto regions = std::make_unique<std::vector<MemoryRegion>>();
std::list<uint64_t> nextVadEntries;
std::unordered_set<uint64_t> visitedVadVAs;
auto nodeAddress = kernelAccess->extractVadTreeRootAddress(eprocessBase);
Expand Down
2 changes: 1 addition & 1 deletion vmicore/src/lib/os/windows/VadTreeWin10.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace VmiCore::Windows
std::string processName,
const std::shared_ptr<ILogging>& logging);

[[nodiscard]] std::unique_ptr<std::list<MemoryRegion>> extractAllMemoryRegions() const override;
[[nodiscard]] std::unique_ptr<std::vector<MemoryRegion>> extractAllMemoryRegions() const override;

private:
std::shared_ptr<IKernelAccess> kernelAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace VmiCore
class MockMemoryRegionExtractor : public IMemoryRegionExtractor
{
public:
MOCK_METHOD(std::unique_ptr<std::list<MemoryRegion>>, extractAllMemoryRegions, (), (const override));
MOCK_METHOD(std::unique_ptr<std::vector<MemoryRegion>>, extractAllMemoryRegions, (), (const override));
};
}

Expand Down