diff --git a/data/SplinterCellConviction.FusionMod/src/system/scripts/SplinterCellConviction.FusionMod.ini b/data/SplinterCellConviction.FusionMod/src/system/scripts/SplinterCellConviction.FusionMod.ini index 06b4c4246..6a4869a5f 100644 --- a/data/SplinterCellConviction.FusionMod/src/system/scripts/SplinterCellConviction.FusionMod.ini +++ b/data/SplinterCellConviction.FusionMod/src/system/scripts/SplinterCellConviction.FusionMod.ini @@ -3,6 +3,7 @@ SkipIntro = 1 WindowedMode = 0 DisableNegativeMouseAcceleration = 1 SkipSystemDetection = 1 +ForceCPUAffinityToAllCores = 1 PartialUltraWideSupport = 1 DisableDOF = 1 DisableBlackAndWhiteFilter = 0 diff --git a/source/SplinterCellConviction.FusionMod/dllmain.cpp b/source/SplinterCellConviction.FusionMod/dllmain.cpp index 6affbcb8e..1f0515ad0 100644 --- a/source/SplinterCellConviction.FusionMod/dllmain.cpp +++ b/source/SplinterCellConviction.FusionMod/dllmain.cpp @@ -6,6 +6,23 @@ #pragma comment(lib, "Ws2_32.lib") #include +SafetyHookInline shSetProcessAffinityMask{}; +BOOL WINAPI SetProcessAffinityMaskHook(HANDLE hProcess, DWORD_PTR dwProcessAffinityMask) +{ + if (hProcess == GetCurrentProcess()) + { + DWORD_PTR processAffinityMask; + DWORD_PTR systemAffinityMask; + + if (GetProcessAffinityMask(GetCurrentProcess(), &processAffinityMask, &systemAffinityMask)) + { + return shSetProcessAffinityMask.stdcall(hProcess, systemAffinityMask); + } + } + + return shSetProcessAffinityMask.stdcall(hProcess, dwProcessAffinityMask); +} + std::string getLocalIPAddress() { WSADATA wsaData; @@ -545,6 +562,7 @@ void Init() auto bWindowedMode = iniReader.ReadInteger("MAIN", "WindowedMode", 0) != 0; auto bDisableNegativeMouseAcceleration = iniReader.ReadInteger("MAIN", "DisableNegativeMouseAcceleration", 1) != 0; auto bSkipSystemDetection = iniReader.ReadInteger("MAIN", "SkipSystemDetection", 1) != 0; + auto bForceCPUAffinityToAllCores = iniReader.ReadInteger("MAIN", "ForceCPUAffinityToAllCores", 1) != 0; auto bPartialUltraWideSupport = iniReader.ReadInteger("MAIN", "PartialUltraWideSupport", 1) != 0; bDisableBlackAndWhiteFilter = iniReader.ReadInteger("MAIN", "DisableBlackAndWhiteFilter", 0) != 0; bBlacklistControlScheme = iniReader.ReadInteger("CONTROLS", "BlacklistControlScheme", 1) != 0; @@ -655,6 +673,11 @@ void Init() injector::WriteMemory(pattern.get_first(), 0xEB, true); } + if (bForceCPUAffinityToAllCores) + { + shSetProcessAffinityMask = safetyhook::create_inline(SetProcessAffinityMask, SetProcessAffinityMaskHook); + } + //if (bDisableBlackAndWhiteFilter) //light and shadow { auto pattern = hook::pattern("E8 ? ? ? ? D9 05 ? ? ? ? 83 C4 0C 33 F6 56 51");