diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index c249699d9b..f635f4b568 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -446,13 +446,29 @@ error_code _sys_prx_unload_module(u32 id, u64 flags, vm::ptr(id); + const auto prx = idm::withdraw(id, [](lv2_prx& prx) -> CellPrxError + { + switch (prx.state) + { + case PRX_STATE_INITIALIZED: + case PRX_STATE_STOPPED: + return {}; + default: break; + } + + return CELL_PRX_ERROR_NOT_REMOVABLE; + }); if (!prx) { return CELL_PRX_ERROR_UNKNOWN_MODULE; } + if (prx.ret) + { + return prx.ret; + } + ppu_unload_prx(*prx); //s32 result = prx->exit ? prx->exit() : CELL_OK;