From 7cd2af9a6696a0291d0b02bf519b4fdb27431b7c Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 11 Aug 2021 17:46:58 -0400 Subject: [PATCH 01/15] Move toast files into toast namespace --- Dalamud/Game/Gui/GameGui.cs | 1 + Dalamud/Game/Gui/{ => Toast}/ToastGui.cs | 3 +-- Dalamud/Game/Gui/{ => Toast}/ToastGuiAddressResolver.cs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) rename Dalamud/Game/Gui/{ => Toast}/ToastGui.cs (99%) rename Dalamud/Game/Gui/{ => Toast}/ToastGuiAddressResolver.cs (95%) diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index df7f0c531..fed5d4207 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -5,6 +5,7 @@ using System.Runtime.InteropServices; using Dalamud.Game.Gui.Addons; using Dalamud.Game.Gui.FlyText; using Dalamud.Game.Gui.PartyFinder; +using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; using Dalamud.Interface; diff --git a/Dalamud/Game/Gui/ToastGui.cs b/Dalamud/Game/Gui/Toast/ToastGui.cs similarity index 99% rename from Dalamud/Game/Gui/ToastGui.cs rename to Dalamud/Game/Gui/Toast/ToastGui.cs index 64931416e..84485cc1e 100644 --- a/Dalamud/Game/Gui/ToastGui.cs +++ b/Dalamud/Game/Gui/Toast/ToastGui.cs @@ -2,11 +2,10 @@ using System; using System.Collections.Generic; using System.Text; -using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Hooking; -namespace Dalamud.Game.Gui +namespace Dalamud.Game.Gui.Toast { /// /// This class facilitates interacting with and creating native toast windows. diff --git a/Dalamud/Game/Gui/ToastGuiAddressResolver.cs b/Dalamud/Game/Gui/Toast/ToastGuiAddressResolver.cs similarity index 95% rename from Dalamud/Game/Gui/ToastGuiAddressResolver.cs rename to Dalamud/Game/Gui/Toast/ToastGuiAddressResolver.cs index adf5e3190..75a1e96b6 100644 --- a/Dalamud/Game/Gui/ToastGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/Toast/ToastGuiAddressResolver.cs @@ -1,8 +1,6 @@ using System; -using Dalamud.Game.Internal; - -namespace Dalamud.Game.Gui +namespace Dalamud.Game.Gui.Toast { /// /// An address resolver for the class. From 3cb15f2b9eacbc58893311813f14df4bd3295798 Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 11 Aug 2021 17:48:04 -0400 Subject: [PATCH 02/15] Add missing documentation --- Dalamud/Game/Gui/FlyText/FlyTextKind.cs | 75 ++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/Dalamud/Game/Gui/FlyText/FlyTextKind.cs b/Dalamud/Game/Gui/FlyText/FlyTextKind.cs index 972ffcce8..fa08c233d 100644 --- a/Dalamud/Game/Gui/FlyText/FlyTextKind.cs +++ b/Dalamud/Game/Gui/FlyText/FlyTextKind.cs @@ -19,8 +19,8 @@ namespace Dalamud.Game.Gui.FlyText DirectHit = 1, /// - /// Val1 in larger serif font with exclamation, with Text2 - /// in sans-serif as subtitle. Does a bigger bounce effect on appearance. + /// Val1 in larger serif font with exclamation, with Text2 in sans-serif as subtitle. + /// Does a bigger bounce effect on appearance. /// CriticalHit = 2, @@ -75,6 +75,10 @@ namespace Dalamud.Game.Gui.FlyText /// Icon next to sans-serif Text1. /// NamedIcon = 12, + + /// + /// Icon next to sans-serif Text1 (2). + /// NamedIcon2 = 13, /// @@ -92,8 +96,19 @@ namespace Dalamud.Game.Gui.FlyText /// NamedTp = 16, + /// + /// AutoAttack with sans-serif Text1 to the left of the Val1 (2). + /// NamedAttack2 = 17, + + /// + /// Sans-serif Text1 next to serif Val1 with all caps condensed font MP with Text2 in sans-serif as subtitle (2). + /// NamedMp2 = 18, + + /// + /// Sans-serif Text1 next to serif Val1 with all caps condensed font TP with Text2 in sans-serif as subtitle (2). + /// NamedTp2 = 19, /// @@ -122,9 +137,25 @@ namespace Dalamud.Game.Gui.FlyText /// AutoAttack with no Text2. /// AutoAttackNoText = 24, + + /// + /// AutoAttack with no Text2 (2). + /// AutoAttackNoText2 = 25, + + /// + /// Val1 in larger serif font with exclamation, with Text2 in sans-serif as subtitle. Does a bigger bounce effect on appearance (2). + /// CriticalHit2 = 26, + + /// + /// AutoAttack with no Text2 (3). + /// AutoAttackNoText3 = 27, + + /// + /// CriticalHit with sans-serif Text1 to the left of the Val1 (2). + /// NamedCriticalHit2 = 28, /// @@ -148,6 +179,11 @@ namespace Dalamud.Game.Gui.FlyText /// Same as NamedIcon but Text1 is slightly faded. Used for buff expiration. /// NamedIconFaded = 32, + + /// + /// Same as NamedIcon but Text1 is slightly faded (2). + /// Used for buff expiration. + /// NamedIconFaded2 = 33, /// @@ -175,8 +211,19 @@ namespace Dalamud.Game.Gui.FlyText /// NamedHasNoEffect = 38, + /// + /// AutoAttack with sans-serif Text1 to the left of the Val1 (3). + /// NamedAttack3 = 39, + + /// + /// Sans-serif Text1 next to serif Val1 with all caps condensed font MP with Text2 in sans-serif as subtitle (3). + /// NamedMp3 = 40, + + /// + /// Sans-serif Text1 next to serif Val1 with all caps condensed font TP with Text2 in sans-serif as subtitle (3). + /// NamedTp3 = 41, /// @@ -194,7 +241,15 @@ namespace Dalamud.Game.Gui.FlyText /// NamedIconWithItemOutline = 44, + /// + /// AutoAttack with no Text2 (4). + /// AutoAttackNoText4 = 45, + + /// + /// Val1 in larger serif font with exclamation, with Text2 in sans-serif as subtitle (3). + /// Does a bigger bounce effect on appearance. + /// CriticalHit3 = 46, /// @@ -207,8 +262,22 @@ namespace Dalamud.Game.Gui.FlyText /// Reflected = 48, + /// + /// Val1 in serif font, Text2 in sans-serif as subtitle (2). + /// Does a bounce effect on appearance. + /// DirectHit2 = 49, - CriticalHit5 = 50, + + /// + /// Val1 in larger serif font with exclamation, with Text2 in sans-serif as subtitle (4). + /// Does a bigger bounce effect on appearance. + /// + CriticalHit4 = 50, + + /// + /// Val1 in even larger serif font with 2 exclamations, Text2 in sans-serif as subtitle (2). + /// Does a large bounce effect on appearance. Does not scroll up or down the screen. + /// CriticalDirectHit2 = 51, } } From 3683ae148e1fd8efee964fe1dec67f2358aa4bfd Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 15 Aug 2021 15:01:24 -0400 Subject: [PATCH 03/15] Boot.cpp getenv improvement --- lib/CoreCLR/boot.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/CoreCLR/boot.cpp b/lib/CoreCLR/boot.cpp index 0782af946..0fc9ca9d5 100644 --- a/lib/CoreCLR/boot.cpp +++ b/lib/CoreCLR/boot.cpp @@ -1,5 +1,4 @@ #define WIN32_LEAN_AND_MEAN -#define _CRT_SECURE_NO_WARNINGS #include #include @@ -36,12 +35,20 @@ int InitializeClrAndGetEntryPoint( CoreCLR clr; SetEnvironmentVariable(L"DOTNET_MULTILEVEL_LOOKUP", L"0"); - char* env_path = std::getenv("DALAMUD_RUNTIME"); wchar_t* dotnet_path; - wchar_t* _appdata; - if (!env_path) + std::wstring buffer; + buffer.resize(0); + result = GetEnvironmentVariableW(L"DALAMUD_RUNTIME", &buffer[0], 0); + + if (result) + { + buffer.resize(result); // The first pass returns the required length + result = GetEnvironmentVariableW(L"DALAMUD_RUNTIME", &buffer[0], result); + dotnet_path = _wcsdup(buffer.c_str()); + } + else { result = SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_DEFAULT, nullptr, &_appdata); @@ -54,12 +61,6 @@ int InitializeClrAndGetEntryPoint( std::filesystem::path fs_app_data(_appdata); dotnet_path = _wcsdup(fs_app_data.append("XIVLauncher").append("runtime").c_str()); } - else - { - const size_t cSize = strlen(env_path)+1; - dotnet_path = new wchar_t[cSize]; - mbstowcs (dotnet_path, env_path, cSize); - } // =========================================================================== // From de0b9338693e279ab0cc50dc429ffdcde4fdcb50 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 15 Aug 2021 15:02:16 -0400 Subject: [PATCH 04/15] Update types in FlyText --- Dalamud/Game/Gui/FlyText/FlyTextGui.cs | 34 ++++++++++++------------- Dalamud/Game/Gui/FlyText/FlyTextKind.cs | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs index 7a3c7af17..44070d911 100644 --- a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs +++ b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs @@ -70,7 +70,7 @@ namespace Dalamud.Game.Gui.FlyText /// private delegate IntPtr CreateFlyTextDelegate( IntPtr addonFlyText, - int kind, + FlyTextKind kind, int val1, int val2, IntPtr text2, @@ -126,10 +126,10 @@ namespace Dalamud.Game.Gui.FlyText public unsafe void AddFlyText(FlyTextKind kind, uint actorIndex, uint val1, uint val2, SeString text1, SeString text2, uint color, uint icon) { // Known valid flytext region within the atk arrays - int numIndex = 28; - int strIndex = 25; - uint numOffset = 147; - uint strOffset = 28; + var numIndex = 28; + var strIndex = 25; + var numOffset = 147u; + var strOffset = 28u; // Get the UI module and flytext addon pointers var ui = (UIModule*)this.Dalamud.Framework.Gui.GetUIModule(); @@ -195,7 +195,7 @@ namespace Dalamud.Game.Gui.FlyText private IntPtr CreateFlyTextDetour( IntPtr addonFlyText, - int kind, + FlyTextKind kind, int val1, int val2, IntPtr text2, @@ -211,7 +211,7 @@ namespace Dalamud.Game.Gui.FlyText var handled = false; - var tmpKind = (FlyTextKind)kind; + var tmpKind = kind; var tmpVal1 = val1; var tmpVal2 = val2; var tmpText1 = MemoryHelper.ReadSeStringNullTerminated(text1); @@ -224,7 +224,7 @@ namespace Dalamud.Game.Gui.FlyText var cmpText2 = tmpText2.ToString(); Log.Verbose($"[FlyText] Called with addonFlyText({addonFlyText.ToInt64():X}) " + - $"kind({((FlyTextKind)kind).ToString()}) val1({val1}) val2({val2}) " + + $"kind({kind}) val1({val1}) val2({val2}) " + $"text1({text1.ToInt64():X}, \"{tmpText1}\") text2({text2.ToInt64():X}, \"{tmpText2}\") " + $"color({color:X}) icon({icon}) yOffset({yOffset})"); Log.Verbose("[FlyText] Calling flytext events!"); @@ -250,14 +250,14 @@ namespace Dalamud.Game.Gui.FlyText } // Check if any values have changed - var dirty = tmpKind != (FlyTextKind)kind || - tmpVal1 != val1 || - tmpVal2 != val2 || - tmpText1.ToString() != cmpText1 || - tmpText2.ToString() != cmpText2 || - tmpColor != color || - tmpIcon != icon || - Math.Abs(tmpYOffset - yOffset) > float.Epsilon; + var dirty = tmpKind != kind || + tmpVal1 != val1 || + tmpVal2 != val2 || + tmpText1.ToString() != cmpText1 || + tmpText2.ToString() != cmpText2 || + tmpColor != color || + tmpIcon != icon || + Math.Abs(tmpYOffset - yOffset) > float.Epsilon; // If not dirty, make the original call if (!dirty) @@ -276,7 +276,7 @@ namespace Dalamud.Game.Gui.FlyText retVal = this.createFlyTextHook.Original( addonFlyText, - (int)tmpKind, + tmpKind, tmpVal1, tmpVal2, pText2, diff --git a/Dalamud/Game/Gui/FlyText/FlyTextKind.cs b/Dalamud/Game/Gui/FlyText/FlyTextKind.cs index fa08c233d..2b059f168 100644 --- a/Dalamud/Game/Gui/FlyText/FlyTextKind.cs +++ b/Dalamud/Game/Gui/FlyText/FlyTextKind.cs @@ -4,7 +4,7 @@ namespace Dalamud.Game.Gui.FlyText /// Enum of FlyTextKind values. Members suffixed with /// a number seem to be a duplicate, or perform duplicate behavior. /// - public enum FlyTextKind + public enum FlyTextKind : int { /// /// Val1 in serif font, Text2 in sans-serif as subtitle. From 2153164d3eeb516f3b9b307ec9cb75a8df7785ea Mon Sep 17 00:00:00 2001 From: Raymond Date: Tue, 10 Aug 2021 20:50:58 -0400 Subject: [PATCH 05/15] Fixup editorconfig --- .editorconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.editorconfig b/.editorconfig index 2dbbff2dc..72d2313af 100644 --- a/.editorconfig +++ b/.editorconfig @@ -64,6 +64,21 @@ dotnet_style_predefined_type_for_member_access = true:suggestion dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion dotnet_style_parentheses_in_other_operators=always_for_clarity:silent dotnet_style_object_initializer = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_empty_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_before_open_square_brackets = false +csharp_space_before_comma = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_comma = true +csharp_space_after_cast = false +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = none +csharp_space_between_square_brackets = false # ReSharper properties resharper_align_linq_query = true From 220f47441a3a338ef7db608c53b01e39ec6e3592 Mon Sep 17 00:00:00 2001 From: Raymond Date: Tue, 10 Aug 2021 20:51:57 -0400 Subject: [PATCH 06/15] Inline startInfo.WorkingDirectory --- Dalamud.Injector/EntryPoint.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dalamud.Injector/EntryPoint.cs b/Dalamud.Injector/EntryPoint.cs index 5501d073c..0a98d7dcd 100644 --- a/Dalamud.Injector/EntryPoint.cs +++ b/Dalamud.Injector/EntryPoint.cs @@ -61,8 +61,6 @@ namespace Dalamud.Injector var process = GetProcess(args.ElementAtOrDefault(1)); var startInfo = GetStartInfo(args.ElementAtOrDefault(2), process); - startInfo.WorkingDirectory = Directory.GetCurrentDirectory(); - // This seems to help with the STATUS_INTERNAL_ERROR condition Thread.Sleep(1000); @@ -245,7 +243,7 @@ namespace Dalamud.Injector startInfo = new DalamudStartInfo { - WorkingDirectory = null, + WorkingDirectory = Directory.GetCurrentDirectory(), ConfigurationPath = Path.Combine(xivlauncherDir, "dalamudConfig.json"), PluginDirectory = Path.Combine(xivlauncherDir, "installedPlugins"), DefaultPluginDirectory = Path.Combine(xivlauncherDir, "devPlugins"), From ca08a8ab28f2ca0fe8254a0c9e5f5116d17ec737 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:52:46 -0400 Subject: [PATCH 07/15] feat: add ReadStringNullTerminated, remove confusion --- Dalamud/Memory/MemoryHelper.cs | 66 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Dalamud/Memory/MemoryHelper.cs b/Dalamud/Memory/MemoryHelper.cs index cf483b65b..08c624bfc 100644 --- a/Dalamud/Memory/MemoryHelper.cs +++ b/Dalamud/Memory/MemoryHelper.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -20,7 +19,6 @@ namespace Dalamud.Memory public static unsafe class MemoryHelper { private static SeStringManager seStringManager; - private static IntPtr handle; #region Read @@ -174,8 +172,23 @@ namespace Dalamud.Memory /// /// The memory address to read from. /// The read in string. - public static string ReadString(IntPtr memoryAddress) - => ReadString(memoryAddress, 256); + public static string ReadStringNullTerminated(IntPtr memoryAddress) + => ReadStringNullTerminated(memoryAddress, Encoding.UTF8); + + /// + /// Read a string with the given encoding from a specified memory address. + /// + /// + /// Attention! If this is an SeString, use the to decode or the applicable helper method. + /// + /// The memory address to read from. + /// The encoding to use to decode the string. + /// The read in string. + public static string ReadStringNullTerminated(IntPtr memoryAddress, Encoding encoding) + { + var buffer = ReadRawNullTerminated(memoryAddress); + return encoding.GetString(buffer); + } /// /// Read a UTF-8 encoded string from a specified memory address. @@ -189,18 +202,6 @@ namespace Dalamud.Memory public static string ReadString(IntPtr memoryAddress, int maxLength) => ReadString(memoryAddress, Encoding.UTF8, maxLength); - /// - /// Read a string with the given encoding from a specified memory address. - /// - /// - /// Attention! If this is an SeString, use the to decode or the applicable helper method. - /// - /// The memory address to read from. - /// The encoding to use to decode the string. - /// The read in string. - public static string ReadString(IntPtr memoryAddress, Encoding encoding) - => ReadString(memoryAddress, encoding, 256); - /// /// Read a string with the given encoding from a specified memory address. /// @@ -288,8 +289,20 @@ namespace Dalamud.Memory /// /// The memory address to read from. /// The read in string. - public static void ReadString(IntPtr memoryAddress, out string value) - => value = ReadString(memoryAddress); + public static void ReadStringNullTerminated(IntPtr memoryAddress, out string value) + => value = ReadStringNullTerminated(memoryAddress); + + /// + /// Read a string with the given encoding from a specified memory address. + /// + /// + /// Attention! If this is an SeString, use the to decode or the applicable helper method. + /// + /// The memory address to read from. + /// The encoding to use to decode the string. + /// The read in string. + public static void ReadStringNullTerminated(IntPtr memoryAddress, Encoding encoding, out string value) + => value = ReadStringNullTerminated(memoryAddress, encoding); /// /// Read a UTF-8 encoded string from a specified memory address. @@ -303,18 +316,6 @@ namespace Dalamud.Memory public static void ReadString(IntPtr memoryAddress, out string value, int maxLength) => value = ReadString(memoryAddress, maxLength); - /// - /// Read a string with the given encoding from a specified memory address. - /// - /// - /// Attention! If this is an SeString, use the to decode or the applicable helper method. - /// - /// The memory address to read from. - /// The encoding to use to decode the string. - /// The read in string. - public static void ReadString(IntPtr memoryAddress, Encoding encoding, out string value) - => value = ReadString(memoryAddress, encoding); - /// /// Read a string with the given encoding from a specified memory address. /// @@ -584,7 +585,7 @@ namespace Dalamud.Memory public static void ReadProcessMemory(IntPtr memoryAddress, ref byte[] value) { var length = value.Length; - var result = NativeFunctions.ReadProcessMemory(handle, memoryAddress, value, length, out _); + var result = NativeFunctions.ReadProcessMemory((IntPtr)0xFFFFFFFF, memoryAddress, value, length, out _); if (!result) throw new MemoryReadException($"Unable to read memory at 0x{memoryAddress.ToInt64():X} of length {length} (result={result})"); @@ -603,7 +604,7 @@ namespace Dalamud.Memory public static void WriteProcessMemory(IntPtr memoryAddress, byte[] data) { var length = data.Length; - var result = NativeFunctions.WriteProcessMemory(handle, memoryAddress, data, length, out _); + var result = NativeFunctions.WriteProcessMemory((IntPtr)0xFFFFFFFF, memoryAddress, data, length, out _); if (!result) throw new MemoryWriteException($"Unable to write memory at 0x{memoryAddress.ToInt64():X} of length {length} (result={result})"); @@ -662,7 +663,6 @@ namespace Dalamud.Memory internal static void Initialize(Dalamud dalamud) { seStringManager = dalamud.SeStringManager; - handle = Process.GetCurrentProcess().Handle; } } } From 0b0371dc32c29ea4e364265896221705e72f8c69 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:57:34 -0400 Subject: [PATCH 08/15] Remove custom UiObject features, use client structs instead Also name things appropriately. --- Dalamud/Game/Gui/GameGui.cs | 107 +++++++++------------ Dalamud/Game/Gui/GameGuiAddressResolver.cs | 24 ----- 2 files changed, 43 insertions(+), 88 deletions(-) diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index fed5d4207..11366e969 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -2,7 +2,6 @@ using System; using System.Numerics; using System.Runtime.InteropServices; -using Dalamud.Game.Gui.Addons; using Dalamud.Game.Gui.FlyText; using Dalamud.Game.Gui.PartyFinder; using Dalamud.Game.Gui.Toast; @@ -24,10 +23,7 @@ namespace Dalamud.Game.Gui private readonly GameGuiAddressResolver address; private readonly GetMatrixSingletonDelegate getMatrixSingleton; - private readonly GetUIObjectDelegate getUIObject; private readonly ScreenToWorldNativeDelegate screenToWorldNative; - private readonly GetUIObjectByNameDelegate getUIObjectByName; - private readonly GetUiModuleDelegate getUiModule; private readonly GetAgentModuleDelegate getAgentModule; private readonly Hook setGlobalBgmHook; @@ -62,7 +58,6 @@ namespace Dalamud.Game.Gui Log.Verbose($"HandleItemHover address 0x{this.address.HandleItemHover.ToInt64():X}"); Log.Verbose($"HandleItemOut address 0x{this.address.HandleItemOut.ToInt64():X}"); Log.Verbose($"HandleImm address 0x{this.address.HandleImm.ToInt64():X}"); - Log.Verbose($"GetUIObject address 0x{this.address.GetUIObject.ToInt64():X}"); Log.Verbose($"GetAgentModule address 0x{this.address.GetAgentModule.ToInt64():X}"); this.Chat = new ChatGui(this.address.ChatManager, scanner, dalamud); @@ -80,44 +75,23 @@ namespace Dalamud.Game.Gui this.handleImmHook = new Hook(this.address.HandleImm, this.HandleImmDetour); - this.getUIObject = Marshal.GetDelegateForFunctionPointer(this.address.GetUIObject); - this.getMatrixSingleton = Marshal.GetDelegateForFunctionPointer(this.address.GetMatrixSingleton); this.screenToWorldNative = Marshal.GetDelegateForFunctionPointer(this.address.ScreenToWorld); this.toggleUiHideHook = new Hook(this.address.ToggleUiHide, this.ToggleUiHideDetour); - this.GetBaseUIObject = Marshal.GetDelegateForFunctionPointer(this.address.GetBaseUIObject); - this.getUIObjectByName = Marshal.GetDelegateForFunctionPointer(this.address.GetUIObjectByName); - - this.getUiModule = Marshal.GetDelegateForFunctionPointer(this.address.GetUIModule); this.getAgentModule = Marshal.GetDelegateForFunctionPointer(this.address.GetAgentModule); } // Marshaled delegates - /// - /// The delegate type of the native method that gets the Client::UI::UIModule address. - /// - /// The Client::UI::UIModule address. - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate IntPtr GetBaseUIObjectDelegate(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate IntPtr GetMatrixSingletonDelegate(); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr GetUIObjectDelegate(); - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private unsafe delegate bool ScreenToWorldNativeDelegate(float* camPos, float* clipPos, float rayDistance, float* worldPos, int* unknown); - [UnmanagedFunctionPointer(CallingConvention.ThisCall, CharSet = CharSet.Ansi)] - private delegate IntPtr GetUIObjectByNameDelegate(IntPtr thisPtr, string uiName, int index); - - private delegate IntPtr GetUiModuleDelegate(IntPtr basePtr); - private delegate IntPtr GetAgentModuleDelegate(IntPtr uiModule); // Hooked delegates @@ -154,12 +128,6 @@ namespace Dalamud.Game.Gui /// public event EventHandler OnUiHideToggled; - /// - /// Gets a callable delegate for the GetBaseUIObject game method. - /// - /// The Client::UI::UIModule address. - public GetBaseUIObjectDelegate GetBaseUIObject { get; } - /// /// Gets the instance. /// @@ -213,19 +181,19 @@ namespace Dalamud.Game.Gui /// True if there were no errors and it could open the map. public bool OpenMapWithMapLink(MapLinkPayload mapLink) { - var uiObjectPtr = this.getUIObject(); + var uiModule = this.GetUIModule(); - if (uiObjectPtr.Equals(IntPtr.Zero)) + if (uiModule == IntPtr.Zero) { Log.Error("OpenMapWithMapLink: Null pointer returned from getUIObject()"); return false; } - this.getUIMapObject = this.address.GetVirtualFunction(uiObjectPtr, 0, 8); + this.getUIMapObject = this.address.GetVirtualFunction(uiModule, 0, 8); - var uiMapObjectPtr = this.getUIMapObject(uiObjectPtr); + var uiMapObjectPtr = this.getUIMapObject(uiModule); - if (uiMapObjectPtr.Equals(IntPtr.Zero)) + if (uiMapObjectPtr == IntPtr.Zero) { Log.Error("OpenMapWithMapLink: Null pointer returned from GetUIMapObject()"); return false; @@ -408,37 +376,40 @@ namespace Dalamud.Game.Gui /// Gets a pointer to the game's UI module. /// /// IntPtr pointing to UI module. - public IntPtr GetUIModule() => this.getUiModule(this.dalamud.Framework.Address.BaseAddress); - - /// - /// Gets the pointer to the UI Object with the given name and index. - /// - /// Name of UI to find. - /// Index of UI to find (1-indexed). - /// IntPtr.Zero if unable to find UI, otherwise IntPtr pointing to the start of the UI Object. - public IntPtr GetUiObjectByName(string name, int index) + public unsafe IntPtr GetUIModule() { - var baseUi = this.GetBaseUIObject(); - if (baseUi == IntPtr.Zero) return IntPtr.Zero; - var baseUiProperties = Marshal.ReadIntPtr(baseUi, 0x20); - if (baseUiProperties == IntPtr.Zero) return IntPtr.Zero; - return this.getUIObjectByName(baseUiProperties, name, index); + var framework = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance(); + if (framework == null) + return IntPtr.Zero; + + var uiModule = framework->GetUiModule(); + if (uiModule == null) + return IntPtr.Zero; + + return (IntPtr)uiModule; } /// - /// Gets an Addon by it's internal name. + /// Gets the pointer to the Addon with the given name and index. /// - /// The addon name. - /// The index of the addon, starting at 1. - /// The native memory representation of the addon, if it exists. - public Addon GetAddonByName(string name, int index) + /// Name of addon to find. + /// Index of addon to find (1-indexed). + /// IntPtr.Zero if unable to find UI, otherwise IntPtr pointing to the start of the addon. + public unsafe IntPtr GetAddonByName(string name, int index) { - var address = this.GetUiObjectByName(name, index); + var atkStage = FFXIVClientStructs.FFXIV.Component.GUI.AtkStage.GetSingleton(); + if (atkStage == null) + return IntPtr.Zero; - if (address == IntPtr.Zero) - return null; + var unitMgr = atkStage->RaptureAtkUnitManager; + if (unitMgr == null) + return IntPtr.Zero; - return new Addon(address); + var addon = unitMgr->GetAddonByName(name, index); + if (addon == null) + return IntPtr.Zero; + + return (IntPtr)addon; } /// @@ -448,7 +419,7 @@ namespace Dalamud.Game.Gui /// A pointer to the agent interface. public IntPtr FindAgentInterface(string addonName) { - var addon = this.dalamud.Framework.Gui.GetUiObjectByName(addonName, 1); + var addon = this.GetAddonByName(addonName, 1); return this.FindAgentInterface(addon); } @@ -457,7 +428,14 @@ namespace Dalamud.Game.Gui /// /// The addon address. /// A pointer to the agent interface. - public IntPtr FindAgentInterface(IntPtr addon) + public unsafe IntPtr FindAgentInterface(void* addon) => this.FindAgentInterface((IntPtr)addon); + + /// + /// Find the agent associated with an addon, if possible. + /// + /// The addon address. + /// A pointer to the agent interface. + public unsafe IntPtr FindAgentInterface(IntPtr addon) { if (addon == IntPtr.Zero) return IntPtr.Zero; @@ -474,9 +452,10 @@ namespace Dalamud.Game.Gui return IntPtr.Zero; } - var id = Marshal.ReadInt16(addon, 0x1CE); + var unitBase = (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)addon; + var id = unitBase->ParentID; if (id == 0) - id = Marshal.ReadInt16(addon, 0x1CC); + id = unitBase->ID; if (id == 0) return IntPtr.Zero; diff --git a/Dalamud/Game/Gui/GameGuiAddressResolver.cs b/Dalamud/Game/Gui/GameGuiAddressResolver.cs index b68ea9496..52e98df6c 100644 --- a/Dalamud/Game/Gui/GameGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/GameGuiAddressResolver.cs @@ -57,11 +57,6 @@ namespace Dalamud.Game.Gui /// public IntPtr HandleImm { get; private set; } - /// - /// Gets the address of the native GetUIObject method. - /// - public IntPtr GetUIObject { get; private set; } - /// /// Gets the address of the native GetMatrixSingleton method. /// @@ -77,21 +72,6 @@ namespace Dalamud.Game.Gui /// public IntPtr ToggleUiHide { get; private set; } - /// - /// Gets the address of the native Client::UI::UIModule getter method. - /// - public IntPtr GetBaseUIObject { get; private set; } - - /// - /// Gets the address of the native GetUIObjectByName method. - /// - public IntPtr GetUIObjectByName { get; private set; } - - /// - /// Gets the address of the native GetUIModule method. - /// - public IntPtr GetUIModule { get; private set; } - /// /// Gets the address of the native GetAgentModule method. /// @@ -106,13 +86,9 @@ namespace Dalamud.Game.Gui this.HandleActionHover = sig.ScanText("E8 ?? ?? ?? ?? E9 ?? ?? ?? ?? 83 F8 0F"); this.HandleActionOut = sig.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B DA 48 8B F9 4D 85 C0 74 1F"); this.HandleImm = sig.ScanText("E8 ?? ?? ?? ?? 84 C0 75 10 48 83 FF 09"); - this.GetUIObject = sig.ScanText("E8 ?? ?? ?? ?? 48 8B C8 48 8B 10 FF 52 40 80 88 ?? ?? ?? ?? 01 E9"); this.GetMatrixSingleton = sig.ScanText("E8 ?? ?? ?? ?? 48 8D 4C 24 ?? 48 89 4c 24 ?? 4C 8D 4D ?? 4C 8D 44 24 ??"); this.ScreenToWorld = sig.ScanText("48 83 EC 48 48 8B 05 ?? ?? ?? ?? 4D 8B D1"); this.ToggleUiHide = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 0F B6 B9 ?? ?? ?? ?? B8 ?? ?? ?? ??"); - this.GetBaseUIObject = sig.ScanText("E8 ?? ?? ?? ?? 41 B8 01 00 00 00 48 8D 15 ?? ?? ?? ?? 48 8B 48 20 E8 ?? ?? ?? ?? 48 8B CF"); - this.GetUIObjectByName = sig.ScanText("E8 ?? ?? ?? ?? 48 8B CF 48 89 87 ?? ?? 00 00 E8 ?? ?? ?? ?? 41 B8 01 00 00 00"); - this.GetUIModule = sig.ScanText("E8 ?? ?? ?? ?? 48 8B C8 48 85 C0 75 2D"); var uiModuleVtableSig = sig.GetStaticAddressFromSig("48 8D 05 ?? ?? ?? ?? 4C 89 61 28"); this.GetAgentModule = Marshal.ReadIntPtr(uiModuleVtableSig, 34 * IntPtr.Size); From a5429fab12dc4154972c10d4746416150a1c66af Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:58:03 -0400 Subject: [PATCH 09/15] Add getter/init props to DalamudStartInfo, change to record type --- Dalamud/DalamudStartInfo.cs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Dalamud/DalamudStartInfo.cs b/Dalamud/DalamudStartInfo.cs index 7678cfb40..b04e5d3cb 100644 --- a/Dalamud/DalamudStartInfo.cs +++ b/Dalamud/DalamudStartInfo.cs @@ -9,47 +9,47 @@ namespace Dalamud /// Struct containing information needed to initialize Dalamud. /// [Serializable] - public struct DalamudStartInfo + public record DalamudStartInfo { /// - /// The working directory of the XIVLauncher installations. + /// Gets the working directory of the XIVLauncher installations. /// - public string WorkingDirectory; + public string WorkingDirectory { get; init; } /// - /// The path to the configuration file. + /// Gets the path to the configuration file. /// - public string ConfigurationPath; + public string ConfigurationPath { get; init; } /// - /// The path to the directory for installed plugins. + /// Gets the path to the directory for installed plugins. /// - public string PluginDirectory; + public string PluginDirectory { get; init; } /// - /// The path to the directory for developer plugins. + /// Gets the path to the directory for developer plugins. /// - public string DefaultPluginDirectory; + public string DefaultPluginDirectory { get; init; } /// - /// The path to core Dalamud assets. + /// Gets the path to core Dalamud assets. /// - public string AssetDirectory; + public string AssetDirectory { get; init; } /// - /// The language of the game client. + /// Gets the language of the game client. /// - public ClientLanguage Language; + public ClientLanguage Language { get; init; } /// - /// The current game version code. + /// Gets the current game version code. /// [JsonConverter(typeof(GameVersionConverter))] - public GameVersion GameVersion; + public GameVersion GameVersion { get; init; } /// - /// Whether or not market board information should be uploaded by default. + /// Gets a value indicating whether or not market board information should be uploaded by default. /// - public bool OptOutMbCollection; + public bool OptOutMbCollection { get; init; } } } From e02505985f182214e01ea2ff133fbabfd17b57b8 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:58:18 -0400 Subject: [PATCH 10/15] Fixup text sanitizer --- Dalamud/Game/Text/Sanitizer/Sanitizer.cs | 31 ++++++------------------ 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/Dalamud/Game/Text/Sanitizer/Sanitizer.cs b/Dalamud/Game/Text/Sanitizer/Sanitizer.cs index ea8cd0000..0cf1f1ea6 100644 --- a/Dalamud/Game/Text/Sanitizer/Sanitizer.cs +++ b/Dalamud/Game/Text/Sanitizer/Sanitizer.cs @@ -84,31 +84,16 @@ namespace Dalamud.Game.Text.Sanitizer }; } - private static IEnumerable SanitizeByLanguage( - IEnumerable unsanitizedStrings, ClientLanguage clientLanguage) + private static IEnumerable SanitizeByLanguage(IEnumerable unsanitizedStrings, ClientLanguage clientLanguage) { - var sanitizedStrings = new List(); - switch (clientLanguage) + return clientLanguage switch { - case ClientLanguage.Japanese: - case ClientLanguage.English: - sanitizedStrings.AddRange(unsanitizedStrings.Select(FilterUnprintableCharacters)); - return sanitizedStrings; - case ClientLanguage.German: - sanitizedStrings.AddRange( - unsanitizedStrings.Select( - unsanitizedString => - FilterByDict(FilterUnprintableCharacters(unsanitizedString), DESanitizationDict))); - return sanitizedStrings; - case ClientLanguage.French: - sanitizedStrings.AddRange( - unsanitizedStrings.Select( - unsanitizedString => - FilterByDict(FilterUnprintableCharacters(unsanitizedString), FRSanitizationDict))); - return sanitizedStrings; - default: - throw new ArgumentOutOfRangeException(nameof(clientLanguage), clientLanguage, null); - } + ClientLanguage.Japanese => unsanitizedStrings.Select(FilterUnprintableCharacters), + ClientLanguage.English => unsanitizedStrings.Select(FilterUnprintableCharacters), + ClientLanguage.German => unsanitizedStrings.Select(original => FilterByDict(FilterUnprintableCharacters(original), DESanitizationDict)), + ClientLanguage.French => unsanitizedStrings.Select(original => FilterByDict(FilterUnprintableCharacters(original), FRSanitizationDict)), + _ => throw new ArgumentOutOfRangeException(nameof(clientLanguage), clientLanguage, null), + }; } private static string FilterUnprintableCharacters(string str) From 7fa5e7adbef64922b4890c8ce6ab07a9ff44d47a Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:58:50 -0400 Subject: [PATCH 11/15] Remove Dalamud Addon class, devs should use AtkUnitBase instead --- Dalamud/Game/Gui/Addons/Addon.cs | 63 ------------------- .../Interface/Internal/Windows/DataWindow.cs | 36 +++++------ 2 files changed, 18 insertions(+), 81 deletions(-) delete mode 100644 Dalamud/Game/Gui/Addons/Addon.cs diff --git a/Dalamud/Game/Gui/Addons/Addon.cs b/Dalamud/Game/Gui/Addons/Addon.cs deleted file mode 100644 index 207443b8b..000000000 --- a/Dalamud/Game/Gui/Addons/Addon.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -using Dalamud.Memory; - -namespace Dalamud.Game.Gui.Addons -{ - /// - /// This class represents an in-game UI "Addon". - /// - public unsafe class Addon - { - /// - /// Initializes a new instance of the class. - /// - /// The address of the addon. - public Addon(IntPtr address) - { - this.Address = address; - } - - /// - /// Gets the address of the addon. - /// - public IntPtr Address { get; } - - /// - /// Gets the name of the addon. - /// - public string Name => MemoryHelper.ReadString((IntPtr)this.Struct->Name, 0x20); - - /// - /// Gets the X position of the addon on screen. - /// - public short X => this.Struct->X; - - /// - /// Gets the Y position of the addon on screen. - /// - public short Y => this.Struct->Y; - - /// - /// Gets the scale of the addon. - /// - public float Scale => this.Struct->Scale; - - /// - /// Gets the width of the addon. This may include non-visible parts. - /// - public unsafe float Width => this.Struct->RootNode->Width * this.Scale; - - /// - /// Gets the height of the addon. This may include non-visible parts. - /// - public unsafe float Height => this.Struct->RootNode->Height * this.Scale; - - /// - /// Gets a value indicating whether the addon is visible. - /// - public bool Visible => this.Struct->IsVisible; - - private FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase* Struct => (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)this.Address; - } -} diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs index d43500dc0..4105e9894 100644 --- a/Dalamud/Interface/Internal/Windows/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs @@ -11,11 +11,11 @@ using Dalamud.Game.ClientState.JobGauge.Enums; using Dalamud.Game.ClientState.JobGauge.Types; using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Game.Gui.Addons; using Dalamud.Game.Gui.FlyText; using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text; using Dalamud.Interface.Windowing; +using Dalamud.Memory; using Dalamud.Plugin; using Dalamud.Utility; using ImGuiNET; @@ -45,7 +45,6 @@ namespace Dalamud.Interface.Internal.Windows private string inputAddonName = string.Empty; private int inputAddonIndex; - private Addon resultAddon; private IntPtr findAgentInterfacePtr; @@ -130,7 +129,6 @@ namespace Dalamud.Interface.Internal.Windows /// public override void OnClose() { - this.resultAddon = null; } /// @@ -843,22 +841,31 @@ namespace Dalamud.Interface.Internal.Windows ImGui.Text($"{command.Key}\n -> {command.Value.HelpMessage}\n -> In help: {command.Value.ShowInHelp}\n\n"); } - private void DrawAddon() + private unsafe void DrawAddon() { + var gameGui = this.dalamud.Framework.Gui; + ImGui.InputText("Addon name", ref this.inputAddonName, 256); ImGui.InputInt("Addon Index", ref this.inputAddonIndex); - if (ImGui.Button("Get Addon")) + if (this.inputAddonName.IsNullOrEmpty()) + return; + + var address = gameGui.GetAddonByName(this.inputAddonName, this.inputAddonIndex); + + if (address == IntPtr.Zero) { - this.resultAddon = this.dalamud.Framework.Gui.GetAddonByName(this.inputAddonName, this.inputAddonIndex); + ImGui.Text("Null"); + return; } - if (ImGui.Button("Find Agent")) - this.findAgentInterfacePtr = this.dalamud.Framework.Gui.FindAgentInterface(this.inputAddonName); + var addon = (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)address; + var name = MemoryHelper.ReadStringNullTerminated((IntPtr)addon->Name); + ImGui.TextUnformatted($"{name} - 0x{address.ToInt64():x}\n v:{addon->IsVisible} x:{addon->X} y:{addon->Y} s:{addon->Scale}, w:{addon->RootNode->Width}, h:{addon->RootNode->Height}"); - if (this.resultAddon != null) + if (ImGui.Button("Find Agent")) { - ImGui.TextUnformatted($"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}"); + this.findAgentInterfacePtr = gameGui.FindAgentInterface(address); } if (this.findAgentInterfacePtr != IntPtr.Zero) @@ -869,13 +876,6 @@ namespace Dalamud.Interface.Internal.Windows if (ImGui.Button("C")) ImGui.SetClipboardText(this.findAgentInterfacePtr.ToInt64().ToString("x")); } - - if (ImGui.Button("Get Base UI object")) - { - var addr = this.dalamud.Framework.Gui.GetBaseUIObject().ToInt64().ToString("x"); - Log.Information("{0}", addr); - ImGui.SetClipboardText(addr); - } } private void DrawAddonInspector() @@ -977,7 +977,7 @@ namespace Dalamud.Interface.Internal.Windows if (ImGui.BeginCombo("Kind", this.flyKind.ToString())) { var names = Enum.GetNames(typeof(FlyTextKind)); - for (int i = 0; i < names.Length; i++) + for (var i = 0; i < names.Length; i++) { if (ImGui.Selectable($"{names[i]} ({i})")) this.flyKind = (FlyTextKind)i; From b3f41c904976a6b357361a68817b272369de5750 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:59:07 -0400 Subject: [PATCH 12/15] SigScanner ctor overload for main module of current process --- Dalamud/Game/SigScanner.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dalamud/Game/SigScanner.cs b/Dalamud/Game/SigScanner.cs index 56d0003e3..285f845fe 100644 --- a/Dalamud/Game/SigScanner.cs +++ b/Dalamud/Game/SigScanner.cs @@ -17,6 +17,15 @@ namespace Dalamud.Game private IntPtr moduleCopyPtr; private long moduleCopyOffset; + /// + /// Initializes a new instance of the class using the main module of the current process. + /// + /// Whether or not to copy the module upon initialization for search operations to use, as to not get disturbed by possible hooks. + public SigScanner(bool doCopy = false) + : this(Process.GetCurrentProcess().MainModule!, doCopy) + { + } + /// /// Initializes a new instance of the class. /// From 072cee417b3e08023a2b93eb20be1709481865fc Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 08:59:25 -0400 Subject: [PATCH 13/15] Fixup CommandManager language/regex setter --- Dalamud/Game/Command/CommandManager.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs index 48364715f..e1f2298f5 100644 --- a/Dalamud/Game/Command/CommandManager.cs +++ b/Dalamud/Game/Command/CommandManager.cs @@ -31,21 +31,14 @@ namespace Dalamud.Game.Command { this.dalamud = dalamud; - switch (language) + this.currentLangCommandRegex = language switch { - case ClientLanguage.Japanese: - this.currentLangCommandRegex = this.commandRegexJp; - break; - case ClientLanguage.English: - this.currentLangCommandRegex = this.commandRegexEn; - break; - case ClientLanguage.German: - this.currentLangCommandRegex = this.commandRegexDe; - break; - case ClientLanguage.French: - this.currentLangCommandRegex = this.commandRegexFr; - break; - } + ClientLanguage.Japanese => this.commandRegexJp, + ClientLanguage.English => this.commandRegexEn, + ClientLanguage.German => this.commandRegexDe, + ClientLanguage.French => this.commandRegexFr, + _ => this.currentLangCommandRegex, + }; dalamud.Framework.Gui.Chat.CheckMessageHandled += this.OnCheckMessageHandled; } From 779179a0cfe0e04d1b34a23c06a5d352b08d3f6f Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 09:00:16 -0400 Subject: [PATCH 14/15] Formatting, misc --- Dalamud/Dalamud.cs | 3 +-- Dalamud/Game/Gui/FlyText/FlyTextGui.cs | 2 +- Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs | 1 - .../Internal/Scratchpad/ScratchExecutionManager.cs | 7 +++---- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index b4adb991c..07ab37343 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -35,9 +35,7 @@ namespace Dalamud #region Internals private readonly ManualResetEvent unloadSignal; - private readonly ManualResetEvent finishUnloadSignal; - private bool hasDisposedPlugins = false; #endregion @@ -237,6 +235,7 @@ namespace Dalamud // Initialize FFXIVClientStructs function resolver FFXIVClientStructs.Resolver.Initialize(); + Log.Information("[T1] FFXIVClientStructs initialized!"); } catch (Exception ex) diff --git a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs index 44070d911..64b3a2ea4 100644 --- a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs +++ b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs @@ -133,7 +133,7 @@ namespace Dalamud.Game.Gui.FlyText // Get the UI module and flytext addon pointers var ui = (UIModule*)this.Dalamud.Framework.Gui.GetUIModule(); - var flytext = this.Dalamud.Framework.Gui.GetUiObjectByName("_FlyText", 1); + var flytext = this.Dalamud.Framework.Gui.GetAddonByName("_FlyText", 1); if (ui == null || flytext == IntPtr.Zero) return; diff --git a/Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs b/Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs index 04bcd1029..69588f085 100644 --- a/Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs +++ b/Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.IO; diff --git a/Dalamud/Interface/Internal/Scratchpad/ScratchExecutionManager.cs b/Dalamud/Interface/Internal/Scratchpad/ScratchExecutionManager.cs index ba3a501eb..676a34381 100644 --- a/Dalamud/Interface/Internal/Scratchpad/ScratchExecutionManager.cs +++ b/Dalamud/Interface/Internal/Scratchpad/ScratchExecutionManager.cs @@ -4,7 +4,6 @@ using System.Linq; using Dalamud.Plugin; using ImGuiNET; -using Lumina.Excel.GeneratedSheets; using Microsoft.CodeAnalysis.CSharp.Scripting; using Microsoft.CodeAnalysis.Scripting; using Serilog; @@ -65,10 +64,10 @@ namespace Dalamud.Interface.Internal.Scratchpad var options = ScriptOptions.Default .AddReferences(typeof(ImGui).Assembly) .AddReferences(typeof(Dalamud).Assembly) - .AddReferences(typeof(FFXIVClientStructs.Attributes.Addon).Assembly) // FFXIVClientStructs + .AddReferences(typeof(FFXIVClientStructs.Resolver).Assembly) // FFXIVClientStructs .AddReferences(typeof(Lumina.GameData).Assembly) // Lumina - .AddReferences(typeof(TerritoryType).Assembly) // Lumina.Excel - // .WithReferences(MetadataReference.CreateFromFile(typeof(ScratchExecutionManager).Assembly.Location)) + .AddReferences(typeof(Lumina.Excel.GeneratedSheets.TerritoryType).Assembly) // Lumina.Excel + // .WithReferences(MetadataReference.CreateFromFile(typeof(ScratchExecutionManager).Assembly.Location)) .AddImports("System") .AddImports("System.IO") .AddImports("System.Reflection") From 965d1c768124b61682ec224541b5703d63a06e42 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 16 Aug 2021 09:01:12 -0400 Subject: [PATCH 15/15] Comment unused code --- Dalamud/Game/Network/GameNetwork.cs | 40 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/Dalamud/Game/Network/GameNetwork.cs b/Dalamud/Game/Network/GameNetwork.cs index 0b982b2b0..90d585654 100644 --- a/Dalamud/Game/Network/GameNetwork.cs +++ b/Dalamud/Game/Network/GameNetwork.cs @@ -160,27 +160,25 @@ namespace Dalamud.Game.Network return this.processZonePacketUpHook.Original(a1, dataPtr, a3, a4); } -#if DEBUG - private void InjectZoneProtoPacket(byte[] data) - { - this.zoneInjectQueue.Enqueue(data); - } + // private void InjectZoneProtoPacket(byte[] data) + // { + // this.zoneInjectQueue.Enqueue(data); + // } - private void InjectActorControl(short cat, int param1) - { - var packetData = new byte[] - { - 0x14, 0x00, 0x8D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x17, 0x7C, 0xC5, 0x5D, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x48, 0xB2, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x43, 0x7F, 0x00, 0x00, - }; - - BitConverter.GetBytes((short)cat).CopyTo(packetData, 0x10); - - BitConverter.GetBytes((uint)param1).CopyTo(packetData, 0x14); - - this.InjectZoneProtoPacket(packetData); - } -#endif + // private void InjectActorControl(short cat, int param1) + // { + // var packetData = new byte[] + // { + // 0x14, 0x00, 0x8D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x17, 0x7C, 0xC5, 0x5D, 0x00, 0x00, 0x00, 0x00, + // 0x05, 0x00, 0x48, 0xB2, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // 0x00, 0x00, 0x00, 0x00, 0x43, 0x7F, 0x00, 0x00, + // }; + // + // BitConverter.GetBytes((short)cat).CopyTo(packetData, 0x10); + // + // BitConverter.GetBytes((uint)param1).CopyTo(packetData, 0x14); + // + // this.InjectZoneProtoPacket(packetData); + // } } }