From f510f9aef273f820d5ba12d78786008b66c817b2 Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Mon, 11 May 2026 22:14:57 -0500 Subject: [PATCH] Core: Various new stubs (#4398) * sceKernelGetProcessType * sceCoredumpRegisterCoredumpHandler stub * Better stub for sceCoredumpRegisterCoredumpHandler, stub sceCoredumpUnregisterCoredumpHandler * sceNpSetNpTitleId stub * sceNpSetContentRestriction stub * sceKernelMlock stub * posix_sigfillset * posix_sigprocmask stub Just logs the how parameter * posix_msync stub Just logging for now * libSceContentExport stubs * Clang * sceVideoRecordingSetInfo stub * sceKernelTitleWorkaroundIsEnabled * Provide title workaround bits Just grabbed them from fpPS4 code, I have a feeling actually applying these is gonna be a bit of a pain though. * fpPS4 has a 0x39 bit, I guess that was probably added after 12.52 though. * Bump to error It's not going to work without proper sceKernelGetAppInfo workaround data * Clang * Clang2 --- CMakeLists.txt | 12 +++- src/common/logging/classes.h | 10 +-- src/common/logging/log.cpp | 2 + .../content_export/content_export.cpp | 56 +++++++++++++++++ .../libraries/content_export/content_export.h | 40 ++++++++++++ .../content_export/content_export_error.h | 26 ++++++++ .../libraries/kernel/coredump/coredump.cpp | 57 +++++++++++++++++ src/core/libraries/kernel/coredump/coredump.h | 47 ++++++++++++++ .../kernel/coredump/coredump_error.h | 14 +++++ src/core/libraries/kernel/kernel.cpp | 29 +++++++++ src/core/libraries/kernel/kernel.h | 61 ++++++++++++++++++ src/core/libraries/kernel/memory.cpp | 14 +++++ .../libraries/kernel/threads/exception.cpp | 15 +++++ src/core/libraries/libs.cpp | 4 ++ src/core/libraries/np/np_manager.cpp | 31 +++++++++ src/core/libraries/np/np_manager.h | 14 +++++ src/core/libraries/np/np_types.h | 9 +++ .../video_recording/video_recording.cpp | 39 ++++++++++++ .../video_recording/video_recording.h | 63 +++++++++++++++++++ .../video_recording/video_recording_error.h | 18 ++++++ 20 files changed, 555 insertions(+), 6 deletions(-) create mode 100644 src/core/libraries/content_export/content_export.cpp create mode 100644 src/core/libraries/content_export/content_export.h create mode 100644 src/core/libraries/content_export/content_export_error.h create mode 100644 src/core/libraries/kernel/coredump/coredump.cpp create mode 100644 src/core/libraries/kernel/coredump/coredump.h create mode 100644 src/core/libraries/kernel/coredump/coredump_error.h create mode 100644 src/core/libraries/video_recording/video_recording.cpp create mode 100644 src/core/libraries/video_recording/video_recording.h create mode 100644 src/core/libraries/video_recording/video_recording_error.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e3740b2a..71bf7aead 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,7 +312,10 @@ set(GNM_LIB src/core/libraries/gnmdriver/gnmdriver.cpp src/core/libraries/gnmdriver/gnm_error.h ) -set(KERNEL_LIB src/core/libraries/kernel/sync/mutex.cpp +set(KERNEL_LIB src/core/libraries/kernel/coredump/coredump.cpp + src/core/libraries/kernel/coredump/coredump.h + src/core/libraries/kernel/coredump/coredump_error.h + src/core/libraries/kernel/sync/mutex.cpp src/core/libraries/kernel/sync/mutex.h src/core/libraries/kernel/sync/semaphore.h src/core/libraries/kernel/threads/condvar.cpp @@ -491,7 +494,12 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp src/core/libraries/font/fontft.cpp src/core/libraries/font/fontft.h src/core/libraries/font/font_error.h - + src/core/libraries/content_export/content_export.cpp + src/core/libraries/content_export/content_export.h + src/core/libraries/content_export/content_export_error.h + src/core/libraries/video_recording/video_recording.cpp + src/core/libraries/video_recording/video_recording.h + src/core/libraries/video_recording/video_recording_error.h ) set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h diff --git a/src/common/logging/classes.h b/src/common/logging/classes.h index eab6dfe27..a25197289 100644 --- a/src/common/logging/classes.h +++ b/src/common/logging/classes.h @@ -34,10 +34,11 @@ constexpr auto Lib_Audio3d = "Lib.Audio3d"; ///< The Lib constexpr auto Lib_AudioIn = "Lib.AudioIn"; ///< The LibSceAudioIn implementation. constexpr auto Lib_AudioOut = "Lib.AudioOut"; ///< The LibSceAudioOut implementation. constexpr auto Lib_AvPlayer = "Lib.AvPlayer"; ///< The LibSceAvPlayer implementation. -constexpr auto Lib_Camera = "Lib.Camera"; ///< The LibCamera implementation. +constexpr auto Lib_Camera = "Lib.Camera"; ///< The LibSceCamera implementation. constexpr auto Lib_CommonDlg = "Lib.CommonDlg"; ///< The LibSceCommonDialog implementation. -constexpr auto Lib_CompanionHttpd = "Lib.CompanionHttpd"; ///< The LibCompanionHttpd implementation. -constexpr auto Lib_CompanionUtil = "Lib.CompanionUtil"; ///< The LibCompanionUtil implementation. +constexpr auto Lib_CompanionHttpd = "Lib.CompanionHttpd"; ///< The LibSceCompanionHttpd implementation. +constexpr auto Lib_CompanionUtil = "Lib.CompanionUtil"; ///< The LibSceCompanionUtil implementation. +constexpr auto Lib_ContentExport = "Lib.ContentExport"; ///< The LibSceContentExport implementation. constexpr auto Lib_DiscMap = "Lib.DiscMap"; ///< The LibSceDiscMap implementation. constexpr auto Lib_ErrorDialog = "Lib.ErrorDialog"; ///< The LibSceErrorDialog implementation. constexpr auto Lib_Fiber = "Lib.Fiber"; ///< The LibSceFiber implementation. @@ -53,7 +54,7 @@ constexpr auto Lib_Ime = "Lib.Ime"; ///< The Lib constexpr auto Lib_ImeDialog = "Lib.ImeDialog"; ///< The LibSceImeDialog implementation. constexpr auto Lib_Jpeg = "Lib.Jpeg"; ///< The LibSceJpeg implementation. constexpr auto Lib_Kernel = "Lib.Kernel"; ///< The LibKernel implementation. -constexpr auto Lib_LibcInternal = "Lib.LibcInternal"; ///< The LibcInternal implementation. +constexpr auto Lib_LibcInternal = "Lib.LibcInternal"; ///< The LibSceLibcInternal implementation. constexpr auto Lib_Mouse = "Lib.Mouse"; ///< The LibSceMouse implementation constexpr auto Lib_Move = "Lib.Move"; ///< The LibSceMove implementation. constexpr auto Lib_MsgDlg = "Lib.MsgDlg"; ///< The LibSceMsgDialog implementation. @@ -98,6 +99,7 @@ constexpr auto Lib_UserService = "Lib.UserService"; ///< The Lib constexpr auto Lib_Vdec2 = "Lib.Vdec2"; ///< The LibSceVideodec2 implementation. constexpr auto Lib_VideoOut = "Lib.VideoOut"; ///< The LibSceVideoOut implementation. constexpr auto Lib_Videodec = "Lib.Videodec"; ///< The LibSceVideodec implementation. +constexpr auto Lib_VideoRecording = "Lib.VideoRecording"; ///< The LibSceVideoRecording implementation. constexpr auto Lib_Voice = "Lib.Voice"; ///< The LibSceVoice implementation. constexpr auto Lib_VrTracker = "Lib.VrTracker"; ///< The LibSceVrTracker implementation. constexpr auto Lib_WebBrowserDialog = "Lib.WebBrowserDialog"; ///< The LibSceWebBrowserDialog implementation diff --git a/src/common/logging/log.cpp b/src/common/logging/log.cpp index c8bfbdb4d..df0b09f3e 100644 --- a/src/common/logging/log.cpp +++ b/src/common/logging/log.cpp @@ -52,6 +52,7 @@ std::unordered_map> ALL_LOGGER {Class::Lib_CommonDlg, nullptr}, {Class::Lib_CompanionHttpd, nullptr}, {Class::Lib_CompanionUtil, nullptr}, + {Class::Lib_ContentExport, nullptr}, {Class::Lib_DiscMap, nullptr}, {Class::Lib_ErrorDialog, nullptr}, {Class::Lib_Fiber, nullptr}, @@ -112,6 +113,7 @@ std::unordered_map> ALL_LOGGER {Class::Lib_Vdec2, nullptr}, {Class::Lib_VideoOut, nullptr}, {Class::Lib_Videodec, nullptr}, + {Class::Lib_VideoRecording, nullptr}, {Class::Lib_Voice, nullptr}, {Class::Lib_VrTracker, nullptr}, {Class::Lib_WebBrowserDialog, nullptr}, diff --git a/src/core/libraries/content_export/content_export.cpp b/src/core/libraries/content_export/content_export.cpp new file mode 100644 index 000000000..9705c002e --- /dev/null +++ b/src/core/libraries/content_export/content_export.cpp @@ -0,0 +1,56 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/content_export/content_export.h" +#include "core/libraries/content_export/content_export_error.h" +#include "core/libraries/libs.h" + +namespace Libraries::ContentExport { + +static bool g_is_initialized = false; + +s32 _sceContentExportInit(OrbisContentExportInitParam* init_param, u8 version) { + if (g_is_initialized) { + return ORBIS_CONTENT_EXPORT_ERROR_MULTIPLEINIT; + } + if (!init_param || !init_param->mallocfunc || !init_param->freefunc) { + return ORBIS_CONTENT_EXPORT_ERROR_INVALDPARAM; + } + if (version == 1 && (init_param->reserved0 != 0 || init_param->reserved1 != 0 || + (init_param->bufsize != 0 && init_param->bufsize < 0x100))) { + return ORBIS_CONTENT_EXPORT_ERROR_INVALDPARAM; + } + g_is_initialized = true; + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceContentExportInit(OrbisContentExportInitParam* init_param) { + LOG_ERROR(Lib_ContentExport, "(STUBBED) called"); + return _sceContentExportInit(init_param, 0); +} + +s32 PS4_SYSV_ABI sceContentExportInit2(OrbisContentExportInitParam* init_param) { + LOG_ERROR(Lib_ContentExport, "(STUBBED) called"); + return _sceContentExportInit(init_param, 1); +} + +s32 PS4_SYSV_ABI sceContentExportTerm() { + LOG_ERROR(Lib_ContentExport, "(STUBBED) called"); + if (!g_is_initialized) { + return ORBIS_CONTENT_EXPORT_ERROR_NOINIT; + } + g_is_initialized = false; + return ORBIS_OK; +} + +void RegisterLib(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("FzEWeYnAFlI", "libSceContentExport", 1, "libSceContentExport", + sceContentExportInit); + LIB_FUNCTION("0GnN4QCgIfs", "libSceContentExport", 1, "libSceContentExport", + sceContentExportInit2); + LIB_FUNCTION("+KDWny9Y-6k", "libSceContentExport", 1, "libSceContentExport", + sceContentExportTerm); +} + +} // namespace Libraries::ContentExport \ No newline at end of file diff --git a/src/core/libraries/content_export/content_export.h b/src/core/libraries/content_export/content_export.h new file mode 100644 index 000000000..670f81ac5 --- /dev/null +++ b/src/core/libraries/content_export/content_export.h @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::ContentExport { + +typedef void* PS4_SYSV_ABI (*OrbisContentExportMalloc)(u64 datasize, void* userdata); +typedef void PS4_SYSV_ABI (*OrbisContentExportFree)(void* p, void* userdata); +typedef s32 PS4_SYSV_ABI (*OrbisContentExportDataProvideFunction)(void** data, u64* datasize, + void* userdata); + +struct OrbisContentExportInitParam { + OrbisContentExportMalloc mallocfunc; + OrbisContentExportFree freefunc; + void* userdata; + u64 bufsize; + s64 reserved0; + s64 reserved1; +}; + +struct OrbisContentExportParam { + char title[257]; + char comment[257]; + char contenttype[65]; +}; + +struct OrbisContentExportCallbackParam { + u64 contentlength; + OrbisContentExportDataProvideFunction func; + void* userdata; +}; + +void RegisterLib(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::ContentExport \ No newline at end of file diff --git a/src/core/libraries/content_export/content_export_error.h b/src/core/libraries/content_export/content_export_error.h new file mode 100644 index 000000000..e611fff15 --- /dev/null +++ b/src/core/libraries/content_export/content_export_error.h @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" +#include "core/libraries/error_codes.h" + +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_CANCELED = 0x809D3001; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_NOTACCEPT = 0x809D3002; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_BUSY = 0x809D3003; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_NOINIT = 0x809D3004; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_MULTIPLEINIT = 0x809D3005; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_NOMEM = 0x809D3006; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_FILE_NOT_FOUND = 0x809D3011; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_NOT_SUPPORTED_FORMAT = 0x809D3012; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_LARGE_TITLE = 0x809D3013; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_LARGE_COMMENT = 0x809D3015; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_INVALDPARAM = 0x809D3016; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_DISKFULL = 0x809D3017; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_EXECUTION_MAX = 0x809D3018; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_NOT_SUPPORT_FORMAT_THUMBNAIL = 0x809D3019; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_FILES_IN_USE = 0x809D301A; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_DATA_PROVIDE_FUNCTION = 0x809D301B; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_BADFILENAME = 0x809D301C; +constexpr s32 ORBIS_CONTENT_EXPORT_ERROR_NOT_IMPLEMENTED = 0x809D3FFF; diff --git a/src/core/libraries/kernel/coredump/coredump.cpp b/src/core/libraries/kernel/coredump/coredump.cpp new file mode 100644 index 000000000..e552898eb --- /dev/null +++ b/src/core/libraries/kernel/coredump/coredump.cpp @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/kernel/coredump/coredump.h" +#include "core/libraries/kernel/coredump/coredump_error.h" +#include "core/libraries/kernel/process.h" +#include "core/libraries/libs.h" + +namespace Libraries::Kernel { + +OrbisCoredumpHandler g_coredump_handler{}; +void* g_coredump_common{}; +s32 g_sdk_ver{}; + +s32 PS4_SYSV_ABI sceCoredumpRegisterCoredumpHandler(OrbisCoredumpHandler handler, u64 stack_size, + void* common) { + LOG_WARNING(Lib_Kernel, "(STUBBED) called, handler = {}, stack_size = {:#x}, common = {}", + fmt::ptr(handler), stack_size, fmt::ptr(common)); + if (g_coredump_handler) { + LOG_ERROR(Lib_Kernel, "Coredump handler is already registered"); + return ORBIS_COREDUMP_ERROR_ALREADY_REGISTERED; + } + if (!handler || stack_size >= 0x20000000) { + LOG_ERROR(Lib_Kernel, "Invalid coredump handler parameters"); + return ORBIS_COREDUMP_ERROR_PARAM; + } + + // Real library starts a separate thread for coredump handling. + // For this stub, just store the globals. + g_coredump_handler = handler; + g_coredump_common = common; + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceCoredumpUnregisterCoredumpHandler() { + LOG_INFO(Lib_Kernel, "called"); + if (!g_coredump_handler) { + LOG_ERROR(Lib_Kernel, "No coredump handler to unregister"); + return ORBIS_COREDUMP_ERROR_NOT_REGISTERED; + } + + g_coredump_handler = nullptr; + return ORBIS_OK; +} + +void RegisterCoredump(Core::Loader::SymbolsResolver* sym) { + ASSERT_MSG(sceKernelGetCompiledSdkVersion(&g_sdk_ver) == ORBIS_OK, + "Failed to retrieve SDK version"); + + LIB_FUNCTION("8zLSfEfW5AU", "libSceCoredump", 1, "libkernel", + sceCoredumpRegisterCoredumpHandler); + LIB_FUNCTION("fFkhOgztiCA", "libSceCoredump", 1, "libkernel", + sceCoredumpUnregisterCoredumpHandler); +} + +} // namespace Libraries::Kernel \ No newline at end of file diff --git a/src/core/libraries/kernel/coredump/coredump.h b/src/core/libraries/kernel/coredump/coredump.h new file mode 100644 index 000000000..4b5fdb55f --- /dev/null +++ b/src/core/libraries/kernel/coredump/coredump.h @@ -0,0 +1,47 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::Kernel { + +typedef s32 PS4_SYSV_ABI (*OrbisCoredumpHandler)(void* common); + +struct OrbisCoredumpStopInfoCpu { + void* thread; + s32 reason_code; +}; + +struct OrbisCoredumpStopInfoGpu { + u64 timestamp; +}; + +struct OrbisCoredumpThreadContextInfo { + u64 rdi; + u64 rsi; + u64 rdx; + u64 rcx; + u64 r8; + u64 r9; + u64 rax; + u64 rbx; + u64 rbp; + u64 r10; + u64 r11; + u64 r12; + u64 r13; + u64 r14; + u64 r15; + u64 rip; + u64 rflags; + u64 rsp; +}; + +void RegisterCoredump(Core::Loader::SymbolsResolver* sym); + +} // namespace Libraries::Kernel \ No newline at end of file diff --git a/src/core/libraries/kernel/coredump/coredump_error.h b/src/core/libraries/kernel/coredump/coredump_error.h new file mode 100644 index 000000000..348a155c7 --- /dev/null +++ b/src/core/libraries/kernel/coredump/coredump_error.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" +#include "core/libraries/error_codes.h" + +constexpr s32 ORBIS_COREDUMP_ERROR_PARAM = 0x81180000; +constexpr s32 ORBIS_COREDUMP_ERROR_NOT_REGISTERED = 0x81180001; +constexpr s32 ORBIS_COREDUMP_ERROR_ALREADY_REGISTERED = 0x81180002; +constexpr s32 ORBIS_COREDUMP_ERROR_NOT_IN_COREDUMP_HANDLER = 0x81180003; +constexpr s32 ORBIS_COREDUMP_ERROR_THREAD_CREATE = 0x81180004; +constexpr s32 ORBIS_COREDUMP_ERROR_STOP_INFO_UNAVAILABLE = 0x81180005; \ No newline at end of file diff --git a/src/core/libraries/kernel/kernel.cpp b/src/core/libraries/kernel/kernel.cpp index 4d74e731b..87c11ce97 100644 --- a/src/core/libraries/kernel/kernel.cpp +++ b/src/core/libraries/kernel/kernel.cpp @@ -13,6 +13,7 @@ #include "common/va_ctx.h" #include "core/file_sys/fs.h" #include "core/libraries/error_codes.h" +#include "core/libraries/kernel/coredump/coredump.h" #include "core/libraries/kernel/debug.h" #include "core/libraries/kernel/equeue.h" #include "core/libraries/kernel/file_system.h" @@ -298,6 +299,31 @@ s32 PS4_SYSV_ABI sceKernelGetAppInfo(s32 pid, OrbisKernelAppInfo* app_info) { return ORBIS_OK; } +s32 PS4_SYSV_ABI sceKernelTitleWorkaroundIsEnabled(OrbisKernelTitleWorkaround* tw, s32 bit, + s32* result) { + LOG_ERROR(Lib_Kernel, "(STUBBED) called, bit {:#x}", bit); + if (!tw || !result) { + return ORBIS_KERNEL_ERROR_EFAULT; + } + + // Maximum bit value is known to change with new firmwares. + if (bit >= 0x3a) { + return ORBIS_KERNEL_ERROR_EINVAL; + } + + // Straight from decompilation, most uses rely on workaround data from sceKernelGetAppInfo. + *result = ((tw->ids[bit >> 6] >> (bit & 0x3f)) & 1); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceKernelGetProcessType(s32 pid) { + LOG_ERROR(Lib_Kernel, "(STUBBED) called, pid: {}", pid); + if (pid != GLOBAL_PID) { + return ORBIS_KERNEL_ERROR_ENOSYS; + } + return 0; +} + // Nominally: long sysconf(int name); u64 PS4_SYSV_ABI posix_sysconf(s32 name) { switch (name) { @@ -431,6 +457,7 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { Libraries::Kernel::RegisterException(sym); Libraries::Kernel::RegisterAio(sym); Libraries::Kernel::RegisterDebug(sym); + Libraries::Kernel::RegisterCoredump(sym); LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", &g_stack_chk_guard); LIB_FUNCTION("D4yla3vx4tY", "libkernel", 1, "libkernel", sceKernelError); @@ -438,6 +465,8 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("Mv1zUObHvXI", "libkernel", 1, "libkernel", sceKernelGetSystemSwVersion); LIB_FUNCTION("igMefp4SAv0", "libkernel", 1, "libkernel", get_authinfo); LIB_FUNCTION("G-MYv5erXaU", "libkernel", 1, "libkernel", sceKernelGetAppInfo); + LIB_FUNCTION("1yca4VvfcNA", "libkernel", 1, "libkernel", sceKernelTitleWorkaroundIsEnabled); + LIB_FUNCTION("+g+UP8Pyfmo", "libkernel", 1, "libkernel", sceKernelGetProcessType); LIB_FUNCTION("PfccT7qURYE", "libkernel", 1, "libkernel", kernel_ioctl); LIB_FUNCTION("wW+k21cmbwQ", "libkernel", 1, "libkernel", kernel_ioctl); LIB_FUNCTION("JGfTMBOdUJo", "libkernel", 1, "libkernel", sceKernelGetFsSandboxRandomWord); diff --git a/src/core/libraries/kernel/kernel.h b/src/core/libraries/kernel/kernel.h index 017749543..d400844d4 100644 --- a/src/core/libraries/kernel/kernel.h +++ b/src/core/libraries/kernel/kernel.h @@ -56,6 +56,67 @@ struct AuthInfoData { u64 ucred[8]; }; +enum OrbisKernelTitleWorkaroundBits { + BUG107292_EXTRA_USB_AUDIO_DEVICE = 0x0, + BUG119504_SUSPEND_BLACK_LIST = 0x1, + BUG113237_LIVE_DETAIL_BLACK_LIST = 0x2, + BUG117780_GPU_DOUBLE_PRECISION = 0x3, + BUG134640_FFXIV_MOVIE_CRASH = 0x4, + BUG140207_FAKE_BG_EXECUTION = 0x5, + BUG140207_DELAY_SUSPEND = 0x6, + BUG141751_FORCE_VIDEO_RECORDING_COMPATIBLE = 0x7, + BUG141953_FORCE_CONTENT_SEARCH_COMPATIBLE = 0x8, + BUG135666_FORCED_BASE_MODE = 0x9, + BUG142996_NEW_QUICK_MENU_BLACK_LIST = 0xa, + BUG146562_PRODUCT_DETAIL_BLACK_LIST = 0xb, + BUG141677_DISABLE_SERVICE_ENTITLEMENT_UPDATE_EVENT = 0xc, + BUG158272_EXTERNAL_HDD_BLACK_LIST = 0xd, + BUG159526_INVALIDATE_ENTITLEMENT_IN_APPLICATION_DB = 0xe, + BUG163566_BOOST_MODE_BLACK_LIST = 0xf, + BUG171584_EXTERNAL_HDD_ACCESS_LATENCY = 0x10, + BUG183465_SPECIAL_ISSUE = 0x11, + BUG183542_NEO_VDDNB_VID_3STEP = 0x12, + BUG183542_NEO_VDDNB_VID_4STEP = 0x13, + BUG183542_NEO_VDDNB_VID_5STEP = 0x14, + BUG184831_NEO_VDDNB_VID_STEP_UP_ALL_TITLE = 0x15, + BUG180029_SAVE_DATA_MEMORY_TIMEOUT_10SEC = 0x16, + BUG180341_WEBAPI_NOT_COPY_ERROR_JSON = 0x17, + BUG180847_USE_RECRYPT_BLOCKS = 0x18, + BUG182301_NP_MANAGER_KEEP_COMPATIBLE = 0x19, + BUG182170_OSK = 0x1a, + BUG188290_NEO_SCLK_DOWN_LEVEL1 = 0x1b, + BUG188290_NEO_SCLK_DOWN_LEVEL2 = 0x1c, + BUG188290_NEO_SCLK_DOWN_LEVEL3 = 0x1d, + BUG187987_NTS_CONNECTHASHTABLE = 0x1e, + BUG190872_HIDE_4K = 0x1f, + BUG191849_HDCP_CHECK_APP_ONLY = 0x20, + BUG193000_USE_OLD_WEB_BROWSER_ENGINE = 0x21, + BUG186690_IME_DISABLE_REMOTE_PLAY = 0x22, + BUG196278_IME_DISABLE_REMOTE_PLAY_WITH_DISABLE_CONTROLLER = 0x23, + BUG196285_IME_PACKED_UPDATE_TEXT = 0x24, + BUG186690_IME_REMOTE_PLAY_FINISHED_BY_PRESS_ENTER = 0x25, + BUG196699_SYSMODULE_SWITCH_LIBSSL = 0x26, + BUG192912_PLAYGO_FULL_MULTISTREAM = 0x27, + BUG201910_DINO_FRONTIER_DLSYM = 0x28, + BUG202240_HIKARU_UTADA_SCHED = 0x29, + BUG198989_ANTHEM_KERNEL_PANIC = 0x2a, + BUG202952_SSL_CHECK_RECV_PENDING_ALWAYS_TRUE = 0x2b, + BUG203700_PARTY_ROLLBACK = 0x2c, + CAMELOT3106_USE_OLD_STYLE_USER_AGENT = 0x2d, + BUG209289_SESSION_SIGNALING_TERMINATE_ON_LEFT = 0x2e, + BUG198642_LB_SYNC_RESET_TO_FIX_CURSOR_8000 = 0x2f, + BUG198642_LB_SYNC_RESET_NOT_TO_FIX_CURSOR = 0x30, + BUG210925_ENABLE_TLS_BUG_FIX = 0x31, + BUG211235_ENABLE_PRIORITIZE_DLC = 0x32, + BUG212056_IGNORE_PRELOAD_PATCH_VERSION = 0x33, + PPRBUG57571_PUSH_CONTEXT_CALLBACK_PTOA_SPEC = 0x34, + PPRBUG58630_LIBHTTP_USERAGENT_VERSION = 0x35, + BUG212932_NOT_TO_FIX_POSIX_SEM = 0x36, + WAL936_DISABLE_KEYBOARD_EVENT_KEY_AND_CODE = 0x37, + PPRREQ81061_ENABLE_GB_18030_2022_FONTSET = 0x38, + PPRREQ103800_AGE_RESTRICTION_CHECK = 0x39, +}; + struct OrbisKernelTitleWorkaround { s32 version; s32 align; diff --git a/src/core/libraries/kernel/memory.cpp b/src/core/libraries/kernel/memory.cpp index f0b7df4c9..5667c1697 100644 --- a/src/core/libraries/kernel/memory.cpp +++ b/src/core/libraries/kernel/memory.cpp @@ -774,6 +774,17 @@ s32 PS4_SYSV_ABI posix_munmap(void* addr, u64 len) { return result; } +s32 PS4_SYSV_ABI sceKernelMlock(void* addr, u64 len) { + LOG_ERROR(Kernel_Vmm, "(STUBBED) called, addr = {}, len = {:#x}", fmt::ptr(addr), len); + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI posix_msync(void* addr, u64 len, s32 flags) { + LOG_ERROR(Kernel_Vmm, "(STUBBED) called, addr = {}, len = {:#x}, flags = {}", fmt::ptr(addr), + len, flags); + return ORBIS_OK; +} + static constexpr s32 MAX_PRT_APERTURES = 3; static constexpr VAddr PRT_AREA_START_ADDR = 0x1000000000; static constexpr u64 PRT_AREA_SIZE = 0xec00000000; @@ -865,6 +876,9 @@ void RegisterMemory(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("BPE9s9vQQXo", "libScePosix", 1, "libkernel", posix_mmap); LIB_FUNCTION("UqDGjXA5yUM", "libkernel", 1, "libkernel", posix_munmap); LIB_FUNCTION("UqDGjXA5yUM", "libScePosix", 1, "libkernel", posix_munmap); + LIB_FUNCTION("3k6kx-zOOSQ", "libkernel", 1, "libkernel", sceKernelMlock); + LIB_FUNCTION("tZY4+SZNFhA", "libkernel", 1, "libkernel", posix_msync); + LIB_FUNCTION("tZY4+SZNFhA", "libScePosix", 1, "libkernel", posix_msync); // PRT memory management LIB_FUNCTION("BohYr-F7-is", "libkernel", 1, "libkernel", sceKernelSetPrtAperture); diff --git a/src/core/libraries/kernel/threads/exception.cpp b/src/core/libraries/kernel/threads/exception.cpp index f9a062da7..dc8607124 100644 --- a/src/core/libraries/kernel/threads/exception.cpp +++ b/src/core/libraries/kernel/threads/exception.cpp @@ -304,10 +304,21 @@ s32 PS4_SYSV_ABI posix_sigemptyset(Sigset* s) { return 0; } +s32 PS4_SYSV_ABI posix_sigfillset(Sigset* s) { + s->bits[0] = ~0U; + s->bits[1] = ~0U; + return 0; +} + bool PS4_SYSV_ABI posix_sigisemptyset(Sigset* s) { return s->bits[0] == 0 && s->bits[1] == 0; } +s32 PS4_SYSV_ABI posix_sigprocmask(s32 how, const Sigset* set, Sigset* oset) { + LOG_ERROR(Lib_Kernel, "(STUBBED) called, how = {}", how); + return ORBIS_OK; +} + s32 PS4_SYSV_ABI posix_sigalstack(const OrbisKernelExceptionHandlerStack* ss, OrbisKernelExceptionHandlerStack* old_ss) { #ifdef __unix__ @@ -516,11 +527,15 @@ void RegisterException(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("KiJEPEWRyUY", "libkernel", 1, "libkernel", posix_sigaction); LIB_FUNCTION("+F7C-hdk7+E", "libkernel", 1, "libkernel", posix_sigemptyset); + LIB_FUNCTION("VkTAsrZDcJ0", "libkernel", 1, "libkernel", posix_sigfillset); + LIB_FUNCTION("aPcyptbOiZs", "libkernel", 1, "libkernel", posix_sigprocmask); LIB_FUNCTION("yH-uQW3LbX0", "libkernel", 1, "libkernel", posix_pthread_kill); LIB_FUNCTION("sHziAegVp74", "libkernel", 1, "libkernel", posix_sigalstack); LIB_FUNCTION("KiJEPEWRyUY", "libScePosix", 1, "libkernel", posix_sigaction); LIB_FUNCTION("+F7C-hdk7+E", "libScePosix", 1, "libkernel", posix_sigemptyset); + LIB_FUNCTION("VkTAsrZDcJ0", "libScePosix", 1, "libkernel", posix_sigfillset); + LIB_FUNCTION("aPcyptbOiZs", "libScePosix", 1, "libkernel", posix_sigprocmask); LIB_FUNCTION("yH-uQW3LbX0", "libScePosix", 1, "libkernel", posix_pthread_kill); LIB_FUNCTION("sHziAegVp74", "libScePosix", 1, "libkernel", posix_sigalstack); } diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index d207126bc..996f90bc3 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -11,6 +11,7 @@ #include "core/libraries/camera/camera.h" #include "core/libraries/companion/companion_httpd.h" #include "core/libraries/companion/companion_util.h" +#include "core/libraries/content_export/content_export.h" #include "core/libraries/disc_map/disc_map.h" #include "core/libraries/game_live_streaming/gamelivestreaming.h" #include "core/libraries/gnmdriver/gnmdriver.h" @@ -65,6 +66,7 @@ #include "core/libraries/system/userservice.h" #include "core/libraries/ulobjmgr/ulobjmgr.h" #include "core/libraries/usbd/usbd.h" +#include "core/libraries/video_recording/video_recording.h" #include "core/libraries/videodec/videodec.h" #include "core/libraries/videodec/videodec2.h" #include "core/libraries/videoout/video_out.h" @@ -151,6 +153,8 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::Voice::RegisterLib(sym); Libraries::Rudp::RegisterLib(sym); Libraries::VrTracker::RegisterLib(sym); + Libraries::ContentExport::RegisterLib(sym); + Libraries::VideoRecording::RegisterLib(sym); // Loading libSceSsl is locked behind a title workaround that currently applies to nothing. // Libraries::Ssl::RegisterLib(sym); diff --git a/src/core/libraries/np/np_manager.cpp b/src/core/libraries/np/np_manager.cpp index b6851cbdb..a797e01e9 100644 --- a/src/core/libraries/np/np_manager.cpp +++ b/src/core/libraries/np/np_manager.cpp @@ -696,6 +696,33 @@ s32 PS4_SYSV_ABI sceNpHasSignedUp(Libraries::UserService::OrbisUserServiceUserId return ORBIS_OK; } +s32 PS4_SYSV_ABI sceNpSetContentRestriction(const OrbisNpContentRestriction* restriction) { + LOG_ERROR(Lib_NpManager, "(STUBBED) called"); + if (restriction == nullptr) { + return ORBIS_NP_ERROR_INVALID_ARGUMENT; + } + if (restriction->size != sizeof(OrbisNpContentRestriction)) { + return ORBIS_NP_ERROR_INVALID_SIZE; + } + if (restriction->default_age_restriction < 0 || restriction->age_restriction_count > 0x100) { + return ORBIS_NP_ERROR_INVALID_ARGUMENT; + } + if (restriction->age_restriction_count > 0 && restriction->age_restriction == nullptr) { + return ORBIS_NP_ERROR_INVALID_ARGUMENT; + } + return ORBIS_OK; +} + +s32 PS4_SYSV_ABI sceNpSetNpTitleId(const OrbisNpTitleId* title_id, + const OrbisNpTitleSecret* title_secret) { + if (title_id == nullptr || title_secret == nullptr) { + LOG_ERROR(Lib_NpManager, "called with invalid arguments"); + return ORBIS_NP_ERROR_INVALID_ARGUMENT; + } + LOG_ERROR(Lib_NpManager, "(STUBBED) called, title_id = {}", title_id->id); + return ORBIS_OK; +} + struct NpStateCallbackForNpToolkit { OrbisNpStateCallbackForNpToolkit func; void* userdata; @@ -826,6 +853,10 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) { LIB_FUNCTION("eQH7nWPcAgc", "libSceNpManager", 1, "libSceNpManager", sceNpGetState); LIB_FUNCTION("VgYczPGB5ss", "libSceNpManager", 1, "libSceNpManager", sceNpGetUserIdByAccountId); LIB_FUNCTION("Oad3rvY-NJQ", "libSceNpManager", 1, "libSceNpManager", sceNpHasSignedUp); + LIB_FUNCTION("A2CQ3kgSopQ", "libSceNpManager", 1, "libSceNpManager", + sceNpSetContentRestriction); + LIB_FUNCTION("Ec63y59l9tw", "libSceNpManager", 1, "libSceNpManager", sceNpSetNpTitleId); + LIB_FUNCTION("3Zl8BePTh9Y", "libSceNpManager", 1, "libSceNpManager", sceNpCheckCallback); LIB_FUNCTION("JELHf4xPufo", "libSceNpManager", 1, "libSceNpManager", sceNpCheckCallbackForLib); LIB_FUNCTION("VfRSmPmj8Q8", "libSceNpManager", 1, "libSceNpManager", diff --git a/src/core/libraries/np/np_manager.h b/src/core/libraries/np/np_manager.h index 49250db03..8af8b73d0 100644 --- a/src/core/libraries/np/np_manager.h +++ b/src/core/libraries/np/np_manager.h @@ -53,6 +53,20 @@ struct OrbisNpCountryCode { char pad; }; +struct OrbisNpAgeRestriction { + OrbisNpCountryCode country_code; + s8 age; + u8 padding[3]; +}; + +struct OrbisNpContentRestriction { + u64 size; + s8 default_age_restriction; + u8 padding[3]; + s32 age_restriction_count; + const OrbisNpAgeRestriction* age_restriction; +}; + struct OrbisNpDate { u16 year; u8 month; diff --git a/src/core/libraries/np/np_types.h b/src/core/libraries/np/np_types.h index 58c119bec..26ad1316a 100644 --- a/src/core/libraries/np/np_types.h +++ b/src/core/libraries/np/np_types.h @@ -11,6 +11,15 @@ namespace Libraries::Np { using OrbisNpAccountId = u64; +struct OrbisNpTitleId { + char id[13]; + u8 padding[3]; +}; + +struct OrbisNpTitleSecret { + u8 data[128]; +}; + constexpr s32 ORBIS_NP_ONLINEID_MAX_LENGTH = 16; struct OrbisNpOnlineId { diff --git a/src/core/libraries/video_recording/video_recording.cpp b/src/core/libraries/video_recording/video_recording.cpp new file mode 100644 index 000000000..e0c013b32 --- /dev/null +++ b/src/core/libraries/video_recording/video_recording.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/logging/log.h" +#include "core/libraries/libs.h" +#include "core/libraries/video_recording/video_recording.h" +#include "core/libraries/video_recording/video_recording_error.h" + +namespace Libraries::VideoRecording { + +s32 PS4_SYSV_ABI sceVideoRecordingSetInfo(OrbisVideoRecordingInfo set_info, const void* info, + u64 info_len) { + LOG_ERROR(Lib_VideoRecording, "(STUBBED) called, set_info = {:#x}, info_len = {:#x}", + static_cast(set_info), info_len); + if (set_info < OrbisVideoRecordingInfo::Subtitle || + (set_info > OrbisVideoRecordingInfo::Subtitle && + set_info < OrbisVideoRecordingInfo::Description) || + (set_info > OrbisVideoRecordingInfo::Keywords && + set_info < OrbisVideoRecordingInfo::Chapter) || + (set_info > OrbisVideoRecordingInfo::Chapter && + set_info < OrbisVideoRecordingInfo::Copyright) || + (set_info > OrbisVideoRecordingInfo::Chapter && + set_info < OrbisVideoRecordingInfo::PermisssionLevel) || + set_info > OrbisVideoRecordingInfo::UserMeta) { + return ORBIS_VIDEO_RECORDING_ERROR_INVALID_VALUE; + } + + // The library seems to rely on libSceAvcap to provide errors for other parameters. + if (!info) { + return ORBIS_VIDEO_RECORDING_ERROR_INVALID_VALUE; + } + return ORBIS_OK; +} + +void RegisterLib(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("Fc8qxlKINYQ", "libSceVideoRecording", 1, "libSceVideoRecording", + sceVideoRecordingSetInfo); +} +} // namespace Libraries::VideoRecording \ No newline at end of file diff --git a/src/core/libraries/video_recording/video_recording.h b/src/core/libraries/video_recording/video_recording.h new file mode 100644 index 000000000..fbd63cf33 --- /dev/null +++ b/src/core/libraries/video_recording/video_recording.h @@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::VideoRecording { + +struct OrbisVideoRecordingParam2 { + u64 size; + u64 affinity_mask; + s32 thread_priority; + s32 ring_sec; +}; + +struct OrbisVideoRecordingInfoUserMeta { + u64 size; + s32 flags; + char name[32]; + char data[128]; +}; + +struct OrbisVideoRecordingInfoGuardArea { + float x1, y1; + float x2, y2; +}; + +enum OrbisVideoRecordingStatus { + None = 0, + Running = 1, + Paused = 2, +}; + +enum OrbisVideoRecordingInfo { + Subtitle = 0x2, + Description = 0x6, + Comments = 0x7, + Keywords = 0x8, + Chapter = 0xd, + Copyright = 0xa01, + PermisssionLevel = 0xa007, + GuardArea = 0xa008, + UserMeta = 0xa009, +}; + +enum OrbisVideoRecordingChapter { + Change = 0, + Prohibit = 1, +}; + +enum OrbisVideoRecordingUserMeta { + Constant = 1, + Timeline = 2, + Variable = 3, + Debug = 0x8000, +}; + +void RegisterLib(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::VideoRecording \ No newline at end of file diff --git a/src/core/libraries/video_recording/video_recording_error.h b/src/core/libraries/video_recording/video_recording_error.h new file mode 100644 index 000000000..b1f114746 --- /dev/null +++ b/src/core/libraries/video_recording/video_recording_error.h @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" +#include "core/libraries/error_codes.h" + +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_OUT_OF_MEMORY = 0x80A80001; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_FATAL = 0x80A80002; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_INVALID_VALUE = 0x80A80003; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_FILE_OPEN = 0x80A80004; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_FILE_WRITE = 0x80A80005; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_INVALID_STATE = 0x80A80006; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_INTERRUPTED = 0x80A80007; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_UNSUPPORTED = 0x80A80008; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_NO_SPACE = 0x80A80009; +constexpr s32 ORBIS_VIDEO_RECORDING_ERROR_FILE_NO_DATA = 0x80A8000A; \ No newline at end of file