diff --git a/CMakeLists.txt b/CMakeLists.txt index c1a9e29a..9306f1a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,8 @@ set(LIBC_SOURCES src/core/libraries/libc/libc.cpp src/core/libraries/libc/libc_string.h src/core/libraries/libc/libc_stdlib.cpp src/core/libraries/libc/libc_stdlib.h + src/core/libraries/libc_internal/libc_internal.cpp + src/core/libraries/libc_internal/libc_internal.h ) set(PAD_LIB src/core/libraries/pad/pad.cpp diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 75064a21..a86c5ac8 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -100,6 +100,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Lib, NpScore) \ SUB(Lib, NpTrophy) \ SUB(Lib, Screenshot) \ + SUB(Lib, LibCInternal) \ CLS(Frontend) \ CLS(Render) \ SUB(Render, Vulkan) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index d18612c2..908cecd9 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -67,6 +67,7 @@ enum class Class : u8 { Lib_NpScore, ///< The LibSceNpScore implementation Lib_NpTrophy, ///< The LibSceNpTrophy implementation Lib_Screenshot, ///< The LibSceScreenshot implementation + Lib_LibCInternal, ///< The LibCInternal implementation. Frontend, ///< Emulator UI Render, ///< Video Core Render_Vulkan, ///< Vulkan backend diff --git a/src/core/libraries/libc_internal/libc_internal.cpp b/src/core/libraries/libc_internal/libc_internal.cpp new file mode 100644 index 00000000..2a9866b6 --- /dev/null +++ b/src/core/libraries/libc_internal/libc_internal.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +// Generated By moduleGenerator +#include "common/logging/log.h" +#include "core/libraries/error_codes.h" +#include "core/libraries/libs.h" +#include "libc_internal.h" + +namespace Libraries::LibcInternal { + +void* PS4_SYSV_ABI internal_memset(void* s, int c, size_t n) { + return std::memset(s, c, n); +} + +errno_t PS4_SYSV_ABI internal_memcpy_s(void* dest, rsize_t destsz, const void* src, rsize_t count) { + return memcpy_s(dest, destsz, src, count); +} + +errno_t PS4_SYSV_ABI internal_strcpy_s(char* dest, rsize_t dest_size, const char* src) { + return strcpy_s(dest, dest_size, src); +} + +int PS4_SYSV_ABI internal_memcmp(const void* s1, const void* s2, size_t n) { + return std::memcmp(s1, s2, n); +} + +void RegisterlibSceLibcInternal(Core::Loader::SymbolsResolver* sym) { + LIB_FUNCTION("NFLs+dRJGNg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, + internal_memcpy_s); + LIB_FUNCTION("8zTFvBIAIN8", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, + internal_memset); + LIB_FUNCTION("5Xa2ACNECdo", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, + internal_strcpy_s); + LIB_FUNCTION("DfivPArhucg", "libSceLibcInternal", 1, "libSceLibcInternal", 1, 1, + internal_memcmp); +}; + +} // namespace Libraries::LibcInternal \ No newline at end of file diff --git a/src/core/libraries/libc_internal/libc_internal.h b/src/core/libraries/libc_internal/libc_internal.h new file mode 100644 index 00000000..37b16fd4 --- /dev/null +++ b/src/core/libraries/libc_internal/libc_internal.h @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/types.h" + +namespace Core::Loader { +class SymbolsResolver; +} + +namespace Libraries::LibcInternal { + +void RegisterlibSceLibcInternal(Core::Loader::SymbolsResolver* sym); +} // namespace Libraries::LibcInternal \ No newline at end of file diff --git a/src/core/libraries/libs.cpp b/src/core/libraries/libs.cpp index 30d1fa6b..61f4878f 100644 --- a/src/core/libraries/libs.cpp +++ b/src/core/libraries/libs.cpp @@ -7,6 +7,7 @@ #include "core/libraries/gnmdriver/gnmdriver.h" #include "core/libraries/kernel/libkernel.h" #include "core/libraries/libc/libc.h" +#include "core/libraries/libc_internal/libc_internal.h" #include "core/libraries/libs.h" #include "core/libraries/network/http.h" #include "core/libraries/network/net.h" @@ -57,6 +58,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) { Libraries::NpScore::RegisterlibSceNpScore(sym); Libraries::NpTrophy::RegisterlibSceNpTrophy(sym); Libraries::ScreenShot::RegisterlibSceScreenShot(sym); + Libraries::LibcInternal::RegisterlibSceLibcInternal(sym); } } // namespace Libraries