Addressed an issue where fog fix would make game to crash after game update

This commit is contained in:
2025-09-24 17:37:27 +02:00
parent 3986f7423f
commit a4d00c1cc8

View File

@@ -190,7 +190,7 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
} }
if (Fogaddress == nullptr) { if (Fogaddress == nullptr) {
constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("F6 ?? ?? ?? ?? 74 ?? 48 8B ?? ?? ?? ?? ?? 83 78 ?? ?? 75 ?? B3"); constexpr auto FogStringObfuscated = make_obfuscated<0x4A>("0F 84 ?? ?? ?? ?? F6 ?? ?? ?? 0F 84 ?? ?? ?? ?? 83 BF");
Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ); Fogaddress = Memory::AOBScan(gameExecutable, FogStringObfuscated.decrypt(), PAGE_EXECUTE_READ);
//"HellIsUs-Win64-Shipping.exe" + 22B77C8 - 74 11 - je "HellIsUs-Win64-Shipping.exe" + 22B77DB //"HellIsUs-Win64-Shipping.exe" + 22B77C8 - 74 11 - je "HellIsUs-Win64-Shipping.exe" + 22B77DB
//"HellIsUs-Win64-Shipping.exe" + 22B77CA - 48 8B 05 8F 23 08 07 - mov rax, ["HellIsUs-Win64-Shipping.exe" + 9339B60] //"HellIsUs-Win64-Shipping.exe" + 22B77CA - 48 8B 05 8F 23 08 07 - mov rax, ["HellIsUs-Win64-Shipping.exe" + 9339B60]
@@ -204,7 +204,6 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled)
logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin."); logger->warn("Fog signature not found. Maybe your game has been updated and is no more compatible with this plugin.");
else { else {
logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress)); logger->info("Fog signature found at address: 0x{:X}.", reinterpret_cast<uintptr_t>(Fogaddress));
Fogaddress += 0x12;
} }
} }
@@ -488,11 +487,8 @@ static void HUDFixEnabled() {
auto* canvasSlot = static_cast<UCanvasPanelSlot*>(widget->Slot); auto* canvasSlot = static_cast<UCanvasPanelSlot*>(widget->Slot);
// Filter on class drawing HUD in game // Filter on class drawing HUD in game
if (canvasSlot && className.contains("CombatHud_SUMG_C")) { if (canvasSlot && className.contains("CombatHud_SUMG_C"))
canvasSlot->SetAnchors(referenceHUDAnchors); canvasSlot->SetAnchors(referenceHUDAnchors);
// Taking benefity of ProcessEvent that is called at level init to call fog fix
FogFixEnabled();
}
} }
} }
} }
@@ -558,24 +554,19 @@ static void VignettingFixEnabled() {
} }
static void FogFixEnabled() { static void FogFixEnabled() {
UWorld* World = UWorld::GetWorld(); if (g_fix_enabled && g_Fog_fix_enabled && Fogaddress) {
if (!World) return; // World not ready ? Do nothing if (!FogHook) {
ULevel* Level = World->PersistentLevel; FogHook = safetyhook::create_mid(Fogaddress,
if (!Level) return; [](SafetyHookContext& ctx) {
TArray<AActor*>& Actors = Level->Actors; ctx.rflags |= 0x40; // ZF=1 r.VolumetricFog = 0
});
for (AActor* Actor : Actors) // Loop through Unreal Engine actors
{
if (Actor && Actor->IsA(AExponentialHeightFog::StaticClass())) {
auto* fogActor = static_cast<AExponentialHeightFog*>(Actor);
// Get final class that controls Fog
if (auto* component = fogActor->GetComponentByClass(UExponentialHeightFogComponent::StaticClass())) {
if (auto* fogComponent = static_cast<UExponentialHeightFogComponent*>(component)) {
fogComponent->SetVisibility(!(g_fix_enabled && g_Fog_fix_enabled), true);
logger->info((g_fix_enabled && g_Fog_fix_enabled) ? "Fog fix enabled." : "Fog fix disabled.");
}
} }
else FogHook.enable();
logger->info("Fog fix enabled");
} }
if (!(g_fix_enabled && g_Fog_fix_enabled) && Fogaddress) {
if (FogHook) FogHook.disable();
logger->info("Fog fix disabled");
} }
} }