mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-04-26 17:04:01 +00:00
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#include "stdafx.h"
|
|
|
|
// From Xbox documentation
|
|
|
|
typedef struct tagTHREADNAME_INFO {
|
|
DWORD dwType; // Must be 0x1000
|
|
LPCSTR szName; // Pointer to name (in user address space)
|
|
DWORD dwThreadID; // Thread ID (-1 for caller thread)
|
|
DWORD dwFlags; // Reserved for future use; must be zero
|
|
} THREADNAME_INFO;
|
|
|
|
void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName )
|
|
{
|
|
#ifndef __PS3__
|
|
THREADNAME_INFO info;
|
|
|
|
info.dwType = 0x1000;
|
|
info.szName = szThreadName;
|
|
info.dwThreadID = dwThreadID;
|
|
info.dwFlags = 0;
|
|
|
|
#if defined(_WINDOWS64)
|
|
// The 0x406D1388 thread-name exception is debugger-only metadata.
|
|
// Skip raising it when no debugger is attached to avoid standalone exits.
|
|
if (!IsDebuggerPresent())
|
|
{
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
#if ( defined _WINDOWS64 || defined _DURANGO )
|
|
__try
|
|
{
|
|
RaiseException( 0x406D1388, 0, 4, (ULONG_PTR *)&info );
|
|
}
|
|
__except( GetExceptionCode()==0x406D1388 ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
}
|
|
#endif
|
|
#ifdef _XBOX
|
|
__try
|
|
{
|
|
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (DWORD *)&info );
|
|
}
|
|
__except( GetExceptionCode()==0x406D1388 ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_EXECUTE_HANDLER )
|
|
{
|
|
}
|
|
#endif
|
|
#endif // __PS3__
|
|
}
|