public static Win32Process CreateProcessAsUser(NtToken token, Win32ProcessConfig config) { using (var resources = new DisposableList <IDisposable>()) { PROCESS_INFORMATION proc_info = new PROCESS_INFORMATION(); STARTUPINFOEX start_info = config.ToStartupInfoEx(resources); SECURITY_ATTRIBUTES proc_attr = config.ProcessSecurityAttributes(resources); SECURITY_ATTRIBUTES thread_attr = config.ThreadSecurityAttributes(resources); if (!CreateProcessAsUser(token.Handle, config.ApplicationName, config.CommandLine, proc_attr, thread_attr, config.InheritHandles, config.CreationFlags | CreateProcessFlags.ExtendedStartupInfoPresent, config.Environment, config.CurrentDirectory, start_info, out proc_info)) { if (!CreateProcessWithTokenW(token.Handle, 0, config.ApplicationName, config.CommandLine, config.CreationFlags, config.Environment, config.CurrentDirectory, ref start_info.StartupInfo, out proc_info)) { throw new SafeWin32Exception(); } } return(new Win32Process(proc_info, config.TerminateOnDispose)); } }
public static Win32Process CreateProcessWithLogin(string username, string domain, string password, CreateProcessLogonFlags logon_flags, string application_name, string command_line, CreateProcessFlags flags, string desktop) { Win32ProcessConfig config = new Win32ProcessConfig(); config.ApplicationName = application_name; config.CommandLine = command_line; config.CreationFlags = flags; config.Desktop = desktop; return(CreateProcessWithLogin(username, domain, password, logon_flags, config)); }
public static Win32Process CreateProcess(NtProcess parent, string application_name, string command_line, CreateProcessFlags flags, string desktop) { Win32ProcessConfig config = new Win32ProcessConfig(); config.ParentProcess = parent; config.ApplicationName = application_name; config.CommandLine = command_line; config.CreationFlags = flags; config.Desktop = desktop; return(CreateProcess(config)); }
public static Win32Process CreateProcessAsUser(NtToken token, string application_name, string command_line, CreateProcessFlags flags, string desktop) { Win32ProcessConfig config = new Win32ProcessConfig(); config.ApplicationName = application_name; config.CommandLine = command_line; config.CreationFlags = flags; config.Desktop = desktop; return(CreateProcessAsUser(token, config)); }
public static Win32Process CreateProcessWithLogin(string username, string domain, string password, CreateProcessLogonFlags logon_flags, Win32ProcessConfig config) { STARTUPINFO start_info = config.ToStartupInfo(); PROCESS_INFORMATION proc_info = new PROCESS_INFORMATION(); if (!CreateProcessWithLogonW(username, domain, password, logon_flags, config.ApplicationName, config.CommandLine, config.CreationFlags, config.Environment, config.CurrentDirectory, ref start_info, out proc_info)) { throw new SafeWin32Exception(); } return(new Win32Process(proc_info, config.TerminateOnDispose)); }