Added The Last Of Us Part I
This commit is contained in:
216
TLOU/TLOU.vcxproj
Normal file
216
TLOU/TLOU.vcxproj
Normal file
@@ -0,0 +1,216 @@
|
||||
<?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>{354D2D75-935B-4CF0-BDC6-98D1797F8AAB}</ProjectGuid>
|
||||
<RootNamespace>TLOU</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>TLOU</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>TLOUCore</TargetName>
|
||||
<TargetExt>.asi</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>TLOUCore</TargetName>
|
||||
<TargetExt>.asi</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetName>TLOUCore</TargetName>
|
||||
<TargetExt>.asi</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>TLOUCore</TargetName>
|
||||
<TargetExt>.asi</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;%(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;%(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;%(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;%(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>
|
||||
<ProjectReference Include="..\Memory\Memory.vcxproj">
|
||||
<Project>{f9b5bbc6-67d4-4290-986f-08c6bac41ba3}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Obfuscate\ObfuscateString.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
261
TLOU/dllmain.cpp
Normal file
261
TLOU/dllmain.cpp
Normal file
@@ -0,0 +1,261 @@
|
||||
#include "Memory.hpp";
|
||||
#include "Maths.hpp";
|
||||
#include "ObfuscateString.h"
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <spdlog/sinks/basic_file_sink.h>
|
||||
#include <safetyhook.hpp>
|
||||
|
||||
// Constants
|
||||
const std::string PLUGIN_NAME = "The Last Of Us : Part I";
|
||||
const std::string PLUGIN_LOG = "TLOU.log";
|
||||
const std::string gameExecutable = "tlou-i.exe";
|
||||
|
||||
// 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_camera_fix_enabled = false;
|
||||
static bool g_sharpness_fix_enabled = false;
|
||||
static int g_AdditionalFOVValue = 0;
|
||||
static float g_CameraValue = 0;
|
||||
static float g_SharpnessValue = 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* CameraAddress = nullptr;
|
||||
static uint8_t* SharpnessAddress = nullptr;
|
||||
|
||||
// Hooking
|
||||
static SafetyHookMid FOVHook{};
|
||||
static SafetyHookMid CameraHook{};
|
||||
static SafetyHookMid SharpnessHook{};
|
||||
|
||||
// Prototypes
|
||||
static void FOVFixEnabled(bool fix_enabled);
|
||||
static void CameraFixEnabled(bool fix_enabled);
|
||||
static void SharpnessFixEnabled(bool fix_enabled);
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
|
||||
{
|
||||
g_fix_enabled = enabled;
|
||||
if (g_fix_enabled && !AOBScanDone) {
|
||||
logger->info("--------------- AOB scanning started ---------------");
|
||||
// === AOB Scans ===
|
||||
if (!FOVAddress) {
|
||||
constexpr auto FOVPattern = make_obfuscated<0x4A>("E8 ?? ?? ?? ?? C5 FA ?? ?? ?? ?? ?? ?? C5 F8 ?? ?? E8 ?? ?? ?? ?? C5 7A");
|
||||
FOVAddress = Memory::aob_scan(gameExecutable, FOVPattern.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"tlou-i.exe" + 48A5B5 - C5 F8 11 41 10 - vmovups[rcx + 10], xmm0
|
||||
//"tlou-i.exe" + 48A5BA - 48 8B CA - mov rcx, rdx
|
||||
//"tlou-i.exe" + 48A5BD - E8 BE 0D 0B 00 - call "tlou-i.exe" + 53B380
|
||||
//"tlou-i.exe" + 48A5C2 - C5 FA 10 35 A6 A0 A6 02 - vmovss xmm6, ["tlou-i.exe" + 2EF4670]
|
||||
//"tlou-i.exe" + 48A5CA - C5 F8 28 CE - vmovaps xmm1, xmm6
|
||||
if (FOVAddress)
|
||||
{
|
||||
logger->info("FOV signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(FOVAddress));
|
||||
FOVAddress += 0x5;
|
||||
}
|
||||
else logger->warn("FOV signature not found. Maybe the game was updated.");
|
||||
}
|
||||
if (!CameraAddress) {
|
||||
constexpr auto CameraPattern = make_obfuscated<0x4A>("C5 FA ?? ?? ?? ?? ?? ?? C5 FA ?? ?? ?? C5 22 ?? ?? ?? C4 C1 ?? ?? ?? C5 FA ?? ?? ?? C5 7A");
|
||||
CameraAddress = Memory::aob_scan(gameExecutable, CameraPattern.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"tlou-i.exe" + 693727 - C5 FA 11 56 0C - vmovss[rsi + 0C], xmm2
|
||||
//"tlou-i.exe" + 69372C - 48 8B 07 - mov rax, [rdi]
|
||||
//"tlou-i.exe" + 69372F - C5 FA 10 05 95 5E EC 02 - vmovss xmm0, ["tlou-i.exe" + 35595CC]
|
||||
//"tlou-i.exe" + 693737 - C5 FA 59 48 20 - vmulss xmm1, xmm0, [rax + 20]
|
||||
//"tlou-i.exe" + 69373C - C5 22 59 48 24 - vmulss xmm9, xmm11, [rax + 24]
|
||||
if (CameraAddress)
|
||||
{
|
||||
logger->info("Camera signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(CameraAddress));
|
||||
CameraAddress += 0x8;
|
||||
}
|
||||
else logger->warn("Camera signature not found. Maybe the game was updated.");
|
||||
}
|
||||
if (!SharpnessAddress) {
|
||||
constexpr auto SharpnessPattern = make_obfuscated<0x4A>("C5 FA ?? ?? ?? ?? ?? ?? 8B 86 ?? ?? ?? ?? 89 87 ?? ?? ?? ?? 0F B6 ?? ?? ?? ?? ?? 89");
|
||||
SharpnessAddress = Memory::aob_scan(gameExecutable, SharpnessPattern.decrypt(), PAGE_EXECUTE_READ);
|
||||
//"tlou-i.exe" + 1F6B4CF - 75 04 - jne "tlou-i.exe" + 1F6B4D5
|
||||
//"tlou-i.exe" + 1F6B4D1 - C5 C8 57 F6 - vxorps xmm6, xmm6, xmm6
|
||||
//"tlou-i.exe" + 1F6B4D5 - C5 FA 11 B7 C4 02 00 00 - vmovss[rdi + 000002C4], xmm6
|
||||
//"tlou-i.exe" + 1F6B4DD - 8B 86 E8 1A 00 00 - mov eax, [rsi + 00001AE8]
|
||||
//"tlou-i.exe" + 1F6B4E3 - 89 87 C8 02 00 00 - mov[rdi + 000002C8], eax
|
||||
if (SharpnessAddress)
|
||||
{
|
||||
logger->info("Sharpness signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(SharpnessAddress));
|
||||
}
|
||||
else logger->warn("Sharpness signature not found. Maybe the game was updated.");
|
||||
if (FOVAddress && CameraAddress && SharpnessAddress) {
|
||||
logger->info("All AOB signatures found. Ready to patch...");
|
||||
logger->info("--------------- AOB scanning finished ---------------");
|
||||
AOBScanDone = true;
|
||||
}
|
||||
else
|
||||
logger->warn("Some AOB signatures could not be found. Fixes may be partially unavailable.");
|
||||
}
|
||||
}
|
||||
// === Activer ou désactiver les patchs ===
|
||||
if (FOVAddress && CameraAddress && SharpnessAddress)
|
||||
{
|
||||
if (g_fix_enabled)
|
||||
{
|
||||
FOVFixEnabled(g_fov_fix_enabled);
|
||||
CameraFixEnabled(g_camera_fix_enabled);
|
||||
SharpnessFixEnabled(g_sharpness_fix_enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
FOVFixEnabled(false);
|
||||
CameraFixEnabled(false);
|
||||
SharpnessFixEnabled(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 SetCameraFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_camera_fix_enabled = enabled;
|
||||
if (!init) CameraFixEnabled(g_camera_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetSharpnessFixEnabled(bool enabled, bool init)
|
||||
{
|
||||
g_sharpness_fix_enabled = enabled;
|
||||
if (!init) SharpnessFixEnabled(g_sharpness_fix_enabled);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetFOV(int fov)
|
||||
{
|
||||
g_AdditionalFOVValue = fov;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetCamera(float cameraDistance)
|
||||
{
|
||||
g_CameraValue = cameraDistance;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void SetSharpness(float sharpness)
|
||||
{
|
||||
g_SharpnessValue = sharpness;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Assembly code injections 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) {
|
||||
if (ctx.xmm0.f32[0] == ctx.xmm3.f32[0]) {
|
||||
g_FOV_In = ctx.xmm0.f32[0];
|
||||
g_FOV_Out = ctx.xmm0.f32[0] += (g_fov_fix_enabled ? g_AdditionalFOVValue : 0); // World FOV
|
||||
}
|
||||
});
|
||||
}
|
||||
else FOVHook.enable();
|
||||
logger->info("FOV fix enabled");
|
||||
}
|
||||
if (!fix_enabled && FOVHook) {
|
||||
FOVHook.disable();
|
||||
logger->info("FOV fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void CameraFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && CameraAddress != nullptr) {
|
||||
if (!CameraHook) {
|
||||
CameraHook = safetyhook::create_mid(CameraAddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ctx.xmm0.f32[0] = (g_camera_fix_enabled ? g_CameraValue : ctx.xmm0.f32[0]);
|
||||
});
|
||||
}
|
||||
else CameraHook.enable();
|
||||
logger->info("Camera fix enabled");
|
||||
}
|
||||
if (!fix_enabled && CameraHook) {
|
||||
CameraHook.disable();
|
||||
logger->info("Camera fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
static void SharpnessFixEnabled(bool fix_enabled) {
|
||||
if (g_fix_enabled && fix_enabled && SharpnessAddress != nullptr) {
|
||||
if (!SharpnessHook) {
|
||||
SharpnessHook = safetyhook::create_mid(SharpnessAddress,
|
||||
[](SafetyHookContext& ctx) {
|
||||
ctx.xmm6.f32[0] = g_SharpnessValue;
|
||||
});
|
||||
}
|
||||
else SharpnessHook.enable();
|
||||
logger->info("Sharpness fix enabled");
|
||||
}
|
||||
if (!fix_enabled && SharpnessHook) {
|
||||
SharpnessHook.disable();
|
||||
logger->info("sharpness fix disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// spdlog init with specific format
|
||||
static void InitializeLogger()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger = spdlog::basic_logger_mt("Fixlib", PLUGIN_LOG, true);
|
||||
spdlog::set_default_logger(logger);
|
||||
// Format : [YYYY-MM-DD HH:MM:SS] [INFO] message
|
||||
spdlog::set_pattern("[%Y-%m-%d %H:%M:%S] [%^%l%$] %v");
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
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);
|
||||
}
|
||||
}
|
||||
HMODULE g_coreModule = nullptr;
|
||||
|
||||
// Entry point
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user