From 85b6f5f5053e4d51a3b590d9ee53c9bace7bde5b Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Thu, 14 May 2026 20:18:16 -0500 Subject: [PATCH] Proper check for double init (#4419) --- src/core/libraries/app_content/app_content.cpp | 15 ++++++++++++++- .../libraries/app_content/app_content_error.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/libraries/app_content/app_content.cpp b/src/core/libraries/app_content/app_content.cpp index c01c0d655..3bf282916 100644 --- a/src/core/libraries/app_content/app_content.cpp +++ b/src/core/libraries/app_content/app_content.cpp @@ -5,12 +5,14 @@ #include "app_content.h" #include "common/assert.h" +#include "common/elf_info.h" #include "common/logging/log.h" #include "common/singleton.h" #include "core/emulator_settings.h" #include "core/file_format/psf.h" #include "core/file_sys/fs.h" #include "core/libraries/app_content/app_content_error.h" +#include "core/libraries/kernel/process.h" #include "core/libraries/libs.h" #include "core/libraries/system/systemservice.h" @@ -29,8 +31,10 @@ static std::array addcont_inf 0x00}}, }}; +static s32 sdk_ver = 0; static s32 addcont_count = 0; static std::string title_id; +static bool is_initialized = false; int PS4_SYSV_ABI _Z5dummyv() { LOG_ERROR(Lib_AppContent, "(STUBBED) called"); @@ -279,7 +283,13 @@ int PS4_SYSV_ABI sceAppContentGetRegion() { int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initParam, OrbisAppContentBootParam* bootParam) { - LOG_ERROR(Lib_AppContent, "(DUMMY) called"); + if (sdk_ver >= Common::ElfInfo::FW_15 && is_initialized) { + LOG_ERROR(Lib_AppContent, "Already initialized"); + return ORBIS_APP_CONTENT_ERROR_BUSY; + } + + LOG_WARNING(Lib_AppContent, "(DUMMY) called"); + is_initialized = true; auto* param_sfo = Common::Singleton::Instance(); const auto addons_dir = EmulatorSettings.GetAddonInstallDir(); @@ -449,6 +459,9 @@ int PS4_SYSV_ABI sceAppContentGetDownloadedStoreCountry() { } void RegisterLib(Core::Loader::SymbolsResolver* sym) { + ASSERT_MSG(Libraries::Kernel::sceKernelGetCompiledSdkVersion(&sdk_ver) == 0, + "Failed to get SDK version"); + LIB_FUNCTION("AS45QoYHjc4", "libSceAppContent", 1, "libSceAppContentUtil", _Z5dummyv); LIB_FUNCTION("ZiATpP9gEkA", "libSceAppContent", 1, "libSceAppContentUtil", sceAppContentAddcontDelete); diff --git a/src/core/libraries/app_content/app_content_error.h b/src/core/libraries/app_content/app_content_error.h index 3a582b998..58358b6d1 100644 --- a/src/core/libraries/app_content/app_content_error.h +++ b/src/core/libraries/app_content/app_content_error.h @@ -7,5 +7,6 @@ // AppContent library constexpr int ORBIS_APP_CONTENT_ERROR_PARAMETER = 0x80D90002; +constexpr int ORBIS_APP_CONTENT_ERROR_BUSY = 0x80D90003; constexpr int ORBIS_APP_CONTENT_ERROR_DRM_NO_ENTITLEMENT = 0x80D90007; constexpr int ORBIS_APP_CONTENT_ERROR_NOT_FOUND = 0x80D90005;