| 56 | } |
| 57 | |
| 58 | static 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 | |
| 85 | void LogStackTrace(const char* header, const bool dump_lua_locals) |
| 86 | { |