1
0
mirror of https://github.com/momo5502/hypervisor.git synced 2025-07-05 10:41:50 +00:00

Reflect memory writes to shadow page

This commit is contained in:
momo5502
2022-05-15 13:07:17 +02:00
parent 489fba2b60
commit 76fcdd0d8e
4 changed files with 73 additions and 5 deletions

View File

@ -1,7 +1,6 @@
#include "std_include.hpp"
#include "memory.hpp"
#include "string.hpp"
#include "process.hpp"
namespace memory
{
@ -84,6 +83,23 @@ namespace memory
_Must_inspect_result_
_IRQL_requires_max_(DISPATCH_LEVEL)
void* map_physical_memory(const uint64_t address, const size_t size)
{
PHYSICAL_ADDRESS physical_address{};
physical_address.QuadPart = static_cast<LONGLONG>(address);
return MmMapIoSpace(physical_address, size, MmNonCached);
}
_IRQL_requires_max_(DISPATCH_LEVEL)
void unmap_physical_memory(void* address, const size_t size)
{
MmUnmapIoSpace(address, size);
}
_Must_inspect_result_
_IRQL_requires_max_(DISPATCH_LEVEL)
void* allocate_non_paged_memory(const size_t size)
{
void* memory = ExAllocatePoolWithTag(NonPagedPool, size, 'MOMO');