MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / GetThreadName

Function GetThreadName

ogsr_engine/xrCore/xrDebugNew.cpp:58–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static const char* GetThreadName()
59{
60 if (IsWindows10OrGreater())
61 {
62 static HMODULE KernelLib = GetModuleHandle("kernel32.dll");
63 using FuncGetThreadDescription = HRESULT (*)(HANDLE, PWSTR*);
64 static auto pGetThreadDescription = (FuncGetThreadDescription)GetProcAddress(KernelLib, "GetThreadDescription");
65
66 if (pGetThreadDescription)
67 {
68 PWSTR wThreadName = nullptr;
69 if (SUCCEEDED(pGetThreadDescription(GetCurrentThread(), &wThreadName)))
70 {
71 if (wThreadName)
72 {
73 static string64 ResThreadName{};
74 WideCharToMultiByte(CP_OEMCP, 0, wThreadName, int(wcslen(wThreadName)), ResThreadName, sizeof(ResThreadName), nullptr, nullptr);
75 LocalFree(wThreadName);
76 if (ResThreadName && strlen(ResThreadName))
77 return ResThreadName;
78 }
79 }
80 }
81 }
82 return "UNKNOWN";
83}
84
85void LogStackTrace(const char* header, const bool dump_lua_locals)
86{

Callers 1

LogStackTraceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected