Skip to content

Commit d096a83

Browse files
committed
Add some missing flags in is_readable
1 parent 4874d1a commit d096a83

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/os/win32/Process.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ namespace hat::process {
4242
}
4343

4444
bool hat::process::is_readable(const std::span<const std::byte> region) {
45+
constexpr DWORD readFlags = PAGE_EXECUTE_READ
46+
| PAGE_EXECUTE_READWRITE
47+
| PAGE_EXECUTE_WRITECOPY
48+
| PAGE_READONLY
49+
| PAGE_READWRITE
50+
| PAGE_WRITECOPY;
4551
for (auto* addr = region.data(); addr < region.data() + region.size();) {
4652
MEMORY_BASIC_INFORMATION mbi{};
4753
if (!VirtualQuery(addr, &mbi, sizeof(mbi))) {
@@ -50,7 +56,7 @@ namespace hat::process {
5056
if (mbi.State != MEM_COMMIT) {
5157
return false;
5258
}
53-
if (!(mbi.Protect & (PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_READONLY | PAGE_READWRITE))) {
59+
if (!(mbi.Protect & readFlags)) {
5460
return false;
5561
}
5662
addr = static_cast<const std::byte*>(mbi.BaseAddress) + mbi.RegionSize;

0 commit comments

Comments
 (0)