From 65070bd765ef01b1b3b376157391716b9afd7f40 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 28 Jul 2022 19:38:18 +0200 Subject: [PATCH] [util] Use transcodeString in setThreadName function --- src/util/util_env.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index 61f6326e1..a759ae349 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -93,13 +93,17 @@ namespace dxvk::env { #ifdef _WIN32 using SetThreadDescriptionProc = HRESULT (WINAPI *) (HANDLE, PCWSTR); - static auto proc = reinterpret_cast( + static auto SetThreadDescription = reinterpret_cast( ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), "SetThreadDescription")); - if (proc != nullptr) { - auto wideName = std::vector(name.length() + 1); - str::tows(name.c_str(), wideName.data(), wideName.size()); - (*proc)(::GetCurrentThread(), wideName.data()); + if (SetThreadDescription) { + std::array wideName = { }; + + str::transcodeString( + wideName.data(), wideName.size() - 1, + name.data(), name.size()); + + SetThreadDescription(::GetCurrentThread(), wideName.data()); } #else std::array posixName = {};