mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-25 22:21:49 +01:00
Switch to CS in NetworkMonitorWidget
This commit is contained in:
parent
2b51a2a54e
commit
36493ec886
1 changed files with 5 additions and 8 deletions
|
|
@ -2,7 +2,6 @@ using System.Collections.Concurrent;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
using Dalamud.Game;
|
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Utility.Raii;
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
|
@ -23,7 +22,7 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
||||||
private readonly ConcurrentQueue<NetworkPacketData> packets = new();
|
private readonly ConcurrentQueue<NetworkPacketData> packets = new();
|
||||||
|
|
||||||
private Hook<PacketDispatcher.Delegates.OnReceivePacket>? hookDown;
|
private Hook<PacketDispatcher.Delegates.OnReceivePacket>? hookDown;
|
||||||
private Hook<ZoneClientSendPacketDelegate>? hookUp;
|
private Hook<ZoneClient.Delegates.SendPacket>? hookUp;
|
||||||
|
|
||||||
private bool trackNetwork;
|
private bool trackNetwork;
|
||||||
private int trackedPackets = 20;
|
private int trackedPackets = 20;
|
||||||
|
|
@ -40,8 +39,6 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
||||||
this.hookUp?.Dispose();
|
this.hookUp?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private delegate byte ZoneClientSendPacketDelegate(ZoneClient* thisPtr, nint packet, uint a3, uint a4, byte a5);
|
|
||||||
|
|
||||||
private enum NetworkMessageDirection
|
private enum NetworkMessageDirection
|
||||||
{
|
{
|
||||||
ZoneDown,
|
ZoneDown,
|
||||||
|
|
@ -64,9 +61,9 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
||||||
(nint)PacketDispatcher.StaticVirtualTablePointer->OnReceivePacket,
|
(nint)PacketDispatcher.StaticVirtualTablePointer->OnReceivePacket,
|
||||||
this.OnReceivePacketDetour);
|
this.OnReceivePacketDetour);
|
||||||
|
|
||||||
// TODO: switch to ZoneClient.SendPacket from CS
|
this.hookUp = Hook<ZoneClient.Delegates.SendPacket>.FromAddress(
|
||||||
if (Service<TargetSigScanner>.Get().TryScanText("E8 ?? ?? ?? ?? 4C 8B 44 24 ?? E9", out var address))
|
(nint)ZoneClient.MemberFunctionPointers.SendPacket,
|
||||||
this.hookUp = Hook<ZoneClientSendPacketDelegate>.FromAddress(address, this.SendPacketDetour);
|
this.SendPacketDetour);
|
||||||
|
|
||||||
this.Ready = true;
|
this.Ready = true;
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +210,7 @@ internal unsafe class NetworkMonitorWidget : IDataWindowWidget
|
||||||
this.hookDown.OriginalDisposeSafe(thisPtr, targetId, packet);
|
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;
|
var opCode = *(ushort*)packet;
|
||||||
this.RecordPacket(new NetworkPacketData(Interlocked.Increment(ref this.nextPacketIndex), DateTime.Now, opCode, NetworkMessageDirection.ZoneUp, 0, string.Empty));
|
this.RecordPacket(new NetworkPacketData(Interlocked.Increment(ref this.nextPacketIndex), DateTime.Now, opCode, NetworkMessageDirection.ZoneUp, 0, string.Empty));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue