Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////
        protected Boolean CreateProcessWithTokenW(IntPtr phNewToken, String name, String arguments)
        {
            Console.WriteLine("CreateProcessWithTokenW");
            IntPtr lpProcessName = Marshal.StringToHGlobalUni(name);
            IntPtr lpProcessArgs = Marshal.StringToHGlobalUni(name);

            Structs._STARTUPINFO startupInfo = new Structs._STARTUPINFO();
            startupInfo.cb = (UInt32)Marshal.SizeOf(typeof(Structs._STARTUPINFO));
            Structs._PROCESS_INFORMATION processInformation = new Structs._PROCESS_INFORMATION();
            if (!advapi32.CreateProcessWithTokenW(
                    phNewToken,
                    Enums.LOGON_FLAGS.NetCredentialsOnly,
                    lpProcessName,
                    lpProcessArgs,
                    Enums.CREATION_FLAGS.NONE,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    ref startupInfo,
                    out processInformation
                    ))
            {
                GetError("CreateProcessWithTokenW: ");
                return(false);
            }
            WriteOutputGood("Created process: " + processInformation.dwProcessId);
            WriteOutputGood("Created thread: " + processInformation.dwThreadId);
            return(true);
        }
Esempio n. 2
0
        ////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////
        protected Boolean CreateProcessWithLogonW(IntPtr phNewToken, String name, String arguments)
        {
            WriteOutputGood("CreateProcessWithLogonW");
            IntPtr lpProcessName = Marshal.StringToHGlobalUni(name);
            IntPtr lpProcessArgs = Marshal.StringToHGlobalUni(name);

            Structs._STARTUPINFO startupInfo = new Structs._STARTUPINFO();
            startupInfo.cb = (UInt32)Marshal.SizeOf(typeof(Structs._STARTUPINFO));
            Structs._PROCESS_INFORMATION processInformation = new Structs._PROCESS_INFORMATION();
            if (!advapi32.CreateProcessWithLogonW(
                    "i",
                    "j",
                    "k",
                    0x00000002,
                    name,
                    arguments,
                    0x04000000,
                    IntPtr.Zero,
                    "C:\\Windows\\System32",
                    ref startupInfo,
                    out processInformation
                    ))
            {
                GetError("CreateProcessWithLogonW: ");
                return(false);
            }
            WriteOutputGood("Created process: " + processInformation.dwProcessId);
            WriteOutputGood("Created thread: " + processInformation.dwThreadId);
            return(true);
        }
Esempio n. 3
0
 internal static extern Boolean CreateProcessWithTokenW(
     IntPtr hToken,
     Enums.LOGON_FLAGS dwLogonFlags,
     IntPtr lpApplicationName,
     IntPtr lpCommandLine,
     Enums.CREATION_FLAGS dwCreationFlags,
     IntPtr lpEnvironment,
     IntPtr lpCurrentDirectory,
     ref Structs._STARTUPINFO lpStartupInfo,
     out Structs._PROCESS_INFORMATION lpProcessInfo
     );
Esempio n. 4
0
 internal static extern Boolean CreateProcessAsUserW(
     IntPtr hToken,
     IntPtr lpApplicationName,
     IntPtr lpCommandLine,
     IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes,
     Boolean bInheritHandles,
     Enums.CREATION_FLAGS dwCreationFlags,
     IntPtr lpEnvironment,
     IntPtr lpCurrentDirectory,
     ref Structs._STARTUPINFO lpStartupInfo,
     out Structs._PROCESS_INFORMATION lpProcessInfo
     );
Esempio n. 5
0
 internal static extern bool CreateProcessWithLogonW(
     String userName,
     String domain,
     String password,
     int logonFlags,
     String applicationName,
     String commandLine,
     int creationFlags,
     IntPtr environment,
     String currentDirectory,
     ref Structs._STARTUPINFO startupInfo,
     out Structs._PROCESS_INFORMATION processInformation
     );