/*Спроба розділити наявну пам'ять між сторінками.*/ void PageMemoryAllocator::ShareMemoryBetweenPages() { unsigned int pageCount = memorySize / pageSize; for(unsigned int i = 0; i < pageCount; i++) { memoryPages.push_back(MemoryPage(memory + i * pageSize)); freePageNumbers.push_back(i); } }
#include "../../src/CheatEngine.h" #include "FakeProcess.h" #include "catch.hpp" #include <string> TEST_CASE("CheatEngine can search for matches") { FakeProcess process; CheatEngine engine{process}; const std::string str = "this is a test."; memory_t memory{std::begin(str), std::end(str)}; process.pages = { MemoryPage(memory.data(), memory.size()) }; process.reads = { memory }; SECTION("does not find a match when the value is missing") { const auto matches = engine.search({ 't', 'e', 's', 's' }); REQUIRE(matches.getPageMatches().empty()); } SECTION("does find a match when the value present") { const auto matches = engine.search({ 'i', 's' }); REQUIRE(matches.getPageMatches().size() == 1); const auto match = matches.getPageMatches().front(); const offsets_t offsets = {2, 5}; REQUIRE(match.getOffsets() == offsets); }