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

Cleanup hook irp

This commit is contained in:
momo5502
2022-04-23 21:40:52 +02:00
parent ea6f18ea5e
commit db4e69f5be
5 changed files with 95 additions and 62 deletions

View File

@ -104,4 +104,24 @@ namespace memory
ExFreePool(memory);
}
}
bool prope_for_read(const void* address, const size_t length, const uint64_t alignment)
{
__try
{
ProbeForRead(const_cast<volatile void*>(address), length, static_cast<ULONG>(alignment));
return true;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
}
void assert_readability(const void* address, const size_t length, const uint64_t alignment)
{
if(!prope_for_read(address, length, alignment)) {
throw std::runtime_error("Access violation");
}
}
}