/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs
197 строк
5 KB
0x5bfa
Code Quality: Remove manual interop definitions and add agent instructions for this (#18449)
31 май 2026, 18:26
Не верифицирован
31 май 2026, 18:26
6245529
Код
Авторство
О чём код?
// Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. using System.IO; using System.Runtime.InteropServices; using Windows.Win32.Foundation; using Windows.Win32.Security.Cryptography; namespace Files.App.Helpers { public static partial class Win32PInvoke { public unsafe struct OVERLAPPED { public IntPtr Internal; public IntPtr InternalHigh; public Union PointerAndOffset; public IntPtr hEvent; [StructLayout(LayoutKind.Explicit)] public struct Union { [FieldOffset(0)] public void* IntPtr; [FieldOffset(0)] public OffsetPair Offset; public struct OffsetPair { public uint Offset; public uint OffsetHigh; } } } public unsafe struct FILE_NOTIFY_INFORMATION { public uint NextEntryOffset; public uint Action; public uint FileNameLength; public fixed char FileName[1]; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct REPARSE_DATA_BUFFER { public uint ReparseTag; public short ReparseDataLength; public short Reserved; public short SubsNameOffset; public short SubsNameLength; public short PrintNameOffset; public short PrintNameLength; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAXIMUM_REPARSE_DATA_BUFFER_SIZE)] public char[] PathBuffer; } [StructLayout(LayoutKind.Sequential)] public struct WIN32_FILE_ATTRIBUTE_DATA { public FileAttributes dwFileAttributes; public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime; public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime; public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime; public uint nFileSizeHigh; public uint nFileSizeLow; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct FILE_ID_BOTH_DIR_INFO { public uint NextEntryOffset; public uint FileIndex; public long CreationTime; public long LastAccessTime; public long LastWriteTime; public long ChangeTime; public long EndOfFile; public long AllocationSize; public uint FileAttributes; public uint FileNameLength; public uint EaSize; public char ShortNameLength; [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 12)] public string ShortName; public long FileId; [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 1)] public string FileName; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 8)] public struct FILE_STREAM_INFO { public uint NextEntryOffset; public uint StreamNameLength; public long StreamSize; public long StreamAllocationSize; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] public string StreamName; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class WIN32_FIND_STREAM_DATA { public long StreamSize; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 296)] public string cStreamName; } [StructLayout(LayoutKind.Sequential)] public struct SID_AND_ATTRIBUTES { public IntPtr Sid; public uint Attributes; } [StructLayout(LayoutKind.Sequential)] public struct SYSTEMTIME { [MarshalAs(UnmanagedType.U2)] public short Year; [MarshalAs(UnmanagedType.U2)] public short Month; [MarshalAs(UnmanagedType.U2)] public short DayOfWeek; [MarshalAs(UnmanagedType.U2)] public short Day; [MarshalAs(UnmanagedType.U2)] public short Hour; [MarshalAs(UnmanagedType.U2)] public short Minute; [MarshalAs(UnmanagedType.U2)] public short Second; [MarshalAs(UnmanagedType.U2)] public short Milliseconds; public SYSTEMTIME(DateTime dt) { dt = dt.ToUniversalTime(); // SetSystemTime expects the SYSTEMTIME in UTC Year = (short)dt.Year; Month = (short)dt.Month; DayOfWeek = (short)dt.DayOfWeek; Day = (short)dt.Day; Hour = (short)dt.Hour; Minute = (short)dt.Minute; Second = (short)dt.Second; Milliseconds = (short)dt.Millisecond; } public DateTime ToDateTime() { return new(Year, Month, Day, Hour, Minute, Second, Milliseconds, DateTimeKind.Utc); } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct WIN32_FIND_DATA { public uint dwFileAttributes; public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime; public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime; public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime; public uint nFileSizeHigh; public uint nFileSizeLow; public uint dwReserved0; public uint dwReserved1; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string cFileName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] public string cAlternateFileName; } [StructLayout(LayoutKind.Sequential)] public unsafe struct SignDataHandle { public uint dwObjSize; public CMSG_SIGNER_INFO* pSignerInfo; public HCERTSTORE hCertStoreHandle; } [StructLayout(LayoutKind.Sequential)] public unsafe struct CRYPTOAPI_BLOB { public uint cbData; public void* pbData; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public unsafe struct CRYPTUI_VIEWSIGNERINFO_STRUCT { public uint dwSize; public HWND hwndParent; public uint dwFlags; public PCSTR szTitle; public CMSG_SIGNER_INFO* pSignerInfo; public void* hMsg; public PCSTR pszOID; public uint? dwReserved; public uint cStores; public HCERTSTORE* rghStores; public uint cPropPages; public void* rgPropPages; } } }