Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys_prx: Implement sys_prx_get_module_id_by_address #10874

Merged
merged 2 commits into from Sep 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 38 additions & 3 deletions rpcs3/Emu/Cell/lv2/sys_prx.cpp
Expand Up @@ -801,7 +801,17 @@ error_code _sys_prx_get_module_info(ppu_thread& ppu, u32 id, u64 flags, vm::ptr<
return CELL_EFAULT;
}

if (pOpt->size != pOpt.size() || !pOpt->info)
if (pOpt->size != pOpt.size())
{
return CELL_EINVAL;
}

if (!pOpt->info)
{
return CELL_EFAULT;
}

if (pOpt->info->size != pOpt->info.size())
{
return CELL_EINVAL;
}
Expand Down Expand Up @@ -857,8 +867,33 @@ error_code _sys_prx_get_module_id_by_address(ppu_thread& ppu, u32 addr)
{
ppu.state += cpu_flag::wait;

sys_prx.todo("_sys_prx_get_module_id_by_address(addr=0x%x)", addr);
return CELL_OK;
sys_prx.warning("_sys_prx_get_module_id_by_address(addr=0x%x)", addr);

if (!vm::check_addr(addr))
{
// Fast check for an invalid argument
return {CELL_PRX_ERROR_UNKNOWN_MODULE, addr};
}

const auto [prx, id] = idm::select<lv2_obj, lv2_prx>([&](u32 id, lv2_prx& prx) -> u32
{
for (const ppu_segment& seg : prx.segs)
{
if (seg.size && addr >= seg.addr && addr < seg.addr + seg.size)
{
return id;
}
}

return 0;
});

if (!id)
{
return {CELL_PRX_ERROR_UNKNOWN_MODULE, addr};
}

return not_an_error(id);
}

error_code _sys_prx_start(ppu_thread& ppu)
Expand Down