From 08fe234c395fca5dc7ca9e1d2dfb0fe98235cc88 Mon Sep 17 00:00:00 2001 From: nastys <@> Date: Mon, 7 Oct 2019 18:39:13 +0200 Subject: [PATCH] Move some patches --- source-code/data/plugins/playerdata.ini | 4 ++-- .../source/plugins/Patches/dllmain.cpp | 5 ---- .../TLAC/Components/PlayerDataManager.cpp | 23 +++++++++++++++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/source-code/data/plugins/playerdata.ini b/source-code/data/plugins/playerdata.ini index 8334fff..b389d91 100644 --- a/source-code/data/plugins/playerdata.ini +++ b/source-code/data/plugins/playerdata.ini @@ -40,10 +40,10 @@ border_excellent = true # Rival score border_rival =false -# Allows module selection (WARNING: It may cause lag in the main menu and other places) +# Allows module selection safely (WARNING: It may cause lag in the main menu and other places) use_card = true -# Allows module selection without card and attempts to disable module refresh when sliding in PV select to reduce CPU and IO load. +# Attempts to disable module refresh when sliding in PV select to reduce CPU and IO load. module_card_workaround = false # Allows use of game mode modifiers (hi-speed, hidden, and sudden) diff --git a/source-code/source/plugins/Patches/dllmain.cpp b/source-code/source/plugins/Patches/dllmain.cpp index 5e5c6d6..b3e1b21 100644 --- a/source-code/source/plugins/Patches/dllmain.cpp +++ b/source-code/source/plugins/Patches/dllmain.cpp @@ -91,11 +91,6 @@ void ApplyPatches() { // Allow modifier mode selection (by Team Shimapan) { (void*)0x00000001405CB1B3, { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 } }, { (void*)0x00000001405CA0F5, { 0x90, 0x90 } }, - // allow modifier modes to work without use_card - { (void*)0x00000001405CB14A,{ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 } }, - { (void*)0x0000000140136CFA,{ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 } }, - // enable module selector without use_card - { (void*)0x00000001405C513B, { 0x01 } }, // Force Hide IDs { (void*)0x00000001409A5918, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, { (void*)0x00000001409A5928, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, diff --git a/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp b/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp index f90cb44..67ded80 100644 --- a/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp +++ b/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp @@ -8,6 +8,16 @@ const std::string PLAYER_DATA_FILE_NAME = "playerdata.ini"; +void InjectCode(void* address, const std::vector data) +{ + const size_t byteCount = data.size() * sizeof(uint8_t); + + DWORD oldProtect; + VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect); + memcpy(address, data.data(), byteCount); + VirtualProtect(address, byteCount, oldProtect, nullptr); +} + namespace TLAC::Components { PlayerDataManager::PlayerDataManager() @@ -38,10 +48,19 @@ namespace TLAC::Components { ApplyCustomData(); - if (false && Input::Keyboard::GetInstance()->IsTapped(VK_F12)) + /*if (false && Input::Keyboard::GetInstance()->IsTapped(VK_F12)) { printf("[TLAC] PlayerDataManager::Update(): Loading config...\n"); LoadConfig(); + }*/ + if (!customPlayerData->UseCard) + { + DWORD oldProtect, bck; + // allow modifier modes to work without use_card + InjectCode((void*)0x00000001405CB14A, { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); + InjectCode((void*)0x0000000140136CFA, { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); + // enable module selector without use_card + InjectCode((void*)0x00000001405C513B, { 0x01 }); } if (moduleCardWorkaround) { int* pvId = (int*)0x00000001418054C4; @@ -195,7 +214,7 @@ namespace TLAC::Components *(byte*)(MODSELECTOR_CHECK_FUNCTION_ERRRET_ADDRESS + 0x1) = 0x01; } VirtualProtect((void*)MODSELECTOR_CHECK_FUNCTION_ERRRET_ADDRESS, sizeof(byte) * 2, oldProtect, &oldProtect); - + // fix annoying behavior of closing after changing module or item (don't yet know the reason, maybe NW/Card checks) { VirtualProtect((void*)MODSELECTOR_CLOSE_AFTER_MODULE, sizeof(uint8_t), PAGE_EXECUTE_READWRITE, &oldProtect);