Dalamud/Dalamud/Game/ClientState/ClientStateAddressResolver.cs
Haselnussbomber 9091216e1c
Update ClientState (#2410)
* Add MapChanged event to ClientState

* Add PublicInstanceId with event to ClientState

* Set eventhandlers to null

* Rework events and add ZoneInit event
2025-09-29 09:02:53 -07:00

47 lines
1.8 KiB
C#

namespace Dalamud.Game.ClientState;
/// <summary>
/// Client state memory address resolver.
/// </summary>
internal sealed class ClientStateAddressResolver : BaseAddressResolver
{
// Static offsets
/// <summary>
/// Gets the address of the keyboard state.
/// </summary>
public nint KeyboardState { get; private set; }
/// <summary>
/// Gets the address of the keyboard state index array which translates the VK enumeration to the key state.
/// </summary>
public nint KeyboardStateIndexArray { get; private set; }
// Functions
/// <summary>
/// Gets the address of the method that handles the ZoneInit packet.
/// </summary>
public nint HandleZoneInitPacket { get; private set; }
/// <summary>
/// Gets the address of the method that sets the current public instance.
/// </summary>
public nint SetCurrentInstance { get; private set; }
/// <summary>
/// Scan for and setup any configured address pointers.
/// </summary>
/// <param name="sig">The signature scanner to facilitate setup.</param>
protected override void Setup64Bit(ISigScanner sig)
{
this.HandleZoneInitPacket = sig.ScanText("E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 44 0F B6 45");
this.SetCurrentInstance = sig.ScanText("E8 ?? ?? ?? ?? 0F B6 55 ?? 48 8D 0D ?? ?? ?? ?? C0 EA"); // NetworkModuleProxy.SetCurrentInstance
// These resolve to fixed offsets only, without the base address added in, so GetStaticAddressFromSig() can't be used.
// lea rcx, ds:1DB9F74h[rax*4] KeyboardState
// movzx edx, byte ptr [rbx+rsi+1D5E0E0h] KeyboardStateIndexArray
this.KeyboardState = sig.ScanText("48 8D 0C 85 ?? ?? ?? ?? 8B 04 31 85 C2 0F 85") + 0x4;
this.KeyboardStateIndexArray = sig.ScanText("0F B6 94 33 ?? ?? ?? ?? 84 D2") + 0x4;
}
}