Move some patches

This commit is contained in:
nastys
2019-10-07 18:39:13 +02:00
parent 075bb91a65
commit 08fe234c39
3 changed files with 23 additions and 9 deletions
+2 -2
View File
@@ -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)
@@ -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 } },
@@ -8,6 +8,16 @@
const std::string PLAYER_DATA_FILE_NAME = "playerdata.ini";
void InjectCode(void* address, const std::vector<uint8_t> 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);