diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-06-02 14:21:13 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-06-20 01:15:34 +0200 |
commit | 970ca6093c590d390d6cfd649ce7f8a9febbd5f7 (patch) | |
tree | 94bcae1e0b71b09139343ab0efdc60f2309b4ead /src/common/Debugging/WheatyExceptionReport.cpp | |
parent | b6714f5746dd2468488b51a6f2b9eb26a6c155e9 (diff) |
Core/Misc: Fixed windows _UNICODE incompatibilities
(cherry picked from commit fd4ffc81b2593dbf5554b553828a736ac6263e98)
Diffstat (limited to 'src/common/Debugging/WheatyExceptionReport.cpp')
-rw-r--r-- | src/common/Debugging/WheatyExceptionReport.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 434d9cd1e07..c9e3a985543 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -41,7 +41,7 @@ inline LPTSTR ErrorMessage(DWORD dw) else { LPTSTR msgBuf = (LPTSTR)LocalAlloc(LPTR, 30); - snprintf(msgBuf, 30, "Unknown error: %u", dw); + _sntprintf(msgBuf, 30, _T("Unknown error: %d"), (int)dw); return msgBuf; } @@ -125,19 +125,25 @@ PEXCEPTION_POINTERS pExceptionInfo) ++pos; TCHAR crash_folder_path[MAX_PATH]; - _stprintf_s(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder); + _stprintf_s(crash_folder_path, _T("%s\\%s"), module_folder_name, CrashFolder); if (!CreateDirectory(crash_folder_path, nullptr)) { if (GetLastError() != ERROR_ALREADY_EXISTS) return 0; } +#ifdef _UNICODE +#define PRSTRc "S" +#else +#define PRSTRc "s" +#endif + SYSTEMTIME systime; GetLocalTime(&systime); - _stprintf_s(m_szDumpFileName, "%s\\%s_%s_[%u-%u_%u-%u-%u].dmp", + _stprintf_s(m_szDumpFileName, _T("%s\\%" PRSTRc "_%s_[%u-%u_%u-%u-%u].dmp"), crash_folder_path, GitRevision::GetHash(), pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond); - _stprintf_s(m_szLogFileName, _T("%s\\%s_%s_[%u-%u_%u-%u-%u].txt"), + _stprintf_s(m_szLogFileName, _T("%s\\%" PRSTRc "_%s_[%u-%u_%u-%u-%u].txt"), crash_folder_path, GitRevision::GetHash(), pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond); m_hDumpFile = CreateFile(m_szDumpFileName, @@ -226,7 +232,7 @@ template<size_t size> void ToTchar(wchar_t const* src, TCHAR (&dst)[size]) { if constexpr (std::is_same_v<TCHAR, char>) - ::wcstombs_s(nullptr, dst, src, size); + ::wcstombs_s(nullptr, dst, src, _TRUNCATE); else ::wcscpy_s(dst, size, src); } @@ -551,7 +557,7 @@ BOOL WheatyExceptionReport::_GetWindowsVersionFromWMI(TCHAR* szVersion, DWORD cn _tcsncat(szVersion, _T(" "), cntMax); memset(buf, 0, sizeof(buf)); ToTchar(field.bstrVal, buf); - if (strlen(buf)) + if (_tcslen(buf)) _tcsncat(szVersion, buf, cntMax); } VariantClear(&field); |