Skip to content

Commit

Permalink
Replace std::list with std::vector in MemoryRegionExtractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorian Eikenberg authored and rageagainsthepc committed Dec 5, 2023
1 parent 7f1bb30 commit d74fe08
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
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

0 comments on commit d74fe08

Please sign in to comment.