Esempio n. 1
0
        NativeDbgProcess CreateProcessDebugWorker(string application, string commandArgs, Microsoft.Samples.Debugging.Native.NativeMethods.CreateProcessFlags flags)
        {
            if (application == null)
            {
                throw new ArgumentException("can't be null", "application");
            }

            // Compensate for Win32's behavior, where arg[0] is the application name.
            if (commandArgs != null)
            {
                commandArgs = application + " " + commandArgs;
            }

            // This is using definition imports from Mdbg core, where these are classes.
            PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); // class

            STARTUPINFO si = new STARTUPINFO(); // struct

            NativeMethods.CreateProcess(
                application,
                commandArgs,
                IntPtr.Zero, // process attributes
                IntPtr.Zero, // thread attributes
                false, // inherit handles,
                NativeMethods.CreateProcessFlags.CREATE_NEW_CONSOLE | flags,
                IntPtr.Zero, // env block
                null, // current dir
                si,
                pi);

            // We'll close these handle now. We'll get them again from the CreateProcess debug event.
            NativeMethods.CloseHandle(pi.hProcess);
            NativeMethods.CloseHandle(pi.hThread);

            return CreateNew(pi.dwProcessId);
        }
Esempio n. 2
0
 public static extern bool CreateProcess(
     string lpApplicationName,
     string lpCommandLine,
     IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes,
     [MarshalAs(UnmanagedType.Bool)]
     bool bInheritHandles,
     CreateProcessFlags dwCreationFlags,
     IntPtr lpEnvironment,
     string lpCurrentDirectory,
     STARTUPINFO lpStartupInfo,// class
     PROCESS_INFORMATION lpProcessInformation // class
 );