diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index 5638f8b50..10960677c 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -15,6 +15,7 @@ using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.System.String; +using FFXIVClientStructs.FFXIV.Client.UI; using ImGuiNET; using Serilog; @@ -31,7 +32,6 @@ namespace Dalamud.Game.Gui private readonly GetMatrixSingletonDelegate getMatrixSingleton; private readonly ScreenToWorldNativeDelegate screenToWorldNative; - private readonly GetAgentModuleDelegate getAgentModule; private readonly Hook setGlobalBgmHook; private readonly Hook handleItemHoverHook; @@ -60,7 +60,6 @@ namespace Dalamud.Game.Gui Log.Verbose($"HandleItemHover address 0x{this.address.HandleItemHover.ToInt64():X}"); Log.Verbose($"HandleItemOut address 0x{this.address.HandleItemOut.ToInt64():X}"); Log.Verbose($"HandleImm address 0x{this.address.HandleImm.ToInt64():X}"); - Log.Verbose($"GetAgentModule address 0x{this.address.GetAgentModule.ToInt64():X}"); Service.Set(new ChatGui(this.address.ChatManager)); Service.Set(); @@ -85,8 +84,6 @@ namespace Dalamud.Game.Gui this.toggleUiHideHook = new Hook(this.address.ToggleUiHide, this.ToggleUiHideDetour); - this.getAgentModule = Marshal.GetDelegateForFunctionPointer(this.address.GetAgentModule); - this.utf8StringFromSequenceHook = new Hook(this.address.Utf8StringFromSequence, this.Utf8StringFromSequenceDetour); } @@ -397,14 +394,14 @@ namespace Dalamud.Game.Gui if (addon == IntPtr.Zero) return IntPtr.Zero; - var uiModule = Service.Get().GetUIModule(); - if (uiModule == IntPtr.Zero) + var uiModule = (UIModule*)Service.Get().GetUIModule(); + if (uiModule == null) { return IntPtr.Zero; } - var agentModule = this.getAgentModule(uiModule); - if (agentModule == IntPtr.Zero) + var agentModule = uiModule->GetAgentModule(); + if (agentModule == null) { return IntPtr.Zero; } @@ -417,13 +414,13 @@ namespace Dalamud.Game.Gui if (id == 0) return IntPtr.Zero; - for (var i = 0; i < 380; i++) + // Patch 6.1, 398 agents + for (var i = 0; i < 398; i++) { - var agent = Marshal.ReadIntPtr(agentModule, 0x20 + (i * 8)); - if (agent == IntPtr.Zero) - continue; - if (Marshal.ReadInt32(agent, 0x20) == id) - return agent; + var agent = &agentModule->AgentArray[i]; + + if (agent->GetAddonID() == id) + return new IntPtr(agent); } return IntPtr.Zero; diff --git a/Dalamud/Game/Gui/GameGuiAddressResolver.cs b/Dalamud/Game/Gui/GameGuiAddressResolver.cs index adeaab1af..299d59ce2 100644 --- a/Dalamud/Game/Gui/GameGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/GameGuiAddressResolver.cs @@ -71,11 +71,6 @@ namespace Dalamud.Game.Gui /// public IntPtr ToggleUiHide { get; private set; } - /// - /// Gets the address of the native GetAgentModule method. - /// - public IntPtr GetAgentModule { get; private set; } - /// /// Gets the address of the native Utf8StringFromSequence method. /// @@ -94,9 +89,6 @@ namespace Dalamud.Game.Gui this.ScreenToWorld = sig.ScanText("48 83 EC 48 48 8B 05 ?? ?? ?? ?? 4D 8B D1"); this.ToggleUiHide = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 0F B6 B9 ?? ?? ?? ?? B8 ?? ?? ?? ??"); this.Utf8StringFromSequence = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8D 41 22 66 C7 41 ?? ?? ?? 48 89 01 49 8B D8"); - - var uiModuleVtableSig = sig.GetStaticAddressFromSig("48 8D 05 ?? ?? ?? ?? 4C 89 61 28"); - this.GetAgentModule = Marshal.ReadIntPtr(uiModuleVtableSig, 34 * IntPtr.Size); } ///