mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-27 04:25:12 +00:00
Mprotect only over whole pages
This commit is contained in:
parent
fed064931a
commit
b929ecf44e
@ -552,17 +552,20 @@ s64 MemoryManager::ProtectBytes(VAddr addr, VirtualMemoryArea vma_base, size_t s
|
|||||||
s32 MemoryManager::Protect(VAddr addr, size_t size, MemoryProt prot) {
|
s32 MemoryManager::Protect(VAddr addr, size_t size, MemoryProt prot) {
|
||||||
std::scoped_lock lk{mutex};
|
std::scoped_lock lk{mutex};
|
||||||
s64 protected_bytes = 0;
|
s64 protected_bytes = 0;
|
||||||
|
|
||||||
|
auto aligned_addr = Common::AlignDown(addr, 16_KB);
|
||||||
|
auto aligned_size = Common::AlignUp(size, 16_KB);
|
||||||
do {
|
do {
|
||||||
auto it = FindVMA(addr + protected_bytes);
|
auto it = FindVMA(aligned_addr + protected_bytes);
|
||||||
auto& vma_base = it->second;
|
auto& vma_base = it->second;
|
||||||
auto result = 0;
|
auto result = 0;
|
||||||
result = ProtectBytes(addr + protected_bytes, vma_base, size - protected_bytes, prot);
|
result = ProtectBytes(aligned_addr + protected_bytes, vma_base, aligned_size - protected_bytes, prot);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
// ProtectBytes returned an error, return it
|
// ProtectBytes returned an error, return it
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
protected_bytes += result;
|
protected_bytes += result;
|
||||||
} while (protected_bytes < size);
|
} while (protected_bytes < aligned_size);
|
||||||
|
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user