From 4e724fbe45d7365b50c0a7f2a966857f55f4310c Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 15 Apr 2025 23:58:01 +0200 Subject: [PATCH] Remove old PInvoke libs --- Dalamud/Dalamud.cs | 7 ++++--- Dalamud/Dalamud.csproj | 4 ---- Dalamud/EntryPoint.cs | 2 +- Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs | 2 -- Dalamud/Interface/Internal/DalamudInterface.cs | 5 ++--- .../Interface/Internal/Windows/Data/Widgets/HookWidget.cs | 3 +-- Dalamud/Interface/Windowing/Window.cs | 3 +-- Dalamud/NativeMethods.txt | 2 ++ 8 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index b25094564..03c7463d4 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -13,9 +13,9 @@ using Dalamud.Plugin.Internal; using Dalamud.Storage; using Dalamud.Utility; using Dalamud.Utility.Timing; -using PInvoke; using Serilog; using Windows.Win32.Foundation; +using Windows.Win32.Security; #if DEBUG [assembly: InternalsVisibleTo("Dalamud.CorePlugin")] @@ -171,8 +171,9 @@ internal sealed unsafe class Dalamud : IServiceType if (!reportCrashesSetting && !pmHasDevPlugins) { // Leaking on purpose for now - var attribs = Kernel32.SECURITY_ATTRIBUTES.Create(); - Kernel32.CreateMutex(attribs, false, "DALAMUD_CRASHES_NO_MORE"); + var attribs = default(SECURITY_ATTRIBUTES); + attribs.nLength = (uint)Unsafe.SizeOf(); + Windows.Win32.PInvoke.CreateMutex(attribs, false, "DALAMUD_CRASHES_NO_MORE"); } this.unloadSignal.Set(); diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index aee6b3507..e613c71f5 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -74,10 +74,6 @@ all - - - - diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index 2592c5877..9e84a60c8 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Net; @@ -16,7 +17,6 @@ using Dalamud.Storage; using Dalamud.Support; using Dalamud.Utility; using Newtonsoft.Json; -using PInvoke; using Serilog; using Serilog.Core; using Serilog.Events; diff --git a/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs b/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs index c60c922a5..6bd8efb65 100644 --- a/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs +++ b/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; -using Dalamud.Memory; using JetBrains.Annotations; -using PInvoke; using Windows.Win32.System.Memory; using Win32Exception = System.ComponentModel.Win32Exception; diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index 7106c94e5..55e705c47 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -40,13 +40,12 @@ using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.System.Framework; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Component.GUI; -using PInvoke; using Serilog.Events; namespace Dalamud.Interface.Internal; /// -/// This plugin implements all of the Dalamud interface separately, to allow for reloading of the interface and rapid prototyping. +/// This plugin implements all the Dalamud interface separately, to allow for reloading of the interface and rapid prototyping. /// [ServiceManager.EarlyLoadedService] internal class DalamudInterface : IInternalDisposableService @@ -575,7 +574,7 @@ internal class DalamudInterface : IInternalDisposableService // Release focus of any ImGui window if we click into the game. var io = ImGui.GetIO(); - if (!io.WantCaptureMouse && (User32.GetKeyState((int)User32.VirtualKey.VK_LBUTTON) & 0x8000) != 0) + if (!io.WantCaptureMouse && (global::Windows.Win32.PInvoke.GetKeyState((int)VirtualKey.LBUTTON) & 0x8000) != 0) { unsafe { diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/HookWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/HookWidget.cs index d1b2d6612..96ff5a812 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/HookWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/HookWidget.cs @@ -2,7 +2,6 @@ using Dalamud.Bindings.ImGui; using Dalamud.Hooking; -using PInvoke; using Serilog; using Windows.Win32.Foundation; using Windows.Win32.UI.WindowsAndMessaging; @@ -81,7 +80,7 @@ internal class HookWidget : IDataWindowWidget var result = this.messageBoxMinHook!.Original(hwnd, "Cause Access Violation?", caption, MESSAGEBOX_STYLE.MB_YESNO); - if (result == (int)User32.MessageBoxResult.IDYES) + if (result == (int)MESSAGEBOX_RESULT.IDYES) { Marshal.ReadByte(IntPtr.Zero); } diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index a89f50014..ddbd1bb3c 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -17,7 +17,6 @@ using Dalamud.Logging.Internal; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.UI; -using PInvoke; namespace Dalamud.Interface.Windowing; @@ -732,7 +731,7 @@ public abstract class Window hovered = true; // We can't use ImGui native functions here, because they don't work with clickthrough - if ((User32.GetKeyState((int)VirtualKey.LBUTTON) & 0x8000) != 0) + if ((global::Windows.Win32.PInvoke.GetKeyState((int)VirtualKey.LBUTTON) & 0x8000) != 0) { held = true; pressed = true; diff --git a/Dalamud/NativeMethods.txt b/Dalamud/NativeMethods.txt index a36542cea..ee888a98b 100644 --- a/Dalamud/NativeMethods.txt +++ b/Dalamud/NativeMethods.txt @@ -8,11 +8,13 @@ SetWindowPos SetForegroundWindow SetFocus SetActiveWindow +GetKeyState HWND_TOPMOST HWND_NOTOPMOST SET_WINDOW_POS_FLAGS SetEvent +CreateMutex SymInitialize SymCleanup