tgstation-server  4.3.2
The /tg/station 13 server suite
NativeMethods.cs
Go to the documentation of this file.
1 using System;
2 using System.Runtime.InteropServices;
3 using System.Text;
4 
5 namespace Tgstation.Server.Host
6 {
10  #pragma warning disable SA1600
11  #pragma warning disable SA1602
12  #pragma warning disable SA1611
13  #pragma warning disable SA1615
14  static class NativeMethods
15  {
19  [Flags]
20  public enum CreateSymbolicLinkFlags : int
21  {
22  None = 0,
23  Directory = 1,
24  AllowUnprivilegedCreate = 2
25  }
26 
30  public enum ThreadAccess : int
31  {
32  SuspendResume = 0x0002,
33  }
34 
38  [DllImport("user32.dll")]
39  public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
40 
44  [DllImport("user32.dll", CharSet = CharSet.Unicode)]
45  public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
46 
50  [DllImport("user32.dll")]
51  public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
52 
56  public delegate bool EnumWindowProc(IntPtr hwnd, IntPtr lParam);
57 
61  [DllImport("user32.dll")]
62  public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);
63 
67  [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
68  public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
69 
73  [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
74  public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken);
75 
79  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
80  public static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, CreateSymbolicLinkFlags dwFlags);
81 
85  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
86  public static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
87 
91  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
92  public static extern bool CloseHandle(IntPtr hObject);
93 
97  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
98  public static extern uint SuspendThread(IntPtr hThread);
99 
103  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
104  public static extern uint ResumeThread(IntPtr hThread);
105  }
106 }
CreateSymbolicLinkFlags
See https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-createsymboliclinka#param...
Native Windows methods used by the code
ThreadAccess
See https://msdn.microsoft.com/en-us/library/windows/desktop/ms686769(v=vs.85).aspx ...