Skip to content

Commit

Permalink
Add some missing flags in is_readable
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroMemes committed Oct 3, 2024
1 parent 4874d1a commit d096a83
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/os/win32/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ namespace hat::process {
}

bool hat::process::is_readable(const std::span<const std::byte> region) {
constexpr DWORD readFlags = PAGE_EXECUTE_READ
| PAGE_EXECUTE_READWRITE
| PAGE_EXECUTE_WRITECOPY
| PAGE_READONLY
| PAGE_READWRITE
| PAGE_WRITECOPY;
for (auto* addr = region.data(); addr < region.data() + region.size();) {
MEMORY_BASIC_INFORMATION mbi{};
if (!VirtualQuery(addr, &mbi, sizeof(mbi))) {
Expand All @@ -50,7 +56,7 @@ namespace hat::process {
if (mbi.State != MEM_COMMIT) {
return false;
}
if (!(mbi.Protect & (PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_READONLY | PAGE_READWRITE))) {
if (!(mbi.Protect & readFlags)) {
return false;
}
addr = static_cast<const std::byte*>(mbi.BaseAddress) + mbi.RegionSize;
Expand Down

0 comments on commit d096a83

Please sign in to comment.