mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 11:13:57 +00:00
Parameterize basic_memory_region to support extended memory flags
This commit is contained in:
@@ -2,14 +2,15 @@
|
||||
#include "memory_permission.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
template<typename PermissionType = memory_permission>
|
||||
struct basic_memory_region
|
||||
{
|
||||
uint64_t start{};
|
||||
size_t length{}; // uint64_t?
|
||||
memory_permission permissions{};
|
||||
PermissionType permissions{};
|
||||
};
|
||||
|
||||
struct memory_region : basic_memory_region
|
||||
struct memory_region : basic_memory_region<>
|
||||
{
|
||||
bool committed{};
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "memory_permission_ext.hpp"
|
||||
#include "memory_region.hpp"
|
||||
#include "serialization.hpp"
|
||||
|
||||
#include <memory_interface.hpp>
|
||||
@@ -14,14 +15,7 @@ constexpr auto MAX_ALLOCATION_ADDRESS = 0x00007ffffffeffffULL;
|
||||
|
||||
// This maps to the `basic_memory_region` struct defined in
|
||||
// emulator\memory_region.hpp
|
||||
struct nt_basic_memory_region
|
||||
{
|
||||
uint64_t start{};
|
||||
size_t length{};
|
||||
nt_memory_permission permissions{};
|
||||
};
|
||||
|
||||
struct region_info : nt_basic_memory_region
|
||||
struct region_info : basic_memory_region<nt_memory_permission>
|
||||
{
|
||||
uint64_t allocation_base{};
|
||||
size_t allocation_length{};
|
||||
|
||||
@@ -15,7 +15,7 @@ using address_name_mapping = std::map<uint64_t, std::string>;
|
||||
struct mapped_section
|
||||
{
|
||||
std::string name{};
|
||||
basic_memory_region region{};
|
||||
basic_memory_region<> region{};
|
||||
};
|
||||
|
||||
struct mapped_module
|
||||
|
||||
@@ -23,14 +23,14 @@ namespace utils
|
||||
buffer.read(sym.address);
|
||||
}
|
||||
|
||||
static void serialize(buffer_serializer& buffer, const basic_memory_region& region)
|
||||
static void serialize(buffer_serializer& buffer, const basic_memory_region<>& region)
|
||||
{
|
||||
buffer.write(region.start);
|
||||
buffer.write<uint64_t>(region.length);
|
||||
buffer.write(region.permissions);
|
||||
}
|
||||
|
||||
static void deserialize(buffer_deserializer& buffer, basic_memory_region& region)
|
||||
static void deserialize(buffer_deserializer& buffer, basic_memory_region<>& region)
|
||||
{
|
||||
buffer.read(region.start);
|
||||
region.length = static_cast<size_t>(buffer.read<uint64_t>());
|
||||
|
||||
Reference in New Issue
Block a user