From 788dde684b19b4e0faa4d7c298e6537c620ce723 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 14 Jul 2023 16:31:47 +0100 Subject: [PATCH] [*] Windows Vista, UWP, and Windows 11: Move Windows 7 and 8 SetThreadGroupAffinity symbol from the IAT to AuProcAddresses.NT.[c/h]pps object [*] Update the READMEs support table --- README.md | 6 +++++- Source/AuProcAddresses.NT.cpp | 3 ++- Source/AuProcAddresses.NT.hpp | 10 +++++++++- Source/Threading/Threads/AuOSThread.cpp | 13 +++++++++---- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6a79bf2e..0998c0d7 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Discord: [Invite](https://discord.gg/XYjCGWWa4J) | Platform | Support | | ----------- | ------- | | NT/XP | ❌ | +| NT/Vista | ⚠️⚠️️ | +| NT/Server 2008 | ⚠️⚠️ | | NT/Win7 | ⚠️ | | NT/Win8.1+ | ⚠️ | | NT/Win10 RS4+ | ✅ | @@ -73,7 +75,9 @@ Discord: [Invite](https://discord.gg/XYjCGWWa4J) Win7/8: memory management (AuProcess) is limited. \ Applications that don't need ::mmap-like functionality **with pre-reserved address allocations** should put your minimum requirements into the Vista era of NTs. \ -See: [Windows 7 defects](https://gitea.reece.sx/AuroraSupport/AuroraRuntime/src/branch/master/Media/Windows%207%20Defects.txt) +See: [Windows 7 defects](https://gitea.reece.sx/AuroraSupport/AuroraRuntime/src/branch/master/Media/Windows%207%20Defects.txt) \ +Earlier NT revisions could be supported; however, there is creep across various subsystems and libraries for XP to not work. In addition, anything older than a fully patched Windows 7 system is untested. + ## Performance Performance of each system should ideally be that of the best implementation on the platform, diff --git a/Source/AuProcAddresses.NT.cpp b/Source/AuProcAddresses.NT.cpp index 05948e7c..fa43f654 100644 --- a/Source/AuProcAddresses.NT.cpp +++ b/Source/AuProcAddresses.NT.cpp @@ -79,7 +79,8 @@ namespace Aurora ADD_GET_PROC(Kernel32, SetThreadInformation) ADD_GET_PROC(Kernel32, SetThreadSelectedCpuSets) ADD_GET_PROC(Kernel32, PrefetchVirtualMemory) - + ADD_GET_PROC(Kernel32, SetThreadGroupAffinity) + ADD_GET_PROC(Sync, WaitOnAddress) ADD_GET_PROC(Sync, WakeByAddressSingle) ADD_GET_PROC(Sync, WakeByAddressAll) diff --git a/Source/AuProcAddresses.NT.hpp b/Source/AuProcAddresses.NT.hpp index 6af66216..eaf3137c 100644 --- a/Source/AuProcAddresses.NT.hpp +++ b/Source/AuProcAddresses.NT.hpp @@ -152,7 +152,15 @@ namespace Aurora const ULONG * CpuSetIds, ULONG CpuSetIdCount ); - + +#if defined(AURORA_PLATFORM_WIN32) + inline BOOL(__stdcall *pSetThreadGroupAffinity)( + HANDLE hThread, + GROUP_AFFINITY * GroupAffinity, + PGROUP_AFFINITY PreviousGroupAffinity + ); +#endif + inline INT(__stdcall *pGetAddrInfoExCancel)( LPHANDLE lpHandle ); diff --git a/Source/Threading/Threads/AuOSThread.cpp b/Source/Threading/Threads/AuOSThread.cpp index 72253f67..c236922b 100644 --- a/Source/Threading/Threads/AuOSThread.cpp +++ b/Source/Threading/Threads/AuOSThread.cpp @@ -980,12 +980,17 @@ namespace Aurora::Threading::Threads } #if defined(AURORA_PLATFORM_WIN32) - GROUP_AFFINITY affinityGroup {0}; - mask.ToMsWin7GroupAffinity(&affinityGroup); - if (SetThreadGroupAffinity(this->handle_, &affinityGroup, nullptr)) + if (pSetThreadGroupAffinity) { - return; + GROUP_AFFINITY affinityGroup { 0 }; + mask.ToMsWin7GroupAffinity(&affinityGroup); + if (pSetThreadGroupAffinity(this->handle_, &affinityGroup, nullptr)) + { + return; + } } + + SetThreadAffinityMask(this->handle_, mask.lower); #endif SysPushErrorUnavailableError("Couldn't set thread affinity");