From 89e0b76ec7a08dda5bb89ec4f684a0e52ca1868f Mon Sep 17 00:00:00 2001 From: igor725 Date: Mon, 27 May 2024 23:40:47 +0300 Subject: [PATCH 1/7] Stub some things --- modules/libSceNpToolkit2/entry.cpp | 33 ++++++++++++++++++++++++++++++ modules/libSceNpWebApi/entry.cpp | 8 ++++++++ 2 files changed, 41 insertions(+) diff --git a/modules/libSceNpToolkit2/entry.cpp b/modules/libSceNpToolkit2/entry.cpp index 76842dba..5b776d5c 100644 --- a/modules/libSceNpToolkit2/entry.cpp +++ b/modules/libSceNpToolkit2/entry.cpp @@ -397,4 +397,37 @@ EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_11UserProf LOG_ERR(L"todo %S", __FUNCTION__); return Ok; } + +/** + * @brief sce::Toolkit::NP::V2::Core::Response::~Response() + * + */ + +EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_8Matching4RoomEED1Ev)() { + LOG_USE_MODULE(libSceNpToolkit2); + LOG_ERR(L"todo %S", __FUNCTION__); + return Ok; +} + +/** + * @brief sce::Toolkit::NP::V2::Core::RequestBase::getFunctionType() const + * + */ + +EXPORT SYSV_ABI int32_t __NID(_ZNK3sce7Toolkit2NP2V24Core11RequestBase15getFunctionTypeEv)() { + LOG_USE_MODULE(libSceNpToolkit2); + LOG_ERR(L"todo %S", __FUNCTION__); + return Ok; +} + +/** + * @brief sce::Toolkit::NP::V2::Core::Response::~Response() + * + */ + +EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_11UserProfile10NpProfilesEED1Ev)() { + LOG_USE_MODULE(libSceNpToolkit2); + LOG_ERR(L"todo %S", __FUNCTION__); + return Ok; +} } diff --git a/modules/libSceNpWebApi/entry.cpp b/modules/libSceNpWebApi/entry.cpp index a72b6def..0a6ae89c 100644 --- a/modules/libSceNpWebApi/entry.cpp +++ b/modules/libSceNpWebApi/entry.cpp @@ -50,6 +50,14 @@ EXPORT SYSV_ABI int32_t sceNpWebApiCreateContextA(int32_t libCtxId, int32_t user return Ok; } +EXPORT SYSV_ABI int32_t sceNpWebApiCreatePushEventFilter() { + return Ok; +} + +EXPORT SYSV_ABI int32_t sceNpWebApiCreateServicePushEventFilter() { + return Ok; +} + EXPORT SYSV_ABI int32_t sceNpWebApiDeleteContext(int32_t titleUserCtxId) { return Ok; } From 82a1e3fcc07dcb0382d0d5bf22a714db276aa827 Mon Sep 17 00:00:00 2001 From: igor725 Date: Tue, 28 May 2024 07:10:00 +0300 Subject: [PATCH 2/7] ERR -> TRACE some continuously called funcs --- modules/libSceGameLiveStreaming/entry.cpp | 6 +++--- modules/libSceRemoteplay/entry.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/libSceGameLiveStreaming/entry.cpp b/modules/libSceGameLiveStreaming/entry.cpp index 0b55209f..daa23dcf 100644 --- a/modules/libSceGameLiveStreaming/entry.cpp +++ b/modules/libSceGameLiveStreaming/entry.cpp @@ -29,7 +29,7 @@ EXPORT SYSV_ABI int32_t sceGameLiveStreamingPermitLiveStreaming() { EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentStatus(SceGameLiveStreamingStatus* glss) { LOG_USE_MODULE(libSceGameLiveStreaming); - LOG_ERR(L"todo %S", __FUNCTION__); + LOG_TRACE(L"todo %S", __FUNCTION__); glss->isOnAir = false; glss->userId = 1; return Ok; @@ -37,7 +37,7 @@ EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentStatus(SceGameLiveStreamin EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentStatus2(SceGameLiveStreamingStatus2* glss2) { LOG_USE_MODULE(libSceGameLiveStreaming); - LOG_ERR(L"todo %S", __FUNCTION__); + LOG_TRACE(L"todo %S", __FUNCTION__); glss2->isOnAir = false; glss2->userId = 1; return Ok; @@ -69,7 +69,7 @@ EXPORT SYSV_ABI int32_t sceGameLiveStreamingSetCameraFrameSetting(const SceGameL EXPORT SYSV_ABI int32_t sceGameLiveStreamingGetCurrentBroadcastScreenLayout(SceGameLiveStreamingBroadcastScreenLayout* layout) { LOG_USE_MODULE(libSceGameLiveStreaming); - LOG_ERR(L"todo %S", __FUNCTION__); + LOG_TRACE(L"todo %S", __FUNCTION__); return Ok; } diff --git a/modules/libSceRemoteplay/entry.cpp b/modules/libSceRemoteplay/entry.cpp index e6296a4a..dee4b4e8 100644 --- a/modules/libSceRemoteplay/entry.cpp +++ b/modules/libSceRemoteplay/entry.cpp @@ -43,7 +43,7 @@ EXPORT SYSV_ABI int sceRemoteplayProhibitStreaming(SceRemoteplayStreamingProhibi EXPORT SYSV_ABI int sceRemoteplayGetConnectionStatus(SceUserServiceUserId userid, SceRemoteplayConnectionStatus* pStatus) { *pStatus = SceRemoteplayConnectionStatus::Disconnect; LOG_USE_MODULE(libSceRemoteplay); - LOG_ERR(L"todo %S", __FUNCTION__); + LOG_TRACE(L"todo %S", __FUNCTION__); return Ok; } -} \ No newline at end of file +} From 5d6b5cdf5cc242d23678dc47c819d791e7625328 Mon Sep 17 00:00:00 2001 From: igor725 Date: Tue, 28 May 2024 08:55:32 +0300 Subject: [PATCH 3/7] Update intercept comment --- core/runtime/exports/intern.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/runtime/exports/intern.cpp b/core/runtime/exports/intern.cpp index 273e1852..a16613fd 100644 --- a/core/runtime/exports/intern.cpp +++ b/core/runtime/exports/intern.cpp @@ -24,12 +24,12 @@ void init() { void initIntercepts() { /*Usage // functions has to be of SYSV_ABI! - accessRuntimeExport()->interceptAdd((uintptr_t)int_Malloc, "Y7aJ1uydPMo", "libc", "libc") + accessRuntimeLinker().interceptAdd((uintptr_t)int_Malloc, "Y7aJ1uydPMo", "libc", "libc") // Calling original - auto const origFunction = accessRuntimeExport()->interceptGetAddr((uintptr_t)int_Malloc); + auto const origFunction = accessRuntimeLinker().interceptGetAddr((uintptr_t)int_Malloc); typedef SYSV_ABI void* (*fcnPtr)(void*, size_t); void* ret = ((fcnPtr)origFunction)(ptr, size); */ } -} // namespace intern \ No newline at end of file +} // namespace intern From 1feeb4ef5c61db402eaf3fa310495644799d18c9 Mon Sep 17 00:00:00 2001 From: igor725 Date: Tue, 28 May 2024 13:13:20 +0300 Subject: [PATCH 4/7] Set eta and entries for playgo --- modules/libScePlayGo/entry.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/libScePlayGo/entry.cpp b/modules/libScePlayGo/entry.cpp index ddb4a644..01341929 100644 --- a/modules/libScePlayGo/entry.cpp +++ b/modules/libScePlayGo/entry.cpp @@ -63,6 +63,7 @@ EXPORT SYSV_ABI int32_t scePlayGoSetToDoList(ScePlayGoHandle handle, const ScePl EXPORT SYSV_ABI int32_t scePlayGoGetToDoList(ScePlayGoHandle handle, ScePlayGoToDo* outTodoList, uint32_t numberOfEntries, uint32_t* outEntries) { LOG_USE_MODULE(libScePlayGo); LOG_ERR(L"TODO: %S", __FUNCTION__); + *outEntries = 0; return Ok; } @@ -75,6 +76,7 @@ EXPORT SYSV_ABI int32_t scePlayGoPrefetch(ScePlayGoHandle handle, const ScePlayG EXPORT SYSV_ABI int32_t scePlayGoGetEta(ScePlayGoHandle handle, const ScePlayGoChunkId* chunkIds, uint32_t numberOfEntries, ScePlayGoEta* outEta) { LOG_USE_MODULE(libScePlayGo); LOG_ERR(L"TODO: %S", __FUNCTION__); + *outEta = 0; return Ok; } From 48475ae8d2f1b97f9d5c1cd16f87ae9cc4300d38 Mon Sep 17 00:00:00 2001 From: igor725 Date: Tue, 28 May 2024 19:28:23 +0300 Subject: [PATCH 5/7] One more stub --- modules/libSceNpToolkit2/entry.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/libSceNpToolkit2/entry.cpp b/modules/libSceNpToolkit2/entry.cpp index 5b776d5c..de1ce23d 100644 --- a/modules/libSceNpToolkit2/entry.cpp +++ b/modules/libSceNpToolkit2/entry.cpp @@ -430,4 +430,26 @@ EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_11UserProf LOG_ERR(L"todo %S", __FUNCTION__); return Ok; } + +/** + * @brief sce::Toolkit::NP::V2::Core::Response::Response() + * + */ + +EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_3TSS7TssDataEEC1Ev)() { + LOG_USE_MODULE(libSceNpToolkit2); + LOG_ERR(L"todo %S", __FUNCTION__); + return Ok; +} + +/** + * @brief sce::Toolkit::NP::V2::Core::Response::~Response() + * + */ + +EXPORT SYSV_ABI int32_t __NID(_ZN3sce7Toolkit2NP2V24Core8ResponseINS2_3TSS7TssDataEED1Ev)() { + LOG_USE_MODULE(libSceNpToolkit2); + LOG_ERR(L"todo %S", __FUNCTION__); + return Ok; +} } From 64ae51ef0cfe84bbc146f6caa7d9f587f9263038 Mon Sep 17 00:00:00 2001 From: igor725 Date: Wed, 29 May 2024 18:09:31 +0300 Subject: [PATCH 6/7] Show module name in error messages --- tools/logging/logging.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/logging/logging.cpp b/tools/logging/logging.cpp index 309e44c4..2e0bef01 100644 --- a/tools/logging/logging.cpp +++ b/tools/logging/logging.cpp @@ -8,9 +8,16 @@ #include #include #include +#include + +// clang-format off + +#include #include #include -#include +#include + +// clang-format on namespace __Log { @@ -124,12 +131,12 @@ void __log(eTrace_Level level, void* hmodule, unsigned short i_wLine, const char if (static_cast::type>(level) == static_cast::type>(eTrace_Level::err)) { - printf("Error:"); + printf("%s| Error:", ((sP7Trace_Module*)hmodule)->pName); vwprintf(i_pFormat, args); printf("\n"); } else if (static_cast::type>(level) == static_cast::type>(eTrace_Level::crit)) { - printf("Critical Error:"); + printf("%s| Critical Error:", ((sP7Trace_Module*)hmodule)->pName); vwprintf(i_pFormat, args); printf("\nExiting\n"); } From 478fefeefe27ccbd670d284dfb313f7814d12f02 Mon Sep 17 00:00:00 2001 From: igor725 Date: Wed, 29 May 2024 18:26:33 +0300 Subject: [PATCH 7/7] Please clang-format, stop being funny --- core/kernel/pthread_types.h | 10 ++++++---- core/runtime/formats/elf64.cpp | 4 ++++ core/runtime/runtimeLinker.cpp | 4 ++++ modules/libSceAvPlayer/types.h | 4 ++++ modules/libSceNpManager/entry.cpp | 2 ++ modules/libkernel/types.h | 4 ++++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/kernel/pthread_types.h b/core/kernel/pthread_types.h index 20e67b87..9e1ee099 100644 --- a/core/kernel/pthread_types.h +++ b/core/kernel/pthread_types.h @@ -1,13 +1,15 @@ #pragma once #include "utility/utility.h" +// clang-format off + using pthread_entry_func_t = SYSV_ABI void* (*)(void*); using pthread_key_destructor_func_t = SYSV_ABI void (*)(void*); +using thread_dtors_func_t = SYSV_ABI void (*)(); +using thread_clean_func_t = SYSV_ABI void (*)(void*); +using pthread_once_init = SYSV_ABI void (*)(); -using thread_dtors_func_t = SYSV_ABI void (*)(); -using thread_clean_func_t = SYSV_ABI void (*)(void*); - -using pthread_once_init = SYSV_ABI void (*)(); +// clang-format on struct SceSchedParam { int sched_priority; diff --git a/core/runtime/formats/elf64.cpp b/core/runtime/formats/elf64.cpp index 55ae4f51..bb07c155 100644 --- a/core/runtime/formats/elf64.cpp +++ b/core/runtime/formats/elf64.cpp @@ -22,10 +22,14 @@ namespace { LOG_DEFINE_MODULE(ELF64); +// clang-format off + using module_func_t = SYSV_ABI int (*)(size_t args, const void* argp); using module_call_func_t = SYSV_ABI void (*)(); using module_ini_fini_func_t = SYSV_ABI int (*)(size_t args, const void* argp, module_func_t func); +// clang-format on + int jmpModule(uint64_t addr, size_t args, const void* argp, module_func_t func) { return reinterpret_cast(addr)(args, argp, func); } diff --git a/core/runtime/runtimeLinker.cpp b/core/runtime/runtimeLinker.cpp index 861e7aba..7e535062 100644 --- a/core/runtime/runtimeLinker.cpp +++ b/core/runtime/runtimeLinker.cpp @@ -26,10 +26,14 @@ LOG_DEFINE_MODULE(RuntimeLinker); namespace { +// clang-format off + using atexit_func_t = SYSV_ABI void (*)(); using entry_func_t = SYSV_ABI void (*)(EntryParams const* params, atexit_func_t atexit_func); using module_func_t = SYSV_ABI int (*)(size_t args, const void* argp, atexit_func_t atexit_func); +// clang-format on + struct FrameS { FrameS* next; uintptr_t ret_addr; diff --git a/modules/libSceAvPlayer/types.h b/modules/libSceAvPlayer/types.h index 098d0f93..597f256c 100644 --- a/modules/libSceAvPlayer/types.h +++ b/modules/libSceAvPlayer/types.h @@ -3,6 +3,8 @@ #include "utility/utility.h" typedef void* SceAvPlayerHandle; +// clang-format off + using SceAvPlayerLogCallback = SYSV_ABI int (*)(void* userData, const char* format, va_list args); using SceAvPlayerAllocate = SYSV_ABI void* (*)(void* argP, uint32_t argAlignment, uint32_t argSize); using SceAvPlayerDeallocate = SYSV_ABI void (*)(void* argP, void* argMemory); @@ -14,6 +16,8 @@ using SceAvPlayerReadOffsetFile = SYSV_ABI int (*)(void* argP, uint8_t* argBu using SceAvPlayerEventCallback = SYSV_ABI void (*)(void* p, int32_t argEventId, int32_t argSourceId, void* argEventData); using SceAvPlayerSizeFile = SYSV_ABI uint64_t (*)(void* argP); +// clang-format on + enum class SceAvPlayerVideoDecoderType { DEFAULT = 0, RESERVED1, RESERVED2, SOFTWARE2 }; enum class SceAvPlayerAudioDecoderType { DEFAULT = 0, RESERVED1, RESERVED2 }; diff --git a/modules/libSceNpManager/entry.cpp b/modules/libSceNpManager/entry.cpp index 686bd9b9..b3f62156 100644 --- a/modules/libSceNpManager/entry.cpp +++ b/modules/libSceNpManager/entry.cpp @@ -7,10 +7,12 @@ LOG_DEFINE_MODULE(libSceNpManager); namespace { +// clang-format off using SceNpStateCallbackA = SYSV_ABI void (*)(int32_t userId, SceNpState state, void* userdata); using SceNpReachabilityStateCallback = SYSV_ABI void (*)(int32_t userId, SceNpReachabilityState state, void* userdata); using SceNpGamePresenceCallbackA = SYSV_ABI void (*)(int32_t userId, SceNpGamePresenceStatus status, void* userdata); using SceNpPlusEventCallback = SYSV_ABI void (*)(int32_t userId, SceNpPlusEventType event, void* userdata); +// clang-format on } // namespace extern "C" { diff --git a/modules/libkernel/types.h b/modules/libkernel/types.h index 5501a5e8..be5e0118 100644 --- a/modules/libkernel/types.h +++ b/modules/libkernel/types.h @@ -5,9 +5,13 @@ using SceKernelModule = int32_t; +// clang-format off + using get_thread_atexit_count_func_t = SYSV_ABI int (*)(SceKernelModule); using thread_atexit_report_func_t = SYSV_ABI void (*)(SceKernelModule); +// clang-format on + typedef int SceKernelAioSubmitId; typedef void* sigset_t;