diff options
Diffstat (limited to 'Whisper/Utils/miscUtils.cpp')
| -rw-r--r-- | Whisper/Utils/miscUtils.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Whisper/Utils/miscUtils.cpp b/Whisper/Utils/miscUtils.cpp new file mode 100644 index 0000000..c3f7dd1 --- /dev/null +++ b/Whisper/Utils/miscUtils.cpp @@ -0,0 +1,33 @@ +#include "stdafx.h" +#include "miscUtils.h" + +void setCurrentThreadName( const char* threadName ) +{ + const DWORD dwThreadID = GetCurrentThreadId(); + + // https://stackoverflow.com/a/10364541/126995 +#pragma pack(push,8) + typedef struct tagTHREADNAME_INFO + { + DWORD dwType; // Must be 0x1000. + LPCSTR szName; // Pointer to name (in user addr space). + DWORD dwThreadID; // Thread ID (-1=caller thread). + DWORD dwFlags; // Reserved for future use, must be zero. + } THREADNAME_INFO; +#pragma pack(pop) + + THREADNAME_INFO info; + info.dwType = 0x1000; + info.szName = threadName; + info.dwThreadID = dwThreadID; + info.dwFlags = 0; + + constexpr DWORD MS_VC_EXCEPTION = 0x406D1388; + __try + { + RaiseException( MS_VC_EXCEPTION, 0, sizeof( info ) / sizeof( ULONG_PTR ), (ULONG_PTR*)&info ); + } + __except( EXCEPTION_EXECUTE_HANDLER ) + { + } +}
\ No newline at end of file |
