From c5748983f6ce0fa83424a56486624ab9381e726d Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 15 Jan 2022 12:20:48 +0100 Subject: [PATCH] WolfSSL: Use a custom UTF-8 aware _stat on Windows --- 3rdparty/curl/CMakeLists.txt | 2 +- 3rdparty/wolfssl/extra/win32/user_settings.h | 4 +++- 3rdparty/wolfssl/wolfssl.vcxproj | 5 ++--- rpcs3/rpcs3qt/curl_handle.cpp | 14 ++++++++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/3rdparty/curl/CMakeLists.txt b/3rdparty/curl/CMakeLists.txt index ebf5b0c7db..6f19710b41 100644 --- a/3rdparty/curl/CMakeLists.txt +++ b/3rdparty/curl/CMakeLists.txt @@ -7,7 +7,7 @@ if(USE_SYSTEM_CURL) target_link_libraries(libcurl INTERFACE CURL::libcurl) else() message("-- RPCS3: building libcurl + wolfssl submodules") - add_compile_definitions(HAVE_SNI) + add_compile_definitions(HAVE_SNI OPENSSL_EXTRA) option(BUILD_CURL_EXE "Set to ON to build curl executable." OFF) option(CMAKE_USE_WOLFSSL "enable wolfSSL for SSL/TLS" ON) option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" ON) diff --git a/3rdparty/wolfssl/extra/win32/user_settings.h b/3rdparty/wolfssl/extra/win32/user_settings.h index ea4c408331..4b84cd949d 100644 --- a/3rdparty/wolfssl/extra/win32/user_settings.h +++ b/3rdparty/wolfssl/extra/win32/user_settings.h @@ -67,7 +67,9 @@ extern FILE* wolfSSL_fopen_utf8(const char* name, const char* mode); #define XFFLUSH fflush #include -#define XSTAT _stat +extern int wolfSSL_stat_utf8(const char* path, struct _stat* buffer); +#define XSTAT wolfSSL_stat_utf8 +#define XSTAT_TYPE struct _stat #define XS_ISREG(s) (s & _S_IFREG) #define SEPARATOR_CHAR ';' diff --git a/3rdparty/wolfssl/wolfssl.vcxproj b/3rdparty/wolfssl/wolfssl.vcxproj index 2574b934b9..ce796eca88 100644 --- a/3rdparty/wolfssl/wolfssl.vcxproj +++ b/3rdparty/wolfssl/wolfssl.vcxproj @@ -101,9 +101,7 @@ - - @@ -115,10 +113,11 @@ - + + diff --git a/rpcs3/rpcs3qt/curl_handle.cpp b/rpcs3/rpcs3qt/curl_handle.cpp index 47aad01b36..c0d170aa1a 100644 --- a/rpcs3/rpcs3qt/curl_handle.cpp +++ b/rpcs3/rpcs3qt/curl_handle.cpp @@ -67,9 +67,19 @@ std::string curl_handle::get_verbose_error(CURLcode code) } #ifdef _WIN32 -// Function exported from our user_settings.h in WolfSSL, implemented in RPCS3 -extern "C" FILE* wolfSSL_fopen_utf8(const char* name, const char* mode) +// Functions exported from our user_settings.h in WolfSSL, implemented in RPCS3 +extern "C" +{ + +FILE* wolfSSL_fopen_utf8(const char* name, const char* mode) { return _wfopen(utf8_to_wchar(name).c_str(), utf8_to_wchar(mode).c_str()); } + +int wolfSSL_stat_utf8(const char* path, struct _stat* buffer) +{ + return _wstat(utf8_to_wchar(path).c_str(), buffer); +} + +} #endif