Added WuchangFF project.
This commit is contained in:
@@ -39,6 +39,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TLOU", "TLOU\TLOU.vcxproj",
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Starfield", "Starfield\Starfield.vcxproj", "{A41D75D0-D4F9-4688-93EE-C33CBC266F52}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Wuchang FF", "WuchangFF\WuchangFF.vcxproj", "{C3F58709-7AD9-4361-9C06-44A3BFFB9CE3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -183,6 +185,14 @@ Global
|
||||
{A41D75D0-D4F9-4688-93EE-C33CBC266F52}.Release|x64.Build.0 = Release|x64
|
||||
{A41D75D0-D4F9-4688-93EE-C33CBC266F52}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A41D75D0-D4F9-4688-93EE-C33CBC266F52}.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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
231
WuchangFF/WuchangFF.vcxproj
Normal file
231
WuchangFF/WuchangFF.vcxproj
Normal 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>
|
||||
410
WuchangFF/dllmain.cpp
Normal file
410
WuchangFF/dllmain.cpp
Normal file
@@ -0,0 +1,410 @@
|
||||
// At this point code injection into the game results in crash.
|
||||
// Do not use this plugin dll injection.
|
||||
|
||||
#include "Memory.hpp";
|
||||
#include "Maths.hpp";
|
||||
#include "ObfuscateString.h"
|
||||
#include <string>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
//#include <safetyhook.hpp>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <Windows.h>
|
||||
#include <TlHelp32.h>
|
||||
#include <MinHook.h>
|
||||
|
||||
|
||||
// Constants
|
||||
const std::string PLUGIN_NAME = "WuchangFF";
|
||||
const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
|
||||
const std::string gameExecutable = "Project_Plague-Win64-Shipping.exe";
|
||||
const float baseAspect = 1.777777791;
|
||||
|
||||
// Logger
|
||||
std::shared_ptr<spdlog::logger> 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_aspect_ratio_fix_enabled = false;
|
||||
static bool g_DOF_fix_enabled = false;
|
||||
static int g_AdditionalValue = 0;
|
||||
|
||||
// Shared values
|
||||
static float g_FOV_In = 0;
|
||||
static float g_Compensated_FOV = 0;
|
||||
static float g_FOV_Out = 0;
|
||||
|
||||
// AOB Scan pointers
|
||||
static uint8_t* FOVaddress = nullptr;
|
||||
static uint8_t* Aspectaddress = nullptr;
|
||||
static uint8_t* DOFaddress = nullptr;
|
||||
|
||||
// Hooking
|
||||
//static SafetyHookMid FOVHook{};
|
||||
//static SafetyHookMid AspectRatioHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled(bool fix_enabled);
|
||||
static void AspectRatioFixEnabled(bool fix_enabled);
|
||||
static void DOFFixEnabled(bool fix_enabled);
|
||||
|
||||
bool IsReadableExecutable(void* addr)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
if (VirtualQuery(addr, &mbi, sizeof(mbi)))
|
||||
{
|
||||
DWORD protect = mbi.Protect;
|
||||
return (protect & PAGE_EXECUTE_READ) || (protect & PAGE_EXECUTE_READWRITE) || (protect & PAGE_EXECUTE_WRITECOPY);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 0F ?? ?? 8B 83");
|
||||
FOVaddress = Memory::aob_scan(gameExecutable, FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
|
||||
|
||||
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<uintptr_t>(FOVaddress));
|
||||
FOVaddress += 0xa; // Offset for the target opcode
|
||||
}
|
||||
}
|
||||
if (Aspectaddress == nullptr) {
|
||||
if (FOVaddress) {
|
||||
Aspectaddress = FOVaddress + 0x0b;
|
||||
logger->info("Aspect ratio signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Aspectaddress));
|
||||
}
|
||||
}
|
||||
if (DOFaddress == nullptr) {
|
||||
constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("8B ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 0F ?? ?? 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 ratio signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(DOFaddress));
|
||||
}
|
||||
if (FOVaddress != nullptr && Aspectaddress != nullptr && DOFaddress != nullptr)
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
if (FOVaddress && Aspectaddress && DOFaddress) AOBScanDone = true;
|
||||
logger->info("--------------- AOB scan finished ---------------");
|
||||
}
|
||||
}
|
||||
if (g_fix_enabled) {
|
||||
if (FOVaddress) FOVFixEnabled(g_fov_fix_enabled || g_aspect_ratio_fix_enabled);
|
||||
if (Aspectaddress) AspectRatioFixEnabled(g_aspect_ratio_fix_enabled);
|
||||
if (DOFaddress) DOFFixEnabled(g_DOF_fix_enabled);
|
||||
}
|
||||
else {
|
||||
if (FOVaddress) FOVFixEnabled(false);
|
||||
if (Aspectaddress) AspectRatioFixEnabled(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 || g_aspect_ratio_fix_enabled); // FOV fix must be enabled when aspect ratio is too to compensate FOV
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetAspectRatioFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_aspect_ratio_fix_enabled = enabled;
|
||||
if (!init) AspectRatioFixEnabled(g_aspect_ratio_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_AdditionalValue = fov;
|
||||
}
|
||||
|
||||
// Getters for Reshade addon call
|
||||
extern "C" __declspec(dllexport) float GetFOVIn() {
|
||||
return g_FOV_In;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) float GetCompensatedFOV() {
|
||||
return g_Compensated_FOV;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) float GetFOVOut() {
|
||||
return g_FOV_Out;
|
||||
}
|
||||
|
||||
DWORD GetCurrentThreadIdSafe() {
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
DWORD GetMainThreadId(DWORD processId) {
|
||||
DWORD mainThreadId = 0;
|
||||
FILETIME earliestCreateTime = { MAXDWORD, MAXDWORD };
|
||||
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||
if (snapshot == INVALID_HANDLE_VALUE) return 0;
|
||||
|
||||
THREADENTRY32 te;
|
||||
te.dwSize = sizeof(te);
|
||||
|
||||
if (Thread32First(snapshot, &te)) {
|
||||
do {
|
||||
if (te.th32OwnerProcessID == processId) {
|
||||
HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE, te.th32ThreadID);
|
||||
if (hThread) {
|
||||
FILETIME createTime, exitTime, kernelTime, userTime;
|
||||
if (GetThreadTimes(hThread, &createTime, &exitTime, &kernelTime, &userTime)) {
|
||||
if (CompareFileTime(&createTime, &earliestCreateTime) < 0) {
|
||||
earliestCreateTime = createTime;
|
||||
mainThreadId = te.th32ThreadID;
|
||||
}
|
||||
}
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
} while (Thread32Next(snapshot, &te));
|
||||
}
|
||||
|
||||
CloseHandle(snapshot);
|
||||
return mainThreadId;
|
||||
}
|
||||
|
||||
void FreezeOtherThreads() {
|
||||
DWORD currentThreadId = GetCurrentThreadId();
|
||||
DWORD currentProcessId = GetCurrentProcessId();
|
||||
DWORD mainThreadId = GetMainThreadId(currentProcessId);
|
||||
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||
if (snapshot == INVALID_HANDLE_VALUE) return;
|
||||
|
||||
THREADENTRY32 te;
|
||||
te.dwSize = sizeof(te);
|
||||
|
||||
if (Thread32First(snapshot, &te)) {
|
||||
do {
|
||||
if (te.th32OwnerProcessID == currentProcessId &&
|
||||
te.th32ThreadID != currentThreadId &&
|
||||
te.th32ThreadID != mainThreadId) {
|
||||
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te.th32ThreadID);
|
||||
if (hThread) {
|
||||
SuspendThread(hThread);
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
} while (Thread32Next(snapshot, &te));
|
||||
}
|
||||
|
||||
CloseHandle(snapshot);
|
||||
}
|
||||
|
||||
|
||||
void ResumeThreads() {
|
||||
DWORD currentThreadId = GetCurrentThreadId();
|
||||
DWORD currentProcessId = GetCurrentProcessId();
|
||||
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||
if (snapshot == INVALID_HANDLE_VALUE) return;
|
||||
|
||||
THREADENTRY32 te;
|
||||
te.dwSize = sizeof(te);
|
||||
|
||||
if (Thread32First(snapshot, &te)) {
|
||||
do {
|
||||
if (te.th32OwnerProcessID == currentProcessId && te.th32ThreadID != currentThreadId) {
|
||||
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te.th32ThreadID);
|
||||
if (hThread) {
|
||||
ResumeThread(hThread);
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
} while (Thread32Next(snapshot, &te));
|
||||
}
|
||||
|
||||
CloseHandle(snapshot);
|
||||
}
|
||||
|
||||
void* g_Trampoline = nullptr;
|
||||
|
||||
void* AllocateNear(void* nearAddr, size_t size) {
|
||||
SYSTEM_INFO sysInfo;
|
||||
GetSystemInfo(&sysInfo);
|
||||
|
||||
uintptr_t startAddr = reinterpret_cast<uintptr_t>(nearAddr);
|
||||
uintptr_t minAddr = (startAddr > 0x7FFFFFFF) ? startAddr - 0x7FFFFFFF : 0; // -2Go
|
||||
uintptr_t maxAddr = startAddr + 0x7FFFFFFF; // +2Go
|
||||
|
||||
uintptr_t addr = minAddr;
|
||||
while (addr < maxAddr) {
|
||||
void* alloc = VirtualAlloc(reinterpret_cast<void*>(addr), size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
if (alloc != nullptr) {
|
||||
logger->info("Allocated memory at 0x{:X} near 0x{:X}", reinterpret_cast<uintptr_t>(alloc), reinterpret_cast<uintptr_t>(nearAddr));
|
||||
return alloc;
|
||||
}
|
||||
addr += sysInfo.dwPageSize;
|
||||
}
|
||||
|
||||
logger->info("Failed to allocate memory near 0x{:X}", reinterpret_cast<uintptr_t>(nearAddr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* CreateTrampoline(void* target_addr, size_t length = 5) {
|
||||
if (length < 5) length = 5; // minimum 5 octets pour jump
|
||||
|
||||
// Allouer mémoire proche
|
||||
//void* trampoline = AllocateNear(target_addr, length + 5); // +5 octets pour jump retour
|
||||
void* trampoline = AllocateNear(target_addr, length + 5); // +5 octets pour jump retour
|
||||
if (!trampoline) {
|
||||
logger->info("Failed to allocate trampoline memory");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Copier les octets originaux
|
||||
memcpy(trampoline, target_addr, length);
|
||||
|
||||
// Calculer l'adresse de retour (target_addr + length)
|
||||
uintptr_t retAddr = reinterpret_cast<uintptr_t>(target_addr) + length;
|
||||
uintptr_t jmpFrom = reinterpret_cast<uintptr_t>(trampoline) + length;
|
||||
|
||||
// Ecrire un jump relatif 5 octets à la fin du trampoline pour revenir au code original
|
||||
int32_t relAddr = static_cast<int32_t>(retAddr - (jmpFrom + 5)); // rel = dest - (src+5)
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(jmpFrom);
|
||||
p[0] = 0xE9; // opcode JMP rel32
|
||||
memcpy(p + 1, &relAddr, sizeof(relAddr));
|
||||
|
||||
logger->info("Trampoline created at 0x{:X}, jump back to 0x{:X}", reinterpret_cast<uintptr_t>(trampoline), retAddr);
|
||||
|
||||
return trampoline;
|
||||
}
|
||||
|
||||
//void HookFunction(void* target, void* destination, size_t length = 5) {
|
||||
// DWORD oldProtect;
|
||||
// VirtualProtect(target, length, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
//
|
||||
// uintptr_t rel_addr = (uintptr_t)destination - (uintptr_t)target - 5;
|
||||
// uint8_t patch[5] = { 0xE9 }; // jmp rel32
|
||||
// *reinterpret_cast<int32_t*>(patch + 1) = static_cast<int32_t>(rel_addr);
|
||||
//
|
||||
// logger->info("Patching FOVaddress (0x{:X}) to jump to trampoline (0x{:X})", reinterpret_cast<uintptr_t>(target), reinterpret_cast<uintptr_t>(destination));
|
||||
// memcpy(target, patch, 5);
|
||||
// VirtualProtect(target, length, oldProtect, &oldProtect);
|
||||
//}
|
||||
using FOVFuncType = void(__fastcall*)();
|
||||
FOVFuncType originalFOV = nullptr;
|
||||
|
||||
static void FOVFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && FOVaddress != nullptr) {
|
||||
|
||||
//if (g_Trampoline)
|
||||
// HookFunction(FOVaddress, g_Trampoline, 5);
|
||||
|
||||
//if (!FOVHook) { // Hook only once
|
||||
//if (IsReadableExecutable(FOVaddress)) {
|
||||
//FOVHook = safetyhook::create_mid(FOVaddress,
|
||||
// [](SafetyHookContext& ctx) {
|
||||
// //g_FOV_In = ctx.xmm0.f32[0];
|
||||
// //if (g_aspect_ratio_fix_enabled)
|
||||
// // g_Compensated_FOV = ctx.xmm0.f32[0] = Maths::CompensateHorizontalFOV(g_FOV_In, baseAspect, aspectRatio);
|
||||
// //else
|
||||
// // g_Compensated_FOV = ctx.xmm0.f32[0];
|
||||
// //g_FOV_Out = ctx.xmm0.f32[0] += (g_fov_fix_enabled ? g_AdditionalValue : 0);
|
||||
// });
|
||||
//}
|
||||
//}
|
||||
//else FOVHook.enable();
|
||||
logger->info("FOV fix enabled");
|
||||
}
|
||||
//if (!fix_enabled /* && FOVHook * / ) {
|
||||
if (!fix_enabled) {
|
||||
//FOVHook.disable();
|
||||
logger->info("FOV fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void AspectRatioFixEnabled(bool fix_enabled) {
|
||||
//if (g_fix_enabled && fix_enabled && Aspectaddress != nullptr) {
|
||||
// if (!AspectRatioHook) {
|
||||
// AspectRatioHook = safetyhook::create_mid(Aspectaddress,
|
||||
// [](SafetyHookContext& ctx) {
|
||||
// ctx.rax = *reinterpret_cast<uint32_t*>(&aspectRatio);
|
||||
// });
|
||||
// }
|
||||
// else {
|
||||
// AspectRatioHook.enable();
|
||||
// FOVFixEnabled(fix_enabled); // Usefull to compensate
|
||||
// }
|
||||
// logger->info("Aspect ratio fix enabled");
|
||||
//}
|
||||
//if (!fix_enabled && AspectRatioHook && Aspectaddress) {
|
||||
// AspectRatioHook.disable();
|
||||
// logger->info("Aspect ratio fix disabled");
|
||||
//}
|
||||
}
|
||||
|
||||
static void DOFFixEnabled(bool fix_enabled) {
|
||||
//if (g_fix_enabled && fix_enabled && DOFaddress != nullptr) {
|
||||
// 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<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);
|
||||
if (MH_Initialize() != MH_OK) {
|
||||
logger->info("MinHook initialization failed!");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (reason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
logger->info("Plugin {} unloaded.", PLUGIN_NAME);
|
||||
spdlog::drop_all();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user