diff options
| author | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
| commit | 8c4603c73675958efc960fbd4bb599a2909d106a (patch) | |
| tree | 714dc6fc9a1672d5fd7f89676b97e10959662abc /Whisper/Utils/miscUtils.cpp | |
| parent | 990a8d0dbaefc996244097397259e92758b15cce (diff) | |
Source codes
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 |
