Add CheckRegion function

This commit is contained in:
EnderIce2 2024-02-01 16:27:10 +02:00
parent a0b98e8c57
commit 053e167002
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -66,6 +66,32 @@ namespace Memory
PTFlag Flag = PTFlag::P, PTFlag Flag = PTFlag::P,
MapType Type = MapType::FourKiB); MapType Type = MapType::FourKiB);
/**
* @brief Check if the region has the specified flag.
*
* @param VirtualAddress Virtual address of the region.
* @param Length Length of the region.
* @param Flag Flag to check.
* @param Type Type of the page. Check MapType enum.
* @return true if the region has the specified flag, false otherwise.
*/
bool CheckRegion(void *VirtualAddress,
size_t Length,
PTFlag Flag = PTFlag::P,
MapType Type = MapType::FourKiB)
{
for (size_t i = 0; i < Length; i += PAGE_SIZE_4K)
{
if (!this->Check((void *)((uintptr_t)VirtualAddress + i), Flag, Type))
{
debug("address %#lx for pt %#lx has flag(s) %#lx",
(uintptr_t)VirtualAddress + i, this->pTable, Flag);
return false;
}
}
return true;
}
/** /**
* @brief Get physical address of the page. * @brief Get physical address of the page.
* @param VirtualAddress Virtual address of the page. * @param VirtualAddress Virtual address of the page.