Kernel.Process: Implement sceKernelGetModuleInfo2, sceKernelGetModuleList2 (#4001)

* twos

* Fixes

Still can't test properly, but this seems to hide system libs, which I'm pretty sure is the necessary difference here.

* Clang

* Extra export for sceKernelGetModuleInfo2
This commit is contained in:
Stephen Miller 2026-02-08 12:07:17 -06:00 committed by GitHub
parent b44ad1e087
commit 2a61851a88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 57 additions and 0 deletions

View File

@ -191,6 +191,26 @@ s32 PS4_SYSV_ABI sceKernelGetModuleInfo(s32 handle, Core::OrbisKernelModuleInfo*
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceKernelGetModuleInfo2(s32 handle, Core::OrbisKernelModuleInfo* info) {
if (info == nullptr) {
return ORBIS_KERNEL_ERROR_EFAULT;
}
if (info->st_size != sizeof(Core::OrbisKernelModuleInfo)) {
return ORBIS_KERNEL_ERROR_EINVAL;
}
auto* linker = Common::Singleton<Core::Linker>::Instance();
auto* module = linker->GetModule(handle);
if (module == nullptr) {
return ORBIS_KERNEL_ERROR_ESRCH;
}
if (module->IsSystemLib()) {
return ORBIS_KERNEL_ERROR_EPERM;
}
*info = module->GetModuleInfo();
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceKernelGetModuleInfoInternal(s32 handle, Core::OrbisKernelModuleInfoEx* info) {
if (info == nullptr) {
return ORBIS_KERNEL_ERROR_EFAULT;
@ -230,6 +250,31 @@ s32 PS4_SYSV_ABI sceKernelGetModuleList(s32* handles, u64 num_array, u64* out_co
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceKernelGetModuleList2(s32* handles, u64 num_array, u64* out_count) {
if (handles == nullptr || out_count == nullptr) {
return ORBIS_KERNEL_ERROR_EFAULT;
}
auto* linker = Common::Singleton<Core::Linker>::Instance();
u64 id = 0;
u64 index = 0;
auto* module = linker->GetModule(id);
while (module != nullptr && index < num_array) {
if (!module->IsSystemLib()) {
handles[index++] = id;
}
id++;
module = linker->GetModule(id);
}
if (index == num_array && module != nullptr) {
return ORBIS_KERNEL_ERROR_ENOMEM;
}
*out_count = index;
return ORBIS_OK;
}
s32 PS4_SYSV_ABI exit(s32 status) {
UNREACHABLE_MSG("Exiting with status code {}", status);
return 0;
@ -249,8 +294,11 @@ void RegisterProcess(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("RpQJJVKTiFM", "libkernel", 1, "libkernel", sceKernelGetModuleInfoForUnwind);
LIB_FUNCTION("f7KBOafysXo", "libkernel", 1, "libkernel", sceKernelGetModuleInfoFromAddr);
LIB_FUNCTION("kUpgrXIrz7Q", "libkernel", 1, "libkernel", sceKernelGetModuleInfo);
LIB_FUNCTION("QgsKEUfkqMA", "libkernel", 1, "libkernel", sceKernelGetModuleInfo2);
LIB_FUNCTION("QgsKEUfkqMA", "libkernel_module_info", 1, "libkernel", sceKernelGetModuleInfo2);
LIB_FUNCTION("HZO7xOos4xc", "libkernel", 1, "libkernel", sceKernelGetModuleInfoInternal);
LIB_FUNCTION("IuxnUuXk6Bg", "libkernel", 1, "libkernel", sceKernelGetModuleList);
LIB_FUNCTION("ZzzC3ZGVAkc", "libkernel", 1, "libkernel", sceKernelGetModuleList2);
LIB_FUNCTION("6Z83sYWFlA8", "libkernel", 1, "libkernel", exit);
}

View File

@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include "common/config.h"
#include "common/types.h"
#include "core/loader/elf.h"
#include "core/loader/symbols_resolver.h"
@ -164,6 +165,14 @@ public:
return elf.IsSharedLib();
}
bool IsSystemLib() {
auto system_path = Config::getSysModulesPath();
if (file.string().starts_with(system_path.string().c_str())) {
return true;
}
return false;
}
template <typename T = VAddr>
T GetProcParam() const noexcept {
return reinterpret_cast<T>(proc_param_virtual_addr);