diff --git a/src/core/hle/libraries/libc/libc.cpp b/src/core/hle/libraries/libc/libc.cpp index f0efa0051..170bd2021 100644 --- a/src/core/hle/libraries/libc/libc.cpp +++ b/src/core/hle/libraries/libc/libc.cpp @@ -440,6 +440,7 @@ void libcSymbolsRegister(Loader::SymbolsResolver* sym) { LIB_FUNCTION("Q2V+iqvjgC0", "libc", 1, "libc", 1, 1, vsnprintf); LIB_FUNCTION("YQ0navp+YIc", "libc", 1, "libc", 1, 1, puts); LIB_FUNCTION("fffwELXNVFA", "libc", 1, "libc", 1, 1, fprintf); + LIB_FUNCTION("eLdDw6l0-bU", "libc", 1, "libc", 1, 1, snprintf); // misc LIB_OBJ("P330P3dFF68", "libc", 1, "libc", 1, 1, &g_need_sceLibc); diff --git a/src/core/hle/libraries/libc/libc_stdio.cpp b/src/core/hle/libraries/libc/libc_stdio.cpp index 52e0c26a9..0b86287f8 100644 --- a/src/core/hle/libraries/libc/libc_stdio.cpp +++ b/src/core/hle/libraries/libc/libc_stdio.cpp @@ -22,6 +22,11 @@ int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS) { return 0; } +int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS) { + VA_CTX(ctx); + return snprintf_ctx(s, n, &ctx); +} + int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg) { return vsnprintf_ctx(s, n, format, arg); } diff --git a/src/core/hle/libraries/libc/libc_stdio.h b/src/core/hle/libraries/libc/libc_stdio.h index 20ffbc21c..961328551 100644 --- a/src/core/hle/libraries/libc/libc_stdio.h +++ b/src/core/hle/libraries/libc/libc_stdio.h @@ -9,5 +9,5 @@ int PS4_SYSV_ABI printf(VA_ARGS); int PS4_SYSV_ABI vsnprintf(char* s, size_t n, const char* format, VaList* arg); int PS4_SYSV_ABI puts(const char* s); int PS4_SYSV_ABI fprintf(FILE* file, VA_ARGS); - +int PS4_SYSV_ABI snprintf(char* s, size_t n, VA_ARGS); } // namespace Core::Libraries::LibC diff --git a/src/core/hle/libraries/libc/printf.h b/src/core/hle/libraries/libc/printf.h index 1fa582535..4a7d0089f 100644 --- a/src/core/hle/libraries/libc/printf.h +++ b/src/core/hle/libraries/libc/printf.h @@ -694,6 +694,14 @@ static int printf_ctx(VaCtx* ctx) { return result; } +static int snprintf_ctx(char* s, size_t n,VaCtx* ctx) { + const char* format = vaArgPtr(&ctx->va_list); + char buffer[256];//it is big enough? + int result = _vsnprintf(_out_buffer, buffer, format, &ctx->va_list); + std::strncpy(s, buffer,n); + return result; +} + static int vsnprintf_ctx(char* s, size_t n, const char* format, VaList* arg) { char buffer[n]; int result = _vsnprintf(_out_buffer, buffer, format, arg);