Skip to content

Commit

Permalink
conviction: affinity tweak
Browse files Browse the repository at this point in the history
- fixes #1614
  • Loading branch information
ThirteenAG committed Sep 3, 2024
1 parent 1337705 commit 84d8581
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SkipIntro = 1
WindowedMode = 0
DisableNegativeMouseAcceleration = 1
SkipSystemDetection = 1
ForceCPUAffinityToAllCores = 1
PartialUltraWideSupport = 1
DisableDOF = 1
DisableBlackAndWhiteFilter = 0
Expand Down
23 changes: 23 additions & 0 deletions source/SplinterCellConviction.FusionMod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
#pragma comment(lib, "Ws2_32.lib")
#include <list>

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<BOOL>(hProcess, systemAffinityMask);
}
}

return shSetProcessAffinityMask.stdcall<BOOL>(hProcess, dwProcessAffinityMask);
}

std::string getLocalIPAddress()
{
WSADATA wsaData;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -655,6 +673,11 @@ void Init()
injector::WriteMemory<uint8_t>(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");
Expand Down

0 comments on commit 84d8581

Please sign in to comment.