Exemple #1
0
        public static extern bool CreateProcess(
				string lpApplicationName,
				string lpCommandLine, 
				ref SecurityAttrs lpProcessAttributes, 
				ref SecurityAttrs lpThreadAttributes, 
				bool bInheritHandles, 
				uint dwCreationFlags, 
				IntPtr lpEnvironment, 
				string lpCurrentDirectory,
				ref StartupInfo lpStartupInfo, 
				out ProcessInfo lpProcessInformation
			);
Exemple #2
0
        public static ProcessInfo CreateAndDebug(string app, string args)
        {
            ProcessInfo info = new ProcessInfo();
            StartupInfo sinfo = new StartupInfo();
            SecurityAttrs pSec = new SecurityAttrs();
            SecurityAttrs tSec = new SecurityAttrs();
            pSec.nLength = Marshal.SizeOf(pSec);
            tSec.nLength = Marshal.SizeOf(tSec);

            bool success = CreateProcess(
                    app, args,
                    ref pSec, ref tSec, true, 0x1|0x4, // DEBUG_PROCESS | CREATE_SUSPENDED
                    IntPtr.Zero, null, ref sinfo, out info
                );
            if(success)
                return info;
            else
                throw new DebugException();
        }