diff --git a/GOWR/GOWR.vcxproj b/GOWR/GOWR.vcxproj new file mode 100644 index 0000000..e3c8ee9 --- /dev/null +++ b/GOWR/GOWR.vcxproj @@ -0,0 +1,216 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {644C5E16-6AE0-43E5-855D-1B59481AEC0D} + Gears Of War Reloaded + 10.0 + Gears Of War Reloaded + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + GOWRCore + .dll + + + GOWRCore + .dll + + + GOWRCore + .dll + + + GOWRCore + .dll + + + + Level3 + true + + + true + NotUsing + + + + $(SolutionDir)Memory;$(SolutionDir)Maths;$(SolutionDir)Obfuscate;$(SolutionDir)external;$(SolutionDir)external\safetyhook\include;$(SolutionDir)external\zydis\dependencies\zycore\include;$(SolutionDir)external\zydis\include;$(SolutionDir)zydis\src;$(SolutionDir)external\MinHook\include;%(AdditionalIncludeDirectories) + /utf-8 %(AdditionalOptions) + MultiThreadedDLL + stdcpp23 + true + + + Windows + true + false + $(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories) + Zydis.lib;Maths.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + + + true + NotUsing + + + + $(SolutionDir)Memory;$(SolutionDir)Maths;$(SolutionDir)Obfuscate;$(SolutionDir)external;$(SolutionDir)external\safetyhook\include;$(SolutionDir)external\zydis\dependencies\zycore\include;$(SolutionDir)external\zydis\include;$(SolutionDir)zydis\src;$(SolutionDir)external\MinHook\include;%(AdditionalIncludeDirectories) + /utf-8 %(AdditionalOptions) + MultiThreadedDLL + stdcpp23 + true + + + Windows + true + false + $(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories) + Zydis.lib;Maths.lib;%(AdditionalDependencies) + + + + + Level3 + true + + + true + NotUsing + + + + $(SolutionDir)Memory;$(SolutionDir)Maths;$(SolutionDir)Obfuscate;$(SolutionDir)external;$(SolutionDir)external\safetyhook\include;$(SolutionDir)external\zydis\dependencies\zycore\include;$(SolutionDir)external\zydis\include;$(SolutionDir)zydis\src;$(SolutionDir)external\MinHook\include;%(AdditionalIncludeDirectories) + /utf-8 %(AdditionalOptions) + MultiThreadedDLL + stdcpp23 + true + + + Windows + true + false + $(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories) + Zydis.lib;Maths.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + + + true + NotUsing + + + + $(SolutionDir)Memory;$(SolutionDir)Maths;$(SolutionDir)Obfuscate;$(SolutionDir)external;$(SolutionDir)external\safetyhook\include;$(SolutionDir)external\zydis\dependencies\zycore\include;$(SolutionDir)external\zydis\include;$(SolutionDir)zydis\src;$(SolutionDir)external\MinHook\include;%(AdditionalIncludeDirectories) + /utf-8 %(AdditionalOptions) + MultiThreadedDLL + stdcpp23 + true + + + Windows + true + false + $(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories) + Zydis.lib;Maths.lib;%(AdditionalDependencies) + + + + + + + + {f9b5bbc6-67d4-4290-986f-08c6bac41ba3} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GOWR/dllmain.cpp b/GOWR/dllmain.cpp new file mode 100644 index 0000000..dc01b91 --- /dev/null +++ b/GOWR/dllmain.cpp @@ -0,0 +1,191 @@ +#include "Memory.hpp"; +#include "Maths.hpp"; +#include "ObfuscateString.h" +#include +#include +#include +#include +#include + +// Constants +const std::string PLUGIN_NAME = "GOWR"; +const std::string PLUGIN_LOG = PLUGIN_NAME + ".log"; +const std::string gameExecutable = "GOWDE-Steam.exe"; + +// Logger +std::shared_ptr logger; + +// Screen informations +static int screenWidth = GetSystemMetrics(SM_CXSCREEN); +static int screenHeight = GetSystemMetrics(SM_CYSCREEN); +static float aspectRatio = (float)screenWidth / screenHeight; + +// Plugin states +static bool AOBScanDone = false; +static bool g_fix_enabled = false; +static bool g_fov_fix_enabled = false; +static bool g_DOF_fix_enabled = false; +static int g_AdditionalFOVValue = 0; + +// Shared values +static float g_FOV_In = 0; +static float g_FOV_Out = 0; + +// AOB Scan pointers +static uint8_t* FOVaddress = nullptr; +static uint8_t* DOFaddress = nullptr; + +// Hooking +static SafetyHookMid FOVHook{}; + +// Prototypes +static void FOVFixEnabled(bool fix_enabled); +static void DOFFixEnabled(bool fix_enabled); + +extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled) +{ + g_fix_enabled = enabled; + if (g_fix_enabled && !AOBScanDone) { + logger->info("--------------- AOB scan started ---------------"); + if (FOVaddress == nullptr) { + constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("C5 FA ?? ?? ?? ?? 48 8B ?? ?? ?? 48 ?? ?? ?? 5F C3 CC CC 48 ?? ?? 48 89 ?? ?? 48 89 ?? ?? C5"); + FOVaddress = Memory::AOBScan(gameExecutable, FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + //"GOWDE-Steam.exe" + 213C8C - 48 8B CF - mov rcx, rdi + //"GOWDE-Steam.exe" + 213C8F - FF D3 - call rbx + //"GOWDE-Steam.exe" + 213C91 - C5 FA 10 44 24 28 - vmovss xmm0, [rsp + 28] + //"GOWDE-Steam.exe" + 213C97 - 48 8B 5C 24 40 - mov rbx, [rsp + 40] + //"GOWDE-Steam.exe" + 213C9C - 48 83 C4 30 - add rsp, 30 + + if (!FOVaddress) + logger->warn("FOV signature not found. Maybe your game has been updated and is no more compatible with this plugin."); + else { + logger->info("FOV signature found at address: 0x{:X}.", reinterpret_cast(FOVaddress)); + FOVaddress += 0x6; + } + } + + //if (DOFaddress == nullptr) { + // constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("75 ?? BF ?? ?? ?? ?? 8B ?? ?? 48 ?? ?? E8"); + // DOFaddress = Memory::AOBScan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + // //"SwordOfTheSea-Win64-Shipping.exe" + 2359B92 - 75 05 - jne "SwordOfTheSea-Win64-Shipping.exe" + 2359B99 + // //"SwordOfTheSea-Win64-Shipping.exe" + 2359B94 - BF 04 00 00 00 - mov edi, "Sword Of The Sea._Init_thread_epoch" + // //"SwordOfTheSea-Win64-Shipping.exe" + 2359B99 - 8B 3C 37 - mov edi, [rdi + rsi] + // //"SwordOfTheSea-Win64-Shipping.exe" + 2359B9C - 48 8B CB - mov rcx, rbx + // //"SwordOfTheSea-Win64-Shipping.exe" + 2359B9F - E8 EC ED 61 01 - call "SwordOfTheSea-Win64-Shipping.exe" + 3978990 + + // if (!DOFaddress) + // logger->warn("DOF signature not found. Maybe your game has been updated and is no more compatible with this plugin."); + // else { + // logger->info("DOF signature found at address: 0x{:X}.", reinterpret_cast(DOFaddress)); + // DOFaddress += 0x7; + // } + //} + + if (FOVaddress /*&& DOFaddress*/) { + logger->info("All AOB signatures found. Ready to patch..."); + AOBScanDone = true; + } + + logger->info("--------------- AOB scan finished ---------------"); + } + if (g_fix_enabled) { + if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled); + //if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled); + } + else { + if (FOVaddress) FOVFixEnabled(false); + //if (DOFaddress) DOFFixEnabled(false); + logger->info("All fixes disabled."); + } +} + +// Setters for Reshade addon call +extern "C" __declspec(dllexport) void SetFOVFixEnabled(bool enabled, bool init) +{ + g_fov_fix_enabled = enabled; + if (!init) FOVFixEnabled(g_fov_fix_enabled); +} + +extern "C" __declspec(dllexport) void SetDOFFixEnabled(bool enabled, bool init) +{ + g_DOF_fix_enabled = enabled; + if (!init) DOFFixEnabled(g_DOF_fix_enabled); +} + +extern "C" __declspec(dllexport) void SetFOV(int fov) +{ + g_AdditionalFOVValue = fov; +} + +// Getters for Reshade addon call +extern "C" __declspec(dllexport) float GetFOVIn() { + return g_FOV_In; +} + +extern "C" __declspec(dllexport) float GetFOVOut() { + return g_FOV_Out; +} + +// Code injection functions +static void FOVFixEnabled(bool fix_enabled) { + if (g_fix_enabled && fix_enabled && FOVaddress != nullptr) { + if (!FOVHook) { // Hook only once + FOVHook = safetyhook::create_mid(FOVaddress, + [](SafetyHookContext& ctx) { + g_FOV_In = ctx.xmm0.f32[0]; + g_FOV_Out = ctx.xmm0.f32[0] += (g_fov_fix_enabled ? g_AdditionalFOVValue : 0); + }); + } + else FOVHook.enable(); + logger->info("FOV fix enabled"); + } + if (!fix_enabled) { + if (FOVHook) FOVHook.disable(); + logger->info("FOV fix disabled"); + } +} + +// Memory patch fixes +static void DOFFixEnabled(bool fix_enabled) { + if (g_fix_enabled && fix_enabled && DOFaddress) { + Memory::PatchBytes(DOFaddress, "\x31\xFF\x90", 3); // xor edi,edi r.DepthOfFieldQuality = 0 + logger->info("Depth of field fix enabled"); + } + if (!fix_enabled && DOFaddress) { + Memory::RestoreBytes(DOFaddress); + logger->info("Depth of field fix disabled"); + } +} + +static void InitializeLogger() +{ + try + { + std::filesystem::path log_path = std::filesystem::absolute(PLUGIN_LOG); + if (std::filesystem::exists(log_path)) + std::filesystem::remove(log_path); + logger = std::make_shared("Gears Of War : Reloaded", std::make_shared(PLUGIN_LOG, 10 * 1024 * 1024, 1)); + logger->flush_on(spdlog::level::debug); // Flush automatically + } + catch (const spdlog::spdlog_ex& ex) + { + std::string plugin_error_message = "Could not open " + PLUGIN_LOG; + MessageBoxA(nullptr, plugin_error_message.c_str(), "Logger Error", MB_ICONERROR | MB_OK); + } +} + +// Standard dll entry +BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) +{ + if (reason == DLL_PROCESS_ATTACH) + { + InitializeLogger(); + logger->info("Plugin {} loaded.", PLUGIN_NAME); + } + else if (reason == DLL_PROCESS_DETACH) + { + logger->info("Plugin {} unloaded.", PLUGIN_NAME); + spdlog::drop_all(); + } + return TRUE; +} \ No newline at end of file diff --git a/Reshade Plugins Core.sln b/Reshade Plugins Core.sln index 0f79562..1aee31c 100644 --- a/Reshade Plugins Core.sln +++ b/Reshade Plugins Core.sln @@ -51,6 +51,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sword Of The Sea", "Sword O EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Metal Gear Solid Delta Snake Eater", "Metal Gear Solid Delta\MGSDelta.vcxproj", "{F34FF148-7868-4D6E-8E55-6741C00A7E4B}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Gears Of War Reloaded", "GOWR\GOWR.vcxproj", "{644C5E16-6AE0-43E5-855D-1B59481AEC0D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -243,6 +245,14 @@ Global {F34FF148-7868-4D6E-8E55-6741C00A7E4B}.Release|x64.Build.0 = Release|x64 {F34FF148-7868-4D6E-8E55-6741C00A7E4B}.Release|x86.ActiveCfg = Release|Win32 {F34FF148-7868-4D6E-8E55-6741C00A7E4B}.Release|x86.Build.0 = Release|Win32 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Debug|x64.ActiveCfg = Debug|x64 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Debug|x64.Build.0 = Debug|x64 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Debug|x86.ActiveCfg = Debug|Win32 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Debug|x86.Build.0 = Debug|Win32 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Release|x64.ActiveCfg = Release|x64 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Release|x64.Build.0 = Release|x64 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Release|x86.ActiveCfg = Release|Win32 + {644C5E16-6AE0-43E5-855D-1B59481AEC0D}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE