From c8fd0c952dc29b18f460831e26f633b988de9bcc Mon Sep 17 00:00:00 2001 From: nastys <@> Date: Thu, 6 Aug 2020 05:23:50 +0200 Subject: [PATCH] [Patches] Hand size option --- source-code/data/plugins/config.ini | 2 ++ .../source/plugins/Launcher/framework.h | 1 + .../source/plugins/Patches/dllmain.cpp | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/source-code/data/plugins/config.ini b/source-code/data/plugins/config.ini index ac90063..8a930d3 100644 --- a/source-code/data/plugins/config.ini +++ b/source-code/data/plugins/config.ini @@ -50,6 +50,8 @@ Force_Expressions=0 Force_Look=0 #Disable hand scaling No_Hand_Scaling=0 +#Default hand size -- -1=default, 12200=PDA +Default_Hand_Size=-1 #Hide the volume and SE control buttons Hide_Volume=0 #Remove the photo controls during PV playback diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 358a6ce..3055def 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -177,6 +177,7 @@ ConfigOptionBase* optionsArray[] = { new DropdownOption(L"force_expressions", PATCHES_SECTION, CONFIG_FILE, L"Expression Type:", L"Change the expressions.", 0, std::vector({ L"Default", L"Force PDA", L"Force FT" })), new DropdownOption(L"force_look", PATCHES_SECTION, CONFIG_FILE, L"Look Type:", L"Change the look animations.", 0, std::vector({ L"Default", L"Force PDA", L"Force FT" })), new BooleanOption(L"no_hand_scaling", PATCHES_SECTION, CONFIG_FILE, L"No Hand Scaling", L"Disable hand scaling.", false, false), + new NumericOption(L"default_hand_size", PATCHES_SECTION, CONFIG_FILE, L"Default Hand Size:", L"-1: default\n12200: PDA", -1, -1, INT_MAX), new OptionMetaSpacer(8), new BooleanOption(L"hide_volume", PATCHES_SECTION, CONFIG_FILE, L"Hide Volume Buttons", L"Hide the volume and SE control buttons.", false, false), diff --git a/source-code/source/plugins/Patches/dllmain.cpp b/source-code/source/plugins/Patches/dllmain.cpp index c3a4be0..90c8525 100644 --- a/source-code/source/plugins/Patches/dllmain.cpp +++ b/source-code/source/plugins/Patches/dllmain.cpp @@ -227,6 +227,7 @@ void ApplyPatches() { auto nQuickStart = GetPrivateProfileIntW(L"patches", L"quick_start", 1, CONFIG_FILE); auto nNoScrollingSfx = GetPrivateProfileIntW(L"patches", L"no_scrolling_sfx", FALSE, CONFIG_FILE); auto nNoHandScaling = GetPrivateProfileIntW(L"patches", L"no_hand_scaling", FALSE, CONFIG_FILE); + auto nDefaultHandSize = GetPrivateProfileIntW(L"patches", L"default_hand_size", -1, CONFIG_FILE); auto nForceMouth = GetPrivateProfileIntW(L"patches", L"force_mouth", 0, CONFIG_FILE); auto nForceExpressions = GetPrivateProfileIntW(L"patches", L"force_expressions", 0, CONFIG_FILE); auto nForceLook = GetPrivateProfileIntW(L"patches", L"force_look", 0, CONFIG_FILE); @@ -803,6 +804,27 @@ void ApplyPatches() { { InjectCode((void*)0x0000000140120709, { 0xE9, 0x82, 0x0A, 0x00 }); } + // Default hand size + if (nDefaultHandSize != -1) + { + printf("[Patches] Changing default hand size...\n"); + const float num = (float)nDefaultHandSize / 10000.0; + DWORD oldProtect; + float* addr1 = (float*)(0x140506B59); + float* addr2 = (float*)(0x140506B60); + /*float* addr3 = (float*)(0x140506B67); + float* addr4 = (float*)(0x140506B71);*/ + VirtualProtect(addr1, 4, PAGE_EXECUTE_READWRITE, &oldProtect); + VirtualProtect(addr2, 4, PAGE_EXECUTE_READWRITE, &oldProtect); + /*VirtualProtect(addr3, 4, PAGE_EXECUTE_READWRITE, &oldProtect); + VirtualProtect(addr4, 4, PAGE_EXECUTE_READWRITE, &oldProtect);*/ + *addr1 = *addr2 /*= *addr3 = *addr4*/ = num; + VirtualProtect(addr1, 4, oldProtect, nullptr); + VirtualProtect(addr2, 4, oldProtect, nullptr); + /*VirtualProtect(addr3, 4, oldProtect, nullptr); + VirtualProtect(addr4, 4, oldProtect, nullptr);*/ + printf("[Patches] New default hand size: %f\n", num); + } // Force mouth animations { if (nForceMouth == 1) // PDA