tgstation-server  4.4.0
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  [Flags]
39  public enum MiniDumpType : uint
40  {
41  WithDataSegs = 0x00000001,
42  WithFullMemory = 0x00000002,
43  WithHandleData = 0x00000004,
44  WithUnloadedModules = 0x00000020,
45  WithThreadInfo = 0x00001000,
46  }
47 
51  [DllImport("user32.dll")]
52  public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
53 
57  [DllImport("user32.dll", CharSet = CharSet.Unicode)]
58  public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
59 
63  [DllImport("user32.dll")]
64  public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
65 
69  public delegate bool EnumWindowProc(IntPtr hwnd, IntPtr lParam);
70 
74  [DllImport("user32.dll")]
75  public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);
76 
80  [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
81  public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
82 
86  [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
87  public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken);
88 
92  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
93  public static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, CreateSymbolicLinkFlags dwFlags);
94 
98  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
99  public static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
100 
104  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
105  public static extern bool CloseHandle(IntPtr hObject);
106 
110  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
111  public static extern uint SuspendThread(IntPtr hThread);
112 
116  [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
117  public static extern uint ResumeThread(IntPtr hThread);
118 
122  [DllImport("dbghelp.dll", SetLastError = true, CharSet = CharSet.Unicode)]
123  public static extern bool MiniDumpWriteDump(
124  IntPtr hProcess,
125  uint processId,
126  SafeHandle hFile,
127  MiniDumpType dumpType,
128  IntPtr expParam,
129  IntPtr userStreamParam,
130  IntPtr callbackParam);
131  }
132 }
MiniDumpType
See https://docs.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidump_type...
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 ...