Update github/codeql-action action to v3.25.10
[ArchiSteamFarm.git] / ArchiSteamFarm / Core / NativeMethods.cs
blob55fcd70317aa6057fc3d47f112141452b979fb5b
1 // ----------------------------------------------------------------------------------------------
2 // _ _ _ ____ _ _____
3 // / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4 // / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5 // / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6 // /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7 // ----------------------------------------------------------------------------------------------
8 // |
9 // Copyright 2015-2024 Ɓukasz "JustArchi" Domeradzki
10 // Contact: JustArchi@JustArchi.net
11 // |
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // you may not use this file except in compliance with the License.
14 // You may obtain a copy of the License at
15 // |
16 // http://www.apache.org/licenses/LICENSE-2.0
17 // |
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the License is distributed on an "AS IS" BASIS,
20 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 // See the License for the specific language governing permissions and
22 // limitations under the License.
24 using System;
25 using System.Runtime.InteropServices;
26 using System.Runtime.Versioning;
28 namespace ArchiSteamFarm.Core;
30 internal static partial class NativeMethods {
31 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
32 [LibraryImport("user32.dll")]
33 [SupportedOSPlatform("Windows")]
34 [return: MarshalAs(UnmanagedType.Bool)]
35 internal static partial void FlashWindowEx(ref FlashWindowInfo pwfi);
37 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
38 [LibraryImport("kernel32.dll")]
39 [SupportedOSPlatform("Windows")]
40 [return: MarshalAs(UnmanagedType.Bool)]
41 internal static partial bool GetConsoleMode(nint hConsoleHandle, out EConsoleMode lpMode);
43 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
44 [LibraryImport("libc", EntryPoint = "geteuid", SetLastError = true)]
45 [SupportedOSPlatform("FreeBSD")]
46 [SupportedOSPlatform("Linux")]
47 [SupportedOSPlatform("MacOS")]
48 internal static partial uint GetEuid();
50 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
51 [LibraryImport("kernel32.dll")]
52 [SupportedOSPlatform("Windows")]
53 internal static partial nint GetStdHandle(EStandardHandle nStdHandle);
55 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
56 [LibraryImport("kernel32.dll")]
57 [SupportedOSPlatform("Windows")]
58 [return: MarshalAs(UnmanagedType.Bool)]
59 internal static partial bool SetConsoleMode(nint hConsoleHandle, EConsoleMode dwMode);
61 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
62 [LibraryImport("kernel32.dll")]
63 [SupportedOSPlatform("Windows")]
64 internal static partial EExecutionState SetThreadExecutionState(EExecutionState executionState);
66 [DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
67 [LibraryImport("user32.dll")]
68 [SupportedOSPlatform("Windows")]
69 [return: MarshalAs(UnmanagedType.Bool)]
70 internal static partial void ShowWindow(nint hWnd, EShowWindow nCmdShow);
72 [Flags]
73 [SupportedOSPlatform("Windows")]
74 internal enum EConsoleMode : uint {
75 EnableQuickEditMode = 0x0040
78 [Flags]
79 [SupportedOSPlatform("Windows")]
80 internal enum EExecutionState : uint {
81 None = 0,
82 SystemRequired = 0x00000001,
83 AwayModeRequired = 0x00000040,
84 Continuous = 0x80000000,
85 Awake = SystemRequired | AwayModeRequired | Continuous
88 [Flags]
89 [SupportedOSPlatform("Windows")]
90 internal enum EFlashFlags : uint {
91 Stop = 0,
92 Caption = 1,
93 Tray = 2,
94 All = Caption | Tray,
95 Timer = 4
98 [SupportedOSPlatform("Windows")]
99 internal enum EShowWindow : uint {
100 Minimize = 6
103 [SupportedOSPlatform("Windows")]
104 internal enum EStandardHandle {
105 Input = -10
108 [StructLayout(LayoutKind.Sequential)]
109 [SupportedOSPlatform("Windows")]
110 internal struct FlashWindowInfo {
111 #pragma warning disable Reordering // TODO: This silly pragma doesn't do anything, but it stops Rider from reordering, we may be able to get rid of it later
112 public uint StructSize;
113 public nint WindowHandle;
114 public EFlashFlags Flags;
115 public uint Count;
116 public uint TimeoutBetweenFlashes;
117 #pragma warning restore Reordering // TODO: This silly pragma doesn't do anything, but it stops Rider from reordering, we may be able to get rid of it later