Skip to content

Commit

Permalink
upd: 7.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluefissure committed Jul 10, 2024
1 parent f5b4073 commit 621e110
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 90 deletions.
23 changes: 5 additions & 18 deletions Inviter/ClientStructs/GroupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,12 @@

namespace Inviter.ClientStructs
{
// Referred from https://github.com/aers/FFXIVClientStructs/blob/main/FFXIV/Group/GroupManager.cs

// there are actually two copies of this back to back in the exe
// maybe for 48 man raid support since the group manager can only hold 1 alliance worth of party members
[StructLayout(LayoutKind.Explicit, Size = 0x3D70)]
// Referred from https://github.com/aers/FFXIVClientStructs/blob/18faa14/FFXIVClientStructs/FFXIV/Client/Game/Group/GroupManager.cs
[StructLayout(LayoutKind.Explicit, Size = 0x65B0)]
public unsafe struct GroupManager
{
[FieldOffset(0x0)] public fixed byte PartyMembers[0x230 * 8]; // PartyMember type
// for some reason the alliance array is size 20. it used to be 16 in old versions.
[FieldOffset(0x1180)] public fixed byte AllianceMembers[0x230 * 20]; // PartyMember type
[FieldOffset(0x3D40)] public uint Unk_3D40;
[FieldOffset(0x3D44)] public ushort Unk_3D44;
[FieldOffset(0x3D48)] public long Unk_3D48;
[FieldOffset(0x3D50)] public long Unk_3D50;
[FieldOffset(0x3D58)] public uint PartyLeaderIndex; // index of party leader in array
[FieldOffset(0x3D5C)] public byte MemberCount;
[FieldOffset(0x3D5D)] public byte Unk_3D5D;
[FieldOffset(0x3D5E)] public bool IsAlliance;
[FieldOffset(0x3D5F)] public byte Unk_3D5F; // some sort of count
[FieldOffset(0x3D60)] public byte Unk_3D60;
[FieldOffset(0x0)] public fixed byte PartyMembers[0x3A0 * 8]; // PartyMember type
[FieldOffset(0x6598)] public uint PartyLeaderIndex; // index of party leader in array
[FieldOffset(0x659C)] public byte MemberCount;
}
}
32 changes: 3 additions & 29 deletions Inviter/ClientStructs/PartyMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,10 @@

namespace Inviter.ClientStructs
{
// Referred from https://github.com/aers/FFXIVClientStructs/blob/main/FFXIV/Group/PartyMember.cs
[StructLayout(LayoutKind.Explicit, Size = 0x230)]
// Referred from https://github.com/aers/FFXIVClientStructs/blob/18faa14/FFXIVClientStructs/FFXIV/Client/Game/Group/PartyMember.cs
[StructLayout(LayoutKind.Explicit, Size = 0x3A0)]
public unsafe struct PartyMember
{
// [FieldOffset(0x0)] public BuffList BuffList;
[FieldOffset(0x190)] public float X;
[FieldOffset(0x194)] public float Y;
[FieldOffset(0x198)] public float Z;
[FieldOffset(0x1A0)] public long Unk_1A0;
[FieldOffset(0x1A8)] public uint ObjectID;
[FieldOffset(0x1AC)] public uint Unk_ObjectID_1;
[FieldOffset(0x1B0)] public uint Unk_ObjectID_2;
[FieldOffset(0x1B4)] public uint CurrentHP;
[FieldOffset(0x1B8)] public uint MaxHP;
[FieldOffset(0x1BC)] public ushort CurrentMP;
[FieldOffset(0x1BE)] public ushort MaxMP;
[FieldOffset(0x1C0)] public ushort TerritoryType; // player zone
[FieldOffset(0x1C2)] public ushort Unk_1C2; // seems to be 0x63/99, no idea what it is
[FieldOffset(0x1C4)] public fixed byte Name[0x40]; // character name string
[FieldOffset(0x204)] public byte Sex;
[FieldOffset(0x205)] public byte ClassJob;
[FieldOffset(0x206)] public byte Level;
// 0x18 byte struct at 0x208
[FieldOffset(0x208)] public byte Unk_Struct_208__0;
[FieldOffset(0x20C)] public uint Unk_Struct_208__4;
[FieldOffset(0x210)] public ushort Unk_Struct_208__8;
[FieldOffset(0x214)] public uint Unk_Struct_208__C;
[FieldOffset(0x218)] public ushort Unk_Struct_208__10;
[FieldOffset(0x21A)] public ushort Unk_Struct_208__14;
[FieldOffset(0x220)] public byte Unk_220;

[FieldOffset(0x32C)] public fixed byte Name[0x40]; // character name string
}
}
8 changes: 1 addition & 7 deletions Inviter/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,10 @@ public class Configuration : IPluginConfiguration

#region Init and Save

[NonSerialized] private DalamudPluginInterface _pluginInterface;

public void Initialize(DalamudPluginInterface pluginInterface)
{
_pluginInterface = pluginInterface;
}

public void Save()
{
_pluginInterface.SavePluginConfig(this);
Inviter.Interface.SavePluginConfig(this);
}

#endregion
Expand Down
59 changes: 28 additions & 31 deletions Inviter/Inviter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Inviter : IDalamudPlugin

private delegate IntPtr GetUIBaseDelegate();
private delegate IntPtr GetUIModuleDelegate(IntPtr basePtr);
private delegate char EasierProcessInviteDelegate(Int64 a1, Int64 a2, IntPtr name, Int16 world_id);
private delegate char EasierProcessInviteDelegate(Int64 a1, Int64 a2, Int16 world_id, IntPtr name, char a5);
private delegate char EasierProcessEurekaInviteDelegate(Int64 a1, Int64 a2);
private delegate char EasierProcessCIDDelegate(Int64 a1, Int64 a2);
private EasierProcessInviteDelegate _EasierProcessInvite;
Expand All @@ -50,8 +50,6 @@ public class Inviter : IDalamudPlugin
private Hook<EasierProcessCIDDelegate> easierProcessCIDHook;
private GetUIModuleDelegate GetUIModule;
private delegate IntPtr GetMagicUIDelegate(IntPtr basePtr);
private IntPtr getUIModulePtr;
private IntPtr uiModulePtr;
private IntPtr uiModule;
private Int64 uiInvite;
private IntPtr groupManagerAddress;
Expand All @@ -65,7 +63,7 @@ public class Inviter : IDalamudPlugin
[PluginService]
public static ISigScanner SigScanner { get; private set; }
[PluginService]
public static DalamudPluginInterface Interface { get; private set; }
public static IDalamudPluginInterface Interface { get; private set; }
[PluginService]
public static IGameGui GameGui { get; private set; }
[PluginService]
Expand All @@ -80,6 +78,8 @@ public class Inviter : IDalamudPlugin
public static IDataManager Data { get; private set; }
[PluginService]
public static IGameInteropProvider Hook { get; private set; }
[PluginService]
public static IPluginLog PluginLog { get; private set; }


public void Dispose()
Expand All @@ -103,26 +103,24 @@ public Inviter()
{
name2CID = new Dictionary<string, long> { };
Config = Interface.GetPluginConfig() as Configuration ?? new Configuration();
Config.Initialize(Interface);
var easierProcessInvitePtr = SigScanner.ScanText("E8 ?? ?? ?? ?? EB 3E 44 0F B7 83 ?? ?? ?? ??");
var easierProcessEurekaInvitePtr = SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8B 83 ?? ?? ?? ?? 48 85 C0 74 62");
var easierProcessCIDPtr = SigScanner.ScanText("40 53 48 83 EC 20 48 8B DA 48 8D 0D ?? ?? ?? ?? 8B 52 08");
getUIModulePtr = SigScanner.ScanText("E8 ?? ?? ?? ?? 48 83 7F ?? 00 48 8B F0");
uiModulePtr = SigScanner.GetStaticAddressFromSig("48 8B 0D ?? ?? ?? ?? 48 8D 54 24 ?? 48 83 C1 10 E8 ?? ?? ?? ??");
var InviteToPartyByName = SigScanner.ScanText("E8 ?? ?? ?? ?? EB CC CC");
var InviteToPartyInInstance = SigScanner.ScanText("E8 ?? ?? ?? ?? EB 71 48 8B 83 ?? ?? ?? ??");
var easierProcessCIDPtr = SigScanner.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 85 C0 74 78");
groupManagerAddress = SigScanner.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? 44 8B E7");
InitUi();
PluginLog.Log("===== I N V I T E R =====");
PluginLog.Log($"Process Invite address {easierProcessInvitePtr:X}");
PluginLog.Log($"Process CID address {easierProcessCIDPtr:X}");
PluginLog.Log($"uiModule address {uiModule:X}");
PluginLog.Log($"uiInvite address {uiInvite:X}");
PluginLog.Log($"groupManager address {groupManagerAddress:X}");
PluginLog.Info("===== I N V I T E R =====");
PluginLog.Info($"InviteToPartyByName address {InviteToPartyByName:X}");
PluginLog.Info($"InviteToPartyInInstance address {InviteToPartyInInstance:X}");
PluginLog.Info($"Process CID address {easierProcessCIDPtr:X}");
PluginLog.Info($"uiModule address {uiModule:X}");
PluginLog.Info($"uiInvite address {uiInvite:X}");
PluginLog.Info($"groupManager address {groupManagerAddress:X}");


//Log($"EurekaInvite:{easierProcessEurekaInvitePtr}");
//Interface.Framework.Gui.Chat.OnChatMessageRaw += Chat_OnChatMessageRaw;
_EasierProcessInvite = Marshal.GetDelegateForFunctionPointer<EasierProcessInviteDelegate>(easierProcessInvitePtr);
_EasierProcessEurekaInvite = Marshal.GetDelegateForFunctionPointer<EasierProcessEurekaInviteDelegate>(easierProcessEurekaInvitePtr);
_EasierProcessInvite = Marshal.GetDelegateForFunctionPointer<EasierProcessInviteDelegate>(InviteToPartyByName);
_EasierProcessEurekaInvite = Marshal.GetDelegateForFunctionPointer<EasierProcessEurekaInviteDelegate>(InviteToPartyInInstance);
/*
easierProcessEurekaInviteHook = new Hook<EasierProcessEurekaInviteDelegate>(easierProcessEurekaInvitePtr,
new EasierProcessEurekaInviteDelegate(EasierProcessEurekaInviteDetour),
Expand Down Expand Up @@ -244,20 +242,19 @@ public void CommandHandler(string command, string arguments)
}
private void InitUi()
{
GetUIModule = Marshal.GetDelegateForFunctionPointer<GetUIModuleDelegate>(getUIModulePtr);
uiModule = GetUIModule(Marshal.ReadIntPtr(uiModulePtr));
uiModule = GameGui.GetUIModule();
if (uiModule == IntPtr.Zero)
throw new ApplicationException("uiModule was null");
IntPtr step2 = Marshal.ReadIntPtr(uiModule) + 272;
PluginLog.Log($"step2:0x{step2:X}");
IntPtr step2 = Marshal.ReadIntPtr(uiModule) + 280;
PluginLog.Info($"step2:0x{step2:X}");
if (step2 == IntPtr.Zero)
throw new ApplicationException("step2 was null");
IntPtr step3 = Marshal.ReadIntPtr(step2);
PluginLog.Log($"step3:0x{step3:X}");
PluginLog.Info($"step3:0x{step3:X}");
if (step3 == IntPtr.Zero)
throw new ApplicationException("step3 was null");
IntPtr step4 = Marshal.GetDelegateForFunctionPointer<GetMagicUIDelegate>(step3)(uiModule) + 6536;
PluginLog.Log($"step4:0x{step4:X}");
PluginLog.Info($"step4:0x{step4:X}");
if (step4 == (IntPtr.Zero + 6536))
throw new ApplicationException("step4 was null");
uiInvite = Marshal.ReadInt64(step4);
Expand All @@ -269,14 +266,14 @@ public void Log(string message)
{
if (!Config.PrintMessage) return;
var msg = $"[{Name}] {message}";
PluginLog.Log(msg);
PluginLog.Info(msg);
ChatGui.Print(msg);
}
public void LogError(string message)
{
if (!Config.PrintError) return;
var msg = $"[{Name}] {message}";
PluginLog.LogError(msg);
PluginLog.Error(msg);
ChatGui.PrintError(msg);
}
private void Chat_OnNetworkMessage(IntPtr dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction)
Expand Down Expand Up @@ -328,7 +325,7 @@ public static string StringFromNativeUtf8(IntPtr nativeUtf8)
Marshal.Copy(nativeUtf8, buffer, 0, buffer.Length);
return Encoding.UTF8.GetString(buffer);
}
private void Chat_OnChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled)
private void Chat_OnChatMessage(XivChatType type, int timestamp, ref SeString sender, ref SeString message, ref bool isHandled)
{
if (!Config.Enable) return;
if (!Enum.IsDefined(typeof(XivChatType), type)) return;
Expand Down Expand Up @@ -439,7 +436,7 @@ public void ProcessInvite(PlayerPayload player)
Marshal.WriteByte(mem1, player_bytes.Length, 0);
lock (LockInviteObj)
{
_EasierProcessInvite(uiInvite, 0, mem1, (short)player.World.RowId);
_EasierProcessInvite(uiInvite, 0, (short)player.World.RowId, mem1, (char)1);
}
Marshal.FreeHGlobal(mem1);
}
Expand Down Expand Up @@ -473,10 +470,10 @@ public char EasierProcessCIDDetour(Int64 a1, Int64 a2)
*/
if (Config.Enable && Config.Eureka && dataPtr != IntPtr.Zero)
{
Int64 CID = Marshal.ReadInt64(dataPtr);
short world_id = Marshal.ReadInt16(dataPtr, 12);
Int64 CID = Marshal.ReadInt64(dataPtr, 8);
short world_id = Marshal.ReadInt16(dataPtr, 20);
var world = Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.World>().GetRow((uint)world_id);
string name = StringFromNativeUtf8(dataPtr + 16);
string name = StringFromNativeUtf8(dataPtr + 24);
Log($"{name}@{world.Name}:{CID}");
string playerNameKey = $"{name}@{world_id}";
if (!name2CID.ContainsKey(playerNameKey))
Expand Down
4 changes: 2 additions & 2 deletions Inviter/Inviter.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -9,7 +9,7 @@
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
Expand Down
6 changes: 3 additions & 3 deletions Inviter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Inviter")]
[assembly: AssemblyCopyright("Copyright © Bluefissure 2023")]
[assembly: AssemblyCopyright("Copyright © Bluefissure 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.1")]
[assembly: AssemblyFileVersion("1.1.1.1")]
[assembly: AssemblyVersion("1.1.2.0")]
[assembly: AssemblyFileVersion("1.1.2.0")]

0 comments on commit 621e110

Please sign in to comment.