From 979bac5d7b08f0de8bf1a634366bf1039f01564d Mon Sep 17 00:00:00 2001 From: goat Date: Wed, 13 Nov 2024 01:18:37 +0100 Subject: [PATCH 1/9] fix nonstandard sizeof() usage --- Dalamud.Boot/utils.cpp | 2 +- Dalamud.Boot/utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud.Boot/utils.cpp b/Dalamud.Boot/utils.cpp index 65018add4..bbe47db82 100644 --- a/Dalamud.Boot/utils.cpp +++ b/Dalamud.Boot/utils.cpp @@ -103,7 +103,7 @@ bool utils::loaded_module::find_imported_function_pointer(const char* pcszDllNam ppFunctionAddress = nullptr; // This span might be too long in terms of meaningful data; it only serves to prevent accessing memory outsides boundaries. - for (const auto& importDescriptor : span_as(directory.VirtualAddress, directory.Size / sizeof IMAGE_IMPORT_DESCRIPTOR)) { + for (const auto& importDescriptor : span_as(directory.VirtualAddress, directory.Size / sizeof(IMAGE_IMPORT_DESCRIPTOR))) { // Having all zero values signals the end of the table. We didn't find anything. if (!importDescriptor.OriginalFirstThunk && !importDescriptor.TimeDateStamp && !importDescriptor.ForwarderChain && !importDescriptor.FirstThunk) diff --git a/Dalamud.Boot/utils.h b/Dalamud.Boot/utils.h index f10e277c0..eef405b26 100644 --- a/Dalamud.Boot/utils.h +++ b/Dalamud.Boot/utils.h @@ -121,7 +121,7 @@ namespace utils { memory_tenderizer(const void* pAddress, size_t length, DWORD dwNewProtect); template&& std::is_standard_layout_v>> - memory_tenderizer(const T& object, DWORD dwNewProtect) : memory_tenderizer(&object, sizeof T, dwNewProtect) {} + memory_tenderizer(const T& object, DWORD dwNewProtect) : memory_tenderizer(&object, sizeof(T), dwNewProtect) {} template memory_tenderizer(std::span s, DWORD dwNewProtect) : memory_tenderizer(&s[0], s.size(), dwNewProtect) {} From bd5f1a32773534c56cc8d036ee3acb6797e8708d Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Thu, 14 Nov 2024 23:51:08 -0800 Subject: [PATCH 2/9] bump cs --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 679b5353c..73ac85afd 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 679b5353cd61baa03b26d95efcac059f8e29b141 +Subproject commit 73ac85afd50968fb9c099507ce05da48bdf72e3c From d6dad8b44a01ffa7a24a50fd5deda29c03860c1e Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 15 Nov 2024 00:20:51 -0800 Subject: [PATCH 3/9] fix gamepad inputs for imgui --- Dalamud/Game/ClientState/GamePad/GamepadInput.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Dalamud/Game/ClientState/GamePad/GamepadInput.cs b/Dalamud/Game/ClientState/GamePad/GamepadInput.cs index 32439cd08..d9dcea60f 100644 --- a/Dalamud/Game/ClientState/GamePad/GamepadInput.cs +++ b/Dalamud/Game/ClientState/GamePad/GamepadInput.cs @@ -16,25 +16,25 @@ public struct GamepadInput /// /// Left analogue stick's horizontal value, -99 for left, 99 for right. /// - [FieldOffset(0x88)] + [FieldOffset(0x78)] public int LeftStickX; /// /// Left analogue stick's vertical value, -99 for down, 99 for up. /// - [FieldOffset(0x8C)] + [FieldOffset(0x7C)] public int LeftStickY; /// /// Right analogue stick's horizontal value, -99 for left, 99 for right. /// - [FieldOffset(0x90)] + [FieldOffset(0x80)] public int RightStickX; /// /// Right analogue stick's vertical value, -99 for down, 99 for up. /// - [FieldOffset(0x94)] + [FieldOffset(0x84)] public int RightStickY; /// @@ -43,7 +43,7 @@ public struct GamepadInput /// /// This is a bitfield. /// - [FieldOffset(0x98)] + [FieldOffset(0x88)] public ushort ButtonsRaw; /// @@ -52,7 +52,7 @@ public struct GamepadInput /// /// This is a bitfield. /// - [FieldOffset(0x9C)] + [FieldOffset(0x8C)] public ushort ButtonsPressed; /// @@ -61,7 +61,7 @@ public struct GamepadInput /// /// This is a bitfield. /// - [FieldOffset(0xA0)] + [FieldOffset(0x90)] public ushort ButtonsReleased; /// @@ -70,6 +70,6 @@ public struct GamepadInput /// /// This is a bitfield. /// - [FieldOffset(0xA4)] + [FieldOffset(0x94)] public ushort ButtonsRepeat; } From b4d9ebe1ef8928124ee278f8a11defc1ef8fe03d Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 15 Nov 2024 08:11:24 -0800 Subject: [PATCH 4/9] bump cs --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 73ac85afd..fca10adca 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 73ac85afd50968fb9c099507ce05da48bdf72e3c +Subproject commit fca10adcab3911c1be79cb0753987a2a02b7e058 From 9ac1f5cdb4a7b2aa1a73cb1546e29281f61fdca6 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 15 Nov 2024 08:18:39 -0800 Subject: [PATCH 5/9] Revert OnLogin event to only fire when LocalPlayer is present --- Dalamud/Game/ClientState/ClientState.cs | 35 ++++++++++++++----------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs index 364466cce..5f22eb54b 100644 --- a/Dalamud/Game/ClientState/ClientState.cs +++ b/Dalamud/Game/ClientState/ClientState.cs @@ -38,11 +38,16 @@ internal sealed class ClientState : IInternalDisposableService, IClientState private readonly ClientStateAddressResolver address; private readonly Hook setupTerritoryTypeHook; private readonly Hook uiModuleHandlePacketHook; - private readonly Hook processPacketPlayerSetupHook; private readonly Hook onLogoutHook; + [ServiceManager.ServiceDependency] + private readonly Framework framework = Service.Get(); + [ServiceManager.ServiceDependency] private readonly NetworkHandlers networkHandlers = Service.Get(); + + private bool lastConditionNone = true; + [ServiceManager.ServiceConstructor] private unsafe ClientState(TargetSigScanner sigScanner, Dalamud dalamud, GameLifecycle lifecycle) @@ -60,14 +65,13 @@ internal sealed class ClientState : IInternalDisposableService, IClientState this.setupTerritoryTypeHook = Hook.FromAddress(setTerritoryTypeAddr, this.SetupTerritoryTypeDetour); this.uiModuleHandlePacketHook = Hook.FromAddress((nint)UIModule.StaticVirtualTablePointer->HandlePacket, this.UIModuleHandlePacketDetour); - this.processPacketPlayerSetupHook = Hook.FromAddress(this.address.ProcessPacketPlayerSetup, this.ProcessPacketPlayerSetupDetour); this.onLogoutHook = Hook.FromAddress((nint)LogoutCallbackInterface.StaticVirtualTablePointer->OnLogout, this.OnLogoutDetour); + this.framework.Update += this.FrameworkOnOnUpdateEvent; this.networkHandlers.CfPop += this.NetworkHandlersOnCfPop; this.setupTerritoryTypeHook.Enable(); this.uiModuleHandlePacketHook.Enable(); - this.processPacketPlayerSetupHook.Enable(); this.onLogoutHook.Enable(); } @@ -171,8 +175,9 @@ internal sealed class ClientState : IInternalDisposableService, IClientState { this.setupTerritoryTypeHook.Dispose(); this.uiModuleHandlePacketHook.Dispose(); - this.processPacketPlayerSetupHook.Dispose(); this.onLogoutHook.Dispose(); + + this.framework.Update -= this.FrameworkOnOnUpdateEvent; this.networkHandlers.CfPop -= this.NetworkHandlersOnCfPop; } @@ -255,24 +260,24 @@ internal sealed class ClientState : IInternalDisposableService, IClientState } } - private unsafe void ProcessPacketPlayerSetupDetour(nint a1, nint packet) + private void FrameworkOnOnUpdateEvent(IFramework framework1) { - // Call original first, so everything is set up. - this.processPacketPlayerSetupHook.Original(a1, packet); - + var condition = Service.GetNullable(); var gameGui = Service.GetNullable(); + var data = Service.GetNullable(); - try + if (condition == null || gameGui == null || data == null) + return; + + if (condition.Any() && this.lastConditionNone && this.LocalPlayer != null) { - Log.Debug("Login"); + Log.Debug("Is login"); + this.lastConditionNone = false; this.Login?.InvokeSafely(); - gameGui?.ResetUiHideState(); + gameGui.ResetUiHideState(); + this.lifecycle.ResetLogout(); } - catch (Exception ex) - { - Log.Error(ex, "Exception during ProcessPacketPlayerSetupDetour"); - } } private unsafe void OnLogoutDetour(LogoutCallbackInterface* thisPtr, LogoutCallbackInterface.LogoutParams* logoutParams) From b43a6b6bce2e5b9b25c89fa5ba74a87241b9dd46 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 15 Nov 2024 08:24:04 -0800 Subject: [PATCH 6/9] fix: OnLogin needs to be callable again --- Dalamud/Game/ClientState/ClientState.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs index 5f22eb54b..1fade54b6 100644 --- a/Dalamud/Game/ClientState/ClientState.cs +++ b/Dalamud/Game/ClientState/ClientState.cs @@ -22,6 +22,8 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent; using Lumina.Excel.Sheets; +using TerraFX.Interop.Windows; + using Action = System.Action; namespace Dalamud.Game.ClientState; @@ -309,6 +311,7 @@ internal sealed class ClientState : IInternalDisposableService, IClientState } gameGui?.ResetUiHideState(); + this.lastConditionNone = true; // unblock login flag this.lifecycle.SetLogout(); } From 4436c58749b5d4e09c186c566254ae88a2423a04 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Fri, 15 Nov 2024 08:25:19 -0800 Subject: [PATCH 7/9] covfefe --- Dalamud/Game/ClientState/ClientState.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs index 1fade54b6..4ab69b391 100644 --- a/Dalamud/Game/ClientState/ClientState.cs +++ b/Dalamud/Game/ClientState/ClientState.cs @@ -22,8 +22,6 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent; using Lumina.Excel.Sheets; -using TerraFX.Interop.Windows; - using Action = System.Action; namespace Dalamud.Game.ClientState; From bbaf60085623faa28db4d2adeb5f0db8cc2121eb Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Fri, 15 Nov 2024 19:31:41 +0100 Subject: [PATCH 8/9] use correct gauge pointer --- Dalamud/Game/ClientState/JobGauge/JobGauges.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/JobGauge/JobGauges.cs b/Dalamud/Game/ClientState/JobGauge/JobGauges.cs index 5a734ed87..e47bead36 100644 --- a/Dalamud/Game/ClientState/JobGauge/JobGauges.cs +++ b/Dalamud/Game/ClientState/JobGauge/JobGauges.cs @@ -28,7 +28,7 @@ internal class JobGauges : IServiceType, IJobGauges } /// - public unsafe IntPtr Address => (nint)(&CSJobGaugeManager.Instance()->CurrentGauge); + public unsafe IntPtr Address => (nint)(CSJobGaugeManager.Instance()->CurrentGauge); /// public T Get() where T : JobGaugeBase From a5b0a3817f63f29d89469af31d75b04b187ff296 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Fri, 15 Nov 2024 19:33:53 +0100 Subject: [PATCH 9/9] ci: rollup into net9 --- .github/workflows/rollup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rollup.yml b/.github/workflows/rollup.yml index 5452d998e..49b3d8c1d 100644 --- a/.github/workflows/rollup.yml +++ b/.github/workflows/rollup.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: branches: - - api11 + - net9 defaults: run: