diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 0797ccb62..c5ecdf65f 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -42,8 +42,6 @@ namespace Dalamud { public readonly IconReplacer IconReplacer; - public readonly IconReplaceChecker IconReplaceChecker; - public Dalamud(DalamudStartInfo info) { this.StartInfo = info; @@ -71,9 +69,7 @@ namespace Dalamud { this.PluginManager = new PluginManager(this, info.PluginDirectory, info.DefaultPluginDirectory); - this.IconReplaceChecker = new IconReplaceChecker(this.targetModule, this.sigScanner); - - this.IconReplacer = new IconReplacer(this, this.targetModule, this.sigScanner); + this.IconReplacer = new IconReplacer(this, this.sigScanner); try { this.PluginManager.LoadPlugins(); @@ -89,8 +85,6 @@ namespace Dalamud { this.BotManager.Start(); - this.IconReplaceChecker.Enable(); - this.IconReplacer.Enable(); } @@ -109,8 +103,6 @@ namespace Dalamud { this.unloadSignal.Dispose(); - this.IconReplaceChecker.Dispose(); - this.IconReplacer.Dispose(); } diff --git a/Dalamud/Game/Internal/Gui/IconReplaceChecker.cs b/Dalamud/Game/Internal/Gui/IconReplaceChecker.cs deleted file mode 100644 index 48eb7f553..000000000 --- a/Dalamud/Game/Internal/Gui/IconReplaceChecker.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Diagnostics; -using Dalamud.Hooking; - -namespace Dalamud.Game.Internal.Gui { - public class IconReplaceChecker { - private IconReplaceCheckerAddressResolver address; - private Hook checkerHook; - - public IconReplaceChecker(ProcessModule module, SigScanner scanner) { - this.address = new IconReplaceCheckerAddressResolver(); - this.address.Setup(scanner); - hookChecker(); - } - - private void hookChecker() { - this.checkerHook = new Hook(this.address.BaseAddress, (Delegate)new OnCheckDetour(this.HandleChecker), (object)this); - } - - public void Enable() { - this.checkerHook.Enable(); - } - - public void Dispose() { - this.checkerHook.Dispose(); - } - - // I hate this function. This is the dumbest function to exist in the game. Just return 1. - // Determines which abilities are allowed to have their icons updated. - private ulong HandleChecker(int actionID) { - return 1; - } - - private delegate ulong OnCheckDetour(int actionID); - - public delegate ulong OnCheckDelegate(int actionID); - } -} diff --git a/Dalamud/Game/Internal/Gui/IconReplaceCheckerAddressResolver.cs b/Dalamud/Game/Internal/Gui/IconReplaceCheckerAddressResolver.cs deleted file mode 100644 index 28ce04bc3..000000000 --- a/Dalamud/Game/Internal/Gui/IconReplaceCheckerAddressResolver.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Dalamud.Game.Internal.Gui { - class IconReplaceCheckerAddressResolver : BaseAddressResolver { - public IntPtr BaseAddress { get; private set; } - protected bool IsResolved { get; set; } - - protected override void Setup64Bit(SigScanner sig) - { - this.BaseAddress = sig.ScanText("81 f9 d4 08 00 00 7f 33 0f 84 fa 01 00 00 83 c1 eb 81 f9 a3 00 00 00"); - } - } -} diff --git a/Dalamud/Game/Internal/Gui/IconReplacer.cs b/Dalamud/Game/Internal/Gui/IconReplacer.cs index 9de2c94b3..a248378c5 100644 --- a/Dalamud/Game/Internal/Gui/IconReplacer.cs +++ b/Dalamud/Game/Internal/Gui/IconReplacer.cs @@ -9,8 +9,14 @@ using System.Runtime.InteropServices; namespace Dalamud.Game.Internal.Gui { public class IconReplacer { - private IconReplacerAddressResolver address; - private Hook iconHook; + public delegate ulong OnGetIconDelegate(byte param1, uint param2); + public delegate ulong OnCheckIsIconReplaceableDelegate(int actionID); + + private Hook iconHook; + private Hook checkerHook; + + private IconReplacerAddressResolver Address; + private IntPtr comboTimer; private IntPtr lastComboMove; private IntPtr activeBuffArray = IntPtr.Zero; @@ -19,28 +25,39 @@ namespace Dalamud.Game.Internal.Gui { private Dalamud dalamud; private PlayerCharacter localCharacter = null; - public unsafe IconReplacer(Dalamud dalamud, ProcessModule module, SigScanner scanner) { + public unsafe IconReplacer(Dalamud dalamud, SigScanner scanner) { this.dalamud = dalamud; - this.address = new IconReplacerAddressResolver(); - this.address.Setup(scanner); + this.Address = new IconReplacerAddressResolver(); + this.Address.Setup(scanner); this.byteBase = scanner.Module.BaseAddress; this.jobInfo = byteBase + 0x1b2d4b4; this.comboTimer = byteBase + 0x1AE1B10; this.lastComboMove = byteBase + 0x1AE1B14; - this.iconHook = new Hook(this.address.BaseAddress, (Delegate)new OnIconDetour(this.HandleIconUpdate), (object)this); + Log.Verbose("===== H O T B A R S ====="); + Log.Verbose("IsIconReplaceable address {IsIconReplaceable}", Address.IsIconReplaceable); + Log.Verbose("GetIcon address {GetIcon}", Address.GetIcon); + this.iconHook = new Hook(this.Address.GetIcon, new OnGetIconDelegate(GetIconDetour), this); + this.checkerHook = new Hook(this.Address.IsIconReplaceable, new OnCheckIsIconReplaceableDelegate(CheckIsIconReplaceableDetour), this); } public void Enable() { this.iconHook.Enable(); + this.checkerHook.Enable(); } public void Dispose() { this.iconHook.Dispose(); + this.checkerHook.Dispose(); } + // I hate this function. This is the dumbest function to exist in the game. Just return 1. + // Determines which abilities are allowed to have their icons updated. + private ulong CheckIsIconReplaceableDetour(int actionID) { + return 1; + } /// /// Replace an ability with another ability @@ -51,7 +68,7 @@ namespace Dalamud.Game.Internal.Gui { /// For example, Souleater combo on DRK happens by dragging Souleater /// onto your bar and mashing it. /// - private unsafe ulong HandleIconUpdate(byte self, uint actionID) { + private unsafe ulong GetIconDetour(byte self, uint actionID) { // TODO: BRD, RDM, level checking for everything. @@ -498,10 +515,6 @@ namespace Dalamud.Game.Internal.Gui { return false; } - private delegate ulong OnIconDetour(byte param1, uint param2); - - public delegate ulong OnIconDelegate(byte param1, uint param2); - private unsafe delegate int* getArray(long* address); private unsafe IntPtr FindBuffAddress() { diff --git a/Dalamud/Game/Internal/Gui/IconReplacerAddressResolver.cs b/Dalamud/Game/Internal/Gui/IconReplacerAddressResolver.cs index e8c37533d..77e8a5859 100644 --- a/Dalamud/Game/Internal/Gui/IconReplacerAddressResolver.cs +++ b/Dalamud/Game/Internal/Gui/IconReplacerAddressResolver.cs @@ -6,11 +6,12 @@ using System.Threading.Tasks; namespace Dalamud.Game.Internal.Gui { class IconReplacerAddressResolver : BaseAddressResolver { - public IntPtr BaseAddress { get; private set; } - protected bool IsResolved { get; set; } + public IntPtr GetIcon { get; private set; } + public IntPtr IsIconReplaceable { get; private set; } protected override void Setup64Bit(SigScanner sig) { - this.BaseAddress = sig.ScanText("81 fa d4 08 00 00 7f 4b 74 44 8d 42 eb 3d a3 00 00 00"); + this.GetIcon = sig.ScanText("81 fa d4 08 00 00 7f 4b 74 44 8d 42 eb 3d a3 00 00 00"); + this.IsIconReplaceable = sig.ScanText("81 f9 d4 08 00 00 7f 33 0f 84 fa 01 00 00 83 c1 eb 81 f9 a3 00 00 00"); } } }