From 123877d88798430de6e9d8c2f7773217e511cfab Mon Sep 17 00:00:00 2001 From: notmatthewbeshay <92357869+NotMachow@users.noreply.github.com> Date: Sat, 14 Mar 2026 06:32:13 +1100 Subject: [PATCH] Remove WinAPI types from thread naming --- Minecraft.World/Util/C4JThread.h | 4 ++-- Minecraft.World/Util/ThreadName.cpp | 19 ++++++++++--------- Minecraft.World/Util/ThreadName.h | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Minecraft.World/Util/C4JThread.h b/Minecraft.World/Util/C4JThread.h index 9a303c7b5..022222744 100644 --- a/Minecraft.World/Util/C4JThread.h +++ b/Minecraft.World/Util/C4JThread.h @@ -1,4 +1,5 @@ #pragma once +#include #include typedef int (C4JThreadStartFunc)(void* lpThreadParameter); @@ -221,5 +222,4 @@ private: static DWORD WINAPI entryPoint(LPVOID lpParam); #endif }; -void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName ); - +void SetThreadName(std::uint32_t threadId, const char *threadName); diff --git a/Minecraft.World/Util/ThreadName.cpp b/Minecraft.World/Util/ThreadName.cpp index 9cd372c96..03f71ffe1 100644 --- a/Minecraft.World/Util/ThreadName.cpp +++ b/Minecraft.World/Util/ThreadName.cpp @@ -1,28 +1,29 @@ #include "../Platform/stdafx.h" +#include // 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 + std::uint32_t dwType; // Must be 0x1000 + const char *szName; // Pointer to name (in user address space) + std::uint32_t dwThreadID; // Thread ID (-1 for caller thread) + std::uint32_t dwFlags; // Reserved for future use; must be zero } THREADNAME_INFO; -void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName ) +void SetThreadName(std::uint32_t threadId, const char *threadName) { #ifndef __PS3__ THREADNAME_INFO info; info.dwType = 0x1000; - info.szName = szThreadName; - info.dwThreadID = dwThreadID; + info.szName = threadName; + info.dwThreadID = threadId; info.dwFlags = 0; #if ( defined _WINDOWS64 | defined _DURANGO ) __try { - RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR *)&info ); + RaiseException(0x406D1388, 0, sizeof(info) / sizeof(std::uint32_t), reinterpret_cast(&info)); } __except( GetExceptionCode()==0x406D1388 ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_EXECUTE_HANDLER ) { @@ -31,7 +32,7 @@ void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName ) #ifdef _XBOX __try { - RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (DWORD *)&info ); + RaiseException(0x406D1388, 0, sizeof(info) / sizeof(std::uint32_t), reinterpret_cast(&info)); } __except( GetExceptionCode()==0x406D1388 ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_EXECUTE_HANDLER ) { diff --git a/Minecraft.World/Util/ThreadName.h b/Minecraft.World/Util/ThreadName.h index e7afe594d..e054fe9a9 100644 --- a/Minecraft.World/Util/ThreadName.h +++ b/Minecraft.World/Util/ThreadName.h @@ -1,3 +1,4 @@ #pragma once +#include -void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName ); \ No newline at end of file +void SetThreadName(std::uint32_t threadId, const char *threadName);