Merged WuchangFF with latest plugin.

This commit is contained in:
2025-08-08 10:52:33 +02:00
3 changed files with 451 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Starfield", "Starfield\Star
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FNAF_SOTM", "FNAF_SOTM\FNAF_SOTM.vcxproj", "{535F706B-2DDD-4543-9A14-FA15A13E253C}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FNAF_SOTM", "FNAF_SOTM\FNAF_SOTM.vcxproj", "{535F706B-2DDD-4543-9A14-FA15A13E253C}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wuchang FF", "WuchangFF\WuchangFF.vcxproj", "{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@@ -193,6 +195,14 @@ Global
{535F706B-2DDD-4543-9A14-FA15A13E253C}.Release|x64.Build.0 = Release|x64 {535F706B-2DDD-4543-9A14-FA15A13E253C}.Release|x64.Build.0 = Release|x64
{535F706B-2DDD-4543-9A14-FA15A13E253C}.Release|x86.ActiveCfg = Release|Win32 {535F706B-2DDD-4543-9A14-FA15A13E253C}.Release|x86.ActiveCfg = Release|Win32
{535F706B-2DDD-4543-9A14-FA15A13E253C}.Release|x86.Build.0 = Release|Win32 {535F706B-2DDD-4543-9A14-FA15A13E253C}.Release|x86.Build.0 = Release|Win32
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Debug|x64.ActiveCfg = Debug|x64
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Debug|x64.Build.0 = Debug|x64
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Debug|x86.ActiveCfg = Debug|Win32
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Debug|x86.Build.0 = Debug|Win32
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Release|x64.ActiveCfg = Release|x64
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Release|x64.Build.0 = Release|x64
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Release|x86.ActiveCfg = Release|Win32
{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

231
WuchangFF/WuchangFF.vcxproj Normal file
View File

@@ -0,0 +1,231 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}</ProjectGuid>
<RootNamespace>Wuchang FF</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>Wuchang FF</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>WuchangFFCore</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>WuchangFFCore</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>WuchangFFCore</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>WuchangFFCore</TargetName>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile />
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp23</LanguageStandard>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>$(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Zydis.lib;Maths.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile />
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp23</LanguageStandard>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>$(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Zydis.lib;Maths.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile />
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp23</LanguageStandard>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>$(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Zydis.lib;Maths.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>
</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile />
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp23</LanguageStandard>
<UseStandardPreprocessor>true</UseStandardPreprocessor>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>$(SolutionDir)external\zydis\Libs;$(SolutionDir)external\Maths;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>Zydis.lib;Maths.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\external\Hooking\InjectHook.h" />
<ClInclude Include="..\external\MinHook\include\MinHook.h" />
<ClInclude Include="..\external\MinHook\src\buffer.h" />
<ClInclude Include="..\external\MinHook\src\hde\hde32.h" />
<ClInclude Include="..\external\MinHook\src\hde\hde64.h" />
<ClInclude Include="..\external\MinHook\src\hde\pstdint.h" />
<ClInclude Include="..\external\MinHook\src\hde\table32.h" />
<ClInclude Include="..\external\MinHook\src\hde\table64.h" />
<ClInclude Include="..\external\MinHook\src\trampoline.h" />
<ClInclude Include="..\Obfuscate\ObfuscateString.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Memory\Memory.vcxproj">
<Project>{f9b5bbc6-67d4-4290-986f-08c6bac41ba3}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\external\Hooking\InjectHook.cpp" />
<ClCompile Include="..\external\MinHook\src\buffer.c" />
<ClCompile Include="..\external\MinHook\src\hde\hde32.c" />
<ClCompile Include="..\external\MinHook\src\hde\hde64.c" />
<ClCompile Include="..\external\MinHook\src\hook.c" />
<ClCompile Include="..\external\MinHook\src\trampoline.c" />
<ClCompile Include="..\external\safetyhook\src\allocator.cpp" />
<ClCompile Include="..\external\safetyhook\src\easy.cpp" />
<ClCompile Include="..\external\safetyhook\src\inline_hook.cpp" />
<ClCompile Include="..\external\safetyhook\src\mid_hook.cpp" />
<ClCompile Include="..\external\safetyhook\src\os.linux.cpp" />
<ClCompile Include="..\external\safetyhook\src\os.windows.cpp" />
<ClCompile Include="..\external\safetyhook\src\utility.cpp" />
<ClCompile Include="..\external\safetyhook\src\vmt_hook.cpp" />
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

210
WuchangFF/dllmain.cpp Normal file
View File

@@ -0,0 +1,210 @@
#include "Memory.hpp";
#include "Maths.hpp";
#include "ObfuscateString.h"
#include <string>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <filesystem>
// Constants
const std::string PLUGIN_NAME = "WuchangFF";
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
const std::string gameExecutable = "Project_Plague-Win64-Shipping.exe";
// Logger
std::shared_ptr<spdlog::logger> logger;
// Plugin states
static bool AOBScanDone = false;
static bool g_fix_enabled = false;
static bool g_aspect_ratio_axis_constrain_fix_enabled = false;
static bool g_DOF_fix_enabled = false;
static bool g_Vignetting_fix_enabled = false;
static bool g_Fog_fix_enabled = false;
// AOB Scan pointers
static uint8_t* HORPLUSaddress = nullptr;
static uint8_t* DOFaddress = nullptr;
static uint8_t* Vignettingaddress = nullptr;
static uint8_t* Fogaddress = nullptr;
// Prototypes
static void HORPlusFixEnabled(bool fix_enabled);
static void DOFFixEnabled(bool fix_enabled);
static void VignettingFixEnabled(bool fix_enabled);
static void FogFixEnabled(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 (HORPLUSaddress == nullptr) {
constexpr auto HORPLUSStringObfuscated = make_obfuscated<0x4A>("41 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 4C ?? ?? 4D ?? ?? E8");
HORPLUSaddress = Memory::aob_scan(gameExecutable, HORPLUSStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
if (!HORPLUSaddress)
logger->warn("HOR+ signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else
logger->info("HOR+ signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(HORPLUSaddress));
}
if (DOFaddress == nullptr) {
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("48 ?? ?? 8B ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? 48 6B ?? ?? 48 8D");
DOFaddress = Memory::aob_scan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
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<uintptr_t>(DOFaddress));
DOFaddress += 0x3;
}
}
if (Vignettingaddress == nullptr) {
constexpr auto VignettingStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3 ?? ?? ?? ?? EB");
Vignettingaddress = Memory::aob_scan(gameExecutable, VignettingStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
if (!Vignettingaddress)
logger->warn("Vignetting signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else {
logger->info("Vignetting signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Vignettingaddress));
}
}
if (Fogaddress == nullptr) {
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 8B");
Fogaddress = Memory::aob_scan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
if (!Fogaddress)
logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else {
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
}
}
if (HORPLUSaddress && DOFaddress && Vignettingaddress && Fogaddress) {
logger->info("All AOB signatures found. Ready to patch...");
AOBScanDone = true;
}
logger->info("--------------- AOB scan finished ---------------");
}
if (g_fix_enabled) {
if (HORPLUSaddress) HORPlusFixEnabled(g_aspect_ratio_axis_constrain_fix_enabled);
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
if (Vignettingaddress) VignettingFixEnabled(g_Vignetting_fix_enabled);
if (Fogaddress) FogFixEnabled(g_Fog_fix_enabled);
}
else {
if (HORPLUSaddress) HORPlusFixEnabled(false);
if (DOFaddress) DOFFixEnabled(false);
if (Vignettingaddress) VignettingFixEnabled(false);
if (Fogaddress) FogFixEnabled(false);
logger->info("All fixes disabled.");
}
}
// Setters for Reshade addon call
extern "C" __declspec(dllexport) void SetARAxisConstrainFixEnabled(bool enabled, bool init)
{
g_aspect_ratio_axis_constrain_fix_enabled = enabled;
if (!init) HORPlusFixEnabled(g_aspect_ratio_axis_constrain_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 SetVignettingFixEnabled(bool enabled, bool init)
{
g_Vignetting_fix_enabled = enabled;
if (!init) VignettingFixEnabled(g_Vignetting_fix_enabled);
}
extern "C" __declspec(dllexport) void SetFogFixEnabled(bool enabled, bool init)
{
g_Fog_fix_enabled = enabled;
if (!init) FogFixEnabled(g_Fog_fix_enabled);
}
// Memory patch fixes
static void HORPlusFixEnabled(bool fix_enabled) {
if (g_fix_enabled && fix_enabled && HORPLUSaddress) {
Memory::PatchBytes(HORPLUSaddress, "\x31\xD2\x90\x90\x90\x90\x90\x90", 8); // xor edx,edx AspectRatioAxisConstraint=AspectRatio_MaintainYFOV
logger->info("HOR+ fix enabled");
}
if (!fix_enabled && HORPLUSaddress) {
Memory::RestoreBytes(HORPLUSaddress);
logger->info("HOR+ fix disabled");
}
}
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 VignettingFixEnabled(bool fix_enabled) {
if (g_fix_enabled && fix_enabled && Vignettingaddress) {
Memory::PatchBytes(Vignettingaddress, "\x31\xC9", 2); // xor ecx,ecx r.Tonemapper.Quality=0
logger->info("Vignetting fix enabled");
}
if (!fix_enabled && Vignettingaddress) {
Memory::RestoreBytes(Vignettingaddress);
logger->info("Vignetting fix disabled");
}
}
static void FogFixEnabled(bool fix_enabled) {
if (g_fix_enabled && fix_enabled && Fogaddress) {
Memory::PatchBytes(Fogaddress, "\xEB", 1); // jmp "Project_Plague-Win64-Shipping.exe"+28E280E
logger->info("Fog fix enabled");
}
if (!fix_enabled && Fogaddress) {
Memory::RestoreBytes(Fogaddress);
logger->info("Fog 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<spdlog::logger>("Wuchang Fallen Feathers", std::make_shared<spdlog::sinks::rotating_file_sink_st>(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;
}