diff options
author | daniel0916 <theschokolps@gmail.com> | 2014-04-12 19:55:37 +0200 |
---|---|---|
committer | daniel0916 <theschokolps@gmail.com> | 2014-04-12 19:55:37 +0200 |
commit | 2689a63e9cf61befba38a20b0bc0503070b05dfe (patch) | |
tree | 847a53356aa91ca677c9fc57e917ee9f9bd7fd6d /src/OSSupport/IsThread.cpp | |
parent | Fixed Bookshelves Checking (not completly) (diff) | |
parent | Updated the NetherFort prefabs to current Gallery contents. (diff) | |
download | cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.tar cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.tar.gz cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.tar.bz2 cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.tar.lz cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.tar.xz cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.tar.zst cuberite-2689a63e9cf61befba38a20b0bc0503070b05dfe.zip |
Diffstat (limited to 'src/OSSupport/IsThread.cpp')
-rw-r--r-- | src/OSSupport/IsThread.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/OSSupport/IsThread.cpp b/src/OSSupport/IsThread.cpp index 36205bcf1..04fc818e4 100644 --- a/src/OSSupport/IsThread.cpp +++ b/src/OSSupport/IsThread.cpp @@ -18,26 +18,33 @@ // Usage: SetThreadName (-1, "MainThread"); // -static void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName) +// Code adapted from MSDN: http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx + +const DWORD MS_VC_EXCEPTION = 0x406D1388; + +#pragma pack(push, 8) +typedef struct tagTHREADNAME_INFO { - struct - { - 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 - } 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) + +static void SetThreadName(DWORD dwThreadID, const char * threadName) +{ + THREADNAME_INFO info; info.dwType = 0x1000; - info.szName = szThreadName; + info.szName = threadName; info.dwThreadID = dwThreadID; info.dwFlags = 0; __try { - RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), (DWORD *)&info); + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info); } - __except(EXCEPTION_CONTINUE_EXECUTION) + __except (EXCEPTION_EXECUTE_HANDLER) { } } |