From 20ea0ee1909de7355491c562f05fb19e91d936b2 Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Sun, 9 Mar 2025 16:17:33 -0500 Subject: [PATCH] Handle error behavior in sceSysmoduleGetModuleInfoForUnwind stub (#2629) * Stubby implementation of sceSysmoduleGetModuleInfoForUnwind * Update sysmodule.cpp * Minor cleanup --- src/core/libraries/kernel/process.cpp | 14 +------------- src/core/libraries/kernel/process.h | 15 +++++++++++++++ src/core/libraries/system/sysmodule.cpp | 8 ++++++-- src/core/libraries/system/sysmodule.h | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/core/libraries/kernel/process.cpp b/src/core/libraries/kernel/process.cpp index 58628867a..cb61bbda9 100644 --- a/src/core/libraries/kernel/process.cpp +++ b/src/core/libraries/kernel/process.cpp @@ -85,19 +85,7 @@ s32 PS4_SYSV_ABI sceKernelDlsym(s32 handle, const char* symbol, void** addrp) { return ORBIS_OK; } -static constexpr size_t ORBIS_DBG_MAX_NAME_LENGTH = 256; - -struct OrbisModuleInfoForUnwind { - u64 st_size; - std::array name; - VAddr eh_frame_hdr_addr; - VAddr eh_frame_addr; - u64 eh_frame_size; - VAddr seg0_addr; - u64 seg0_size; -}; - -s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, int flags, +s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags, OrbisModuleInfoForUnwind* info) { if (flags >= 3) { std::memset(info, 0, sizeof(OrbisModuleInfoForUnwind)); diff --git a/src/core/libraries/kernel/process.h b/src/core/libraries/kernel/process.h index 0340a9793..09e4276fb 100644 --- a/src/core/libraries/kernel/process.h +++ b/src/core/libraries/kernel/process.h @@ -11,10 +11,25 @@ class SymbolsResolver; namespace Libraries::Kernel { +static constexpr size_t ORBIS_DBG_MAX_NAME_LENGTH = 256; + +struct OrbisModuleInfoForUnwind { + u64 st_size; + std::array name; + VAddr eh_frame_hdr_addr; + VAddr eh_frame_addr; + u64 eh_frame_size; + VAddr seg0_addr; + u64 seg0_size; +}; + int PS4_SYSV_ABI sceKernelIsNeoMode(); int PS4_SYSV_ABI sceKernelGetCompiledSdkVersion(int* ver); +s32 PS4_SYSV_ABI sceKernelGetModuleInfoForUnwind(VAddr addr, s32 flags, + OrbisModuleInfoForUnwind* info); + void RegisterProcess(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Kernel diff --git a/src/core/libraries/system/sysmodule.cpp b/src/core/libraries/system/sysmodule.cpp index 350f1317b..6c73764f2 100644 --- a/src/core/libraries/system/sysmodule.cpp +++ b/src/core/libraries/system/sysmodule.cpp @@ -7,6 +7,7 @@ #include "common/logging/log.h" #include "core/libraries/error_codes.h" +#include "core/libraries/kernel/process.h" #include "core/libraries/libs.h" #include "core/libraries/system/sysmodule.h" #include "core/libraries/system/system_error.h" @@ -18,9 +19,12 @@ int PS4_SYSV_ABI sceSysmoduleGetModuleHandleInternal() { return ORBIS_OK; } -int PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind() { +s32 PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(VAddr addr, s32 flags, void* info) { LOG_ERROR(Lib_SysModule, "(STUBBED) called"); - return ORBIS_OK; + Kernel::OrbisModuleInfoForUnwind module_info; + module_info.st_size = 0x130; + s32 res = Kernel::sceKernelGetModuleInfoForUnwind(addr, flags, &module_info); + return res; } int PS4_SYSV_ABI sceSysmoduleIsCalledFromSysModule() { diff --git a/src/core/libraries/system/sysmodule.h b/src/core/libraries/system/sysmodule.h index 3630fb58e..dfbdca162 100644 --- a/src/core/libraries/system/sysmodule.h +++ b/src/core/libraries/system/sysmodule.h @@ -152,7 +152,7 @@ enum class OrbisSysModuleInternal : u32 { }; int PS4_SYSV_ABI sceSysmoduleGetModuleHandleInternal(); -int PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(); +s32 PS4_SYSV_ABI sceSysmoduleGetModuleInfoForUnwind(VAddr addr, s32 flags, void* info); int PS4_SYSV_ABI sceSysmoduleIsCalledFromSysModule(); int PS4_SYSV_ABI sceSysmoduleIsCameraPreloaded(); int PS4_SYSV_ABI sceSysmoduleIsLoaded(OrbisSysModule id);