diff --git a/EternalStrands/dllmain.cpp b/EternalStrands/dllmain.cpp index 9e744a3..ce13295 100644 --- a/EternalStrands/dllmain.cpp +++ b/EternalStrands/dllmain.cpp @@ -1,4 +1,5 @@ -#include "CommonHeaders.h" +#include +#include "CommonHeaders.h" #include "GameFixes.h" #include "GameInformations.h" #include "ObfuscateString.h" @@ -7,13 +8,19 @@ #include "UEngine.hpp" #include "SDK/Basic.hpp" #include "SDK/Engine_classes.hpp" +#include "SDK/UMG_classes.hpp" +#include "SDK/BPW_UI_HUD_Expedition_classes.hpp" +//#include "SDK/BPW_UI_HUD_Vitals_Stamina_3D_classes.hpp" +#include "SDK/BPW_UI_HUD_Vitals_classes.hpp" +#include "SDK/BPW_UI_HUD_Compass_classes.hpp" +//#include "SDK/BPW_UI_HUD_MagicandWeaponSelector_classes.hpp" +//#include "SDK/BPW_UI_HUD_EpicHealthBar_classes.hpp" using namespace SDK; // Constants const std::string PLUGIN_NAME = "EternalStrands"; const std::string PLUGIN_LOG = PLUGIN_NAME + ".log"; -const std::string gameExecutable = "EternalStrandsSteam-Win64-Shipping.exe"; // Logger std::shared_ptr logger; @@ -56,12 +63,14 @@ static uint8_t* Fogaddress = nullptr; static uint8_t* CameraComponentaddress = nullptr; static uint8_t* ConstrainAspectRatioaddress = nullptr; static uint8_t* AspectRatioAxisConstraintaddress = nullptr; +static uint8_t* NativeConstructaddress = nullptr; // Hooking static SafetyHookMid FOVHook{}; static SafetyHookMid CameraHook{}; static SafetyHookMid FogHook{}; static SafetyHookMid ProcessEventHook{}; +static SafetyHookMid NativeConstructHook{}; // Prototypes static void FOVFixEnabled(); @@ -73,6 +82,7 @@ static void VignettingFixEnabled(); static void FogFixEnabled(); static void VolumetricFogFixEnabled(); static void EnableConsole(); +static void HUDFixEnabled(); extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) { @@ -81,7 +91,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) logger->info("--------------- AOB scan started ---------------"); if (CameraComponentaddress == nullptr) { // Unreal Engine 5.3.2 constexpr auto FOVStringObfuscated = make_obfuscated<0x4A>("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 83 ?? ?? ?? ?? 89"); - CameraComponentaddress = Memory::AOBScan(gameExecutable, FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + CameraComponentaddress = Memory::AOBScan("", FOVStringObfuscated.decrypt(), PAGE_EXECUTE_READ, logger); if (!CameraComponentaddress) logger->warn("Camera component signature not found. Maybe your game has been updated and is no more compatible with this plugin."); @@ -94,7 +104,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!AspectRatioAxisConstraintaddress) { constexpr auto AspectRatioAxisConstraintStringObfuscated = make_obfuscated<0x4A>("41 0F ?? ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 4C ?? ?? 4D ?? ?? E8"); - AspectRatioAxisConstraintaddress = Memory::AOBScan(gameExecutable, AspectRatioAxisConstraintStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + AspectRatioAxisConstraintaddress = Memory::AOBScan("", AspectRatioAxisConstraintStringObfuscated.decrypt(), PAGE_EXECUTE_READ); if (!AspectRatioAxisConstraintaddress) logger->warn("HOR+ signature not found. Maybe your game has been updated and is no more compatible with this plugin."); @@ -104,7 +114,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (Cameraaddress == nullptr) { // Unreal Engine 5.3.2 constexpr auto CameraStringObfuscated = make_obfuscated<0x4A>("F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? F3 41 ?? ?? ?? F2 44"); - Cameraaddress = Memory::AOBScan(gameExecutable, CameraStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + Cameraaddress = Memory::AOBScan("", CameraStringObfuscated.decrypt(), PAGE_EXECUTE_READ); //"EternalStrandsSteam-Win64-Shipping.exe" + 4521641 - F2 0F 58 F8 - addsd xmm7, xmm0 //"EternalStrandsSteam-Win64-Shipping.exe" + 4521645 - 0F 29 AD D0 02 00 00 - movaps[rbp + 000002D0], xmm5 //"EternalStrandsSteam-Win64-Shipping.exe" + 452164C - F3 0F 10 87 A0 02 00 00 - movss xmm0, [rdi + 000002A0] @@ -121,7 +131,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!DOFaddress) { constexpr auto DOFStringObfuscated = make_obfuscated<0x4A>("8B ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 6B ?? ?? 48 8D"); - DOFaddress = Memory::AOBScan(gameExecutable, DOFStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + DOFaddress = Memory::AOBScan("", 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."); @@ -131,7 +141,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!CAaddress) { constexpr auto CAStringObfuscated = make_obfuscated<0x4A>("7F ?? 89 B3 ?? ?? ?? ?? 8B ?? ?? 39 05 ?? ?? ?? ?? 0F 8F"); - CAaddress = Memory::AOBScan(gameExecutable, CAStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + CAaddress = Memory::AOBScan("", CAStringObfuscated.decrypt(), PAGE_EXECUTE_READ); if (!CAaddress) logger->warn("Chromatic aberrations signature not found. Maybe your game has been updated and is no more compatible with this plugin."); @@ -141,7 +151,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!Vignettingaddress) { constexpr auto CAStringObfuscated = make_obfuscated<0x4A>("8B ?? 83 ?? ?? 7D ?? 89 B3 ?? ?? ?? ?? EB"); - Vignettingaddress = Memory::AOBScan(gameExecutable, CAStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + Vignettingaddress = Memory::AOBScan("", CAStringObfuscated.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."); @@ -151,7 +161,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!Fogaddress) { constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("74 ?? 48 8B ?? ?? ?? ?? ?? 83 ?? ?? ?? 75 ?? B3 ?? EB ?? 32 ?? 48 8B ?? ?? ?? 48 ?? ?? 74 ?? E8 ?? ?? ?? ?? 84"); - Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + Fogaddress = Memory::AOBScan("", 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."); @@ -163,7 +173,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!VolumetricFogaddress){ constexpr auto VolumetricFogStringObfuscated = make_obfuscated<0x4A>("84 ?? 0F 84 ?? ?? ?? ?? 48 ?? ?? 0F 84 ?? ?? ?? ?? 83 3D ?? ?? ?? ?? ?? 0F 84"); - VolumetricFogaddress = Memory::AOBScan(gameExecutable, VolumetricFogStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + VolumetricFogaddress = Memory::AOBScan("", VolumetricFogStringObfuscated.decrypt(), PAGE_EXECUTE_READ); if (!VolumetricFogaddress) logger->warn("Volumetric fog signature not found. Maybe your game has been updated and is no more compatible with this plugin."); @@ -171,6 +181,16 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) logger->info("Volumetric fog signature found at address: 0x{:X}.", reinterpret_cast(VolumetricFogaddress)); } + if (!NativeConstructaddress) { + constexpr auto NativeConstructStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 45 33 ?? 48 8B ?? 48 8B ?? FF ?? 48 8B ?? E8 ?? ?? ?? ?? 48 8B"); + NativeConstructaddress = Memory::AOBScan("", NativeConstructStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + + if (!NativeConstructaddress) + logger->warn("Native Construct signature not found. Maybe your game has been updated and is no more compatible with this plugin."); + else + logger->info("Native Construct signature found at address: 0x{:X}.", reinterpret_cast(NativeConstructaddress)); + } + if (CameraComponentaddress && FOVaddress && Cameraaddress && DOFaddress && CAaddress && Vignettingaddress && Fogaddress && VolumetricFogaddress && ConstrainAspectRatioaddress && AspectRatioAxisConstraintaddress) { logger->info("All AOB signatures found. Ready to patch..."); @@ -182,11 +202,11 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) uint8_t* baseModule = reinterpret_cast(GetModuleHandleA(nullptr)); // Get game base address constexpr auto GObjetcsStringObfuscated = make_obfuscated<0x4A>("48 8B ?? ?? ?? ?? ?? 48 8B ?? ?? 48 8D ?? ?? EB ?? 33"); - GObjectsaddress = Memory::AOBScan(gameExecutable, GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + GObjectsaddress = Memory::AOBScan("", GObjetcsStringObfuscated.decrypt(), PAGE_EXECUTE_READ); constexpr auto GNamesStringObfuscated = make_obfuscated<0x4A>("48 8D ?? ?? ?? ?? ?? EB ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? ?? 0F ?? ?? 4C"); - GNamesaddress = Memory::AOBScan(gameExecutable, GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + GNamesaddress = Memory::AOBScan("", GNamesStringObfuscated.decrypt(), PAGE_EXECUTE_READ); constexpr auto ProcessEventStringObfuscated = make_obfuscated<0x4A>("40 ?? 56 57 41 ?? 41 ?? 41 ?? 41 ?? 48 81 ?? ?? ?? ?? ?? 48 8D ?? ?? ?? 48 89 ?? ?? ?? ?? ?? 48 8B ?? ?? ?? ?? ?? 48 ?? ?? 48 89 ?? ?? ?? ?? ?? 4D 8B"); - ProcessEventaddress = Memory::AOBScan(gameExecutable, ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ); + ProcessEventaddress = Memory::AOBScan("", ProcessEventStringObfuscated.decrypt(), PAGE_EXECUTE_READ); if (!GObjectsaddress) logger->warn("GObjects signature not found. Maybe your game has been updated and is no more compatible with this plugin."); @@ -207,7 +227,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!ProcessEventaddress) logger->warn("Process Event signature not found. Maybe your game has been updated and is no more compatible with this plugin."); else { - std::optional gProcessEventOffsetOpt = UE::CalculateOffset(gameExecutable, ProcessEventaddress); + std::optional gProcessEventOffsetOpt = UE::CalculateOffset("", ProcessEventaddress); uint32_t gProcessEventOffset = *gProcessEventOffsetOpt; logger->info("Process Event offset is: 0x{:X}.", gProcessEventOffset); Offsets::ProcessEvent = static_cast(gProcessEventOffset);// Update ProcessEvent offset @@ -225,6 +245,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init) if (!init && Vignettingaddress) VignettingFixEnabled(); if (!init && Fogaddress) FogFixEnabled(); if (!init && VolumetricFogaddress) VolumetricFogFixEnabled(); + HUDFixEnabled(); } // Setters for Reshade addon call @@ -319,6 +340,62 @@ static void CameraFixEnabled() { } } +static void HUDFixEnabled() { + //if (NativeConstructaddress) { + // if (!NativeConstructHook) { + // NativeConstructHook = safetyhook::create_mid(NativeConstructaddress, + // [](SafetyHookContext& ctx) { + // if (!ctx.rcx) return; + + // auto* widget = reinterpret_cast(ctx.rcx); + // if (!widget) return; + // std::string widgetName = widget->GetName(); + + // //logger->debug("Widget class name: {}", widgetName); + // if (widgetName.contains("BPW_UI_HUD_Expedition_C") && widget->IsA(UBPW_UI_HUD_Expedition_C::StaticClass())) { + // auto* expeditionHUD = static_cast(widget); + + // if (expeditionHUD->BPW_UI_HUD_Compass && expeditionHUD->BPW_UI_HUD_Compass->Img_Compass) { + // auto compassImage = expeditionHUD->BPW_UI_HUD_Compass->Img_Compass; + // //expeditionHUD->BPW_InventoryWheel-> + // if (auto compassSlot = static_cast(compassImage->Slot)) + // compassSlot->SetPadding({ 0, 0, 650, 0 }); + // } + // auto* HUDVitals = expeditionHUD->BPW_Vitals; + + // std::thread([HUDVitals]() { + // std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + // auto healthImage = HUDVitals->Img_HealthGauge; + // auto manaImage = HUDVitals->Img_ManaGauge; + // auto manaSMoke = HUDVitals->VFX_ManaSmoke; + // auto MantlePowerImage = HUDVitals->Img_MantlePower; + + // if (MantlePowerImage && MantlePowerImage->Slot && + // MantlePowerImage->Slot->IsA(UOverlaySlot::StaticClass())) { + // auto* mantlePowerSlot = static_cast(MantlePowerImage->Slot); + // mantlePowerSlot->SetPadding({ 650, 0, 0, 0 }); + // } + + // if (manaImage && manaImage->Slot && + // manaImage->Slot->IsA(UOverlaySlot::StaticClass())) { + // auto* manaSlot = static_cast(manaImage->Slot); + // manaSlot->SetPadding({ 650, 0, 0, 0 }); + // } + + // if (manaSMoke && manaSMoke->Slot && + // manaSMoke->Slot->IsA(UOverlaySlot::StaticClass())) { + // auto* manaSMokeSlot = static_cast(manaSMoke->Slot); + // manaSMokeSlot->SetPadding({ 650, 0, 0, 0 }); + // } + // //HUDVitals->InvalidateLayoutAndVolatility(); + // logger->debug("[HUD] Vitals repositioned after delay"); + // }).detach(); + // } + // }); + // } + //} +} // Memory patch fixes static void UltraWideFixEnabled() { if (g_fix_enabled && g_ultrawide_fix_enabled && AspectRatioAxisConstraintaddress && ConstrainAspectRatioaddress) {