2 using System.Runtime.InteropServices;
10 #pragma warning disable SA1600 11 #pragma warning disable SA1602 12 #pragma warning disable SA1611 13 #pragma warning disable SA1615 24 AllowUnprivilegedCreate = 2
32 SuspendResume = 0x0002,
38 [DllImport(
"user32.dll")]
39 public static extern int GetWindowThreadProcessId(IntPtr hWnd, out
int lpdwProcessId);
44 [DllImport(
"user32.dll", CharSet = CharSet.Unicode)]
45 public static extern IntPtr FindWindow(
string lpClassName,
string lpWindowName);
50 [DllImport(
"user32.dll")]
51 public static extern int SendMessage(IntPtr hWnd,
int wMsg, IntPtr wParam, IntPtr lParam);
56 public delegate
bool EnumWindowProc(IntPtr hwnd, IntPtr lParam);
61 [DllImport(
"user32.dll")]
62 public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);
67 [DllImport(
"user32.dll", CharSet = CharSet.Unicode, SetLastError =
true)]
68 public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString,
int nMaxCount);
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);
79 [DllImport(
"kernel32.dll", SetLastError =
true, CharSet = CharSet.Unicode)]
80 public static extern bool CreateSymbolicLink(
string lpSymlinkFileName,
string lpTargetFileName,
CreateSymbolicLinkFlags dwFlags);
85 [DllImport(
"kernel32.dll", SetLastError =
true, CharSet = CharSet.Unicode)]
86 public static extern IntPtr OpenThread(
ThreadAccess dwDesiredAccess,
bool bInheritHandle, uint dwThreadId);
91 [DllImport(
"kernel32.dll", SetLastError =
true, CharSet = CharSet.Unicode)]
92 public static extern bool CloseHandle(IntPtr hObject);
97 [DllImport(
"kernel32.dll", SetLastError =
true, CharSet = CharSet.Unicode)]
98 public static extern uint SuspendThread(IntPtr hThread);
103 [DllImport(
"kernel32.dll", SetLastError =
true, CharSet = CharSet.Unicode)]
104 public static extern uint ResumeThread(IntPtr hThread);
Use server authentication
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 ...