mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
libobs/util: Improve SetThreadDescription usage
Fix warning about potential passing of NULL to FreeLibrary, and switch from Kernel32.dll to KernelBase.dll based on MS documentation.
This commit is contained in:
parent
aba94c71e2
commit
1eb20ad5aa
@ -194,20 +194,23 @@ void os_set_thread_name(const char *name)
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef HRESULT(WINAPI * set_thread_description_t)(HANDLE thread,
|
||||
PCWSTR desc);
|
||||
const HMODULE hModule = LoadLibrary(L"KernelBase.dll");
|
||||
if (hModule) {
|
||||
typedef HRESULT(WINAPI * set_thread_description_t)(HANDLE,
|
||||
PCWSTR);
|
||||
|
||||
HMODULE k32 = LoadLibraryW(L"Kernel32.dll");
|
||||
set_thread_description_t std = NULL;
|
||||
std = (set_thread_description_t)GetProcAddress(k32,
|
||||
"SetThreadDescription");
|
||||
if (std) {
|
||||
wchar_t *wname;
|
||||
os_utf8_to_wcs_ptr(name, 0, &wname);
|
||||
const set_thread_description_t std =
|
||||
(set_thread_description_t)GetProcAddress(
|
||||
hModule, "SetThreadDescription");
|
||||
if (std) {
|
||||
wchar_t *wname;
|
||||
os_utf8_to_wcs_ptr(name, 0, &wname);
|
||||
|
||||
std(GetCurrentThread(), wname);
|
||||
std(GetCurrentThread(), wname);
|
||||
|
||||
bfree(wname);
|
||||
bfree(wname);
|
||||
}
|
||||
|
||||
FreeLibrary(hModule);
|
||||
}
|
||||
FreeLibrary(k32);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user