Better bounds checks for sceKernelDlsym

Unity, being the awful game engine it is, checks for a return value of zero to determine if sceKernelLoadStartModule failed. This results in it throwing an error code into sceKernelDlsym's handle parameter when the module it's searching for doesn't exist.
This commit is contained in:
Stephen Miller 2025-02-09 21:02:42 -06:00
parent 22357f70c2
commit 61a168091f
2 changed files with 7 additions and 1 deletions

View File

@ -75,6 +75,9 @@ s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, size_t arg
s32 PS4_SYSV_ABI sceKernelDlsym(s32 handle, const char* symbol, void** addrp) {
auto* linker = Common::Singleton<Core::Linker>::Instance();
auto* module = linker->GetModule(handle);
if (module == nullptr) {
return ORBIS_KERNEL_ERROR_ESRCH;
}
*addrp = module->FindByName(symbol);
if (*addrp == nullptr) {
return ORBIS_KERNEL_ERROR_ESRCH;

View File

@ -83,7 +83,10 @@ public:
}
Module* GetModule(s32 index) const {
return m_modules.at(index).get();
if (index >= 0 || index < m_modules.size()) {
return m_modules.at(index).get();
}
return nullptr;
}
u32 FindByName(const std::filesystem::path& name) const {