MCPcopy Create free account
hub / github.com/HexHive/NASS / SetThreadName

Function SetThreadName

fuzz/libfuzzer/FuzzerUtilWindows.cpp:241–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void SetThreadName(std::thread &thread, const std::string &name) {
242 typedef HRESULT(WINAPI * proc)(HANDLE, PCWSTR);
243 HMODULE kbase = GetModuleHandleA("KernelBase.dll");
244 proc ThreadNameProc =
245 reinterpret_cast<proc>(GetProcAddress(kbase, "SetThreadDescription"));
246 if (ThreadNameProc) {
247 std::wstring buf;
248 auto sz = MultiByteToWideChar(CP_UTF8, 0, name.data(), -1, nullptr, 0);
249 if (sz > 0) {
250 buf.resize(sz);
251 if (MultiByteToWideChar(CP_UTF8, 0, name.data(), -1, &buf[0], sz) > 0) {
252 (void)ThreadNameProc(thread.native_handle(), buf.c_str());
253 }
254 }
255 }
256}
257
258} // namespace fuzzer
259

Callers

nothing calls this directly

Calls 3

dataMethod · 0.45
resizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected