mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Restore original hookwidget logic
This commit is contained in:
parent
d47a41b295
commit
8e8d0246bc
1 changed files with 22 additions and 17 deletions
|
|
@ -5,8 +5,8 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState;
|
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Windows.Win32.Foundation;
|
using Windows.Win32.Foundation;
|
||||||
using Windows.Win32.UI.WindowsAndMessaging;
|
using Windows.Win32.UI.WindowsAndMessaging;
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Widget for displaying hook information.
|
/// Widget for displaying hook information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class HookWidget : IDataWindowWidget
|
internal unsafe class HookWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
private readonly List<IDalamudHook> hookStressTestList = [];
|
private readonly List<IDalamudHook> hookStressTestList = [];
|
||||||
|
|
||||||
|
|
@ -31,9 +31,9 @@ internal class HookWidget : IDataWindowWidget
|
||||||
private bool hookStressTestRunning = false;
|
private bool hookStressTestRunning = false;
|
||||||
|
|
||||||
private MessageBoxWDelegate? messageBoxWOriginal;
|
private MessageBoxWDelegate? messageBoxWOriginal;
|
||||||
private HandleZoneInitPacketDelegate? zoneInitOriginal;
|
private AddonFinalizeDelegate? addonFinalizeOriginal;
|
||||||
|
|
||||||
private ClientStateAddressResolver? address;
|
private nint address;
|
||||||
|
|
||||||
private delegate int MessageBoxWDelegate(
|
private delegate int MessageBoxWDelegate(
|
||||||
IntPtr hWnd,
|
IntPtr hWnd,
|
||||||
|
|
@ -41,12 +41,12 @@ internal class HookWidget : IDataWindowWidget
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string caption,
|
[MarshalAs(UnmanagedType.LPWStr)] string caption,
|
||||||
MESSAGEBOX_STYLE type);
|
MESSAGEBOX_STYLE type);
|
||||||
|
|
||||||
private delegate void HandleZoneInitPacketDelegate(nint a1, uint localPlayerEntityId, nint packet, byte type);
|
private delegate void AddonFinalizeDelegate(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase);
|
||||||
|
|
||||||
private enum StressTestHookTarget
|
private enum StressTestHookTarget
|
||||||
{
|
{
|
||||||
MessageBoxW,
|
MessageBoxW,
|
||||||
ZoneInit,
|
AddonFinalize,
|
||||||
Random,
|
Random,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ internal class HookWidget : IDataWindowWidget
|
||||||
public string DisplayName { get; init; } = "Hook";
|
public string DisplayName { get; init; } = "Hook";
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string[]? CommandShortcuts { get; init; } = { "hook" };
|
public string[]? CommandShortcuts { get; init; } = ["hook"];
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool Ready { get; set; }
|
public bool Ready { get; set; }
|
||||||
|
|
@ -64,8 +64,8 @@ internal class HookWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
this.Ready = true;
|
this.Ready = true;
|
||||||
|
|
||||||
this.address = new ClientStateAddressResolver();
|
var sigScanner = Service<TargetSigScanner>.Get();
|
||||||
this.address.Setup(Service<TargetSigScanner>.Get());
|
this.address = sigScanner.ScanText("E8 ?? ?? ?? ?? 48 83 EF 01 75 D5");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
@ -178,7 +178,7 @@ internal class HookWidget : IDataWindowWidget
|
||||||
return target switch
|
return target switch
|
||||||
{
|
{
|
||||||
StressTestHookTarget.MessageBoxW => "MessageBoxW (Hook)",
|
StressTestHookTarget.MessageBoxW => "MessageBoxW (Hook)",
|
||||||
StressTestHookTarget.ZoneInit => "ZoneInit (Hook)",
|
StressTestHookTarget.AddonFinalize => "AddonFinalize (Hook)",
|
||||||
_ => target.ToString(),
|
_ => target.ToString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -197,10 +197,15 @@ internal class HookWidget : IDataWindowWidget
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnZoneInit(IntPtr a1, uint localPlayerEntityId, IntPtr packet, byte type)
|
private void OnAddonFinalize(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase)
|
||||||
{
|
{
|
||||||
Log.Information("OnZoneInit");
|
Log.Information("OnAddonFinalize");
|
||||||
this.zoneInitOriginal!.Invoke(a1, localPlayerEntityId, packet, type);
|
this.addonFinalizeOriginal!(unitManager, atkUnitBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAddonUpdate(AtkUnitBase* thisPtr, float delta)
|
||||||
|
{
|
||||||
|
Log.Information("OnAddonUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDalamudHook HookMessageBoxW()
|
private IDalamudHook HookMessageBoxW()
|
||||||
|
|
@ -216,11 +221,11 @@ internal class HookWidget : IDataWindowWidget
|
||||||
return hook;
|
return hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDalamudHook HookZoneInit()
|
private IDalamudHook HookAddonFinalize()
|
||||||
{
|
{
|
||||||
var hook = Hook<HandleZoneInitPacketDelegate>.FromAddress(this.address!.HandleZoneInitPacket, this.OnZoneInit);
|
var hook = Hook<AddonFinalizeDelegate>.FromAddress(this.address, this.OnAddonFinalize);
|
||||||
|
|
||||||
this.zoneInitOriginal = hook.Original;
|
this.addonFinalizeOriginal = hook.Original;
|
||||||
hook.Enable();
|
hook.Enable();
|
||||||
return hook;
|
return hook;
|
||||||
}
|
}
|
||||||
|
|
@ -235,7 +240,7 @@ internal class HookWidget : IDataWindowWidget
|
||||||
return target switch
|
return target switch
|
||||||
{
|
{
|
||||||
StressTestHookTarget.MessageBoxW => this.HookMessageBoxW(),
|
StressTestHookTarget.MessageBoxW => this.HookMessageBoxW(),
|
||||||
StressTestHookTarget.ZoneInit => this.HookZoneInit(),
|
StressTestHookTarget.AddonFinalize => this.HookAddonFinalize(),
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(target), target, null),
|
_ => throw new ArgumentOutOfRangeException(nameof(target), target, null),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue