diff --git a/src/Files.App/Helpers/Win32/Win32PInvoke.Enums.cs b/src/Files.App/Helpers/Win32/Win32PInvoke.Enums.cs index 55bb016bb843..c9d3acb14e80 100644 --- a/src/Files.App/Helpers/Win32/Win32PInvoke.Enums.cs +++ b/src/Files.App/Helpers/Win32/Win32PInvoke.Enums.cs @@ -81,88 +81,6 @@ public enum StreamInfoLevels FindStreamInfoStandard = 0 } - [Flags] - public enum CryptProtectFlags - { - CRYPTPROTECT_UI_FORBIDDEN = 0x1, - CRYPTPROTECT_LOCAL_MACHINE = 0x4, - CRYPTPROTECT_CRED_SYNC = 0x8, - CRYPTPROTECT_AUDIT = 0x10, - CRYPTPROTECT_NO_RECOVERY = 0x20, - CRYPTPROTECT_VERIFY_PROTECTION = 0x40, - CRYPTPROTECT_CRED_REGENERATE = 0x80 - } - - public enum TOKEN_INFORMATION_CLASS - { - TokenUser = 1, - TokenGroups, - TokenPrivileges, - TokenOwner, - TokenPrimaryGroup, - TokenDefaultDacl, - TokenSource, - TokenType, - TokenImpersonationLevel, - TokenStatistics, - TokenRestrictedSids, - TokenSessionId, - TokenGroupsAndPrivileges, - TokenSessionReference, - TokenSandBoxInert, - TokenAuditPolicy, - TokenOrigin, - TokenElevationType, - TokenLinkedToken, - TokenElevation, - TokenHasRestrictions, - TokenAccessInformation, - TokenVirtualizationAllowed, - TokenVirtualizationEnabled, - TokenIntegrityLevel, - TokenUIAccess, - TokenMandatoryPolicy, - TokenLogonSid, - TokenIsAppContainer, - TokenCapabilities, - TokenAppContainerSid, - TokenAppContainerNumber, - TokenUserClaimAttributes, - TokenDeviceClaimAttributes, - TokenRestrictedUserClaimAttributes, - TokenRestrictedDeviceClaimAttributes, - TokenDeviceGroups, - TokenRestrictedDeviceGroups, - TokenSecurityAttributes, - TokenIsRestricted - } - - [Serializable] - public enum TOKEN_TYPE - { - TokenPrimary = 1, - TokenImpersonation = 2 - } - - [Flags] - public enum TokenAccess : uint - { - TOKEN_ASSIGN_PRIMARY = 0x0001, - TOKEN_DUPLICATE = 0x0002, - TOKEN_IMPERSONATE = 0x0004, - TOKEN_QUERY = 0x0008, - TOKEN_QUERY_SOURCE = 0x0010, - TOKEN_ADJUST_PRIVILEGES = 0x0020, - TOKEN_ADJUST_GROUPS = 0x0040, - TOKEN_ADJUST_DEFAULT = 0x0080, - TOKEN_ADJUST_SESSIONID = 0x0100, - TOKEN_ALL_ACCESS_P = 0x000F00FF, - TOKEN_ALL_ACCESS = 0x000F01FF, - TOKEN_READ = 0x00020008, - TOKEN_WRITE = 0x000200E0, - TOKEN_EXECUTE = 0x00020000 - } - public enum FINDEX_INFO_LEVELS { FindExInfoStandard = 0, diff --git a/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs b/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs index ff7db579caf0..5d700736a2fa 100644 --- a/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs +++ b/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2024 Files Community +// Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. using System.IO; @@ -56,13 +56,6 @@ public static extern int RmGetList( ref uint lpdwRebootReasons ); - [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool SetPropW( - IntPtr hWnd, - string lpString, - IntPtr hData - ); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr CreateEvent( IntPtr lpEventAttributes, @@ -102,39 +95,12 @@ public static extern bool CloseHandle( IntPtr hObject ); - [DllImport("api-ms-win-core-io-l1-1-1.dll")] - public static extern bool GetOverlappedResult( - IntPtr hFile, - OVERLAPPED lpOverlapped, - out int lpNumberOfBytesTransferred, - bool bWait - ); - - [DllImport("api-ms-win-core-io-l1-1-1.dll")] - public static extern bool CancelIo( - IntPtr hFile - ); - [DllImport("api-ms-win-core-io-l1-1-1.dll")] public static extern bool CancelIoEx( IntPtr hFile, IntPtr lpOverlapped ); - [DllImport("api-ms-win-core-synch-l1-2-0.dll")] - public static extern uint WaitForMultipleObjectsEx( - uint nCount, - IntPtr[] lpHandles, - bool bWaitAll, - uint dwMilliseconds, - bool bAlertable - ); - - [DllImport("api-ms-win-core-synch-l1-2-0.dll", SetLastError = true)] - public static extern bool ResetEvent( - IntPtr hEvent - ); - [DllImport("api-ms-win-core-synch-l1-2-0.dll", SetLastError = true)] public static extern uint WaitForSingleObjectEx( IntPtr hHandle, @@ -202,16 +168,6 @@ public static extern bool DeviceIoControl( out uint lpBytesReturned, IntPtr lpOverlapped); - [DllImport("user32.dll")] - public static extern int ToUnicode( - uint virtualKeyCode, - uint scanCode, - byte[] keyboardState, - [Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)] StringBuilder receivingBuffer, - int bufferSize, - uint flags - ); - [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int ToUnicodeEx( uint virtualKeyCode, @@ -223,11 +179,6 @@ public static extern int ToUnicodeEx( IntPtr keyboardLayout ); - [DllImport("user32.dll")] - public static extern bool TranslateMessage( - ref MSG lpMsg - ); - [DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)] public static extern IntPtr CreateFileFromApp( string lpFileName, @@ -252,14 +203,6 @@ public static extern bool SetFileAttributesFromApp( string lpFileName, FileAttributes dwFileAttributes); - [DllImport("api-ms-win-core-file-l1-2-1.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)] - public static extern uint SetFilePointer( - IntPtr hFile, - long lDistanceToMove, - IntPtr lpDistanceToMoveHigh, - uint dwMoveMethod - ); - [DllImport("api-ms-win-core-file-l1-2-1.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)] public unsafe static extern bool ReadFile( IntPtr hFile, @@ -310,14 +253,6 @@ public static extern bool GetFileInformationByHandleEx( uint dwBufferSize ); - [DllImport("api-ms-win-core-file-l2-1-1.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)] - public static extern bool GetFileInformationByHandleEx( - IntPtr hFile, - FILE_INFO_BY_HANDLE_CLASS infoClass, - IntPtr dirInfo, - uint dwBufferSize - ); - [DllImport("kernel32.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)] public static extern IntPtr FindFirstStreamW( string lpFileName, @@ -333,49 +268,6 @@ public static extern bool FindNextStreamW( [In, Out, MarshalAs(UnmanagedType.LPStruct)] WIN32_FIND_STREAM_DATA lpFindStreamData ); - [DllImport("Shcore.dll", SetLastError = true)] - public static extern int GetDpiForMonitor( - IntPtr hmonitor, - uint dpiType, - out uint dpiX, - out uint dpiY - ); - - [DllImport("api-ms-win-core-processthreads-l1-1-0.dll", SetLastError = true, ExactSpelling = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool OpenProcessToken( - [In] IntPtr ProcessHandle, TokenAccess DesiredAccess, out IntPtr TokenHandle); - - [DllImport("api-ms-win-core-processthreads-l1-1-2.dll", SetLastError = true, ExactSpelling = true)] - public static extern IntPtr GetCurrentProcess(); - - [DllImport("api-ms-win-security-base-l1-1-0.dll", SetLastError = true, ExactSpelling = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetTokenInformation( - IntPtr hObject, - TOKEN_INFORMATION_CLASS tokenInfoClass, - IntPtr pTokenInfo, - int tokenInfoLength, - out int returnLength - ); - - [DllImport("api-ms-win-security-base-l1-1-0.dll", ExactSpelling = true, SetLastError = true)] - public static extern int GetLengthSid( - IntPtr pSid - ); - - [DllImport("crypt32.dll", SetLastError = true, CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CryptUnprotectData( - in CRYPTOAPI_BLOB pDataIn, - StringBuilder szDataDescr, - in CRYPTOAPI_BLOB pOptionalEntropy, - IntPtr pvReserved, - IntPtr pPromptStruct, - CryptProtectFlags dwFlags, - out CRYPTOAPI_BLOB pDataOut - ); - [DllImport("api-ms-win-core-wow64-l1-1-1.dll", SetLastError = true)] public static extern bool IsWow64Process2( IntPtr process, @@ -410,19 +302,6 @@ public static extern IntPtr FindFirstFileExFromApp( int dwAdditionalFlags ); - [DllImport("api-ms-win-core-string-l1-1-0.dll", CharSet = CharSet.Unicode)] - public static extern int CompareStringEx( - string localeName, - int flags, - string str1, - int count1, - string str2, - int count2, - IntPtr versionInformation, - IntPtr reserved, - int param - ); - [LibraryImport("shell32.dll", EntryPoint = "#865", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static partial bool IsElevationRequired( diff --git a/src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs b/src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs index 39114386bc74..d54e6ee441e7 100644 --- a/src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs +++ b/src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs @@ -139,12 +139,6 @@ public sealed class WIN32_FIND_STREAM_DATA public string cStreamName; } - [StructLayout(LayoutKind.Sequential)] - public struct TOKEN_USER - { - public SID_AND_ATTRIBUTES User; - } - [StructLayout(LayoutKind.Sequential)] public struct SID_AND_ATTRIBUTES { @@ -153,13 +147,6 @@ public struct SID_AND_ATTRIBUTES public uint Attributes; } - [StructLayout(LayoutKind.Sequential)] - public struct CRYPTOAPI_BLOB - { - public uint cbData; - public IntPtr pbData; - } - [StructLayout(LayoutKind.Sequential)] public struct SYSTEMTIME { @@ -211,16 +198,5 @@ public struct WIN32_FIND_DATA [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] public string cAlternateFileName; } - - [StructLayout(LayoutKind.Sequential)] - public struct MSG - { - public IntPtr hwnd; - public uint message; - public IntPtr wParam; - public IntPtr lParam; - public uint time; - public System.Drawing.Point pt; - } } }