From 741ae447e0faa6a10200797e743e6a580fa37292 Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Tue, 6 Apr 2021 21:58:21 -0400 Subject: [PATCH] fix: use UiModule error toast function --- Dalamud/Game/Internal/Gui/ToastGui.cs | 17 +++++------------ .../Internal/Gui/ToastGuiAddressResolver.cs | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Dalamud/Game/Internal/Gui/ToastGui.cs b/Dalamud/Game/Internal/Gui/ToastGui.cs index 8b5df8b2c..e4e4b305c 100755 --- a/Dalamud/Game/Internal/Gui/ToastGui.cs +++ b/Dalamud/Game/Internal/Gui/ToastGui.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using System.Text; using Dalamud.Game.Internal.Gui.Toast; @@ -54,9 +53,7 @@ namespace Dalamud.Game.Internal.Gui private delegate byte ShowQuestToastDelegate(IntPtr manager, int position, IntPtr text, uint iconOrCheck1, byte playSound, uint iconOrCheck2, byte alsoPlaySound); - private delegate byte ShowErrorToastDelegate(IntPtr manager, IntPtr text, int layer, byte respectsHidingMaybe); - - private delegate IntPtr GetAtkModuleDelegate(IntPtr uiModule); + private delegate byte ShowErrorToastDelegate(IntPtr manager, IntPtr text, byte respectsHidingMaybe); #endregion @@ -265,11 +262,7 @@ namespace Dalamud.Game.Internal.Gui private void ShowError(byte[] bytes) { - var uiModule = this.Dalamud.Framework.Gui.GetUIModule(); - var vtbl = Marshal.ReadIntPtr(uiModule); - var atkModulePtr = Marshal.ReadIntPtr(vtbl + (7 * 8)); - var getAtkModule = Marshal.GetDelegateForFunctionPointer(atkModulePtr); - var manager = getAtkModule(uiModule); + var manager = this.Dalamud.Framework.Gui.GetUIModule(); // terminate the string var terminated = Terminate(bytes); @@ -278,7 +271,7 @@ namespace Dalamud.Game.Internal.Gui { fixed (byte* ptr = terminated) { - this.HandleErrorToastDetour(manager, (IntPtr) ptr, 10, 0); + this.HandleErrorToastDetour(manager, (IntPtr) ptr, 0); } } } @@ -366,7 +359,7 @@ namespace Dalamud.Game.Internal.Gui } } - private byte HandleErrorToastDetour(IntPtr manager, IntPtr text, int layer, byte respectsHidingMaybe) + private byte HandleErrorToastDetour(IntPtr manager, IntPtr text, byte respectsHidingMaybe) { if (text == IntPtr.Zero) { @@ -391,7 +384,7 @@ namespace Dalamud.Game.Internal.Gui { fixed (byte* message = terminated) { - return this.showErrorToastHook.Original(manager, (IntPtr) message, layer, respectsHidingMaybe); + return this.showErrorToastHook.Original(manager, (IntPtr) message, respectsHidingMaybe); } } } diff --git a/Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs b/Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs index 969b15ecb..c89eeb20b 100755 --- a/Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs +++ b/Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs @@ -14,7 +14,7 @@ namespace Dalamud.Game.Internal.Gui { this.ShowNormalToast = sig.ScanText("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 83 3D ?? ?? ?? ?? ??"); this.ShowQuestToast = sig.ScanText("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 40 83 3D ?? ?? ?? ?? ??"); - this.ShowErrorToast = sig.ScanText("40 56 57 41 56 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 41 8B F0"); + this.ShowErrorToast = sig.ScanText("48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 83 3D ?? ?? ?? ?? ?? 41 0F B6 F0"); } } }