Fix page fault area range check

Range end check was bugged (always true), also rewrite it so vm::get would be called only once
This commit is contained in:
eladash 2019-03-12 17:45:15 +02:00 committed by Ivan
parent f2bbae9db4
commit 16f86b2458

View file

@ -1279,14 +1279,14 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
u32 pf_port_id = 0; u32 pf_port_id = 0;
if (auto pf_entries = fxm::get<page_fault_notification_entries>()) if (auto pf_entries = fxm::get<page_fault_notification_entries>())
{
if (auto mem = vm::get(vm::any, addr))
{ {
std::shared_lock lock(pf_entries->mutex); std::shared_lock lock(pf_entries->mutex);
for (const auto& entry : pf_entries->entries) for (const auto& entry : pf_entries->entries)
{ {
if (auto mem = vm::get(vm::any, entry.start_addr)) if (entry.start_addr == mem->addr)
{
if (entry.start_addr <= addr && addr <= addr + mem->size - 1)
{ {
pf_port_id = entry.port_id; pf_port_id = entry.port_id;
break; break;