diff --git a/Reshade Plugins Core.sln b/Reshade Plugins Core.sln
index 85680dc..b323ac3 100644
--- a/Reshade Plugins Core.sln
+++ b/Reshade Plugins Core.sln
@@ -33,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Metro Exodus", "Metro Exodu
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ASILoader", "ASILoader\ASILoader.vcxproj", "{0DB8F2E7-EEC8-4C7A-A1BF-C7D51AF69D28}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Robocop UB", "Robocop UB\RobocopUB.vcxproj", "{E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -153,6 +155,14 @@ Global
{0DB8F2E7-EEC8-4C7A-A1BF-C7D51AF69D28}.Release|x64.Build.0 = Release|x64
{0DB8F2E7-EEC8-4C7A-A1BF-C7D51AF69D28}.Release|x86.ActiveCfg = Release|Win32
{0DB8F2E7-EEC8-4C7A-A1BF-C7D51AF69D28}.Release|x86.Build.0 = Release|Win32
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Debug|x64.ActiveCfg = Debug|x64
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Debug|x64.Build.0 = Debug|x64
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Debug|x86.ActiveCfg = Debug|Win32
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Debug|x86.Build.0 = Debug|Win32
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Release|x64.ActiveCfg = Release|x64
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Release|x64.Build.0 = Release|x64
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Release|x86.ActiveCfg = Release|Win32
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Robocop UB/RobocopUB.vcxproj b/Robocop UB/RobocopUB.vcxproj
new file mode 100644
index 0000000..07ce785
--- /dev/null
+++ b/Robocop UB/RobocopUB.vcxproj
@@ -0,0 +1,216 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 17.0
+ Win32Proj
+ {E2D1F83A-A184-41CF-8B61-3F80E0D2BB0A}
+ RobocopUB
+ 10.0
+ Robocop UB
+
+
+
+ DynamicLibrary
+ true
+ v143
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v143
+ true
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v143
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RobocopUBCore
+ .asi
+
+
+ RobocopUBCore
+ .asi
+
+
+ RobocopUBCore
+ .asi
+
+
+ RobocopUBCore
+ .asi
+
+
+
+ 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;%(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;%(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;%(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;%(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/Robocop UB/dllmain.cpp b/Robocop UB/dllmain.cpp
new file mode 100644
index 0000000..c052ddd
--- /dev/null
+++ b/Robocop UB/dllmain.cpp
@@ -0,0 +1,230 @@
+#include "Memory.hpp";
+#include "Maths.hpp";
+#include "ObfuscateString.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+// Constants
+const std::string PLUGIN_NAME = "robocop UB";
+const std::string PLUGIN_LOG = PLUGIN_NAME + ".log";
+const std::string gameExecutable = "RoboCopUnfinishedBusiness-Win64-Shipping.exe";
+const float baseAspect = 1.777777791;
+
+// 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_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);
+
+extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
+{
+ g_fix_enabled = enabled;
+ if (g_fix_enabled && !AOBScanDone) {
+ logger->info("--------------- AOB scanning started ---------------");
+ if (FOVaddress == nullptr) {
+ constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("F3 0F ?? ?? ?? 48 8B ?? 48 8B ?? 4C 8D ?? ?? 48 8B");
+ 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(FOVaddress));
+ }
+ }
+ if (Aspectaddress == nullptr) {
+ constexpr auto AspectStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 83 ?? ?? ?? ?? 89");
+ Aspectaddress = Memory::aob_scan(gameExecutable, AspectStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
+
+ if (!Aspectaddress)
+ logger->info("Aspect ratio signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
+ else {
+ logger->info("Aspect ratio signature found at address: 0x{:X}.", reinterpret_cast(Aspectaddress));
+ Aspectaddress += 0x15; // Target opcode offset
+ }
+ }
+ if (DOFaddress == nullptr) {
+ constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("8B ?? ?? 48 8B ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 6B ?? ?? 48");
+ 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(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 scanning 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;
+}
+
+// Injection routines
+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];
+ 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) {
+ 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(&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");
+ }
+}
+
+// Initialisation de spdlog avec format personnalisé
+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);
+ }
+}
+
+// Entrée standard DLL
+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