mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-07 08:24:37 +01:00
Switch to CS in NetworkMonitorWidget (#2600)
* Switch to CS in NetworkMonitorWidget * Lazy-init the hooks * Fix warnings
This commit is contained in:
parent
aa4ace976e
commit
33a7cdefa8
5 changed files with 16 additions and 22 deletions
|
|
@ -336,7 +336,7 @@ internal sealed unsafe class ContextMenu : IInternalDisposableService, IContextM
|
|||
this.MenuCallbackIds.Clear();
|
||||
this.SelectedAgent = agent;
|
||||
var unitManager = RaptureAtkUnitManager.Instance();
|
||||
this.SelectedParentAddon = unitManager->GetAddonById(unitManager->GetAddonByName(addonName)->ContextMenuParentId);
|
||||
this.SelectedParentAddon = unitManager->GetAddonById(unitManager->GetAddonByName(addonName)->BlockedParentId);
|
||||
this.SelectedEventInterfaces.Clear();
|
||||
if (this.SelectedAgent == AgentInventoryContext.Instance())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ internal class GaugeWidget : IDataWindowWidget
|
|||
40 => jobGauges.Get<SGEGauge>(),
|
||||
41 => jobGauges.Get<VPRGauge>(),
|
||||
42 => jobGauges.Get<PCTGauge>(),
|
||||
_ => null
|
||||
_ => null,
|
||||
};
|
||||
|
||||
if (gauge == null)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ internal unsafe class HookWidget : IDataWindowWidget
|
|||
{
|
||||
MessageBoxW,
|
||||
AddonFinalize,
|
||||
Random
|
||||
Random,
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System.Collections.Concurrent;
|
|||
using System.Threading;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
|
@ -23,7 +22,7 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
|||
private readonly ConcurrentQueue<NetworkPacketData> packets = new();
|
||||
|
||||
private Hook<PacketDispatcher.Delegates.OnReceivePacket>? hookDown;
|
||||
private Hook<ZoneClientSendPacketDelegate>? hookUp;
|
||||
private Hook<ZoneClient.Delegates.SendPacket>? hookUp;
|
||||
|
||||
private bool trackNetwork;
|
||||
private int trackedPackets = 20;
|
||||
|
|
@ -40,8 +39,6 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
|||
this.hookUp?.Dispose();
|
||||
}
|
||||
|
||||
private delegate byte ZoneClientSendPacketDelegate(ZoneClient* thisPtr, nint packet, uint a3, uint a4, byte a5);
|
||||
|
||||
private enum NetworkMessageDirection
|
||||
{
|
||||
ZoneDown,
|
||||
|
|
@ -58,22 +55,19 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
|||
public bool Ready { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Load()
|
||||
{
|
||||
this.hookDown = Hook<PacketDispatcher.Delegates.OnReceivePacket>.FromAddress(
|
||||
(nint)PacketDispatcher.StaticVirtualTablePointer->OnReceivePacket,
|
||||
this.OnReceivePacketDetour);
|
||||
|
||||
// TODO: switch to ZoneClient.SendPacket from CS
|
||||
if (Service<TargetSigScanner>.Get().TryScanText("E8 ?? ?? ?? ?? 4C 8B 44 24 ?? E9", out var address))
|
||||
this.hookUp = Hook<ZoneClientSendPacketDelegate>.FromAddress(address, this.SendPacketDetour);
|
||||
|
||||
this.Ready = true;
|
||||
}
|
||||
public void Load() => this.Ready = true;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Draw()
|
||||
{
|
||||
this.hookDown ??= Hook<PacketDispatcher.Delegates.OnReceivePacket>.FromAddress(
|
||||
(nint)PacketDispatcher.StaticVirtualTablePointer->OnReceivePacket,
|
||||
this.OnReceivePacketDetour);
|
||||
|
||||
this.hookUp ??= Hook<ZoneClient.Delegates.SendPacket>.FromAddress(
|
||||
(nint)ZoneClient.MemberFunctionPointers.SendPacket,
|
||||
this.SendPacketDetour);
|
||||
|
||||
if (ImGui.Checkbox("Track Network Packets"u8, ref this.trackNetwork))
|
||||
{
|
||||
if (this.trackNetwork)
|
||||
|
|
@ -213,7 +207,7 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
|||
this.hookDown.OriginalDisposeSafe(thisPtr, targetId, packet);
|
||||
}
|
||||
|
||||
private byte SendPacketDetour(ZoneClient* thisPtr, nint packet, uint a3, uint a4, byte a5)
|
||||
private bool SendPacketDetour(ZoneClient* thisPtr, nint packet, uint a3, uint a4, bool a5)
|
||||
{
|
||||
var opCode = *(ushort*)packet;
|
||||
this.RecordPacket(new NetworkPacketData(Interlocked.Increment(ref this.nextPacketIndex), DateTime.Now, opCode, NetworkMessageDirection.ZoneUp, 0, string.Empty));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
|
@ -322,7 +322,7 @@ public interface ITextureProvider : IDalamudService
|
|||
/// <param name="leaveWrapOpen">Whether to leave <paramref name="wrap"/> non-disposed when the returned
|
||||
/// <see cref="Task{TResult}"/> completes.</param>
|
||||
/// <returns>Address of the new <see cref="FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.Texture"/>.</returns>
|
||||
/// <example>See <c>PrintTextureInfo</c> in <see cref="Interface.Internal.UiDebug.Browsing.ImageNodeTre"/> for an example
|
||||
/// <example>See <c>PrintTextureInfo</c> in <see cref="Interface.Internal.UiDebug.Browsing.ImageNodeTree"/> for an example
|
||||
/// of replacing the texture of an image node.</example>
|
||||
/// <remarks>
|
||||
/// <para>If the returned kernel texture is to be destroyed, call the fourth function in its vtable, by calling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue