Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4fa3d80

Browse files
Code Quality: Removed unused P/Invoke methods from helper class (#17120)
1 parent b348223 commit 4fa3d80

File tree

3 files changed

+1
-228
lines changed

3 files changed

+1
-228
lines changed

‎src/Files.App/Helpers/Win32/Win32PInvoke.Enums.cs‎

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -81,88 +81,6 @@ public enum StreamInfoLevels
8181
FindStreamInfoStandard = 0
8282
}
8383

84-
[Flags]
85-
public enum CryptProtectFlags
86-
{
87-
CRYPTPROTECT_UI_FORBIDDEN = 0x1,
88-
CRYPTPROTECT_LOCAL_MACHINE = 0x4,
89-
CRYPTPROTECT_CRED_SYNC = 0x8,
90-
CRYPTPROTECT_AUDIT = 0x10,
91-
CRYPTPROTECT_NO_RECOVERY = 0x20,
92-
CRYPTPROTECT_VERIFY_PROTECTION = 0x40,
93-
CRYPTPROTECT_CRED_REGENERATE = 0x80
94-
}
95-
96-
public enum TOKEN_INFORMATION_CLASS
97-
{
98-
TokenUser = 1,
99-
TokenGroups,
100-
TokenPrivileges,
101-
TokenOwner,
102-
TokenPrimaryGroup,
103-
TokenDefaultDacl,
104-
TokenSource,
105-
TokenType,
106-
TokenImpersonationLevel,
107-
TokenStatistics,
108-
TokenRestrictedSids,
109-
TokenSessionId,
110-
TokenGroupsAndPrivileges,
111-
TokenSessionReference,
112-
TokenSandBoxInert,
113-
TokenAuditPolicy,
114-
TokenOrigin,
115-
TokenElevationType,
116-
TokenLinkedToken,
117-
TokenElevation,
118-
TokenHasRestrictions,
119-
TokenAccessInformation,
120-
TokenVirtualizationAllowed,
121-
TokenVirtualizationEnabled,
122-
TokenIntegrityLevel,
123-
TokenUIAccess,
124-
TokenMandatoryPolicy,
125-
TokenLogonSid,
126-
TokenIsAppContainer,
127-
TokenCapabilities,
128-
TokenAppContainerSid,
129-
TokenAppContainerNumber,
130-
TokenUserClaimAttributes,
131-
TokenDeviceClaimAttributes,
132-
TokenRestrictedUserClaimAttributes,
133-
TokenRestrictedDeviceClaimAttributes,
134-
TokenDeviceGroups,
135-
TokenRestrictedDeviceGroups,
136-
TokenSecurityAttributes,
137-
TokenIsRestricted
138-
}
139-
140-
[Serializable]
141-
public enum TOKEN_TYPE
142-
{
143-
TokenPrimary = 1,
144-
TokenImpersonation = 2
145-
}
146-
147-
[Flags]
148-
public enum TokenAccess : uint
149-
{
150-
TOKEN_ASSIGN_PRIMARY = 0x0001,
151-
TOKEN_DUPLICATE = 0x0002,
152-
TOKEN_IMPERSONATE = 0x0004,
153-
TOKEN_QUERY = 0x0008,
154-
TOKEN_QUERY_SOURCE = 0x0010,
155-
TOKEN_ADJUST_PRIVILEGES = 0x0020,
156-
TOKEN_ADJUST_GROUPS = 0x0040,
157-
TOKEN_ADJUST_DEFAULT = 0x0080,
158-
TOKEN_ADJUST_SESSIONID = 0x0100,
159-
TOKEN_ALL_ACCESS_P = 0x000F00FF,
160-
TOKEN_ALL_ACCESS = 0x000F01FF,
161-
TOKEN_READ = 0x00020008,
162-
TOKEN_WRITE = 0x000200E0,
163-
TOKEN_EXECUTE = 0x00020000
164-
}
165-
16684
public enum FINDEX_INFO_LEVELS
16785
{
16886
FindExInfoStandard = 0,

‎src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs‎

Lines changed: 1 addition & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2024 Files Community
1+
// Copyright (c) 2024 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

44
using System.IO;
@@ -56,13 +56,6 @@ public static extern int RmGetList(
5656
ref uint lpdwRebootReasons
5757
);
5858

59-
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
60-
public static extern bool SetPropW(
61-
IntPtr hWnd,
62-
string lpString,
63-
IntPtr hData
64-
);
65-
6659
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
6760
public static extern IntPtr CreateEvent(
6861
IntPtr lpEventAttributes,
@@ -102,39 +95,12 @@ public static extern bool CloseHandle(
10295
IntPtr hObject
10396
);
10497

105-
[DllImport("api-ms-win-core-io-l1-1-1.dll")]
106-
public static extern bool GetOverlappedResult(
107-
IntPtr hFile,
108-
OVERLAPPED lpOverlapped,
109-
out int lpNumberOfBytesTransferred,
110-
bool bWait
111-
);
112-
113-
[DllImport("api-ms-win-core-io-l1-1-1.dll")]
114-
public static extern bool CancelIo(
115-
IntPtr hFile
116-
);
117-
11898
[DllImport("api-ms-win-core-io-l1-1-1.dll")]
11999
public static extern bool CancelIoEx(
120100
IntPtr hFile,
121101
IntPtr lpOverlapped
122102
);
123103

124-
[DllImport("api-ms-win-core-synch-l1-2-0.dll")]
125-
public static extern uint WaitForMultipleObjectsEx(
126-
uint nCount,
127-
IntPtr[] lpHandles,
128-
bool bWaitAll,
129-
uint dwMilliseconds,
130-
bool bAlertable
131-
);
132-
133-
[DllImport("api-ms-win-core-synch-l1-2-0.dll", SetLastError = true)]
134-
public static extern bool ResetEvent(
135-
IntPtr hEvent
136-
);
137-
138104
[DllImport("api-ms-win-core-synch-l1-2-0.dll", SetLastError = true)]
139105
public static extern uint WaitForSingleObjectEx(
140106
IntPtr hHandle,
@@ -202,16 +168,6 @@ public static extern bool DeviceIoControl(
202168
out uint lpBytesReturned,
203169
IntPtr lpOverlapped);
204170

205-
[DllImport("user32.dll")]
206-
public static extern int ToUnicode(
207-
uint virtualKeyCode,
208-
uint scanCode,
209-
byte[] keyboardState,
210-
[Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)] StringBuilder receivingBuffer,
211-
int bufferSize,
212-
uint flags
213-
);
214-
215171
[DllImport("user32.dll", CharSet = CharSet.Auto)]
216172
public static extern int ToUnicodeEx(
217173
uint virtualKeyCode,
@@ -223,11 +179,6 @@ public static extern int ToUnicodeEx(
223179
IntPtr keyboardLayout
224180
);
225181

226-
[DllImport("user32.dll")]
227-
public static extern bool TranslateMessage(
228-
ref MSG lpMsg
229-
);
230-
231182
[DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
232183
public static extern IntPtr CreateFileFromApp(
233184
string lpFileName,
@@ -252,14 +203,6 @@ public static extern bool SetFileAttributesFromApp(
252203
string lpFileName,
253204
FileAttributes dwFileAttributes);
254205

255-
[DllImport("api-ms-win-core-file-l1-2-1.dll", ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
256-
public static extern uint SetFilePointer(
257-
IntPtr hFile,
258-
long lDistanceToMove,
259-
IntPtr lpDistanceToMoveHigh,
260-
uint dwMoveMethod
261-
);
262-
263206
[DllImport("api-ms-win-core-file-l1-2-1.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
264207
public unsafe static extern bool ReadFile(
265208
IntPtr hFile,
@@ -310,14 +253,6 @@ public static extern bool GetFileInformationByHandleEx(
310253
uint dwBufferSize
311254
);
312255

313-
[DllImport("api-ms-win-core-file-l2-1-1.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
314-
public static extern bool GetFileInformationByHandleEx(
315-
IntPtr hFile,
316-
FILE_INFO_BY_HANDLE_CLASS infoClass,
317-
IntPtr dirInfo,
318-
uint dwBufferSize
319-
);
320-
321256
[DllImport("kernel32.dll", ExactSpelling = true, CharSet = CharSet.Auto, SetLastError = true)]
322257
public static extern IntPtr FindFirstStreamW(
323258
string lpFileName,
@@ -333,49 +268,6 @@ public static extern bool FindNextStreamW(
333268
[In, Out, MarshalAs(UnmanagedType.LPStruct)] WIN32_FIND_STREAM_DATA lpFindStreamData
334269
);
335270

336-
[DllImport("Shcore.dll", SetLastError = true)]
337-
public static extern int GetDpiForMonitor(
338-
IntPtr hmonitor,
339-
uint dpiType,
340-
out uint dpiX,
341-
out uint dpiY
342-
);
343-
344-
[DllImport("api-ms-win-core-processthreads-l1-1-0.dll", SetLastError = true, ExactSpelling = true)]
345-
[return: MarshalAs(UnmanagedType.Bool)]
346-
public static extern bool OpenProcessToken(
347-
[In] IntPtr ProcessHandle, TokenAccess DesiredAccess, out IntPtr TokenHandle);
348-
349-
[DllImport("api-ms-win-core-processthreads-l1-1-2.dll", SetLastError = true, ExactSpelling = true)]
350-
public static extern IntPtr GetCurrentProcess();
351-
352-
[DllImport("api-ms-win-security-base-l1-1-0.dll", SetLastError = true, ExactSpelling = true)]
353-
[return: MarshalAs(UnmanagedType.Bool)]
354-
public static extern bool GetTokenInformation(
355-
IntPtr hObject,
356-
TOKEN_INFORMATION_CLASS tokenInfoClass,
357-
IntPtr pTokenInfo,
358-
int tokenInfoLength,
359-
out int returnLength
360-
);
361-
362-
[DllImport("api-ms-win-security-base-l1-1-0.dll", ExactSpelling = true, SetLastError = true)]
363-
public static extern int GetLengthSid(
364-
IntPtr pSid
365-
);
366-
367-
[DllImport("crypt32.dll", SetLastError = true, CharSet = CharSet.Auto)]
368-
[return: MarshalAs(UnmanagedType.Bool)]
369-
public static extern bool CryptUnprotectData(
370-
in CRYPTOAPI_BLOB pDataIn,
371-
StringBuilder szDataDescr,
372-
in CRYPTOAPI_BLOB pOptionalEntropy,
373-
IntPtr pvReserved,
374-
IntPtr pPromptStruct,
375-
CryptProtectFlags dwFlags,
376-
out CRYPTOAPI_BLOB pDataOut
377-
);
378-
379271
[DllImport("api-ms-win-core-wow64-l1-1-1.dll", SetLastError = true)]
380272
public static extern bool IsWow64Process2(
381273
IntPtr process,
@@ -410,19 +302,6 @@ public static extern IntPtr FindFirstFileExFromApp(
410302
int dwAdditionalFlags
411303
);
412304

413-
[DllImport("api-ms-win-core-string-l1-1-0.dll", CharSet = CharSet.Unicode)]
414-
public static extern int CompareStringEx(
415-
string localeName,
416-
int flags,
417-
string str1,
418-
int count1,
419-
string str2,
420-
int count2,
421-
IntPtr versionInformation,
422-
IntPtr reserved,
423-
int param
424-
);
425-
426305
[LibraryImport("shell32.dll", EntryPoint = "#865", SetLastError = true)]
427306
[return: MarshalAs(UnmanagedType.Bool)]
428307
public static partial bool IsElevationRequired(

‎src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ public sealed class WIN32_FIND_STREAM_DATA
139139
public string cStreamName;
140140
}
141141

142-
[StructLayout(LayoutKind.Sequential)]
143-
public struct TOKEN_USER
144-
{
145-
public SID_AND_ATTRIBUTES User;
146-
}
147-
148142
[StructLayout(LayoutKind.Sequential)]
149143
public struct SID_AND_ATTRIBUTES
150144
{
@@ -153,13 +147,6 @@ public struct SID_AND_ATTRIBUTES
153147
public uint Attributes;
154148
}
155149

156-
[StructLayout(LayoutKind.Sequential)]
157-
public struct CRYPTOAPI_BLOB
158-
{
159-
public uint cbData;
160-
public IntPtr pbData;
161-
}
162-
163150
[StructLayout(LayoutKind.Sequential)]
164151
public struct SYSTEMTIME
165152
{
@@ -211,16 +198,5 @@ public struct WIN32_FIND_DATA
211198
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
212199
public string cAlternateFileName;
213200
}
214-
215-
[StructLayout(LayoutKind.Sequential)]
216-
public struct MSG
217-
{
218-
public IntPtr hwnd;
219-
public uint message;
220-
public IntPtr wParam;
221-
public IntPtr lParam;
222-
public uint time;
223-
public System.Drawing.Point pt;
224-
}
225201
}
226202
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /