diff --git a/webrtc/base/win32.cc b/webrtc/base/win32.cc index c1b55bf63..fa7555992 100644 --- a/webrtc/base/win32.cc +++ b/webrtc/base/win32.cc @@ -453,4 +453,19 @@ bool GetCurrentProcessIntegrityLevel(int* level) { } return ret; } + +void SetCurrentThreadName(const char* name) { + struct { + DWORD dwType; + LPCSTR szName; + DWORD dwThreadID; + DWORD dwFlags; + } threadname_info = {0x100, name, static_cast(-1), 0}; + + __try { + ::RaiseException(0x406D1388, 0, sizeof(threadname_info) / sizeof(DWORD), + reinterpret_cast(&threadname_info)); + } __except (EXCEPTION_EXECUTE_HANDLER) { + } +} } // namespace rtc diff --git a/webrtc/base/win32.h b/webrtc/base/win32.h index 07e1e1ea5..a302c47a4 100644 --- a/webrtc/base/win32.h +++ b/webrtc/base/win32.h @@ -46,8 +46,6 @@ namespace rtc { const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size); int win32_inet_pton(int af, const char* src, void *dst); -/////////////////////////////////////////////////////////////////////////////// - inline std::wstring ToUtf16(const char* utf8, size_t len) { int len16 = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast(len), NULL, 0); @@ -128,7 +126,8 @@ inline bool IsCurrentProcessLowIntegrity() { bool AdjustCurrentProcessPrivilege(const TCHAR* privilege, bool to_enable); -/////////////////////////////////////////////////////////////////////////////// +// Sets the current thread name for the windows debugger. +void SetCurrentThreadName(const char* name); } // namespace rtc